| Divide and Conquer: Relating Complex Linux Problems to Tiny Pieces of C++ Code |
|
|
|
| Written by Rex Djere |
| Saturday, 13 February 2010 22:24 |
|
Any modern Linux distribution is made up of thousands of software packages usually maintained by incredibly large groups of people. How is this done without the entire process falling into chaos and disarray? The simple answer is a key concept called modularity. Modularity simply means building complex designs, such as a word processing program, in manageable modules. This technique is analogous to the “divide-and-conquer technique”. If a community of 10 people are working on a word processing program, they might divide the tasks needed to build the program into the skill sets in which each of the 10 members is the strongest. For example, 1 member might be an expert of building spell-checking functionality. This expert might build the spell-checking modules of the word processor. This modular design makes the software's code much easier to review and much easier to maintain. If the group wants to upgrade the spell-checking feature of the word processor, it is very likely that the code for the other parts of the word processor will not have to be changed very much, if at all. Most likely, only the code for the word processing module will have to be upgraded. This allows for a great deal of development independence. As long as the maintainer adheres to protocols that allow the different modules to communicate with each other, he or she can work on their individual module relatively autonomously. They can maintain a reasonable level of certainty that the overall program will continue to work. Periodic testing and communication between the module developers can verify this.
To delve into this topic in more detail, I will relate Linux software development to the development of programming code in C++. In C++, there are a set of standard functions that any C++ programmer can use. The functions have been built by other coders, freeing the programmer from having to build these functions from scratch. For example, one of the standard math functions in C++ is the fabs(x) function. The fabs(x) function returns the absolute value of whatever number is placed inside the parentheses in place of “x”. For example, fabs(-9.23) would return 9.23. The fabs(x) function is an example of a module. It is also known as a function, a method, or a procedure, depending on what programming language one is using. However, the concept remains the same. The programmer does not need to know the details of how fabs(x) does what it does. He or she only needs to know what the result of its calculation will be. Writing Linux software operates in a similar manner. The maintainer of the “export to alternate file format” module of our word processing example doesn't really care how the spell-checking module works, only THAT it works. The only people that really need to know the precise details of how the spell-checking modules works are those that maintain it. Good Linux programs are written the same way good C++ programs are written: the programmer combines pre-existing functions and classes with custom ones that he or she writes. In doing so, a functional program is created that meets the needs of solving a particular problem or set of problems. If you are writing Linux software, even in a language other than C++, the same basic principles and concepts will allow you to write good code.
So we have created a basic conceptual relationship between the disciplines necessary to produce good C++ code to producing good Linux programs. Linux programs can be written in C, C++, C#, D, Java, Pascal, or a host of other programming languages. The principles of writing good code in any application are the same. A good C++ programmer can become a good programmer in ANY language or application. How is this possible? A great professional athlete is always one who is well grounded in fundamentals. A player that is not strong in the fundamental skills can perform well in one game or one week, or even one season, but he or she cannot perform well for an entire career. Fundamental skills and good habits are a prerequisite for success in any field of endeavor. A good programmer forms and maintains good habits that can translate to any programming application. What are these fundamental habits?
1. Fully understand the problem.
2. Planning, planning, planning.
3. Downloading, compiling, installing, set up etc.
4. Testing.
5. Release the final product for production work.
Once you master steps 1 through 5 above, you will be able to consistently solve any problem well, whether a programming problem, a Linux problem, or otherwise. Good luck applying these principles. I hope that they help you to tackle any challenges that you wish to overcome. |
| Last Updated on Tuesday, 06 July 2010 21:26 |




![Validate my RSS feed [Valid RSS]](/images/valid-rss.png)
