Section 2.1: Programming paradigms

Slides:



Advertisements
Similar presentations
Object Oriented Programming
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
More about classes and objects Classes in Visual Basic.NET.
Object-oriented Programming Concepts
Classes in C++ Bryce Boe 2012/08/15 CS32, Summer 2012 B.
BACS 287 Basics of Object-Oriented Programming 1.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Introduction to Object-oriented programming and software development Lecture 1.
An Object-Oriented Approach to Programming Logic and Design
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
JavaScript, Fourth Edition
1 Procedures Blocks of code which can be called from anywhere in a program Enable us to avoid needless repetition of the same code Can take parameters.
CS200 Algorithms and Data StructuresColorado State University Part 4. Advanced Java Topics Instructor: Sangmi Pallickara
1 Classes and Controls CE-105 Spring 2007 By: Engr. Faisal ur Rehman.
Advanced Object- Oriented Programming Programming Right from the Start with Visual Basic.NET 1/e 14.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
Delphi Classes – roll your own l Delphi classes u Modify to change visibility of properties l Inherit from others u Add extra specialised behaviour l Create.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Chapter 10 Classes and Objects In-Depth. Chapter 10 A class provides the foundation for creating specific objects, each of which shares the general attributes,
Microsoft Visual Basic 2008 CHAPTER ELEVEN Multiple Classes and Inheritance.
 Objects versus Class  Three main concepts of OOP ◦ Encapsulation ◦ Inheritance ◦ Polymorphism  Method ◦ Parameterized ◦ Value-Returning.
1 OOP - An Introduction ISQS 6337 John R. Durrett.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Chapter 12 Object-Oriented Programming Starting Out with Games & Graphics.
Inspired by the Oulipu. The 3 Tenets of OO Encapsulation Polymorphism Inheritance.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
 We have created our two separate 'person' objects, we can set their properties using the methods (the setters) we created.  class person {  var $name;
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
OOP in C# - part 1 OOP in C#: –Object Interaction. –Inheritance and Polymorphism (next module). FEN 20121UCN Technology: Computer Science.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Chapter 11: Abstract Data Types Lecture # 17. Chapter 11 Topics The Concept of Abstraction Advantages of Abstract Data Types Design Issues for Abstract.
Object-oriented programming (OOP) is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their.
CE-105 Spring 2007 By: Engr. Faisal ur Rehman
Introduction to Object-oriented Programming
Advanced Programming in Java
Advanced Programming in Java
OOP: Encapsulation &Abstraction
Classes (Part 1) Lecture 3
Classes & Objects There are two main programming paradigms: Procedural Object-Oriented Up to now, everything we have done has been procedural.
Objects as a programming concept
Multiple Classes and Inheritance
A first Look at Classes.
Microsoft Visual Basic 2005: Reloaded Second Edition
About the Presentations
Section 2.1: Programming paradigms
PRINCIPALES OF OBJECT ORIENTED PROGRAMMING
Introduction to Object-oriented Program Design
3 Fundamentals of Object-Oriented Programming
Object-oriented programming
Inheritance Basics Programming with Inheritance
Object-Oriented Programming
Week 3 Object-based Programming: Classes and Objects
Features of OOP Abstraction Encapsulation Data Hiding Inheritance
Advanced Programming in Java
Computer Programming with JAVA
Object-Oriented Programming
Advanced Programming in Java
Object-Oriented Programming: Classes and Objects
CLASSES AND OBJECTS.
CPS120: Introduction to Computer Science
Fundaments of Game Design
Object-Oriented Programming
CPS120: Introduction to Computer Science
CSG2H3 Object Oriented Programming
11.1 The Concept of Abstraction
Presentation transcript:

Section 2.1: Programming paradigms A class in OOP The basics of declaring a new class in Delphi

Defining a class You may find it useful to follow these steps: Step 1: Name the class. Step 2: Decide on the properties of the class. Step 3: Declare properties as private. Step 4: Declare the constructor of the class. Step 5: Declare the methods (procedures and functions). Step 6: Write the code for your methods.

A basic OOP class in Delphi interface Step 1: Name the class. type Tractor = class private Step 2: Decide on the properties of the class. manufacturer: integer; horsePower: integer; engineHours: integer; public Step 3: Declare properties as private. constructor Create; function getmanufacturer; procedure setmanufacturer(man:String); function gethorsePower; procedure sethorsePower(hp: integer); function getEngineHours; procedure setEngineHours(eh:integer); Step 4: Define the constructor of the class as public. Step 5: Declare the methods (procedures and functions). end; implementation constructor Tractor.create; begin engineHours:=0; end; …. ETC Step 6: Write the code for your methods.

Summary Properties of a class are declared as private. This is so they cannot be accessed outside the class. Methods (procedures and functions) are public and are written to enable the properties of the class to be accessed from outside the class. A constructor is a special method that is used when a new object is created of that class. When an object is created it has all the methods and variables defined in the class. Encapsulation is a term used to describe the combination of the object and its methods. This promotes separation of the implementation and the interface. Because the properties of the class are private, you can control changes to the actual object. In addition, you have the flexibility to change the implementation without affecting anything outside the class. This principle is known as information hiding. Inheritance is where one class can inherit methods and properties from another class. This promotes efficiency because code from one class can be reused in its sub-class.