Code Design

Is it important? People always misunderstand code design with code tidy. Code tidy is not code design. Code tidy can be done automatically by some popular IDE. By example if you press CTRL+SHIFT+F in Eclipse, it will tidy the code in less than one second with the format you determined in the preference menu. However, some IDE has some features to help implementing code design .

What's the impact of a bad designed code, or an un-designed code? A well designed code will lengthen the code's lifetime coz it can be easily changed, maintained, and added. I think that this is what make a programmer doesn't hate his job. In my opinion, code design is crucial to a software company. A company which has a bad smelled code won't be productive enough to grow rapidly along the technology improvement. And what will the programmer do when the code started to smell very bad? They resigned and move to another company because they feel that:

  • They have a lot of work to do
  • The customer always love to ask for features which need changes in the code which they think is impossible to implement
At this time, they preferred to blame the "job" or the "company" rather than the "code" which they themselves wrote several years ago. Which is tightly coupled, and has a low cohesion. Afterward, I think this code or this software product will be died soon it's continuously going like that.

Imagine a small cup sized 100 cc. You can't load the cup with 200 cc of waters if its size is only 100 cc. In this case, you have to change the cup with a bigger cup. The cup is the code's design, and the water is the features of the software application.

Below are some of the major bad smelled codes:
  1. Doesn't implement any programming style (ex: OOP)
  2. Duplicated code
  3. Big class
  4. Big method
  5. Too many temporary variable
  6. Nested if
  7. Nested loop
  8. Nested try catch finally block
  9. Long parameter list
  10. Unused codes
The best time to fix bad smelled code is when you are starting writing a project. When it's already deployed to client, it won't be easy anymore to fix it, especially to a project which doesn't has unit test and automated test at all. In this time what you can do is to refactor just a little part of the code of which you have to modify or add something.

Maybe you felt that it happened to you, or you see it happened in your company, but this is just my opinion and I don't meant to hurt anyone.

0 comments: (+add yours?)