HomePractices Page 3 - The Art Of Software Development (part 3): Coding To A Plan
Breaking It Down - Practices
With the design out of the way, it's time to finally sit downand write some code. This article discusses the implementation phase ofthe software cycle, outlining some ideas and techniques that should helpyou deliver cleaner, faster and more maintainable code. Miss it at yourperil!
You should also spend time modularizing your application by breaking it up into discrete components - this simplifies development by allowing you to focus on smaller pieces of the puzzle at any one time, and also makes the code easier to maintain.
Code modularization can be as simple or as complex as you like. At one end of the scale is very basic abstraction - separating common interface elements or configuration variables into independent files, which may be included wherever required. Global changes then become as simple as altering a single file, with the changes appearing instantly across the application.
The next step is to do the same with your code - separate common functions into subroutines that can be invoked wherever needed in your application. This has a couple of advantages: first, a subroutine allows you to separate your code into easily identifiable subsections, thereby making it easier to understand and debug. And second, a subroutine makes your program modular by allowing you to write a piece of code once and then re-use it multiple times within the same program.
As your familiarity with code modularization increases, you will find yourself grouping your functions into reusable objects, and writing code using OOP techniques. Remember to clearly define the input and output interfaces of each object, and the interfaces between objects. Create standard APIs so that you can implement "black box" techniques and thereby minimize the impact of a change in one module on other modules.
Since objects allow for inheritance and extensibility, you should consider building a library of standard objects, and using this library whenever needed in your development activities - this can significantly reduce the time you spend on coding standard functions, and also gives you a base of stable and robust code. As you develop new objects, always try to make them as generic as possible, so that they become reusable and useful for subsequent projects. And don't forget the Web - there are rich code repositories for almost every programming language online, and you can often substantially reduce development time by using a free, open-source widget instead of building your own from scratch.