CSC/ECE 517 Fall 2011/ch1 1e ap

From Expertiza_Wiki
Revision as of 15:51, 2 November 2011 by Pramasw3 (talk | contribs)
Jump to navigation Jump to search

Introduction to Object Oriented Design

Introduction to Object Oriented Programming

Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions" and data rather than logic. It uses "objects" - data structures consisting of data fields and methods together with their interactions – to design applications and computer programs.

Object-oriented programming takes the view that what we really care about are the objects we want to manipulate rather than the logic required to manipulate them. Examples of objects range from human beings (described by name, address, and so forth) to buildings and floors (whose properties can be described and managed) down to the little widgets on your computer desktop (such as buttons and scroll bars).

Object-oriented programming is a method of programming based on a hierarchy of classes, and well-defined and cooperating objects.

  • Classes

The class is the fundamental object-oriented unit. It is a structure that defines the data and the methods to work on that data. Classes define a set of objects that share a common structure and behavior. When you write programs in the Java language, all program data is wrapped in a class.All objects are created from classes, so it important to understand the structure of a class. In fact, it is the design of classes that has fueled the development of various Object Oriented languages.Object is an instance of a class.

  • Objects

An "Object" is binding together of data and behavior, and Object Oriented programming, is the use of objects while solving the problem. What makes an "object" unique is the formal and explicit combination of these smaller pieces' behavior with its' data into a single entity.

Object Oriented Design

Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem. It is one approach to software design. 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. Much of design involves refining the analysis model through the introduction of classes and algorithms that define exactly how certain required features are realized. Another common design activity is the development of an overall system architecture. This entails organizing the system as a set of major building blocks, such as subsystems or components. For a concurrent system, the architecture includes the basic task or process structure.For a distributed system, it includes the organization of hardware in terms of processors and their interconnections. Basically, object-oriented design (OOD) entails transforming the analysis model into a feasible design. Once the design reaches a sufficient level of specificity, it is translated into an implementation through object-oriented programming. This task can be either relatively straightforward or rather challenging, depending upon the amount of detail in the design.


The first question in OOD ,especially for newcomers, is "How can I decide what classes my program should have in it?" The fundamental rule is that a class should represent some abstraction. For example, a Date class might represent calendar dates, an Integer class might deal with integers, and a Matrix class would represent mathematical matrices. So you need to ask "What kinds of entities does my application manipulate?".

Some examples of potential classes in different application areas would include:

a) GUI/Graphics - Line, Circle, Window, TextArea, Button, Point

b) Architecture - Building, Plot, Room

b) Geography - River, Country, Sea, Continent


Instead of viewing an application as something that performs steps A, B, and C, that is, looking at the program in terms of its functions, instead ask what types of objects and data the application manipulates. Instead of taking a function-oriented approach, take an object-oriented one.

Object Oriented Concepts

Abstraction

Encapsulation

Inheritence

Polymorphsim

Examples

Advantages of OOD