Object oriented vs procedural programming

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

Department of Computer Engineering Faculty of Engineering, Prince of Songkla University 1 5 – Abstract Data Types.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
1 OBJECT-ORIENTED CONCEPTS. 2 What is an object?  An object is a software entity that mirrors the real world in some way.  A software object in OOP.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science) MCA, MSc[IT], MTech[IT],MPhil (Comp.Sci), PGDCA, ADCA, Dc. Sc. & Engg.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
C++ fundamentals.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
OBJECT ORIENTED PROGRAMMING IN C++ LECTURE
Object Oriented Software Development
Inheritance using Java
Object Oriented Programming Development
Sadegh Aliakbary Sharif University of Technology Fall 2011.
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
11 Chapter 11 Object-Oriented Databases Database Systems: Design, Implementation, and Management 4th Edition Peter Rob & Carlos Coronel.
Chapter 7 Objects and Classes 1 Fall 2012 CS2302: Programming Principles.
Object Oriented Programming Concepts. Object Oriented Programming Type of programming whereby the programmer defines the data types of a data structure.
Encapsulation, Inheritance & Polymorphism. OOP Properties Encapsulation ­The process of creating programs so that information within a class is not accessible.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Definition of Object - Oriented Language.. Object-oriented programming (OOP) is a programming language model organized around "objects" rather than "actions"
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Learners Support Publications Object Oriented Programming.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
Abstraction ADTs, Information Hiding and Encapsulation.
Programming Paradigms Lecturer Hamza Azeem. What is PP ? Revision of Programming concepts learned in CPLB Learning how to perform “Object-Oriented Programming”
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
08 Encapsulation and Abstraction. 2 Contents Defining Abstraction Levels of Abstraction Class as Abstraction Defining a Java Class Instantiating a Class.
: Maha Sabri Altememe Lecturer : Maha Sabri Altememe Lecture :1 1.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Lecture 2: Review of Object Orientation. © Lethbridge/La ganière 2005 Chapter 2: Review of Object Orientation What is Object Orientation? Procedural.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
OOPS CONCEPT.  OOPS  Benefits of OOPs  OOPs Principles  Class  Object Objectives.
Chapter 2 Principles of Programming and Software Engineering.
OOP Basics Classes & Methods (c) IDMS/SQL News
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Object Oriented Programming Some Interesting Genes.
Computer Programming II Lecture 5. Introduction to Object Oriented Programming (OOP) - There are two common programming methods : procedural programming.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
 The Object Oriented concepts was evolved for solving complex problems. Object- oriented software development started in the 1980s. Object-oriented design.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
OOP - Object Oriented Programming
Programming paradigms
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.
Object Oriented Programming
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING
Concepts of Object Oriented Programming
Programming Logic and Design Seventh Edition
Object Oriented Programming F3031
Objects as a programming concept
Chapter 11 Object-Oriented Design
OBJECT ORIENTED PROGRAMMING overview
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Object Oriented Analysis and Design
Object-oriented Design in Processing
Object-Oriented Programming
Programming paradigms
Object-oriented Design in Processing
Object oriented vs procedural vs event driven programming
Software Design Principles
Object-oriented Design in Processing
Object-Oriented Programming
Agenda Software development (SD) & Software development methodologies (SDM) Orthogonal views of the software OOSD Methodology Why an Object Orientation?
Object-oriented Design in Processing
CSG2H3 Object Oriented Programming
Presentation transcript:

Object oriented vs procedural programming

Procedural programming Although Java is primarily object oriented up until now all we have used it to produce is procedural code. The language C is an example of a strictly procedural language Object Oriented Programming(OOP) languages such as C++, C# and Java improve on this. Procedural programming is a list or set of instructions telling a computer what to do step by step and how to perform from the first code to the second code. (A systematic order of statements, functions and commands)

Procedural programming example code A simple C hello world program Note the complete lack of class It has a main method And other methods could be written but that’s it #include <stdio.h> int main() { printf("Hello, World!"); return 0; }

Object-Oriented Concept Object-oriented programming models the real world in terms of objects. Everything in the world can be modeled as an object. A circle is an object, a person is an object, and a Window icon is an object. Even a loan can be perceived as an object. A Java program is object-oriented because programming in Java is centered on creating objects, manipulating objects, and making objects work together.

Object-oriented Continued Objects hold information about state and behaviour: States are the characteristics of the object, or the words you would use to describe it, and usually take the form of is or has descriptors. A computer is either on or off, a chair has four legs, and you have a name. Behaviours are the things the object can do, or the actions the object can perform, and are usually verbs that end in ing. You are sitting, using a computer, and reading.

Object-oriented Example For Pac-Man, there are three objects: Pac-Man, a ghost, and a pac-dot. The ghost has states of: colour name state (eatable or not) direction speed and behaviours of: moving changing state

OO Programming example: Properties/variables (State) Methods(Behaviour)

Key features of Object Oriented Programming Abstraction Allows for simple things to represent complexity. Such as objects, classes, and variables representing more complex underlying code and data. We all know how to turn the TV on, but we don’t need to know how it works in order to enjoy it. For example in our code we could create a TV object then ask it to turn on. We don’t need to worry about how the TV object works as long as we know it has a on method within. Consider the scanner import – we don’t worry about how it works we just create a scanner object and use it when we want user input. This is important because it lets avoid repeating the same work multiple times.

Key features of Object Oriented Programming Polymorphism Allows us to use the same word to mean different things in different contexts.  The capability of a method to do different things and take on many forms based on the object that it is acting upon. In other words, polymorphism allows you define one interface (or class) and have multiple implementations. 

Key features of Object Oriented Programming Inheritance Inheritance can be defined as the process where one class acquires the properties, methods and fields of another. With the use of inheritance the information is made manageable in a hierarchical order. The class which inherits the properties of the other is known as subclass, derivedclass, childclass and the class whose properties are inherited are known as superclass, baseclass, parentclass.

Key features of Object Oriented Programming Encapsulation Encapsulation in Java is a mechanism of wrapping the data variables and code acting on the data methods together as a single unit. The variables of a class will be hidden from other classes, and can be accessed only through the methods of their current class, therefore it is also known as data hiding. To achieve encapsulation in Java we declare the variables of a class as private. Provide public setter and getter methods to modify and view the variables values. We can re-use objects like code components or variables without allowing open access to the data system-wide.

Object Oriented example code class Cow { String size; String sex; public void moo() { System.out.println("Cow says moo."); } public class OldMacDonald { public static void main( String[] args ) { Cow maudine = new Cow(); An object is an instance of a class.

OOD vs procedural Procedural programming uses a list of instructions to tell the computer what to do step-by-step. Procedural programming relies on what’s known: Procedures: A series of computational steps to be carried out in order. Subroutines(Also know as functions/methods): Again a series of computational steps but this time they return a value. Consider how methods work in Java.

OOD vs procedural continued The design method used in procedural programming is called Top Down Design. Start with a problem (procedure) Systematically break the problem down into sub problems (sub procedures). This is called functional decomposition, which continues until a sub problem is straightforward enough to be solved by the corresponding sub procedure. The difficulties with this type of programming, is that software maintenance can be difficult and time consuming. When changes are made to the main procedure (top), those changes can cascade to the sub procedures of main, and the sub-sub procedures and so on, where the change may impact all procedures in the pyramid.

OOD vs procedural continued Object oriented programming is meant to address the difficulties with procedural programming. In object oriented programming, the main modules in a program are classes, rather than procedures. The object-oriented approach lets you create classes and objects that model real world objects. Procedural code is quicker to implement for simpler code but get’s increasingly complex and difficult to manage as the program get’s larger. OOP allows for easy re-use code enabling faster coding and managing on larger projects