Java Application Architecture

Modularity Patterns with Examples Using OSGi

Category: Extensibility Pattern

Colocate Exceptions

For the full description, implementation variations, consequences, and detailed sample, see Page 150 in Java Application Architecture.
Statement
Exceptions should be close to the class or interface that throw them.
Description
Sadly, dealing with exceptions in enterprise software systems is often an afterthought. But allocation of exceptions to modules has significant implications on the modularity, and more specifically the [...]

Implementation Factory

For the full description, implementation variations, consequences, and detailed sample, see Page 150 in Java Application Architecture.
Statement
Use factories to create a modules implementation classes.
Description
One of the challenges we face with Abstract Modules is how the object relationships are established at runtime. A class dependent on an abstraction should avoid referencing any of the implementing classes, [...]

Separate Abstractions

For the full description, implementation variations, consequences, and detailed sample, see Page 150 in Java Application Architecture.
Statement
Place abstractions and the classes that implement them in separate modules.
Description
You create an abstract class or interface to help reduce coupling between classes. This offers the ability to create new implementations of the abstraction without impacting clients dependent on [...]

Abstract Modules

For the full description, implementation variations, consequences, and detailed sample, see Page 150 in Java Application Architecture.
Statement
Depend upon the abstract elements of a module.
Description
Modules heavily depended upon have many incoming dependencies. In other words, you may have many modules that all depend on a single module. On one hand, this is a good thing because [...]