Sign InCoursewareNuggetsTutorials AboutClassesCodePad

Why Modules?

After you define a class, say NinjaTurtle, that contains cool funtions to draw different shapes, how can you use the functions from this class in different Python programs? What if you want to share it with your friends who also want to use the functions to draw their pictures?

When your program is getting more complex, it is sometimes not practical to write code in a single file. In fact, computer programs in the real world usually contain many different files and packages.

Recall that decomposition is an important step in the computational thinking process. One way to decompose a large program is to break it down into manageable modules. Each module provides a clearly specified functionality. This allows you to develop and test each module individually, before integrating them into a complete system.

There are three major advantages of creating modules in a program:

  1. Breaking a complex program into smaller, easier to manage parts.
  2. Allowing different people or teams to work on separate piece of code at the same time.
  3. Making it easier to reuse and share code.
© CS Wonders·About·Classes·Cheatsheet