Software Architecture – How to Think When Grouping Functionality into Modules

Architectureinterfacesmodules

What are some commonly used strategies when it comes to divide software into modules, other than there should not be any cyclic dependency between any modules? Some ways I think of

  1. Group everything that relates to a set of related classes into one module. I could have one module for 1d data (curves), and one module for 2d data (images). It may happen that multiple types support a particular operation. In this case, both a curve and an image can be interpolated.

  2. Group everything that relates to a particular set of operations into one module. This way, the interpolation variants would live in one module, min/max search in another and so on.

In general, a module should group related functionality, but what exactly is related?

Option (1) has the benefit of not having to update any algorithm library when a new type is introduced. At the same time, some algorithm implementations are directly applicable on multiple types, which makes this approach less good.

Option (2) Is naturally the opposite of option (1).

Best Answer

Both of your examples could be valid groupings to create modules.

Besides that modules group related functionality, there is another, possibly more important, property to them: Modules communicate a concept to others within your organization, a concept that has a higher abstraction level than a class or a function.

In that sense, it is equally valid to have a module for Nd data structures and their operations (including both 1d and 2d data structures).

The important part about modules is that you can talk with a fellow architect about the X module and they understand

  • what is in that module, even if they have never seen the code and donĀ“t know the exact classes/functions that make up the module
  • how it makes your life and that of your team easier by grouping the functionality in that particular way.

You can look at creating modules as similar to deciding what concept to describe by a class, but then at a higher abstraction level.