Online Book Reader

Home Category

Beautiful Code [291]

By Root 5071 0
mutex. A one-size-fits-all solution, however, is inadequate to meet the needs of all logging services because different customer requirements and different operating environments can have significantly different impacts on time/space trade-offs, cost, and schedule. A key challenge is therefore to design a configurable logging server that is easily extensible to meet new needs with a minimum of effort.

At the heart of the solution to this challenge is a thorough understanding of the patterns and associated design techniques needed to develop OO frameworks that efficiently:

Capture common structure and behavior in base classes and generic classes

Enable selective customization of behavior via subclasses and by providing concrete parameters to generic classes

Figure 26-2 illustrates the design of an OO logging server framework that realizes these goals. The core of this design is the Logging_Server class, which defines the common structure and functionality for the logging server via the use of:

C++ parameterized types, which allow developers to defer the selection of data types used in generic classes or functions until their point of instantiation

The Template Method pattern, which defines the skeleton of an algorithm, delegating individual steps to methods that may be overridden by subclasses

The Wrapper Facade pattern, which encapsulates non-object-oriented APIs and data within type-safe object-oriented classes

Subclasses and concrete instantiations of Logging_Server refine this common reusable architecture to customize variable steps in the logging server behavior by selecting desired IPC mechanisms, concurrency models, and locking strategies. The Logging_Server is thus a product-line architecture [#]that defines an integrated set of classes that collaborate to define a reusable design for a family of related logging servers.

[#]Software Product Lines: Practices and Patterns, Paul Clements and Linda Northrop, Addison-Wesley, 2001.

Figure 26-2. Object-oriented design for the logging server framework

The remainder of this chapter is organized as follows. The next section describes the OO design of the logging server framework, exploring its architecture and the forces that influence the design of the OO framework to illustrate why we selected certain patterns and language features, as well as summarizing alternative approaches that we rejected for various reasons. Two further sections present several C++ sequential programming instantiations of the logging server framework and of concurrent programming instantiations of this framework. We conclude by summarizing the beauty of the OO software concepts and techniques in this chapter.

Labor-Saving Architecture: An Object-Oriented Framework for Networked Software > Object-Oriented Design of the Logging Server Framework

26.2. Object-Oriented Design of the Logging Server Framework

Before we discuss the OO design of our logging server, it is important to understand several key concepts about OO frameworks. Most programmers are familiar with the concept of a class library, which is a set of reusable classes that provides functionality that may be used when developing OO programs. OO frameworks extend the benefits of OO class libraries in the following ways: [**]

[**] "Frameworks = Patterns + Components," Ralph Johnson, Communications of the ACM, Vol. 40, No. 10, October 1997.

They define "semi-complete" applications that embody domain-specific object structures and functionality

Classes in a framework work together to provide a generic architectural skeleton for applications in a particular domain, such as graphical user interfaces, avionics mission computing, or networked logging services. Complete applications can be composed by inheriting from and/or instantiating framework components. In contrast, class libraries are less domain-specific and provide a smaller scope of reuse. For instance, class library components such as classes for strings, complex numbers, arrays, and bitsets are relatively low-level and ubiquitous across many application

Return Main Page Previous Page Next Page

®Online Book Reader