Code Reuse and Modularity in Python 3

In this ,we are going to learn about code reuse and modularity. What is the definition, types, feature and benefit of each of them.

What is code reuse and modularity

What is Code Reuse ?

  • It refers to the concept of writing a single function and reusing it for multiple times.
  • It also minimizes duplications.
  • It should be easy to implement because, it is enough to write a single function and can use for multiple times.
  • It can save time, improve efficiency, and also reduces errors and bugs.

Code Reuse is categorized into two types. They are :

  1. Internal reuse
  2. External reuse

Internal reuse :

  • It means that it reuses its own components.

External reuse :

  • It uses third-party component.

Feature :

  • Allows you to reuse the code from the existing class in the new class without duplicating.

Benefit :

  • It allows to implement new features and functionality.

What is Modularity ? 

Modularity is nothing but it is the concept of making multiple modules at first and combining them to form a single complete system.

(Or)

Dividing a system into separate modules or components.

  • It enables reusability and minimizes duplication.
  • It increases product variety.
  • Reduces production time.

Features :

  1. Platform independence
  2. Code Reusability

Platform independence 

  • It often leads to platform independent ,making them more portable.

Code Reusability

  • Modules are reused in different contexts.

Benefit :

  • Module can be reused throughout the program. It means that once module is created, it can be used many times again and again.

Example :

The best example of modularity is a Computer.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top