Your SlideShare is downloading. ×
Code Quality Practice and Tools
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Saving this for later?

Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime - even offline.

Text the download link to your phone

Standard text messaging rates apply

Code Quality Practice and Tools

599
views

Published on

Why you should write quality code and how to effectively use tools to do it.

Why you should write quality code and how to effectively use tools to do it.

Published in: Technology

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
599
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
19
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide
  • So often people look at this as an oxymoron. As long as it works isn't that enough. Well those of us that have been doing this long enough know there's more to delivery than just getting the code to work. We all seemed to know what bad code looks like but what about good code. It's harder to nail down a generic definition that's useful in all cases but we will try anyways.
  • Long Methods Tight Coupling Concrete Implementation Excessive Code Branching
  • Short Methods Loose Coupling Abstract Implementation Minimal Code Branching
  • Transcript

    • 1. Code Quality Paulin Solutions LLC
    • 2. Paulin Solutions LLC
      • Have code will travel
      • Mobile Web Development
      • CMS/Portal (Liferay Adobe CQ 5.x)
      • Delivery Innovation
    • 3. Topics
      • Why bother writing quality code?
      • What is Code Quality
      • Components of Code Quality
      • Tools
      • Final Thoughts/Discussion
    • 4. Why Bother?
    • 5. What your client sees
    • 6. What you see
    • 7. The Psychology of Computer Programming
      • Gerald Weinberg
      • Programming is a social activity
      • CODE – It's not just for computers anymore!
    • 8. Why would you do this to another Human Being!?!?
    • 9. What is Code Quality?
      • ?
    • 10. Good or Bad? protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (req != null ) { if (req.getParameter( "type" ) != null ) { String reqType = req.getParameter( "type" ); if (reqType == "FOO" ) //Do something }}}
    • 11. Good or Bad protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String type = req.getParameter( "type" ); if ( FORWARD_TYPE .equalsIgnoreCase(type)) { countForward(req, resp); } else if ( BACKWARD_TYPE .equalsIgnoreCase(type)) { countBackwards(req, resp); } else { throw new RuntimeException( "This type is not supported." ); }
    • 12. Bad Code Smells!
    • 13. I've learned to live with the smell why else should I care?
    • 14. Reduce Bugs
    • 15. Lower Maintenance Effort
    • 16. It's Easier to Extend Good Code
    • 17. Create Good Code Karma
    • 18. Give your client the warm and fuzzy feeling. Quality Code = Trust
    • 19. Components of Code Quality
    • 20. Good Code Should Work! Functional/Non-Functional
    • 21. Components should be testable
    • 22. Hard to Test
      • p rivate void addPlayerObjects()
      • /* the physical objects are the enclosing box and its spheres */
      • {
      • // create the spheres
      • players = new PlayerManager(sceneBG, world, collSpace, BLUE, RED);
      • // need to add DLL files ElementXML.dll, Java_sml_ClientInterface.dll,
      • // and SoarKernalSML.dll to java.library.path
      • IFormation offFormation = new FndtFormation(
      • PlayerManager.OFF_PLAYER_TYPE);
      • IFormation defFormation = new FndtFormation(
      • PlayerManager.DEF_PLAYER_TYPE);
      • InitFootballAgents initTask = new InitFootballAgents(positions,
      • offFormation, defFormation);
      • FormationSoarTask task = new FormationSoarTask(playText, offFormation,
      • defFormation);
      • try
      • {
      • soarManager.clearAgents();
      • soarManager.executeSoarTask(initTask);
      • soarManager.executeSoarTask(task);
      • } catch (Exception e)
      • {
      • e.printStackTrace();
      • JOptionPane.showMessageDialog( this , e.getMessage(), "Soar Error" ,
      • JOptionPane.ERROR_MESSAGE);
      • }
    • 23. Easy to test
      • public ModelAndView welcome(HttpServletRequest request,
      • HttpServletResponse response) throws Exception {
      • return new ModelAndView( "welcome.page" , "data" , dataManager );
      • }
      • public ModelAndView openMenu(HttpServletRequest request,
      • HttpServletResponse response) throws Exception {
      • return new ModelAndView( "topNav.comp" , "data" , dataManager );
      • }
      • public ModelAndView manageUsers(HttpServletRequest request,
      • HttpServletResponse response) throws Exception {
      • return new ModelAndView( "manageusers.page" , "userList" , dietDaoService .getUsers());
      • }
    • 24. Rule of thumb for writing testable code...
    • 25. Practice good design!
    • 26. Good code should be easy to maintain
    • 27. Readable
    • 28. Stay DRY
    • 29. Avoid Excessive Complexity
    • 30. Ummmmmm that sounds like a lot of work!
    • 31. Making sure it works
    • 32. Benefits of Functional Test Frameworks
      • Test often
      • Self Documenting
      • Code Fearlessly
    • 33. Making sure it's tested
      • Cobertura
      • Emma
      • Clover
      • Jacoco
      • DevPartner
    • 34. Benefits of Code Coverage Tools
      • Know where your risk is
      • Help with Debugging
      • Determine what your QA is doing
    • 35. Making sure it's maintainable
      • PMD
      • FindBugs
      • DevPartner
    • 36. Benefits of Static Analysis
      • Find bugs before you check in code
      • Enforce Coding Standards
      • Low effort code reviews
    • 37. Putting it all together
    • 38. Benefits of Sonar
      • Single Dashboard to display test results, coverage, static analysis.
      • Drill down into the code with syntax highlighting
      • Issue Assignment and workflow
      • Simple build integration
    • 39. Parting thoughts Don't write crappy code. I know where you live.