Most of us feel that developing algorithm is the main part of whole SDLC(Software Development Life Cycle) which is actually not the case. We, generally, ignore the vital part of coding and do it in our stride. Here, I am mentioning the 3 ‘S’ of coding which one must take care always:
1) Simple: As they say, "Think simple, think better". Keep the design as simple as you can(of course, it should be meeting all functional specifications). One thing worth noting with simplicity is that generally, the first thought that comes to our mind is simple and better. We are the one who make it complex later. So, Believe on your first idea.
2) Scalable: You design should be scalable enough. By scalability, it means “It should be modular enough to accommodate further changes in requirements without modifying much at the base level.” For example, if the logic of your problem demands reading/writing from/to an XML file, you have two ways to do this:
a. Either do normal XML parsing using XMLDocument Class Object(in C#).
b. Use concept of Serialization/Deserialization to derive object out of classes(formed from XML Schema(Xsd)) and populate those object. This will save you at later stage when you need to do some changes in XML. Using this method, you need to just change your schema and voila , you are done! No need to modify hard code.
Clearly, scheme 2 is more scalable. But as you can see, Simplicity and Scalability often contradicts each other. It needs a great combination of experience and expertise to make a balance between two.
3) Standard: This is one of the thing, we ignore the most. But, this is the most important ‘S’ out of 3. Being Standard means following some standard notations, that are followed in industry. This benefits in two ways:
a. Following standards makes the code easy to debug.
b. It also help the followers of your code in easy understanding.
Different languages follow different standards, but common ones are:
i. Identifier Naming: Using camel casing for variable names and Pascal notation for properties and functions. Identifier names should be fully descriptive e.g for a varible which stores the count of old customers in an airline, use variable name as oldCustomerCount rather than using some fundoo names as oldcustcnt or CustmrCnt. Adding few extra characters won’t affect you much in this world of Intellisense and all.. Will it?
ii. Adding Comments: Adding comments to code is also an art. It’s not that you add whatever you want to. It also follows few standard conventions like adding name of the editor, date and time of comment etc.
iii. Indentation and Line Folding: These are generally taken care of automatically in advanced IDEs like Visual Studio, Eclipse etc and need little from side of programmer. Of course, you need to take care if you are using some ancient compilers like Turbo C .:)
iv. Minimal use of Public members: One should use public variables in classes(in C++, C# etc.) as less as possible. Rather use private variables and properties(get and set) derived out of them.
Also, few other things like preferring Asynchronous Callbacks over Continous Polling are also counted as Good programming skills.
So, merely developing algorithm is not enough. You need to implement them by coding and coding well. You will have to do trade-offs among 3 ‘S’ of coding at various stages but that’s how you develop and mature. Isn’t it?
Happy Coding :)