Improve Your Code Now! SIMPLE and Exciting Techniques to Improve System Quality22 Feb 2011 | Comments
Yeah, I know the title sounds very corny - just like those howtos books.
Anyway - that is actually the title of the presentation that I gave at a place that I used to work. At that place, the developer team had to deal with .. to call it a spaghetti code would be a compliment, a big ball of mud would be more appropriate.
Without further a due, this is the presentation.
Improve the code – one line at a time. Refactoring / code improvement begins by small steps but if done by everyone over the period of time, it will evolve to a great system – a system that everyone will be happy to work with.
It will take commitment and perhaps some learning/training is needed if you are less experienced / knowledgeable in one area/several areas.
Why do we need to improve the code? Simple, the code is tangled, difficult to maintain and brittle. We all experience daily frustrations dealing with such codebase.
I will look at some examples from the codebase and suggest some simple improvements:
- Indent the code
- Fix spelling mistakes
- Fix HTML codes - unclosed tags, deprecated tags, mixed casings
- Move styles from HTML to CSS files
- Put comment to the code (especially the ones that are hard to understand). This also applies if you just figured out what a piece of code does, if it wasn't obvious to you in the first place - chances are it won't be obvious to other people in the team
- Remove codes that are not used (client left us), remove commented codes, remove codes by developers who have left the company and the codes are not in production. Dead codes make our application FAT
- Re-structure codes into different sections / includes – group them logically – learning from MVC concepts we can do similarly now!
- Avoid code repetition (DRY – Do not Repeat Yourselves) – do not cut and paste without thinking – use CFCs, Custom Tags, CFinclude, JS files, CSS etc2. Again do not make the application fatter than it is now.
- ?? – share your own ideas on what you can do TODAY that brings the quality of the code.
Whenever you touch the code - make sure you make it better than before.