Writing
a high quality code
Saki
Jozef Sakáloš
•provide project consultancy and supervision
•on-line consultancy, code review, extensions
•deliver Sen...
Contact
•jsakalos@extjs.eu, jsakalos@gmail.com
•Facebook: jsakalos
•Skype: jsakalos
•Sencha Forums: jsakalos
Code Quality
Code must work, but
•fixing a bug introduces (many) new bugs
•a new developer cannot (easily) comprehend the code
•impleme...
if(anyOfAbove === “yes”) {
codeQuality !== “high enough”;
}
Quality
1. is degree of perfection of a product
2. is the standard of something as
measured against other things of a
simi...
High quality code is
1. pleasant to read and easy to grasp
2. abide by standards
3. modular
4. bug-free
High quality code is
5. finished
6. clean
7. documented
8. working
The code must be
pleasant to read and
easy to grasp
Write the code for
another person
Ugly code
Ugliest code
Beautiful code
The code must abide
by standards
Two kind of standards
•JavaScript standards
•your coding conventions
http://jslint.com
Do you have a written
Code Style Guide?
Style Guide
•naming conventions
•spaces, indenting, commas
•how to write docs
•how to write file header footer
•... and ot...
Sencha recommends
naming conventions
in The Class System
guide
Code must be
modular
Example
Task #1:
Split the app into
small modules.
Rule #1: Define and
then abide by API of
modules
Corollaries
•controller must not know view internals
•view must fire custom events
•dynamic view must expose an API
•view ...
Don’t do it like this
Controller
View
Button
ListenHide/Show
View
Store
Record/Field
...but like this
Controller
View
Button
View
Store
setVisible
handler
custom event
updateRecord
No more spaghetti code
The code must be
bug-free
The code must be finished
Finished === there is nothing more to
be done on it
if(code.indexOf(“@todo”) !== -1) {
code !== ...
The code must be
documented
see http://github.com/senchalabs/jsduck
And, of course, the
code must WORK!
Questions?
Happy quality
coding!
Writing High Quality Code
Upcoming SlideShare
Loading in...5
×

Writing High Quality Code

2,438

Published on

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

Published in: Technology
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
2,438
On Slideshare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
9
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

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!
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×