O slideshow foi denunciado.
Utilizamos seu perfil e dados de atividades no LinkedIn para personalizar e exibir anúncios mais relevantes. Altere suas preferências de anúncios quando desejar.

Writing High Quality Code

Jozef Sakalos at ModUX 2013
http://moduxcon.com

  • Entre para ver os comentários

Writing High Quality Code

  1. 1. Writing a high quality code
  2. 2. Saki Jozef Sakáloš •provide project consultancy and supervision •on-line consultancy, code review, extensions •deliver Sencha Ext and Touch Courses
  3. 3. Contact •jsakalos@extjs.eu, jsakalos@gmail.com •Facebook: jsakalos •Skype: jsakalos •Sencha Forums: jsakalos
  4. 4. Code Quality
  5. 5. Code must work, but •fixing a bug introduces (many) new bugs •a new developer cannot (easily) comprehend the code •implementing changes/features is (extremely) difficult •no, or not up-to-date documentation •cross browser problems
  6. 6. if(anyOfAbove === “yes”) { codeQuality !== “high enough”; }
  7. 7. Quality 1. is degree of perfection of a product 2. is the standard of something as measured against other things of a similar kind
  8. 8. High quality code is 1. pleasant to read and easy to grasp 2. abide by standards 3. modular 4. bug-free
  9. 9. High quality code is 5. finished 6. clean 7. documented 8. working
  10. 10. The code must be pleasant to read and easy to grasp
  11. 11. Write the code for another person
  12. 12. Ugly code
  13. 13. Ugliest code
  14. 14. Beautiful code
  15. 15. The code must abide by standards
  16. 16. Two kind of standards •JavaScript standards •your coding conventions
  17. 17. http://jslint.com
  18. 18. Do you have a written Code Style Guide?
  19. 19. Style Guide •naming conventions •spaces, indenting, commas •how to write docs •how to write file header footer •... and others
  20. 20. Sencha recommends naming conventions in The Class System guide
  21. 21. Code must be modular
  22. 22. Example
  23. 23. Task #1: Split the app into small modules.
  24. 24. Rule #1: Define and then abide by API of modules
  25. 25. Corollaries •controller must not know view internals •view must fire custom events •dynamic view must expose an API •view must not access another view
  26. 26. Don’t do it like this Controller View Button ListenHide/Show View Store Record/Field
  27. 27. ...but like this Controller View Button View Store setVisible handler custom event updateRecord
  28. 28. No more spaghetti code
  29. 29. The code must be bug-free
  30. 30. The code must be finished Finished === there is nothing more to be done on it if(code.indexOf(“@todo”) !== -1) { code !== “finished”; }
  31. 31. The code must be documented see http://github.com/senchalabs/jsduck
  32. 32. And, of course, the code must WORK!
  33. 33. Questions?
  34. 34. Happy quality coding!

×