### Modular programming and the divide and conquer methodology

• Solving a complex problem

• After you graduate as a computer science major, you will rarely be asked in real life to write computer programs to solve simple problems

• Most real life problems are very complex; requiring many processing steps to complete.

• An essential skill for a Computer Science professionals is:

 Break a complex problem into simpler problems where each simpler problem can be solved independently from each other.

Example:

• Suppose the original problem reads some input and will produce a certain output:

• The common approach to solve a complex problem is to

• identify a number of simpler problems within the original problem:

• Solve the simpler problems individually

• Properties of the simpler problems:

• Each simpler problem will has its own input data and will produce its own output

• Each simpler problem will

• consume some data, and also
• produce some data

• In other words:

 Each simpler problem will transform the input data gradually into the solution of the original problem.

• The modular programming methodology

• The modular programming methodology goes a step further in specifying how the simpler problems should be designed.

• Further desirable properties:

• In modular programming, the simpler problems in which the original problem is broken into should be independent.

• In other words:

 Each simpler problem can be solved, programmed and tested independently from each other.

• When we can break a complex problem into a number of simpler and independent problems, we can manage the complexity easier

This approach is also known as

 divide and conquer....

• Modular programming is an art...

• Unfortunately, the skill to break a complex problem up into simpler and independent problem cannot be taught....

• I can only show you some (one) example...

You must develop this skill on your own - with time and practice; (and by studying how good programmers do their programming).