Monday, May 24, 2010

How do programmers use modules in computer programming to solve problems?

Anyone have any ideas about modules and how they help to solve problems?

How do programmers use modules in computer programming to solve problems?
Kinda like a modular stereo system - you pick (or create) modules that do specific things with your specific criteria in mind, then tie them all together. With a sound system, you use wires and cables. In a computer program, you use "calls". That's really all there is to it. Just pick (or create) modules that YOU need and add them to your program, then "call" them as you need them.
Reply:This is called modular programming. You write a part of your program called a module (sub-program) that you call many times in your whole program.


For example it can be a complex function which consists of many lines of code. Instead of writing these lines every time you need this function, you write it once and then just call it passing the input parameters. The function returns you the answer.


The module can be a sub-program. That means it doesn't return a result, it just does something. For example - a module which draws 1000 circles on the screen. You write the code once and when you need 1000 circles on the screen you just call this module.


No comments:

Post a Comment