Different platforms offer different reuse mechanisms for code, but all support some way of grouping related code together into modules, and there is no consistent definition of modules and many definitions have many interactions with each other.
**Definition**
We use modularity to describe a logical grouping of related code, which could be a group of classes in an object-oriented language or functions in a structured or functional language. Most languages provide mechanisms for modularity
*Architects must be aware of how developers package things because it has important implications in architecture. For example, if several packages are tightly coupled together, reusing one of them for related work becomes more difficult.*
**Measuring modularity:**
- Cohesion
- Cohesion refers to what extent the parts of a module should be contained within the same module.
- If you break them into smaller pieces it would lead you to coupling parts together via calls between the modules, and it increase coupling and reduce readability.
- Types of cohesion sorted from best to worse:
- Functional: Every part of the module is related to the other, and the module contains every‐ thing essential to function.
- Sequential: Two modules interact, where one outputs data that becomes the input for the other
- Communicational: Two modules form a communication chain, where each operates on information and/or contributes to some output. For example, add a record to the database and generate an email based on that information.
- Procedural: Two modules must execute code in a particular order.
- Temporal: Modules are related based on timing dependencies. For example, many systems have a list of seemingly unrelated things that must be initialized at system bootstrap; these different tasks are temporally cohesive.
- Logical: The data within modules is related logically but not functionally. Example: conversion module from many data types to each other.
- Coincidental cohesion: Elements in a module are not related other than being in the same source file; this represents the most negative form of cohesion.
- Coupling
- Abstractness
- Instability
- Distance from Main Sequence
- Connascence
Questions:
1 - Why architect must be aware of how developers package things?
2 - What is called the logical group of codes together?
3 - Name measures for modularity.
4 - Name type of cohesions and describe them briefly.
5 -