Pages

Wednesday, December 7, 2011

Introduction To Object Oriented Programming










Introduction To Object Oriented Programming

By: razi.smartcomputing123@gmail.com



OOP Concept

The following part is extracted from: http://en.wikipedia.org/wiki/Object-oriented_programming



What is Object Oriented Programming?

Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs.



What is Programming Paradigm?

Programming Paradigm simply means the way programmers look at problem solving approach using computers.

Example type of paradigm

Procedure Oriented Programming, i.e. Programmers writes instructions in block of codes that carry out specific action.

This paradigm has some limitations and OOP concept is now receiving attention.






What does “object” in OOP mean?

Object is a kind of Data Structure that consists of data (properties) and procedures (methods) to work with them.

Object is the natural way we recognize entities in the real world, for e.g, a postman (an object) is a person (known by his name and employee number) that delivers parcels (his associated role)



What are other examples of “Object”?

A Washing Machine

Properties: (Machine Serial Number, Wash_Type, Rinse_Type, Spin_Type)

Methods: (Wash, Rinse, Spin)

Exam Session Manager;

Properties: (Exam Date, Subject, Candidate_Lists, Session_Status)

Methods: (Register_Candidate, Run_Session, Close_Session)



What is the problem of non-OOP program?

Simple, non-OOP programs may be one "long" list of statements (or commands).

More complex programs will often group smaller sections of these statements into functions or subroutines each of which might perform a particular task.

With designs of this sort, it is common for some of the program's data to be 'global', i.e. accessible from any part of the program.

As programs grow in size, allowing any function to modify any piece of data means that bugs can have wide-reaching effects.



How does OOP address the ‘global’ data issue in non-OOP program?

object-oriented approach encourages the programmer to place data where it is not directly accessible by the rest of the program.

Instead, the data is accessed by calling specially written functions, commonly called methods, which are either bundled in with the data.

This protects the consistency of the data.



The following part is extracted from: http://www.jrobbins.org/ics121f03/lesson-uml-structure.html

OOP and UML Modeling



Why make models?

Software systems are very complex and hard to understand

Models are abstractions of systems:

They express certain aspects of the system and ignore others

They are less complex and easier to understand

Models can make certain aspects more clearly visible than in the real system

What can you do with models?

Express your ideas and communicate with other engineers

Reason about the system: detect errors, predict qualities

Generate parts of the real system: code, schemas

Reverse-engineer the real system to make a model



What is UML?

Unified Modeling Language

A modeling language standardized between 1995 and 1997 by Rational, IBM, HP, Microsoft, Oracle, MCI, Unisys, DEC, and others

“Unified” means:

Unified existing approaches to OO design notations: Booch, OMT, Objectory, and Statecharts

Unified notation used in multiple phases of development: Requirements, design, and implementation

Unified industry interest, training, and skills/job market

The UML notation consists of:

Class diagrams

Object diagrams

Use case diagrams

Collaboration diagrams

Sequence diagrams

Statechart diagrams

Activity diagrams

Component and deployment diagrams



UML Class Diagram

Class Diagram shows the structure of a class (template for object), i.e the Class Name, Properties and Methods

WASHING MACHINE

Machine_No

Wash_Type

Rinse_Type

Spin_Type

Wash()

Rinse()

Spin()

EXAM SESSION MANAGER

Exam_Date

Exam_Subject

Candidate_Lists

Session_Status

RegisterCandidate()

RunSession()

CloseSession()



UML Use Case Diagram

Use Case Diagram shows the behavior of an object

Washing

Machine

Wash

Rinse

Spin

Exam Session Manager

Register

Run

Close

No comments:

Stats