2.5 OOP Principles Part 2 academy.zariba.com 1. Lecture Content 1.Polymorphism 2.Cohesion 3.Coupling 2.

Slides:



Advertisements
Similar presentations
I Spy! Shapes in our world.
Advertisements

Space and Shape. rectangle Shape ? trapezium.
Circle – Formulas Radius of the circle is generally denoted by letter R. Diameter of the circle D = 2 × R Circumference of the circle C = 2 ×  × R (
More about classes and objects Classes in Visual Basic.NET.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Objects First with Java A Practical Introduction using BlueJ
HST 952 Computing for Biomedical Scientists Lecture 2.
Criteria for good design. aim to appreciate the proper and improper uses of inheritance and appreciate the concepts of coupling and cohesion.
Data Abstraction: The Walls
CO320 Introduction to Object- Oriented Programming Michael Kölling 3.0.
Lilian Blot INHERITANCE Object Oriented Programming Spring 2014 TPOP 1.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
Abstraction: Polymorphism, pt. 1 Abstracting Objects.
Geometry Badran Awadeh. Content Area: Math Grade Level: 3 rd Summary: The purpose of this instructional PowerPoint is to give the students the ability.
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.
Definitions and formulas for the shapes you love Perimeter and Area.
2.5 OOP Principles Part 1 academy.zariba.com 1. Lecture Content 1.Fundamental Principles of OOP 2.Inheritance 3.Abstraction 4.Encapsulation 2.
Namespaces, Cohesion and Coupling Veselin Georgiev National Academy for Software Development academy.devbg.org Svetlin Nakov Telerik Corporation
Area and Perimeter.
Copyright 2008 by Pearson Education Building Java Programs Chapter 9 Lecture 9-4: Interfaces reading: self-check: exercises: #11.
Area of shapes © T Madas.
Svetlin Nakov Telerik Corporation
S3 BLOCK 8 Area and volume Area Learning Outcomes
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Finding Areas of Shapes. Area of a Triangle Area of Triangle = 1 x Base x Vertical Height 2 Vertical Height Base Right Angle.
An Object-Oriented Approach to Programming Logic and Design
S3 BLOCK 8 Area and volume 1. Area I can find the area of the following 2D shapes.  Rectangle  Triangle  Trapezium  Circle.
5.0 Objects First with Java A Practical Introduction using BlueJ Introduction to Computer Science I Instructor: Allyson Anderson.
Object-Oriented Programming (OOP) CSC-2071 (3+1=4 Credits) Lecture No. 1 MBY.
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.
Areas and Perimeter of Rectangles, Square, Triangles and Circles
Encapsulation and Polymorphism Encapsulation, Polymorphism, Class Hierarchies, Cohesion and Coupling SoftUni Team Technical Trainers Software University.
OBJECT-ORIENTED PROGRAMMING (OOP) WITH C++ Instructor: Dr. Hany H. Ammar Dept. of Electrical and Computer Engineering, WVU.
By. Circle Draw a circle in the box Tell about its attributes: sides, angles, whether or not it’s a polygon. Add any additional information you know about.
Area & Perimeter. SHAPE OVERVIEW Rectangle Triangle Hexagon Trapezoid Square Parallelogram Pentagon Circle.
Tangrams Learning Objectives
Geometry How can I describe the attributes of quadrilaterals/shapes?
Do Now: Calculate the measure of an interior angle and a central angle of a regular heptagon.
5.0 Objects First with Java A Practical Introduction using BlueJ David J. Barnes Michael Kölling.
 Hexagons have 6 sides and 6 angles and vertices.
Chapter 21 Design Patterns Reviewed from the New Perspective of Object-Oriented Design Ku-Yaw Chang Assistant Professor, Department.
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
WEL COME PRAVEEN M JIGAJINNI PGT (Computer Science)
What is 1) A rhombus? 2) A parallelogram? 3) A square? 4) A rectangle?
Polymorphism, Class Hierarchies, Exceptions, Strong Cohesion and Loose Coupling.
How many …?. What shape can you see? I can see some _____. Q1 Q1 stars.
SHAPES There are many shapes in our world. These are circles. Circles are never ending lines.
Eg. 2Year 8/9/10. LO: Calculate the surface area of Cube/Cuboid/Cylinder/Cone 1.Draw the net 2.Work out the surface area of the shape I would provide.
Inheritance Class Hierarchies SoftUni Team Technical Trainers Software University
MIS Professor Sandvig MIS 324 Professor Sandvig
Abstract Classes, Abstract Methods, Override Methods
Object-Oriented Programming Concepts
Objects First with Java A Practical Introduction using BlueJ
Area of Shapes.
JavaScript OOP academy.zariba.com.
Name the shape below. rectangle rhombus square triangle A B C D
UNIT 8: 2-D MEASUREMENTS PERIMETER AREA SQUARE RECTANGLE PARALLELOGRAM
Objects First with Java A Practical Introduction using BlueJ
AREA OF SHAPES.
Multiplication as arrays
Object Oriented Programming
Shapes.
Inheritance in Graphics
CISC/CMPE320 - Prof. McLeod
Objects First with Java A Practical Introduction using BlueJ
SPLITTING OF COMBINED SHAPES
Objects First with Java A Practical Introduction using BlueJ
Object-Oriented Programming
By- Sabrina,Julianna, and Killian
C++ Object Oriented 1.
Presentation transcript:

2.5 OOP Principles Part 2 academy.zariba.com 1

Lecture Content 1.Polymorphism 2.Cohesion 3.Coupling 2

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

1. Polymorphism 4 Polymorphism is the ability to take more than one form – a derived class can be used through its parent interface Derived classes can override some of the behaviour of the parent class Polymorphism allows abstract operations to be defined and invoked. It also allows you to mix related types in the same collection

2. Cohesion 5 Cohesion describes how closely routines in a class/method or generally in the code support a central purpose Cohesion must be strong – classes must contain strongly related functionality and aim for a single purpose e.g. The Math class, DateTime class e.g. A class which creates all characters, draws them, moves them, starts the game…

3. Coupling 6 Coupling describes how tightly a class/method/routine is related to other classes or routines Coupling must be loose – there should be little or no dependency between classes If there is dependency it should be clearly stated

Summary 7 OOP fundamental principles are: inheritance, encapsulation, abstraction, polymorphism Inheritance allows inheriting members from a base class Abstraction and encapsulation hide internal data and allow working through more abstract interfaces Polymorphism allows working with objects through their parent interface and invoke abstract actions Use strong cohesion and loose coupling to avoid spaghetti code

Homework 8 1. Design an application which calculates the surface and perimeter of different shapes: circle, triangle, square, rectangle, trapezium, rhombus and a regular n-gon. Make an abstract class Shape which will hold 2 methods (calculate area and perimeter) and a single attribute value. Be very careful when using inheritance and abstraction – all common features of each shape should be inherited from the base shape. The picture below could be useful (or not). If you can calculate the area using the sides only, you should do that. Otherwise, define all necessary additional fields you may need like angles, heights and so on. Test your application with all possible shapes, stored in a list, and print their area and perimeter.

9 References

10 Zariba Academy Questions