Framework Design Rules

This document describes design rules to follow while developing and using object-oriented frameworks for communication systems.

Table of Contents

1. Introduction
2. Programming Principles
3. Compiler Concessions
4. Configuration Concerns
5. Initialization Issues
6. Pattern Practices
7. Multi-threaded Matters
8. Real-time Rules
9. International Intents
10. Conclusions

1. Introduction

The OO application framework design rules described below have been derived by re-engineering the design, implementation, and proper use of the ACE C++ framework. ACE is an object-oriented (OO) framework that implements many core design patterns for concurrent communication software. ACE provides a rich set of reusable C++ wrappers and framework components that perform common communication software tasks across a range of operating system platforms.


2. Programming Principles

This section describes coding practices that directly result from practical framework design issues, including maintainability and reusability.

  • #guard header files
  • Avoid global functions
  • Respect user namespace
  • Use explicit destructor with placement new
  • Avoid -> chains
  • Avoid making direct system calls
  • Use consistent error handling
  • Implement dump() methods
  • Use abstractions for file descriptors
  • Allow for run-time tracing
  • Check all returned values
  • Qualify methods not in scope
  • Avoid data members in base classes
  • Implement open()/close() methods
  • [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]


    3. Compiler Concessions

    This section presents rules that allow the framework design to flexibly cope the wide range of C++ compilers and their various levels of compliance with the C++ Standard.
  • Avoid using inline directly
  • Separate templates from non-templates
  • Use traits in templates
  • Use a non-template class as base
  • #guard template source files
  • [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]


    4. Configuration Concerns

    The issues addressed by these guidelines impact the design of frameworks with regard to how to ease porting tasks among different compiler, OS and hardware platforms.
  • #guard against compiler quirks
  • Specify a platform by its features
  • Use a config.h file
  • [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]


    5. Initialization Issues

    Initialialization issues arise naturally in frameworks, since there are various objects for which only one instance should ever exist, known as singletons. Often, singleton classes will employ the use of static declarations for its own data members. This section warns about such practices.
  • Initialize on first use
  • Avoid creating statics
  • Provide destructors for singletons
  • [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]


    6. Pattern Practices

    The design rules here encourage the use of particularly appropriate patterns that lend themselves to providing identifiable framework idioms. In general, these patterns particularly strengthen the skeleton nature of the framework while increasing the flexibility available to the application developer.
  • Strategize memory allocation
  • Apply the strategy pattern
  • Create a wrapper for similar functions
  • Parameterize components by wrappers
  • Implement iterators
  • Separate creation from use
  • [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]


    7. Multi-threaded Matters

    The use of these guidelines help framework designs avoid the common pitfalls present in the development of concurrent systems. Namely, race conditions and deadlocks. Also included are design rules that help avoid contention.
  • Make all methods reentrant
  • Avoid using sentinels
  • Use unguarded destructors
  • Guard open()/close methods
  • Use unguarded protected/private methods
  • Wait for spawned threads/processes
  • Avoid using reference counters
  • [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive]


    8. Real-time Rules

    The rules in this section describe promote framework designs that lead to the development of more correct and efficient framework components.
  • Avoid unequal priority sharing
  • [an error occurred while processing this directive]


    9. Internationalization Intents

    As systems have to be ported to environments in which character sets are much larger than can be represented by 8 bits, internationalization of systems and frameworks can have a significant impact on design. These rules help reduce this impact.
  • Use an abstraction for char
  • [an error occurred while processing this directive]


    10. Conclusions


    Last modified: Sun Mar 29 02:40:33 CST 1998