The most important point to consider while designing and writing code
1) Always design code in such a way that it is Open for extension but Closed for modification.
i.e when a new requirement comes don't add new code to the classes that work but create new classes to fulfill those requirement . i.e the previous code is locked.
The more code code you add to the existing working code the more possibility of introducing new bugs and ofcourse you have to change the UnitTest Code too.
ALWAYS TRY TO USE DESIGN PATTERN LIKE FACTORY,SINGLETON ETC.
USE OOP CONCEPTS TO KEEP THE DEPENDENCY TO MINIMUM.
I will give you an example here...
Create a Abstract base class... and derive your classes from that i.e different version of classes.
This way you can use the factory pattern and create the appropriate version of the classes depending upon the requirement.
This way you keep the dependency to minimum.
VERY USEFUL TECHNIQUE----
2) ALWAYS GO BACK AND REFACTOR YOUR CODE (Very Important)
As new requirement come always go back and try to refactor you code, create new classes, delegate functionality to different classes, this makes the individual code more testable.
Very important while writing code.
When you have implement something..
a)Start with simple things... make then work as desired.
b) Then go back and add new functionality to it.
c) Side by Side your integration code should go on, i.e think about how you will integrate with you add i.e creating MSI, installers etc...
If you write code this way, there are more chances of finding the edge cases and your code will be more solid. Always implement small components i.e small projects and then integrate with the main application.
Don't code the whole thing in one shot, Very important concept to remember.
When designing api's, try to separate out the common things from the things that differ. Designing good api is a very important thing in software developers life (atleast for me it is the single most important thing) .
If you follow this, your code will definitely be more solid and testable.
These are some of the points I learned from my Manager here in Redmond, WA.
Update:
Before writing code two things to remember
1) Code should be as testable as possible.
2) Code should be reusable.
Consider each functionality as a seperate set of class.-- Always think how I can refactor this functionality into different set of classes. (Very important for good design.)
Happy Programming!!!
Yash
Saturday, May 31, 2008
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment