Object oriented design
From Wikipedia, the free encyclopedia
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 business problem that was identified and documented during object oriented analysis.
The origins of object oriented programming is structured programming. Structured programming fell short in big and complex programs. Object oriented methodology tries to remedy those shortfalls.
The first object oriented languages were Simula and SmallTalk. The use of object oriented languages became popular after Grady Booch wrote the first paper titled Object-Oriented Design, in 1982.
Object oriented design is defined as a programming language that has five conceptual tools to aid the programmer. These programs are often more readable than non-object oriented programs, and debugging becomes easier with locality.
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 not object database is used, usually the relational data model should 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:
- Encapsulation: 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 often the implementation of 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 child class has a whole section that is the parent class and then it has its own set of functions and data.
- Interface: A definition of functions or methods, and their signatures that are available for use to manipulate a given instance of an object.
- Polymorphism: The ability to define different functions or classes as having the same name but taking different data types.
[edit] Designing concepts
- Defining objects, creating class diagram from conceptual diagram: Usually map entity to class.
- Identifying attributes.
- Use design patterns (if applicable): A design pattern is not a finished design, it is a description of a solution to a common problem. A design pattern can be reused in multiply application, and that is the main advantage of using it. It can also be see as a template for how to solve a problem that can be used in many different situations and/or applications. It is not code reuse, but code can be easily created from a design pattern. 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 persisted objects/data (if applicable): Identify objects that have to be persisted. If relational database is used design the object relation mapping.
- Identify, define remote objects (if applicable)
[edit] Output (deliverables) of object oriented design
- Class diagram: Class diagram is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, and the relationships between the classes.
- Sequence diagram: Expend the System Sequence Diagram to add specific objects that handle the system events. Usually we create sequence diagram 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
[edit] Current OO languages
Some modern languages that endorse object oriented design practices:
- CLOS (an expansion of the Lisp Programming Language)
- C++
- C#
- Eiffel
- Java
- Objective-C
- Python
- Simula
- SmallTalk
- VB.Net