אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 1 פרק 3 OCP.

Slides:



Advertisements
Similar presentations
Lecture Computer Science I - Martin Hardwick The Programming Process rUse an editor to create a program file (source file). l contains the text of.
Advertisements

Operator overloading redefine the operations of operators
For(int i = 1; i
Factorial Preparatory Exercise #include using namespace std; double fact(double); int fact(int); int main(void) { const int n=20; ofstream my_file("results.txt");
The C ++ Language BY Shery khan. The C++ Language Bjarne Stroupstrup, the language’s creator C++ was designed to provide Simula’s facilities for program.
Class 15 - Overhead 11Object Oriented Programming Using C #define t_circle 1 #define t_rectangle 2 struct circle_shape {short type; double x,y; double.
1 CSC241: Object Oriented Programming Lecture No 21.
Riyadh Philanthropic Society For Science Prince Sultan College For Woman Dept. of Computer & Information Sciences CS 102 Computer Programming II (Lab:
Esempio Polimorfismo1 // Definition of abstract base class Shape #ifndef SHAPE_H #define SHAPE_H class Shape { public: virtual double area() const { return.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
1 Inheritance Concepts n Derive a new class (subclass) from an existing class (base class or superclass). n Inheritance creates a hierarchy of related.
Common mistakes Basic Design Principles David Rabinowitz.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 10 Packages.
אביב תשס"ה JCTתיכון תוכנה: ד"ר ראובן גלנט1 פרק 8 נקודות חשובות בתרגילים 7-9.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 תיכון מערכות תוכנה להנדסה ופיתוח פרוייקט אישי Software Design.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 13 Case Study: Weather Station.
Common mistakes Basic Design Principles Amit Shabtay.
אביב תשס"ה JCTתיכון תוכנה: ד"ר ראובן גלנט1 פרק 9 נקודות חשובות בתרגיל 10 Guarded Operation.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 6 DIP דוגמאות נוספות.
1 ָ נן oop Dynamic Binding uBinding uBinding time uMotivation uDynamic Binding uHigh Level Methods.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 4 LSP.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 11 Statecharts תכונות מתקדמות.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 12 אינטרקציה בין statecharts של אובייקטים שונים דוגמא : Dishwasher.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 7 ISP דוגמא נוספת.
Run-Time Type Identification Jim Fawcett CSE687 – Object Oriented Design Spring 2007.
CS 192 Lecture 3 Winter 2003 December 5, 2003 Dr. Shafay Shamail.
COMPUTER PROGRAMMING. Data Types “Hello world” program Does it do a useful work? Writing several lines of code. Compiling the program. Executing the program.
Advanced Principles I Principles of Object-Oriented Class Design Copyright  by Object Mentor, Inc All Rights Reserved Portions of this material.
 Programming Languages  First Generation Languages (Machine Language)  We Actually have to do a few things. First we have to find the operating code,
C++ Lecture 7 Thursday, 21 July Chapter 9 Inheritance l Creating new classes from the existing classes l The notions of base classes and derived.
© 2004 Capgemini - All rights reserved SOLID - OO DESIGN PRINCIPLES Andreas Enbohm, Capgemini.
CPSC 372 John D. McGregor Module 4 Session 1 Design Patterns.
Design Principles iwongu at gmail dot com.
The benefits of SOLID in software development Ruben Agudo Santos (GS-AIS-HR)
Frameworks & Patterns Use of Organized Classes. Frameworks vs Toolkits Framework Framework  Start with classes and interfaces that define a rudimentary.
CSC241 Object-Oriented Programming (OOP) Lecture No. 16.
Chapter 10 Inheritance and Polymorphism
1 Interfaces and Abstract Classes Chapter Objectives You will be able to: Write Interface definitions and class definitions that implement them.
CPSC 871 John D. McGregor Module 5 Session 1 Design Patterns.
Variables and Data Types.  Variable: Portion of memory for storing a determined value.  Could be numerical, could be character or sequence of characters.
Subtype Polymorphism, Subtyping vs
Peyman Dodangeh Sharif University of Technology Fall 2014.
OBJECT ORIENTED PROGRAMMING. Design principles for organizing code into user-defined types Principles include: Encapsulation Inheritance Polymorphism.
S.Ducasse Stéphane Ducasse 1 Some Principles Stéphane Ducasse ---
 constant represented by a name, just like a variable, but whose value cannot be changed  The const keyword precedes the type, name, and initialization.
 2000 Prentice Hall, Inc. All rights reserved. Chapter 20 - Virtual Functions Outline 20.1Introduction 20.2Type Fields and switch Statements 20.3Virtual.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Subtype Polymorphism, Subtyping vs. Subclassing, Liskov Substitution Principle.
Copyright © 2016 Robert W. Hasker. exponent /-mantissa 1 bit 6 bits9 bits.
אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכויות שמורות 1 פרק 5 תרשימי מצבים Statecharts למחלקות תגובתיות Reactive Classes הקדמה ודוגמא.
C++ Lesson 1.
Asst.Prof.Dr. Tayfun ÖZGÜR
Advanced Programming in Java
Data types Data types Basic types
Name the shape below. rectangle rhombus square triangle A B C D
Reserved Words.
Object-Oriented Programming (OOP) Lecture No. 28
null, true, and false are also reserved.
C++ Basics.
درس برنامه‌سازي کامپيوتر
HYBRID INHERITANCE : AMBIGUITY REMOVAL
Subtype Polymorphism, Subtyping vs
Keywords.
Prof. Bhushan Trivedi Director GLS Institute of Computer Technology
Shapes.
Inheritance: Polymorphism and Virtual Functions
Module 2 Variables, Assignment, and Data Types
Programming Language C Language.
Principles of Object-Oriented Design
Advanced Programming in Java
Presentation transcript:

אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 1 פרק 3 OCP

אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 2 Open Closed Principle (OCP) האסטרטגיה שעל פיה ניתן לתת מענה לדרישות משתנות דוגמאות למימוש

אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 3 הפשטה / רב צורתיות ללא OO(ירושה) הדפסת 'צורה' 1 enum ShapeType {circle, square}; struct Point{…}; struct Shape { ShapeType itsType; }; struct Circle { ShapeType itsType; double itsRadius; Point itsCenter; }; struct Square { ShapeType itsType; double itsSide; Point itsTopLeft; }; 2 void drawSquare(Square* s){…}; void drawCircle(Circle* c){…}; void drawAllShapes(Shape* list[], int n) { int i; for (i=0; i<n; i++) { Shape *s = list[i]; switch (s->itsType) { case square: drawSquare((Square*)s); break; case circle: drawCircle((Circle*)s); break; }

אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 4 רב צורתיות עם OO (ירושה ) הדפסת 'צורה' class Shape { public: virtual void draw() const = 0; }; class Square : public Shape { public: virtual void draw() const; }; void drawAllShapes(Shape* list[], int n) { int i; for (i=0; i<n; i++) list[i]->draw(); } class Circle : public Shape { public: virtual void draw() const; };

אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 5 Run Time Type Identification (RTTI) (תוכנית שאינה עומדת ב-OCP) class Point{...}; class Shape {}; class Square : public Shape { private: Point itsTopLeft; double itsSide; friend void drawSquare(Square*); }; void drawAllShapes(Shape *line[],int n ) { for (int i=0;i<n;i++) { Circle* c = dynamic_cast (line[i]); Square* s = dynamic_cast (line[i]); if (c) drawCircle(c); else if (s) drawSquare(s); } class Circle : public Shape { private: Point itsCenter; double itsRadius; friend void drawCircle(Circle*); };

אביב תשס " ה JCT תיכון תוכנה ד " ר ר ' גלנט / י ' לויאןכל הזכורות שמורות 6 Run Time Type Identification (RTTI) ( תוכנית העומדת ב -OCP) class Shape { public: virtual void draw() const = 0; }; class Square : public Shape { public: virtual void draw() const; }; void drawSquaresOnly(Shape *line[],int size) { for (int i=0; i<size; i++) { Square* s = dynamic_cast (line[i]); if (s) s->draw(); }