The goal of every programmer is producing a good program. Nearly all programmers strive to sharpen their skill in coding and engineering stuff. But programming is not only matters of code.
A good program is a program which is not only having good response and robust. But we should not forget that other factors are important for a project.
In this article, I list some characteristic of good program design according to me.
The main goal in any program should be to minimize complexity. As a developer, our time will be maintaining or upgrading existing code. If it is a complete mess, then your life is going to be that much harder. Try and avoid those solutions where you use a one line complex solution to replace 20 lines of easy to read code. In a year, when you come back to that code, it will take you that much longer to figure out what you did.
The best practice of it will be structuration of code and following some patterns. A modularity is also good for design, don’t write all codes into a single source file.
Ease of Maintenance
This is making your code easy to update. Find where your code is most likely going to change, and make it easy to update. The easier you make it, the easier your life is going to be down the road. Think of it as a little insurance for your code.
So What is loose coupling? It is when one portion of code is not dependant on another to run properly. It is bundling code into nice little self reliant packages that don’t rely on any outside code. How do you do this? Make good use of abstraction and information hiding.
This means that you design your program so that you can add or remove elements from your program without disturbing the underlying structure of the program. A good example would be a plug-in.
Write code that will be able to be used in unrelated projects. Save yourself some time. Again information hiding is your best bet for making this happen.
This refers to having a large number of classes that use a given class. This implies that you are making good use of utility classes. For example you might have a bunch of classes that use the Math class to do calculations.
Low to Medium Fan-out
This refers to having a low to medium amount of classes used by any given class. If you had a class that includes 7 or more classes this is considered high fan out. So try and keep the number of classes you include down to a minimum. Having a high fan-out suggests that the design may be too complex.
Simply put, design a system that can be moved to another environment. This isn’t always a requirement of a program, but it should be considered. It might make your life easier if you find out your program does have to work on different platforms.
Leanness means making the design with no extra parts. Everything that is within the design has to be there. This is generally a goal if you have speed and efficiency in mind. A good example of where this might come in handy is creating a program that has to run on a system with limited resources (cell phone, older computers)
Try and standardize your code. If each developer puts in their own flavor of code you will end up with an unwieldy mess. Try to layout common approaches for developers to follow, and it will give your code a sense of familiarity for all developers working on it.architecture