Advanced Object Oriented Design Laboratory.

Similar documents
CAS 703 Software Design

Lecture: Modular Design

Chapter 8: Class and Method Design

Object-Oriented Design I

Classes and Objects. Object Orientated Analysis and Design. Benjamin Kenwright

Refactoring Practice: How it is and How it Should be Supported

Object Oriented Metrics. Impact on Software Quality

CMPS 115 Winter 04. Class #10 (2004/02/05) Changes/Review Programming Paradigms Principles of OOD <break> Design Patterns

Object-Oriented Design II - GRASP

PRINCIPLES OF SOFTWARE DESIGN

Classes. Logical method to organise data and functions in a same structure. Also known as abstract data type (ADT).

CPSC 310: Sample Final Exam Study Questions 2014S1 (These are in addition to the Study Questions listed at the end of some lectures)

Facade and Adapter. Comp-303 : Programming Techniques Lecture 19. Alexandre Denault Computer Science McGill University Winter 2004

Aspect Oriented Programming

1 Software Architecture

Maintainable Software. Software Engineering Andreas Zeller, Saarland University

Abstraction. Design fundamentals in OO Systems. Fundamental Software Development Principles

GRASP Design Patterns A.A. 2018/2019

Application Architectures, Design Patterns

Elementary Concepts of Object Class

Principles of Object-Oriented Design

Determining responsibilities. What object should be responsible for what behavior?

Laboratorio di Tecnologie dell'informazione

2009 Shawn A. Bohner. Shawn Bohner Office: Moench Room F212 Phone: (812)

CS 520 Theory and Practice of Software Engineering Fall 2017

Software Engineering Principles

CS 520 Theory and Practice of Software Engineering Fall 2018

Practice Problems. Review, with SOME solutions

INTERNAL ASSESSMENT TEST III Answer Schema

6 The MVC model. Main concepts to be covered. Pattern structure. Using design patterns. Design pattern: Observer. Observers

Object-Oriented Design

CS 320 Introduction to Software Engineering Spring March 06, 2017

Design Patterns Reid Holmes

Java EE Architecture, Part Three. Java EE architecture, part three 1(57)

Object interconnections

Object-oriented metrics 1

Four More GRASP Principles CSSE 574: Session 5, Part 2

Refining the Observer Pattern: The Middle Observer Pattern

OO Design Principles

Common mistakes and Basic Design Principles. David Rabinowitz

Tuesday, October 4. Announcements

Software Engineering I (02161)

Inheritance Modes. Controlling Inheritance 1

CPSC 427: Object-Oriented Programming

Software Engineering

Non-Blocking Inter-Partition Communication with Wait-Free Pair Transactions

Restructuring. What is restructuring? Tudor Gîrba Reengineering life cycle. What? forward engineering. reverse engineering

Principles of Software Construction: Objects, Design, and Concurrency

Today's Agenda. References. Open Closed Principle. CS 247: Software Engineering Principles. Object-Oriented Design Principles

Magento Technical Guidelines

Software Engineering Testing and Debugging Testing

CS304 Object Oriented Programming Final Term

Software Eningeering. Lecture 9 Design Patterns 2

Clean Code Why Clean Code matters

02291: System Integration

CHAPTER 5 GENERAL OOP CONCEPTS

Design Patterns Lecture 2

Principles of Software Design. Software Engineering Alessio Gambi Saarland University

Comp151. Inheritance: Introduction

Accessibility (1A) Young Won Lim 8/22/13

CSCD01 Engineering Large Software Systems. Design Patterns. Joe Bettridge. Winter With thanks to Anya Tafliovich

Inheritance Inheritance :

Design Patterns. An introduction

Design of Software Systems (Ontwerp van SoftwareSystemen) Design Patterns Reference. Roel Wuyts

5. (a) What is secondary storage? How does it differ from a primary storage? (b) Explain the functions of (i) cache memory (ii) Register

Software Engineering I (02161)

Study Guide to Exam 2

9/19/2018 Programming Data Structures. Polymorphism And Abstract

Object Oriented Programming

Microsoft Word - Templates

Design Patterns (Composite, Iterator)

Software Design Patterns. Background 1. Background 2. Jonathan I. Maletic, Ph.D.

Introduction to Architecture. Introduction to Architecture 1


Topics. Software Process. Agile. Requirements. Basic Design. Modular Design. Design Patterns. Testing. Quality. Refactoring.

Modularity Guidelines for design in any programming language

Chapter 5 Object-Oriented Programming

What is a Pattern? Lecture 40: Design Patterns. Elements of Design Patterns. What are design patterns?


Scanner - A tool for collecting object oriented software metrics from C++ class definitions

18.1 Definitions and General OO Principles

FINAL TERM EXAMINATION SPRING 2010 CS304- OBJECT ORIENTED PROGRAMMING

Lecture 13: Design Patterns

COURSE 2 DESIGN PATTERNS

Pattern Resources. Lecture 25: Design Patterns. What are Patterns? Design Patterns. Pattern Languages of Programming. The Portland Pattern Repository

Software Architecture With ColdFusion: Design Patterns and Beyond Topics Outline Prepared by Simon Horwith for CFUnderground 6

The Stepping Stones. to Object-Oriented Design and Programming. Karl J. Lieberherr. Northeastern University, College of Computer Science

Software Design and Analysis for Engineers

25.1 Introduction Façade Design Pattern Identification Problem Structure Participants...

The Challenge. Principles of Software Design

Clean

Application Frameworks Function Oriented Object Oriented Service Oriented

Object Oriented Design

CPSC 310 Software Engineering. Lecture 11. Design Patterns

Abstract Classes. Abstract Classes a and Interfaces. Class Shape Hierarchy. Problem AND Requirements. Abstract Classes.

Object interconnections גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון

Modularity!! Guidelines for design! in any programming language!

Setting up the reading pane

Topics in Object-Oriented Design Patterns

Software Development. Modular Design and Algorithm Analysis

Transcription:

Advanced Object Oriented Design Laboratory Blazej.Pietrzak@cs.put.poznan.pl

Message Chains

Law of Demeter Principle Object- Oriented style rule for builing systems (Dem et er Research Group 1987, published 1988) General Form: Each unit should only use a limited set of other units: only units closely related to the current unit Don t talk to strangers

Law of Demeter Principle cont. friends

Object Form of Law of Demeter Principle unit = method Closely related: 3. A parameter of the method 4. The enclosing object (this). 5. A static object. 6. An immediate part object (computed or stored): a. An object that the enclosing method returns b. At tributes of the enclosing object c. An element of a collection which is an attribute of the enclosing object 7. An object created within the method.

Object Form of Law of Demeter Principle unit = method Closely related: 3. A parameter of the method 4. The enclosing object (this). 5. A static object. public void dosth(object obj) { System.out.println(obj.toString()); this.dosth( LoD );

Object Form of Law of Demeter Principle 1. An immediate part object (computed or stored): a. An object that the enclosing method returns public class SthClass {... public Object getobj() { return new Object(); public void dosth() { System.out.println(getObj().toString());

Object Form of Law of Demeter Principle 1. An immediate part object (computed or stored): a. At tributes of the enclosing object b. An element of a collection which is an attribute of the enclosing object public class SthClass { public List collection;... public void dosth() { Object elem = collection.get(0); System.out.println(elem.toString());

Object Form of Law of Demeter Principle 1. An object created within the method. public void dosth() { Object obj = new Object(); System.out.println(obj.toString());

Law of Demeter Principle - Motivation Programmers can only keep a limited set of items in short- term memory and it is easier to keep them in memory if they are closely related Hiding the structure of navigation causes less changes to client. Reusability of m ethods (low coupling)

Law of Demeter Principle The Strong Law of Demeter The instance variables make up a given class. Inherited instance variable types may not be passed messages. The Weak Law of Demeter The instance variables and any instance variables inherited from other classes make up a given class

What is Message Chains? Message Chains is a violation of the Law of Demeter Principle

example public class Person { private Department department; public void setdepartment(department department){ this.department = department; public Department getdepartment() { return department;

example cont. public class Department { public Department(Person manager) { this.manager = manager; public Person getmanager() { return manager;

example cont....... Person manager = john.getdepartment().getmanager(); Violation of the Law of Demeter

example public class Person { private Department department; public void setdepartment(department department){ this.department = department; public Department getdepartment() { return department; public Person getmanager() { return department.getmanager(); Extract to method Move method Hide delegate Correct