August 2016
Intermediate to advanced
286 pages
5h 31m
English
This Appendix shows a version of the code from appendices B and C that extracts the domain logic from the page script into a Transactions class. Note how the original page script is now reduced to being a object creation and injection mechanism, and hands off most logic to the Transactions classes. Note also how the $failure, $credits, and $article_types variables are now properties on the Transactions class, and how the normalization/sanitizing logic and credit-calculation logic is part of the Transactions logic.
page_script.php <?php 2 3 // ... $user_id value created earlier 4 5 $db = new Database($db_host, $db_user, $db_pass); 6 $articles_gateway = new ArticlesGateway($db); 7 $users_gateway = new UsersGateway($db); ...Read now
Unlock full access