object-orinted design, objeck oriented programming

Object-Oriented Design and Programming

Object-Oriented Programming Concepts

Search in English
Custom Search
 
 
Help us continue to create free tutorials.
 
Currency
 
Amount $ 
 
Help us help you
Computer Tutorials      Free Computer Tutorials      Object Oriented Programming Concepts


 Object Oriented Programming Concepts


      Object-oriented Design and Programming Concepts:

          Watch the video tutorial on Object Oriented Programming Concepts:


          Or read the Object-Oriented Concepts tutorial below:

                Introduction to object-oriented programming
                Class
                Object
                Method
                Message Passing
                Inheritance
                Abstraction
                Encapsulation
                Polymorphism

Introduction to object-oriented programming

  • An object-oriented program may be considered a collection of interacting objects.  Each object is capable of sending and receiving messages, and processing data.  Consider the objects of a driver, a car, and a traffic light.  When the traffic light changes, it sends a virtual message to the driver.  The driver receives the message, and then chooses to accelerate or decelerate. This sends a virtual message to the car.  When the car's speed changes, it sends a virtual message back to the driver, via the speedometer.

    oo programming and sofware engineering

           Return to beginning of  Object-oriented Design and Programming Concepts

Class

  • A class defines the characteristics of an object.  Characteristics include: Attributes (fields or properties), and behaviors (methods or operations).  For example, a "Car" class could have properties such as: year, make, model, color, number of doors, and engine.  Behaviors of the "Car" class include: On, off, change gears, accelerate, decelerate, turn, and brake.

    define java class properties

           Return to beginning of  Object-oriented Design and Programming Concepts

Object

  • An object is an instance of a class.  Creating an object is also known as instantiation.  For example, the object "my Porsche" is an instance of the car class.

    create object in java, c#, perl, php, and c++

           Return to beginning of  Object-oriented Design and Programming Concepts

Method

  • A method is a behavior of an object.  Within a program, a method usually affects only one particular object.  In our example, all cars can accelerate, but the program only needs to make "my Porsche" accelerate.

    define a method in c#, perl, java, c++, php

           Return to beginning of  Object-oriented Design and Programming Concepts

Message Passing

  • Message passing (or method calling) is the process where an object sends data to another object to inkove a method.  For example, when the object called "joe" (an instance of the driver class), presses the gas pedal, he literally passes an accelerate message to object "my Porsche", which in turn, invokes the "my Porsche" accelerate method.

    call method in java, invoke method in c#, pass message to object

           Return to beginning of  Object-oriented Design and Programming Concepts

Inheritance

  • Inheritance (also known as subclasses) occurs when a specialized version of a class is defined.  The subclass inherits attributes and behaviors from the parent class.  For example, the "Car" class could have subclasses called "Porsche car", "Chevy car", and "Ford car".  Subclasses inherit properties and methods from the parent class.  The software engineer only only has to write the code for them once.  A subclass can alter its inherited attributes or methods.  In our example, the "Porsche car" subclass would specify that the default make is Porsche.  A subclass can also include its own attributes and behaviors.

    object orientd program inheritance

  • We could create a subclass of "Porsche car" called "Porsche Carrera GT".  The "Porsche Carrerra GT" class could further specify a default model of "Carrera GT" and "number of doors" as two.  It could also include a new method called "deploy rear wing spoiler".

    define subcalss method in c# java program

  • The object of "my Porsche" may be instantiated from class "Porsche Carrera GT" instead of class "Car".  This allows sending a message to invoke the new method "deploy rear wing spoiler".

    create method in class

           Return to beginning of  Object-oriented Design and Programming Concepts

Abstraction

  • Abstraction is the practice of reducing details so that someone can focus on a few consepts at a time.  For example, "my Porsche" may be treated as a "Car" most of the time.  It may sometimes be treated as a "Porsche Carrera GT" to access specific properties and methods relevant to "Porsche Carrera GT".  It could also be treated as a vehichle, the parent class of "Car" when considering all traffic in your neighborhood.

    java abstract and object-oriented abstraction

           Return to beginning of  Object-oriented Design and Programming Concepts

Encapsulation

  • Encapsulation conceals the functional details of a class from objects that send messages to it.  For example, the "Porsche Carrera GT" class has a method called "accelerate".  The code for the "accelerate" method defines exactly how acceleration occurs.  In this example, fuel is pumped from gas tank and mixed with air in the cylinders.  Pistons move causing compression, resulting in combustion, etc.  Object "Joe" is an instance of the "Driver" class.  It does not need to know how "my Porsche" accelerates when sending it an accelerate message.

    encapsulation in object-oriented design

  • Encapsulation protects the integrity of an object by preventing users from changing internal data into something invalid.  Encapsulation reduces system complexity and thus increases robustness, by limiting inter-dependencies between components.

    protect attributes and data in java and c#

           Return to beginning of  Object-oriented Design and Programming Concepts

Polymorphism

  • Polymorphism is the ability of one type to appear as (and be used like) another type.  Classes "Porsche Carrera GT" and "Ford Mustang" both inherited a method called "brake" from a similar parent class.

    c# polymorphism, java message passing, inheritance c++

  • The results of executing method "brake" for the two types produces different results.  "my Porsche" may brake at a rate of 33 feet per second, whereas "my Mustang" may brake at a rate of 29 feet per second.

    programming language differences between types

           Return to beginning of  Object-oriented Design and Programming Concepts





Copyright © 2009 www.FreeComputerTutor.net                                       Sitemap