10 Guidelines To Write Better Code For Creating Awesome Applications

On with 0 Comment
I strongly believe that writing a better code base is an art that is fine tuned with experience. Millions of professional programmers around the world use different programming languages and platforms to build awesome applications. Large scale projects involving several team members presents new challenges when it comes to maintaining the project code among distributed teams. Each programmer tends to program in his own way that includes the way he align the code and the way he maintain it. Although every company's SDLC guidelines clearly define the principles of coding, still some unwritten rules need to be followed to get the best possible results. Let's see how you can practice best coding principles to deliver top notch applications that not only generates an awesome application but can also be easily extended by other programmers at a later stage. These guidelines are simple to follow and will equip you with some basic coding de facto standards to earn you a badge of a professional coding ninja.

C code
Ensuring Readability - No matter how efficient and optimized code you've written, unless it is not formatted well, it's just a crap for other developers. Alignment, indentation and spacing are equally important as the code itself. Readability adds value to your code and makes it much more extensible. You can use a specialized source code editor like Notepad++ or an integrated development environment (IDE) like Eclipse and NetBeans that automatically formats the code for better readability.

Using Annotations (comments) - Proper code formatting alone doesn't make your code easily understandable unless you compliment it with annotations. Almost every language supports inline comments to add helpful annotations to the code. This is very helpful when you're working with a team and your code is used by other members of the team. Annotations ease the deciphering process and helps in quickly absorbing the functioning of your code by other programmers.

Creating Documentation - Although annotation is a big help in deciphering the code, still it does not gives a larger picture in one go. And that's where technical documentation comes handy. Whether it's flow charts, rough sketches or notes, decision tables or pie charts, keeping a hard or soft copy of these documents helps a great deal in better understanding of your code. And above all, documentation acts like a raw framework that presents a big picture giving you enough idea about how all pieces are knitted together to get a finished product. You can also use specialized software documentation tool like Doxygen to quickly generate professional-grade technical documentation for your code.

Maintaining Version History - Large projects involving continuous development routine require proper archiving of source code as well as the builds (executable) for later reference. Unless you maintain each and every version of your source code files, you'll struggle to refer things while going back in the development tree. You can use a specialized version control system like CVS to archive each version of your source code files. This way you can easily trace the development path for any feature of your software.

Reducing Dependencies - Now this can be a bit tricky. Depending on the platform and software you're using, reducing external dependency (calling external libraries) may enhance the performance and efficiency of your application. If you choose the cut down external dependencies drastically, your application's executable can become quite large and may consume large amount of memory. On the other hand, if you keep only the necessary core routines in the main executable and connect with external libraries dynamically during run-time, it may consume less memory but performance may degrade significantly. It's up to you to asses and formulate a strategy about how much external dependencies will be fine for the application.

Delaying Modules Loading - Dynamically linking with external library is one of the common traits of modern applications. This technique doesn't load external modules in memory until they're not needed by the application. It may happen that your application rarely needs an external dependency during the run-time. This saves the system memory and keeps the application fast and efficient. Carefully plan loading of dynamic libraries and make sure all rarely used libraries are only loaded when they are actually required during run-time.

Ensuring Zero Memory Leaks - One of the problems with poorly coded applications is memory leakage that brings the system down while performing critical tasks. Unfortunately, very less programmers check for memory leaks through debuggers to ensure no leakage of memory during run-time under any circumstances. This activity is generally done thoroughly during the testing phase through artificial test cases. Make sure all memory allocations are relinquished in your source code through at least one condition.

Implementing Exception Handling - Applications may behave unexpectedly on client's site or on end-user machines. During development phase, no matter how good are your test cases, you cannot emulate almost every possible condition while testing the software. To prevent crashing of your software in exceptional conditions makes sure you thoroughly implement exception handling logic in your source code. Good software has 25% to 30% business logic and the rest part comprises of exception handling.

Optimizing For Less CPU usage - In programming world, you can code a same task in 10 different ways. Writing problem-solving code and writing efficient problem-solving code are two different things. Do not settle for the very first code sequence written for solving a given problem. Do some research and testing to find out the most efficient way to get things done. You goal should be to make an application that is memory efficient and consumes less CPU resources. This way your software will not be categorized as memory or resource hogger.

Embedding Help Messages - While developing software, do take care of coding help messages through popups or tool-tips wherever required. Good software without such help messages is like an egg without an outer shell. User-friendliness is one of the major features of good software. While programming such help messages, keep the message text in memory rather than pulling from back-end.


Post a Comment