Modularity divides a large program into relatively independent parts, grouping related behavioral meaning while keeping responsibilities separable. Packages, services, libraries, and subsystems provide common organizational forms. section 1.3.2 section 1.4.1
A useful module exposes a stable public interface while hiding an unstable private implementation. Clients depend on the interface rather than implementation details, so internal changes need not break them. section 1.4.1
Modularity works with several complementary design ideas:
- Interfaces establish the boundary that client code uses. section 1.3.2
- Inversion of control helps separate cooperating responsibilities. section 1.3.2 section 1.4.2
- Polymorphism allows multiple implementations to vary behind a unifying interface. section 1.4.1
- Low coupling and high cohesion keep complexity manageable across object-oriented, imperative, and functional designs. section 1.6
Opaque C interfaces
C can represent a module with a public opaque type and procedures such as create and destroy operations. Client code uses the declared interface without depending on the private structure behind it. section 1.4.1
#1
#2
typedef struct MYPROCOBJECT_Tag MYPROCOBJECT; #3
typedef struct MYPROCTYPE_Tag MYPROCTYPE;
MYPROCOBJECT *visor_proc_CreateObject(MYPROCTYPE *type, #4
const char *name,
void *context);
void visor_proc_DestroyObject(MYPROCOBJECT *obj);
Inspect the opaque C declarations that separate public types and procedures from their implementation. section 1.4.1









