clean code in small companies stock photo not actual
play

Clean Code in Small Companies Stock photo, not actual developer - PowerPoint PPT Presentation

Clean Code in Small Companies Stock photo, not actual developer Stock photo, not actual developer Stock photo, not actual developer Robert C. Martin Uncle Bob 1. Reading code is hard 1. Reading code is hard 2. We all have to read code


  1. Route:: get ( '/users' , function ( UserBusinessLogic $userBusinessLogic ) { return 'User list' ; } );

  2. class UserRegisterController { public function __construct( UserBusinessLogic $userBusinessLogic ) { } public function register() { } }

  3. Static Typing Saves you from a **** ton of issues

  4. function search( $needle, $haystack ) { }

  5. function search( string $needle, array $haystack ) { }

  6. JavaScript Typescript PHP phpstan Python mypy Java builtin

  7. Strict Typing Because your String is not an Integer

  8. <?php PHP declare (strict_types=1);

  9. <?php PHP declare (strict_types=1); JavaScript Typescript

  10. Structuring your Code Because your Code is not a Clown Car

  11. /controller UserRegisterController.php UserListController.php … /model /view

  12. /user /controller UserRegisterController.php UserListController.php … /business /storage /blog /controller /business /storage

  13. Testing You test your code, right?

  14. Application

  15. User Interface Application

  16. Test Code User Interface Application

  17. Test Code User Interface Application Database Connector

  18. Test Code User Interface Application Database Connector Test Database

  19. Test Code User Interface Application Database Connector Test Database

  20. Application

  21. Test Code Application

  22. Test Code Application Fake Database Connector

  23. Test Code Application Fake Database Connector

  24. Test Code User Interface Fake Application

  25. function testGetShouldReturnUser(){ //region Setup $userStorage = new UserStorageFake(); $userStorage-> backingStorage [ 'test-user' ] = UserFactory:: create ( "test-user" , "Test User" , "test@example.com" , "*" ); $business = new UserGetBusinessLogicImpl($userStorage); //endregion //region Execute... //region Asset... }

  26. function testGetShouldReturnUser(){ //region Setup... //region Execute $user = $business->getById( "test-user" ); //endregion //region Assert assertEquals( "test-user" , $user->getId()); //endregion }

  27. Putting it together Building an actual system

  28. Many thanks to: Cristina Laskar

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend