Presentation is loading. Please wait.

Presentation is loading. Please wait.

What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.

Similar presentations


Presentation on theme: "What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related."— Presentation transcript:

1

2 What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related activities. In pure OOP terms an object is an instance of a class.

3 Real World Objects Real-world objects share two characteristics.
They all have state and behavior. Objects State Behavior Let’s take an Example of a “Dog”

4 Example : A “Dog” Object
Dog have a State and as well as Behavior. Dog’s States are : Name Color Height Weight Dog’s Behaviors are : Walking, Eating, Barking

5 Software Engineering Objects
Software objects are conceptually similar to real-world objects. An object stores its State in Fields (Variables) and exposes its Behavior through Methods (Functions). Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication.

6 Software Engineering Object

7 Bicycle Object By attributing State (current speed, current pedal cadence, and current gear) and providing Methods for changing that state. For example, if the bicycle only has 6 gears, a method to change gears could reject any value that is less than 1 or greater than 6.

8 What is a Class In the real world, you'll often find many individual objects all of the same kind. There may be thousands of other bicycles in existence, all of the same make and model. Each bicycle was built from the same set of blueprints and therefore contains the same components. A Class is the Blueprint from which the individual objects are created

9 Example for a Class class Bicycle { int speed = 0; //Fields (Varibales) int gear = 1; //Fields (Varibales) void changeGear(int newValue) { gear = newValue; } void speedUp(int increment) { speed = speed + increment; Expose the Behavior through the Methods void printStates() { System.out.println (“ speed:" + speed + " gear:" + gear); }

10 class BicycleDemo { public static void main(String[] args) { // Create two different Bicycle objects Bicycle bike1 = new Bicycle(); Bicycle bike2 = new Bicycle(); // Invoke methods on those objects bike1.speedUp(10); bike1.changeGear(2); bike1.printStates(); bike2.speedUp(10); bike2.changeGear(2); bike2.printStates(); }

11 Four Main OOP Concepts For build a Software System it need many Objects and Classes. It is like a big organization with thousands of employees. So to reduce the complexity OOP use several techniques, which can be group under four main concepts. Inheritance Encapsulation Polymorphism Abstraction

12 Inheritance Allow Classes to inherit commonly used State and Behavior from other Classes. Ability to create a new class from an existing class by extending it.

13 Encapsulation A class is kind of a container or capsule or a cell, which encapsulate a set of methods, attribute and properties to provide its indented functionalities to other classes. That idea of encapsulation is to hide how a class does its business, while allowing other classes to make requests of it.

14 Polymorphism It is a ability of an object to take on many forms.
In OOP Polymorphism is archive by using many different techniques named Overriding, Overloading.

15 Abstraction Abstraction is the process of refining away all the unneeded/unimportant attributes of an object and keep only the characteristics best suitable for your domain. E.g. for a person: you decide to keep first and last name and SSN. Age, height, weight etc are ignored as irrelevant. Abstraction is where your design starts.

16 Modularization  One of the most prominent problems in software engineering has been how to program large and complex pieces of software. Often, large projects involve hundreds of programmers working on millions of lines of code. In this kind of environment, it is easy to lose track of what particular code does, or to produce code that must be rewritten elsewhere. To avoid such poor-planning scenarios, computer scientists began to organize around the concept of "modularization," which means to break up and organize code based on the task it executes. In this way, code becomes reusable and easier to debug and manage.

17 Modular programming is the process of subdividing a computer program into separate sub-programs.
A module is a separate software component. It can often be used in a variety of applications and functions with other components of the system. Similar functions are grouped in the same unit of programming code and separate functions are developed as separate units of code so that the code can be reused by other applications. Object-oriented programming (OOP) is compatible with the modular programming concept to a large extent. Modular programming enables multiple programmers to divide up the work and debug pieces of the program independently.

18


Download ppt "What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related."

Similar presentations


Ads by Google