Object-oriented design

From Wikipedia, the free encyclopedia

Figure 1:An object
Figure 1:An object

Object-oriented design is part of OO methodology and it forces programmers to think in terms of objects, rather than procedures, when they plan their code. An object contains encapsulated data and procedures grouped together to represent an entity. The 'object interface', how the object can be interacted, is also defined. An object-oriented program is described by the interaction of these objects. Object-oriented design is the discipline of defining the objects and their interactions to solve a problem that was identified and documented during object-oriented analysis.

Contents

[edit] Object-oriented design

[edit] Input (sources) for object-oriented design

  • Conceptual model (must have): Conceptual model is the result of object-oriented analysis, it captures concepts in the problem domain. The conceptual model is explicitly chosen to be independent of implementation details, such as concurrency or data storage.
  • Use case (must have): Use case is description of sequences of events that, taken together, lead to a system doing something useful. Each use case provides one or more scenarios that convey how the system should interact with the users called actors to achieve a specific business goal or function. Use case actors may be end users or other systems.
  • System Sequence Diagram (should have): System Sequence diagram (SSD) is a picture that shows, for a particular scenario of a use case, the events that external actors generate, their order, and possible inter-system events.
  • User interface documentations (if applicable): Document that shows and describes the look and feel of the end product's user interface. This is not mandatory to have, but helps to visualize the end-product and such helps the designer.
  • Relational data model (if applicable): A data model is an abstract model that describes how data is represented and used. If an object database is not used, the relational data model should usually be created before the design can start. How the relational to object mapping is done is included to the OO design.

[edit] Object-oriented concepts supported by an OO language

The five basic concepts of object-oriented design are the implementation level features that are built into the programming language. These features are often referred to by these common names:

  • Object/Class: A tight coupling or association of data structures with the methods or functions that act on the data. This is called a class, or object (an object is created based on a class).
  • Information hiding: The ability to protect some components of the object from external entities. This is realized by language keywords to enable a variable to be declared as private or protected to the owning class.
  • Inheritance: The ability for a class to extend or override functionality of another class. The so-called sub class has a whole section that is the super class and then it has its own set of functions and data.
  • Interface: The ability to defer the implementation of a method. The ability to define the functions or methods signatures without implementing them.
  • Polymorphism: The ability to substitute an object with its sub objects. The ability of an object-variable to contain, not only that object, but also all of its sub objects as well.

[edit] Designing concepts

  • Use design patterns (if applicable): A design pattern is not a finished design, it is a description of a solution to a common problem, in a context[1]. The main advantage of using a design pattern is that it can be reused in multiple applications. It can also be thought of as a template for how to solve a problem that can be used in many different situations and/or applications. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved.
  • Define application framework (if applicable): Application framework is a term usually used to refer to a set of libraries or classes that are used to implement the standard structure of an application for a specific operating system. By bundling a large amount of reusable code into a framework, much time is saved for the developer, since he/she is saved the task of rewriting large amounts of standard code for each new application that is developed.
  • Identify persistent objects/data (if applicable): Identify objects that have to last longer than a single runtime of the application. If a relational database is used, design the object relation mapping.
  • Identify and define remote objects (if applicable)

[edit] Output (deliverables) of object-oriented design

  • Class diagram: A class diagram is a type of static structure UML diagram that describes the structure of a system by showing the system's classes, their attributes, and the relationships between the classes.
  • Sequence Diagram: Extends the System Sequence Diagram to add specific objects that handle the system events. These are usually created for important and complex system events, not for simple or trivial ones.
A sequence diagram shows, as parallel vertical lines, different processes or objects that live simultaneously, and, as horizontal arrows, the messages exchanged between them, in the order in which they occur.

[edit] Programming concepts

  • Aspect-oriented programming: One view of aspect-oriented programming (AOP) is that every major feature of the program, core concern (business logic), or cross-cutting concern (additional features), is an aspect, and by weaving them together (also called composition), you finally produce a whole out of the separate aspects.
  • Dependency injection: The basic idea is that if an object depends upon having an instance of some other object then the needed object is "injected" into the dependent object. For example, being passed a database connection as an argument to the constructor instead of creating one internally
  • Acyclic Dependencies Principle: The dependency graph of packages or components should have no cycles. This is also referred to as having a Directed Acyclic Graph. [2] For example, package C depends on package B, which depends on package A. If package A also depended on package C, then you would have a cycle.
  • Composite Reuse Principle: Favor polymorphic composition of objects over inheritance.[1]

[edit] References

  1. ^ a b (1995) Design Patterns: Elements of Reusable Object-Oriented Software. Addison-Wesley. ISBN 0-201-63361-2. 
  2. ^ What Is Object-Oriented Design?. Object Mentor. Retrieved on 2007-07-03.

[edit] External links