It's not a good programming practice to try to solve a complex problem with a single function. The proper way to
approach it is to break the problem into several smaller and simpler pieces that can be understood in more details, and
then start to define and build functions to solve those smaller and simpler problems. Keep in mind that each of your
functions should do only one task, but do it well.
As your program continues to grow, you should consider breaking it into several source files, with each source file
containing a small group of cohesive functions. Such source files are also called modules. Put data declarations and
function prototypes into header files so that any changes to the declarations or prototypes can be automatically
signified to all source files that include the header file.
You can use a software-engineering technique known as information hiding to reduce the complexity of
programming. Simply speaking, information hiding requires a module to withhold information from other modules
unless it's necessary.
The C compiler enables you to compile and debug different source files separately. In this way, you can focus on one
source file at a time, and complete the compiling before you move to the next one. With the separate compilation, you can compile only those source files that have been changed and leave the source files that have already been compiled and debugged unattached.
If you're interested in knowing more about software engineering, study Ian Sommerville's classic book, Software
Engineering, which is on the list of recommended books at the end of this lesson.
Friday, October 16, 2009
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment