1.4. Context Object

Context Object encapsulates state in a protocol-independent way to be shared throughout your application. Using Context Object makes testing easier, facilitating a more generic test environment with reduced dependence upon a specific container. The Context Object pattern is used to encapsulate the specifics of protocol implementation to be shared. 

UML representation


Benefits

The following lists the benefits of using the Context Object pattern:
  • Improves reusability and maintainability
  • Allows code to be portable across operating systems

When to Use

You should use the Context Object pattern when:
  • Components need access to system information
  • Decouple application from underlining protocols and system interfaces
Comments