• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Clean application development tutorial
 

Clean application development tutorial

on

  • 4,493 views

No matter what level of development we are at in our careers we all face a daily battle to write good code for ourselves and others, deliver finished applications fast to satisfy business, and ensure ...

No matter what level of development we are at in our careers we all face a daily battle to write good code for ourselves and others, deliver finished applications fast to satisfy business, and ensure everything is tested to prevent end-user fails.

In this session we will discuss what clean application development is, and how it can help us win those battles. It will provide practical and usable examples and tools to take with you, integrate into your workflow, and continue to grow into good habits.

(Topics: Version control, refactoring, coding standards, frameworks, architecture, automation, time management, and more.)

Statistics

Views

Total Views
4,493
Views on SlideShare
4,264
Embed Views
229

Actions

Likes
9
Downloads
12
Comments
1

8 Embeds 229

http://librosweb.es 87
http://eventifier.co 57
http://www.eventifier.co 54
http://eventifier.com 18
http://lanyrd.com 7
http://bitswapping.com 3
http://ec2-54-243-189-159.compute-1.amazonaws.com 2
https://twitter.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel

11 of 1 previous next

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • He, Unfortunatuly I havent been able to make it to the conference but I went through your slides and I must say that I like it very much. A lot of usefull and important information put together.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Clean application development tutorial Clean application development tutorial Presentation Transcript

    • Clean Application Development Adam Culp @adamculp https://joind.in/9284
    • Clean Application Development – About me ● About ● ● ● ● ● ● 2 me PHP 5.3 Certified Consultant at Zend Technologies Organizer of SoFloPHP (South Florida) Organizer of SunshinePHP (Miami) Long distance (ultramarathon) runner Judo black belt instructor
    • Clean Application Development – Iteration ● HUGE ● fan of iteration Skills require iteration to do well: ● ● Training to run. ● Evading project managers. ● Writing clean code. ● Refactoring. ● 3 Learning to walk. Testing.
    • Clean Application Development – Learning ● Clean application development cannot be taught quickly. ● ● Leave the code better than you found it. ● Always watch for new techniques. ● Want to do better. ● No “silver bullet“. ● 4 Practice, Practice, Practice. Oh, and practice.
    • Clean Application Development – Parts ● Parts of clean application development. ● ● Documentation ● Source Control ● Workflow ● Time Estimation ● Requirements Gathering ● Issue Tracking ● Time Management ● Dev Tools ● Databases ● Code ● Refactoring ● Testing ● 5 Communication Continuous Integration
    • Clean Application Development – Communication Communication 6
    • Clean Application Development – Comm. Policy ● Team Commication Policy: ● ● Should be clear. ● Should be expected. ● 7 Should be agreed upon by team. Should be enforced.
    • Clean Application Development – Comm. Levels ● Communication ● Levels Instant (5 minutes to 1 hour) ● ● ● Instant Messages (Skype, AOL) Chat (IRC) Intermediate (2 to 4 hours) ● ● ● Phone Call, text message Voicemail Slow (6 to 8 hours) ● ● ● Email Issue Tracking Casual (days) ● ● 8 Forum Meeting
    • Clean Application Development – Behavior ● Desired behaviour ● ● Alert early. ● Share information. ● Be on time for meetings. ● ● Openly discuss problems. Attention! Bad behaviour ● ● Hoarding info. ● Bringing attitude to meetings. ● 9 Hiding. Interrupting others.
    • Clean Application Development – Documentation Documentation 10
    • Clean Application Development – Doc. Practices ● Document ● EVERYTHING! Write down everything. ● You WILL want it later. ● ● Architecture decisions. ● Changes in design. ● Business logic. ● 11 Meeting notes. Everything!
    • Clean Application Development – Doc. How ● How ● to document. Meeting notes, architecture decisions, design changes, business logic. ● Keep a notebook. Never throw pages away again. ● ● ● Composition Book. Evernote/Google keep. In code. ● Class Docblocks: business logic description. ● ● Ticket System. ● Source control comments. ● PHP Documentor. ● White papers. ● 12 Wiki. Everywhere!
    • Clean Application Development – Requirements Requirements 13
    • Clean Application Development – What are they ● What are requirements: ● ● Business owners vision. ● Expected behaviour of application. ● Application reaction to business logic. ● 14 End-user dreams. Specific needs.
    • Clean Application Development – How to create ● User story format works well. ● ● Create persona of target user. ● Create goals of what is desired. ● Create benefit that goals help obtain. ● Now create a story to make it real. ● 15 Create roles of potential users. Insist on specificity!
    • Clean Application Development – Req. = Important ● Key ● things about requirements: Do not start coding without them. ● ● ● Hold their hand to get them started. Even if the project is your own. Use a tool to organize them. ● ● Get sign-off from stakeholder. ● 16 Reqharbor.com No sign-off = scope creep later
    • Clean Application Development – Time Estimating Time Estimating 17
    • Clean Application Development – Wrong way! ● Guessing, then multiplying by 2 or 3 is WRONG! ● ● 18 Sometimes accurate, but still a guess. What if guess is wrong?
    • Clean Application Development – Why is it wrong? ● Guessing is wrong because: ● Still a guess. ● Lacks requirements. ● If requirements are completed, why guess? ● Welcomes scope creep. ● Application lacks design. ● Causes bad practices: ● ● ● Shortcut tests. Increases code smells. Prevents honest answers later. ● 19 How's it going????
    • Clean Application Development – Now thats better! ●A better way: ● Gather requirements. ● Plan application. ● ● How many actions in each * average hours per. ● ● How many controllers * average hours per. How many models/entities * average hours per. Include meetings. ● 15 minutes per day (daily scrum) ● 2 hours per sprint for planning. ● 1 hour per sprint for show. ● ● Include time for DBA, graphic designer. ● 20 Plan resources/developers and QA/QC testers, and tests for each action. Include time for estimating each sprint.
    • Clean Application Development – Get paid! ● Freelancers, ensure you get paid for the estimate! ● It's hard work to plan an application. ● It takes time: (time == money) ● ● Gathering requirements > 40 hours. ● Wireframes, images > 40 hours. ● Creating an accurate estimate. ● Documenting technologies. ● 21 Interview > 5 hours. Etc.
    • Clean Application Development – Issue Tracking Issue Tracking 22
    • Clean Application Development – Why track? ● Why track issues/requests: ● ● Ensures ideas are not lost. ● User perception highlighted. ● Bugs not forgotten. ● Ownership for users. ● Auditable. ● Scheduling. ● 23 Helps create documentation later. Track effort.
    • Clean Application Development – Tracking Tools ● Use ● tools. Many software packages available. ● ● Should be simple. ● Should compliment workflow. ● Connected with source control. ● Must enhance communication. ● 24 Agreed upon by team. Customizable. (not just appearance)
    • Clean Application Development – Tracking Reports ● Useful ● report examples. Average time spent per ticket. ● ● By severity. ● ● By category. By developer. % Deadlines met on time. (SLA) ● ● ● Total. By Developer. Avg. # failed fixes by QA. ● ● Count per category assigned. ● 25 By developer. By Developer.
    • Clean Application Development – Time Management Time Management 26
    • Clean Application Development – Key Elements ● Key ● Track everything! ● ● elements Build habits. Use applications. ● ● ● Hamster. Freshbooks. Keep it simple. ● Easy input. ● Basic reports. ● 27 Future estimates.
    • Clean Application Development – Service Level Agreement SLA – Service Level Agreement 28
    • Clean Application Development – Agreement ● Definition ● and acceptance. Determine acceptable response levels. ● Get agreement from stakeholders. ● ● Based on ticket severity. ● 29 Make them public. Must manage user perception.
    • Clean Application Development – Responsiveness ● Response Times. ● ● Urgent = someone can't work – 3 to 4 hour response ● High = customer inconvenienced – 8 hour or 1 day response ● Medium = employee annoyance – 2 days to 1 week response ● Low = nice to have – 1 to 2 week response ● 30 Blocker = business stopped – 1 hour response Wish = no response, but perhaps a friendly thank you email
    • Clean Application Development – Response ● Response Contents. ● ● Acknowledge understanding. (re-state problem) ● Provide “real“ time estimate of work. ● Define when work will start. (for higher priority items) ● 31 Thank user. Give idea of when work will start for low priority items.
    • Clean Application Development – Dev Tools Dev Tools 32
    • Clean Application Development – Using an IDE ● Modern IDE ● Pick one, learn it WELL! ● Features: ● ● Code completion. ● Source control integration. ● Issue tracking integration. ● DB management. ● Deployment. ● Testing. ● Console. ● 33 Syntax highlighting. Debugging.
    • Clean Application Development – Basic Editor ● Basic Editor ● Pick one, learn it WELL! ● Features: ● ● Able to handle large files. ● Opens fast. ● Saves quickly. ● 34 Syntax highlighting. Closes error free.
    • Clean Application Development – Vi / Vim ● Vim Editor ● ● Exists on most Linux and Unix servers. ● 35 Must know at least basic usage. Don't fear it.
    • Clean Application Development – PHPCloud ● phpcloud.com ● ● Development environment hosting (not production) ● Deploy to any cloud provider when ready to go LIVE! ● Zend Server. ● Zend Framework. ● Zend Debugger. ● 36 Git hosting. FREE!!!
    • Clean Application Development – Vagrant ● Vagrant for virtualized development ● Vagrantup.com ● Vagrantbox.es ● Command line tool. ● Uses: ● VirtualBox ● VMWare ● AWS ● Others... ● ● 37 Can use Puppet or Chef. Free and open source.
    • Clean Application Development – Vagrant Automated ● Vagrant automated ● ● 38 http://puphpet.com For Puppet manifests. http://rove.io For Chef recipes.
    • Clean Application Development – Using frameworks ● Frameworks help keep things in line ● Using a framework helps keep your code light, simpler. ● Heavy lifting and complexity within core. ● Most modern frameworks are MVC ● ● 39 View – GUI, Presentation ● ● Model – Business logic, Data Controller – Directs, Commands Generally have a naming convention and coding standard.
    • Clean Application Development – Frameworks ● Dos ● ● Dabble with others secondary. ● Get certified. ● ● Pick one, and learn it best. Create your own. Don'ts ● ● Edit framework core. ● Rebuild functionality. ● 40 Roll your own for large projects. Fall behind. (learn more)
    • Clean Application Development – Debugging Proxy ● Debugging Proxy ● ● Exists on most Linux and Unix servers. ● 41 Must know at least basic usage. Don't fear them.
    • Clean Application Development – Zend Server ● Zend Server ● ● Debugging and profiling. ● Code tracing. ● Monitoring. ● Bytecode caching. ● Session clustering. ● Page caching. ● On many cloud providers. ● Available at ServerGrove! ● 42 Deployment and rollback. IDE Integration.
    • Clean Application Development – PHP QA Tools ● PHP ● QA tools http://phpqatools.org ● ● PHP CPD (copy/paste detector) ● PHP Loc (lines of code) ● PHP MD (mess detector) ● PHP Codesniffer ● PHP Depend ● Jenkins PHP ● 43 PHP Unit More....
    • Clean Application Development – XHProf ● XHProf ● ● Hierarchical profiler. ● 44 Pecl package. 'How to' on my blog. (http://geekyboy.com)
    • Clean Application Development – XDebug ● XDebug ● ● Can be installed via Pecl, or using phpize or manual compiling. ● Allows debugging of PHP code. ● 45 An extension for PHP. IDE integration.
    • Clean Application Development – Composer ● getcomposer.org ● ● Not a package manager. ● It is a PHP application in composer.phar. ● 46 Dependency manager for PHP. Configured by using composer.json file.
    • Clean Application Development – Composer Usage ● Using Composer ● ● Issue commands to the composer.phar. ● 47 Used via command line. Packages get downloaded, WITH dependencies.
    • Clean Application Development – Packagist ● Packagist.org ● Composer package repository. ● Archivist of PHP libraries. ● 14,505 packages listed! ● 47,316 versions. ● 52,034,902 packages installed since 2012-04-13. ● How to use: ● ● Copy/paste the required line to composer.json. ● 48 Search for desired package. Run 'composer install' (or update).
    • Clean Application Development – Packagist Search ● Just 49 search!
    • Clean Application Development – Database Datebase 50
    • Clean Application Development – Data Conventions ● Database ● should be clean as well Stick to conventions. (defined by project) ● ● ID field ● Foreign field names {table}_id ● 51 Table names Timestamps for created/modified
    • Clean Application Development – Right Database ● Choose ● the right database for the job Many to choose from: ● ● MongoDB ● MSSQL ● DB2 ● Postgres ● Oracle ● SQLite ● 52 MySQL Text file
    • Clean Application Development – Source Control Source Control 53
    • Clean Application Development – Baby steps ● Learning ● to code, like walking, takes time We fall down...alot! ● ● Scope changes. ● Bugs. ● 54 Learning new methods. Refactoring.
    • Clean Application Development – Pick-up ● Source ● Control Helps us get back up! ● ● Blame. ● Rollback. ● Audit trail. ● 55 Diff. Link back to tickets.
    • Clean Application Development – Characteristics ● Key characteristics of source control ● ● Keep history. ● Be available. ● Easy to use. ● Secure. ● Allow multi-user. ● 56 Track changes. Able to merge changes.
    • Clean Application Development – Subversion ● Subversion style SCM workflow Shared Repository Developer 57 Developer Developer
    • Clean Application Development – Integration Mgr. ● Integration manager SCM workflow Blessed Repository Integration Manager 58 Developer Public Developer Public Developer Private Developer Private
    • Clean Application Development – Dictator/Lieutenant ● Dictator and lieutenants SCM workflow Blessed Repository Dictator Lieutenant Lieutenant Developer 59 Developer Developer Developer
    • Clean Application Development – Workflow Workflow 60
    • Clean Application Development – Agile ● Project Iteration ● Average sprint is 2 weeks. ● At the end of the sprint EVERYTHING is “done“. ● ● ● Development. ● ● Tests. Documentation. Velocity charts are very important, put them up! Burn down chart must go on the wall to let everyone know just how “screwed“ they really are. ● ● Allows business to recover. ● 61 Agile = hope killer. *joking* Lack of charts prevent graceful recovery.
    • Clean Application Development – Team Workflow ● Team development workflow ● Developer is assigned task. ● Checks out code to private development branch. ● Developer adds functionality. Project assigned 62 Checkout dev. to private {user}-development Coding
    • Clean Application Development – Team Workflow ● Team ● development workflow After coding is completed developer tests code. Project assigned 63 Checkout dev. to private {user}-development Coding Testing
    • Clean Application Development – Team Workflow ● Team ● development workflow When all tests pass, developer pushes code to public development branch. Project assigned Tests pass 64 Checkout dev. to private {user}-development Merge changes to development Coding Testing
    • Clean Application Development – Team Workflow ● Team QA workflow ● QA testing in development branch. ● If bugs, return to developer. ● If pass, merge with staging branch. Return to developer flow no Testing assigned 65 Testing from development Test passed yes Merge to staging
    • Clean Application Development – Team Workflow ● Team deployment manager workflow ● Regression test in staging branch. ● If failed, create temp branch for bug fix. Bug fixed Temp branch created no Deploy assigned 66 Regression testing In staging Test passed
    • Clean Application Development – Team Workflow ● Team deployment manager workflow ● If pass, merge to master branch. ● Create tag for new version. Bug fixed Temp branch created no Deploy assigned Regression testing In staging Test passed yes Tag created 67 Merge to master
    • Clean Application Development – Team Workflow ● Single developer workflow ● Pretty similar, but no staging. ● Still use a private development branch. 68 {user}-development Test passed Merge to development Tag created Project assigned Merge to master Regression test
    • Clean Application Development – The Code The Code 69
    • Clean Application Development – Resources ● Resource on clean coding practices. Clean Code By Robert C. Martin 70
    • Clean Application Development – Drivers ● Disasters happen, resulting in bad code... ● ● Short deadlines. ● Laziness. ● Lack of “how-to“. ● Coupled application. ● Impatient boss. ● Bored of same ol' app. ● Come back and clean later. ● We are the cause! ● 71 Writing dirty code is easy. Why did we write it!?!
    • Clean Application Development – Defend the code ● It is our responsibility to say “NO“ and provide good code ● ● Our job = defend the code. ● 72 Managers job = defend schedule and features. Managers cave to realistic reasons and explanations.
    • Clean Application Development – Result of bad code ● We have all seen bad code ● ● Causes bugs. ● Excessive debugging ● Causes procrastination. ● Missed deadlines. ● Technical debt. ● Financial losses. ● Company killer. ● 73 Time waster. I didn't write it!!!
    • Clean Application Development – Dirty Code Results 74
    • Clean Application Development – Dirty Code Results Time Waste 75
    • Clean Application Development – Dirty Code Results Time Waste 76
    • Clean Application Development – Dirty Code Results Time Waste 77 Creates Bugs
    • Clean Application Development – Dirty Code Results Time Waste 78 Creates Bugs
    • Clean Application Development – Dirty Code Results Time Waste 79 Creates Bugs Debugging
    • Clean Application Development – Dirty Code Results Time Waste 80 Creates Bugs Debugging
    • Clean Application Development – Dirty Code Results Time Waste Procrastination 81 Creates Bugs Debugging
    • Clean Application Development – Dirty Code Results Time Waste Procrastination 82 Creates Bugs Debugging
    • Clean Application Development – Dirty Code Results Time Waste Procrastination 83 Creates Bugs Late Projects Debugging
    • Clean Application Development – Dirty Code Results Time Waste Procrastination 84 Creates Bugs Late Projects Debugging
    • Clean Application Development – Dirty Code Results Time Waste Debugging Procrastination 85 Creates Bugs Late Projects $$$ Loss
    • Clean Application Development – How we cause it? ● Bad code starts innocently ● Hire a new professional/developer ● Clean slate, no expectations. ● Start ● a new project Initial code output is quick, setting expectation. ● ● Bug introduction increases. ● Over-coupled system. ● Complexity increases. ● Completion time...unknown. ● 86 Slows down over time. Domino effect.
    • Clean Application Development – The aftermath ● How do we handle this? ● ● Hide. ● Become defensive. ● Blame others/requirements. ● Add more developers to increase productivity. ● New developers break the system, because they don't “know“ it. ● Change jobs. ● 87 Severely padded estimates. Rewrite!
    • Clean Application Development – You are judged ● Others judge us on our code ● We are @authors. ● Others read our code regularly. ● And they talk about it! ● How developers talk about us = “CRED“. And they talk about it! 88
    • Clean Application Development – Coding standards ● Coding Standards save time ● Choosing a standard gives direction on best practices. ● PHP Framework Interoperability Group (https://www.php-fig.org). ● PSR-0 Autoloader. ● PSR-1 Basic Coding Standard. ● PSR-2 Coding Style Guide. ● PSR-3 Logging ● ● Zend Framework (helped with PSR). ● Symfony2 (helped with PSR). ● CakePHP (helped with PSR. ● Lithium (helped with PSR). ● 89 PEAR (helped with PSR). Many more (helped with PSR).
    • Clean Application Development – Clear names ● Names ● should be clear Functions and variables should tell a story. Bad $elapsed; $createdDays; $modifiedDays; $age; 90 Good $elapsedTimeInDays; $daysSinceCreation; $daysSinceModified; $fileAgeInDays;
    • Clean Application Development – No confusion ● Shy ● away from variations of the same name To ensure names are different enough to portray difference. What is the difference between these? $product $productInfo $productData $productDescription 91
    • Clean Application Development – Bad characters ● Certain characters are hard to understand Bad Lower case L Uppercase O (oh) Uppercase I (eye) 92
    • Clean Application Development – Name grammar ● Use technical names to help developers, since developers will be reading the code. Leave non-technical terms for client documentation. ● Class names should be nouns ● They describe. ● Ex. - Customer, Account, Product, Company. ● Method names should be verbs ● Take action. ● Ex. - getCustomer, closeAccount, updateProduct, addCompany. ● Pick a set of keywords and stick with them. ● 93 Ex. - fetch, get, add, update, remove, delete
    • Clean Application Development – Common sense ● With all of these problems, clean code makes sense ● ● On-boarding of developers easier. ● Less bugs. ● Happier end-users. ● Predictable schedules. ● 94 Shortens development time. It's the professional thing to do.
    • Clean Application Development – Rewrite problems ● The ● problem with a rewrite Reasons NOT to rewrite: ● Budget. ● Time. ● Retain business logic. ● ● Refactoring = best teacher. ● 95 Rewrite is the lazy way out. (perceived) Circle of HELL!
    • Clean Application Development – Clean code ● More ● on Clean Code Functions are pretty much what we expected. No surprises. ● ● ● Small and well named. Code makes language look simple. Recognizing bad code doesn't mean we know how to write clean code. ● ● ● ● 96 We know if a song is good/bad, but we are not song writers. Knowing code is bad doesn't mean we know how to clean it up. Clean code is written by someone who cares, and it can't really be changed much. Does not require many, if any, comments.
    • Clean Application Development – Code comments ● Comments can also be a bad “smell“ ● ● 97 Comments are often used to cover up bad code. Code should be self-documenting
    • Clean Application Development – Design Patterns ● Standard and quick solutions to common coding problems ● Provide standard ways of dealing with common code problems. ● “Guide to PHP Design Patterns“ by Jason Sweat. ● 98 “Design Patterns, Elements of Reusable Object-Oriented Software“ by Gang of four
    • Clean Application Development – Peer code reviews ● Peer code review great learning tool ● ● Fresh set of eyes. ● 99 Peers help train each other on strong points. Builds better teams.
    • Clean Application Development – Refactoring Refactoring 100
    • Clean Application Development – Resources ● Great refactoring resource. Refactoring By Martin Fowler Companion PHP code at: https://github.com/adamculp/refactoring101 101
    • Clean Application Development – Definition ● What ● is refactoring? ...process of changing a computer program's source code without modifying its external functional behavior... en.wikipedia.org/wiki/Refactoring ● ● Improve code readability. ● Simplify code. ● 102 Should not add functionality. Not optimizing.
    • Clean Application Development – Two Hats ● Two hats ● ● Refactoring hat ● 103 Adding functionality hat We add functionality, then refactor, then add more functionality ...
    • Clean Application Development – Why Refactory ● Why refactor? ● ● Poor design. ● Preserve design. ● Reduce duplication. ● Improve maintainability. ● Help code faster. ● Locate bugs. ● Code smells. ● 104 Prevent code decay. It's professional.
    • Clean Application Development – Code Smells ● Code ● smells What are smells? ● ● Not conclusive. ● 105 Indications of spoiled code nearby. Smell is not bad code, but hints of potential problems.
    • Clean Application Development – Smells of bad code ● Smells list ● Duplicate code. ● Large class. ● Long methods (functions). ● Long parameter (argument) list. ● Divergent change – cascade change to accommodate one. ● Shotgun surgery – change ripples as bugs throughout. ● Feature envy – method uses many parts from other class. ● Data clumps – data items accomplany one another. ● ● 106 Primitive Obsession – using primitive objects to represent various concepts in places they don't actually fit. (string vs integer, integer vs float, string vs date) Switch statements – often not alone, and sacrifice polymorphism.
    • Clean Application Development – Smells of bad code ● Smells list (cont'd.) ● ● Lazy class – class not doing much, just to be a class. ● Speculative generality – something built for possible future. ● Temporary field/variable. ● Message chains – object asking object asking object, etc. ● Middle man – directors in place but serve no real purpose. ● Inappropriate intimacy – classes should not share private parts. ● Data class – getters and/or setters, but nothing else. ● 107 Parellel inheritance hierarchies – forced to subclass due to another subclass. Comments – where comments explain bad code.
    • Clean Application Development – Code sniffer ● Let PHP CodeSniffer detect bad smells ● ● Run during commits in version control. ● 108 Set rules to detect if coding standard is not followed. IDE integration.
    • Clean Application Development – When to refactor ● When to refactor? ● No special time, do in short bursts. ● Don't decide to refactor, do it to gain something. ● Prior to adding functionality. ● ● ● Highlights code to modify. Fix code preventing addition. When fixing a bug. ● ● ● Makes code understandable. Highlights the bug. During code review. ● ● 109 Fresh eyes see things differently. More concrete results.
    • Clean Application Development – How to start ● First ● steps Use source control (Git, SVN, etc.) ● ● ● Record each step, and provides rollback points. Prove we did/didn't break it. We MUST FIRST GET IT WORKING! ● Do NOT refactor a broken application. ● ● 110 Pre-load database or create fixtures for consistent results. Create tests on working application.
    • Clean Application Development – Tests ● Tests ● Cannot properly refactor without tests. ● ● and refactoring To gauge success/failure. Basic refactor steps: ● Ensure tests pass. ● Plan refactor. ● Implement. ● Ensure tests still pass. ● Updating tests if needed. Only needed if structure changed. Add more tests to cover newly discovered items. ● ● ● 111 Repeat!
    • Clean Application Development – Refactoring 112
    • Clean Application Development – Refactoring Not if Broken 113
    • Clean Application Development – Refactoring Not if Broken 114
    • Clean Application Development – Refactoring Not if Broken 115 Create Tests
    • Clean Application Development – Refactoring Not if Broken 116 Create Tests
    • Clean Application Development – Refactoring Not if Broken 117 Create Tests Detect Smells
    • Clean Application Development – Refactoring Not if Broken 118 Create Tests Detect Smells
    • Clean Application Development – Refactoring Not if Broken Different Hats 119 Create Tests Detect Smells
    • Clean Application Development – Refactoring Not if Broken Different Hats 120 Create Tests Detect Smells
    • Clean Application Development – Refactoring Not if Broken Different Hats 121 Create Tests Improve Code Detect Smells
    • Clean Application Development – Refactoring Not if Broken Different Hats 122 Create Tests Improve Code Detect Smells
    • Clean Application Development – Refactoring Not if Broken Detect Smells Different Hats 123 Create Tests Improve Code No Change
    • Clean Application Development – Architecture Architecture 124
    • Clean Application Development – Clear architecture ● We can tell pretty simply this “looks“ like a library. (bookshelves, computers, book categories) 125
    • Clean Application Development – Simple overview ● With cars driving through and shelves on the sides we can guess this is a drive through. 126
    • Clean Application Development – Obvious purpose ● These 127 are pretty obvious without any explanation.
    • Clean Application Development – MVC architecture? ● This 128 would take a bit more digging to figure out.
    • Clean Application Development – Future challenges ● Shouldn't “Architecure“ be cleaner/clearer/simpler? 129
    • Clean Application Development – Testing Testing 130
    • Clean Application Development – Selenium IDE ● Selenium IDE ● ● Automates human steps. ● 131 Integrated into browsers. Customizable.
    • Clean Application Development – Behavior Driven ● Behat ● ● For PHP 5.3 and 5.4. ● 132 Open source. Human-readable sentences describing feature.
    • Clean Application Development – Unit Testing ● Unit testing (our parachute) ensures we write clean code ● ● Function should only do one thing, making them short. ● Testing ensures system is functioning as expected. ● 133 A unit test should only test one thing, a function may need multiple tests. Helps make refactoring and cleaning easier.
    • Clean Application Development – TDD ● Unit ● 134 testing is important, so should be done first Write failing tests first, then write the code required to make it pass.
    • Clean Application Development – Tests = QA ● If tests are trusted, they become QA process ● If tests are good, QA finds no issues. ● If QA finds an issue, write a test for it. ● Tests cover requirements. ● Tests = requirements. ● QA to write automated tests that fail. ● 135 Developers execute tests during development till they pass.
    • Clean Application Development – QA and unit tests ● Put QA at the begining of the process, instead of the end ● QA has a terrible job, waiting for code to test. ● If they write unit tests they jump to the front. ● Developers write code to pass tests. ● 136 The end is not so bad now.
    • Clean Application Development – Continuous Int. Continuous Integration 137
    • Clean Application Development – Phing ● PHing Is Not GNU make. ● Based on Apache Ant. ● Uses simple XML build files and extensible PHP 'task' classes. ● ● File transformations ● File system operations. ● Interactive build support. ● SQL execution. ● SCM operations. ● Documentation generation. ● 138 Runs unit tests. More....
    • Clean Application Development – Zend Deployment ● Zend Deployment ● ● Create ZPK of project in Zend Studio. ● Upload to Zend Server. ● 139 Built into Zend Server. Deploy!
    • Clean Application Development – Jenkins ● Jenkins ● ● Built with Java. ● 789 plugins. ● Runs PHPUnit. ● Runs CodeSniffer. ● Runs PHP QA Tools. ● 140 Formerly known as Hudson. Deploys.
    • Clean Application Development – Jenkins Results ● Jenkins 141 Results
    • Clean Application Development – Professional Be Professional Grade! 142
    • Clean Application Development – Human resources ● Our ● ● Professionals are trusted to do a good job, give good estimate, and provide quality. Professionals are fairly easily replaced, depending on availability. ● ● 143 clients hired a professional, they should get one Replaceable = Promotable (and you can take vacation easily) Shouldn't need to start from scratch.
    • Clean Application Development – Close ● Clean application development is: ● ● Clear architecture. ● Coding standards and styles. ● Framework and best practices. ● Testing. ● Agile. ● Learning to say “NO“, and defend the code. ● 144 Learning, repetition, practice. Living up to the title “Professional“.
    • ● Resources ● Adam Culp @adamculp and http://geekyboy.com ● Book: “Clean Code“ by Robert C. Martin ● Book: “Refactoring“ by Martin Fowler ● Book: “Guide to PHP Design Patterns“ by Jason Sweat ● Book: “Design Patterns“ by Gang of four ● http://www.php-fig.org ● http://www.phpunit.de ● http://www.soflophp.org Thank You! https://joind.in/9284