2.5 OOP Principles Part 1 academy.zariba.com 1. Lecture Content 1.Fundamental Principles of OOP 2.Inheritance 3.Abstraction 4.Encapsulation 2.

Slides:



Advertisements
Similar presentations
OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
Advertisements

1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
CS 211 Inheritance AAA.
Inheritance Definition Relationships Member Access Control Data Encapsulation Overloading vs. Overriding Constructors & Destructors.
Inheritance Inheritance Reserved word protected Reserved word super
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
Chapter 10: Introduction to Inheritance
Sadegh Aliakbary Sharif University of Technology Fall 2010.
Session 07: C# OOP 4 Review of: Inheritance and Polymorphism. Static and dynamic type of an object. Abstract Classes. Interfaces. FEN AK - IT:
More about classes and objects Classes in Visual Basic.NET.
1 CS1001 Lecture Overview Homework 3 Homework 3 Project/Paper Project/Paper Object Oriented Design Object Oriented Design.
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 8.1 – 8.5.
INF 523Q Chapter 7: Inheritance. 2 Inheritance  Another fundamental object-oriented technique is called inheritance, which enhances software design and.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Advanced Object-Oriented Programming Features
1 Inheritance and Polymorphism Inheritance (Continued) Polymorphism Polymorphism by inheritance Polymorphism by interfaces Reading for this lecture: L&L.
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Chapter 13: Object-Oriented Programming
Inheritance and Polymorphism CS351 – Programming Paradigms.
Object-Oriented Programming Fundamental Principles – Part I
1.11 Introduction to OOP academy.zariba.com 1. Lecture Content 1.What is OOP and why use it? 2.Classes and objects 3.Static classes 4.Properties, fields.
Inheritance. © 2004 Pearson Addison-Wesley. All rights reserved 8-2 Inheritance Inheritance is a fundamental object-oriented design technique used to.
2.5 OOP Principles Part 2 academy.zariba.com 1. Lecture Content 1.Polymorphism 2.Cohesion 3.Coupling 2.
Abstraction, Inheritance, and Polymorphism in Java.
Svetlin Nakov Telerik Corporation
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.
Lecture 8 Inheritance Richard Gesick. 2 OBJECTIVES How inheritance promotes software reusability. The concepts of base classes and derived classes. To.
An Object-Oriented Approach to Programming Logic and Design
OBJECT ORIENTED PROGRAMMING CONCEPTS ISC 560. Object-oriented Concepts  Objects – things names with nouns  Classes – classifications (groups) of similar.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
CSE 501N Fall ‘09 14: Inheritance 20 October 2009 Nick Leidenfrost.
Workshop on Graph Theory academy.zariba.com 1. Workshop Contents 1.What are graphs? 2.Are they useful? 3.Implementing our own Generic Graph 4.Depth First.
Tuc Goodwin  Object and Component-Oriented Programming  Classes in C#  Scope and Accessibility  Methods and Properties  Nested.
Object Oriented Software Development
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
Inheritance. Inheritance is a fundamental object-oriented design technique used to create and organize reusable classes Chapter 8 focuses on: deriving.
Chapter 8 Specialization aka Inheritance. 2 Inheritance  Review of class relationships  Uses – One class uses the services of another class, either.
Chapter 8 Inheritance. 2  Review of class relationships  Uses – One class uses the services of another class, either by making objects of that class.
Interfaces Chapter 9. 9 Creating Interfaces An interface is a contract. Every class that implements the interface must provide the interface’s defined.
Coming up: Inheritance
1 Inheritance Reserved word protected Reserved word super Overriding methods Class Hierarchies Reading for this lecture: L&L 9.1 – 9.4.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
1 Lecture 23: Dynamic Binding (Section ) CSCI 431 Programming Languages Fall 2002 A compilation of material developed by Felix Hernandez-Campos.
 Description of Inheritance  Base Class Object  Subclass, Subtype, and Substitutability  Forms of Inheritance  Modifiers and Inheritance  The Benefits.
Software Construction Lab 05 Abstraction, Inheritance, and Polymorphism in Java.
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.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
Modern Programming Tools And Techniques-I
Object-Oriented Programming Concepts
Inheritance and Polymorphism
One class is an extension of another.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Object Oriented Concepts
Inheritance B.Ramamurthy 11/7/2018 B.Ramamurthy.
Object Oriented Analysis and Design
One class is an extension of another.
Inheritance Basics Programming with Inheritance
Lecture 22 Inheritance Richard Gesick.
Computer Programming with JAVA
Overriding Methods & Class Hierarchies
Object Oriented Analysis and Design
Object Oriented Design & Analysis
Presentation transcript:

2.5 OOP Principles Part 1 academy.zariba.com 1

Lecture Content 1.Fundamental Principles of OOP 2.Inheritance 3.Abstraction 4.Encapsulation 2

1. Fundamental Principles of OOP 3 Inheritance Inherit members from parent class Abstraction Define and execute abstract actions Encapsulation Hide the internals of a class Polymorphism Access a class through its parent interface

2. Inheritance 4

Inheritance 5 Inheritance allows child (derived) classes to inherit the characteristics of an existing parent (base) class – attributes and operations Derived classes can extend the parent class by adding new fields or methods and redefining already existing methods Use inheritance for building is-a relationship Use property implementation when building has-a relationship.

Inheritance - Benefits 6 Extensibility Reusability Provides abstraction Eliminates redundant code

Inheritance – Important Aspects 7 Structures cannot be inherited In C# there is no multiple inheritance Multiple inheritance can be implemented with interfaces Constructors are not inherited Inheritance is a transitive relation You cannot remove inherited features A class can declare virtual methods and properties

3. Abstraction 8

Abstraction 9 Abstraction means ignoring irrelevant features, properties, or functions and emphasizing on the ones relevant to the specific project Abstraction helps managing complexity Abstraction in.Net can be done with the use of abstract classes or interfaces (or both)

Interfaces 10 Interfaces define a set of operations and attributes They do not provide any implementation – only a contract for implementing the defined features of a class Can be extended by other interfaces Cannot be instantiated

Abstract Classes 11 Abstract classes are a mix between an interface and a class Partially or fully provide implementation Non implemented methods are declared as abstract and are left empty (same as interfaces) Cannot be instantiated Child classes, which are not abstract, should implement all abstract methods

4. Encapsulation 12 Fields are always declared private Constructors are almost always public Interface methods are always public Non-interface methods are declared private or protected Hides implementation details and reduces complexity

Homework We are given a school. In the school there are classes of students. Each class has a set of teachers. Each teacher teaches a set of disciplines. Students have a name and a unique class number. Classes have unique text identifier. Teachers have a name. Disciplines have a name, number of lectures and number of exercises. Both teachers and students are people. Students, classes, teachers and disciplines could have optional comments (free text block). Your task is to identify the OOP classes, their attributes and operations, encapsulate their fields, define the class hierarchy and create a class diagram.

Homework Define an abstract class Human with a first name and last name. Define a new class Student which is derived from Human and a has a new field – grade. Define class worker derived from Human with a new property WeekSalary and WorkHoursPerDay and a method MoneyPerHour() which returns the money earned per hour. Define the constructors and properties for this hierarchy. Initialize a list of 10 students and sort them by grade in ascending order (Linq?). Initialize a list of 10 workers and sort them by money per hour in descending order. Merge the lists and sort them by first name and last name

15 References

16 Zariba Academy Questions