Reusability

One of the tenets of modularity is reusability. We earlier used the analogy of building blocks to describe modules. The idea of plugging in reusable modules together to create different applications is very powerful indeed! In order to make modules reusable, they should ideally have the following characteristics:

  • They should have some specialized and limited responsibility. A module that does too many things is hard to reuse effectively.
  • They should be independent--If a module depends on a whole lot of other modules to function, it becomes harder to reuse the module itself.
  • It should be configurable--If the module is tweak-able and can be made to work for different use cases, it makes the module more amenable to reuse.

These characteristics do come with some trade-offs though! Here are a couple of them:

  • Having smaller specialized or single purpose modules sometimes results in very small and fragmented modules, often requiring multiple modules to get anything done.
  • Configurable APIs in modules often results in more complicated APIs, since the consumers have to deal with more knobs and levers to tweak and operate in order to work with your module. One way to get around this problem is to provide sensible defaults and provide configuration just as an override.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.144.229