Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic.

Similar documents
Data Structures and Algorithms Design Goals Implementation Goals Design Principles Design Techniques. Version 03.s 2-1

Chapter 5 Object-Oriented Programming

COURSE 2 DESIGN PATTERNS

Chapter 1: Programming Principles

Data Abstraction. Hwansoo Han

CO Java SE 8: Fundamentals

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

Building Java Programs

C++ Important Questions with Answers

Object-Oriented Concepts and Design Principles

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 17: Types and Type-Checking 25 Feb 08

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

Top Down Design vs. Modularization

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

Produced by. Design Patterns. MSc in Communications Software. Eamonn de Leastar

INHERITANCE & POLYMORPHISM. INTRODUCTION IB DP Computer science Standard Level ICS3U. INTRODUCTION IB DP Computer science Standard Level ICS3U

Casting -Allows a narrowing assignment by asking the Java compiler to "trust us"

Idioms and Design Patterns. Martin Skogevall IDE, Mälardalen University

BASIC CONCEPT OF OOP

C++ (Non for C Programmer) (BT307) 40 Hours

Exam in TDDB84: Design Patterns,

Lecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction

Software Engineering

CompuScholar, Inc. 9th - 12th grades

Object-Oriented Concepts and Principles (Adapted from Dr. Osman Balci)

Singleton Pattern Creational

PROGRAMMING LANGUAGE 2

CHAPTER 5 GENERAL OOP CONCEPTS

TeenCoder : Java Programming (ISBN )

Introduction to Programming Using Java (98-388)

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

What s Conformance? Conformance. Conformance and Class Invariants Question: Conformance and Overriding

What are the characteristics of Object Oriented programming language?

1. Software Systems Complexity, OO Paradigm, UML

Chapter 1: Principles of Programming and Software Engineering

Object-Oriented Design

Objects First with Java

Inheritance and Substitution (Budd chapter 8, 10)

Chapter 13 Object Oriented Programming. Copyright 2006 The McGraw-Hill Companies, Inc.

Think of drawing/diagramming editors. ECE450 Software Engineering II. The problem. The Composite pattern

Software Paradigms (Lesson 3) Object-Oriented Paradigm (2)

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

Design Pattern What is a Design Pattern? Design Pattern Elements. Almas Ansari Page 1

be used for more than one use case (for instance, for use cases Create User and Delete User, one can have one UserController, instead of two separate

Core Java - SCJP. Q2Technologies, Rajajinagar. Course content

Programming II (CS300)

EPL 603 TOPICS IN SOFTWARE ENGINEERING. Lab 6: Design Patterns

EINDHOVEN UNIVERSITY OF TECHNOLOGY

THE OBJECT-ORIENTED DESIGN PROCESS AND DESIGN AXIOMS (CH -9)

Object-Oriented Programming

Object Oriented Paradigm

Object Oriented Programming. Solved MCQs - Part 2

Concepts of Programming Languages

CMSC 132: Object-Oriented Programming II

Object-oriented Software Design Patterns

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

CLASSES AND OBJECTS IN JAVA

Course Description. Learn To: : Intro to JAVA SE7 and Programming using JAVA SE7. Course Outline ::

Appendix A - Glossary(of OO software term s)

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

WA1278 Introduction to Java Using Eclipse

Software Design COSC 4353/6353 D R. R A J S I N G H

Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

DOWNLOAD PDF CORE JAVA APTITUDE QUESTIONS AND ANSWERS

CMSC 132: Object-Oriented Programming II

Design Patterns Revisited

Object Oriented Paradigm

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

STUDENT LESSON A20 Inheritance, Polymorphism, and Abstract Classes

Unit Wise Questions. Unit-1 Concepts

Unit - IV CHAPTER - 13 INTRODUCTION TO OOP WITH C++ Part 1 Choose the best answer

Design Patterns: Structural and Behavioural

Chapter 5: Procedural abstraction. Function procedures. Function procedures. Proper procedures and function procedures

OBJECT ORİENTATİON ENCAPSULATİON

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Objects and Iterators

+ Abstract Data Types

Data Structures (list, dictionary, tuples, sets, strings)

Lecture Notes on Programming Languages

BCS THE CHARTERED INSTITUTE FOR IT. BCS HIGHER EDUCATION QUALIFICATIONS BCS Level 5 Diploma in IT OBJECT ORIENTED PROGRAMMING

Overview of Java s Support for Polymorphism

DESIGN PATTERN - INTERVIEW QUESTIONS

Design Pattern. CMPSC 487 Lecture 10 Topics: Design Patterns: Elements of Reusable Object-Oriented Software (Gamma, et al.)

Part 7 - Object Oriented Concepts Classes, Objects, Properties and Methods

Tuesday, October 4. Announcements

Foundations of object orientation

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

An Introduction to Patterns

Object-Oriented Modeling Using UML. CS151 Chris Pollett Aug. 29, 2005.

ENCAPSULATION AND POLYMORPHISM

Object-oriented Compiler Construction

Chapter 8: Class and Method Design

Conformance. Object-Oriented Programming Spring 2015

02 Features of C#, Part 1. Jerry Nixon Microsoft Developer Evangelist Daren May President & Co-founder, Crank211

Programming for the Web with PHP

Object Orientated Analysis and Design. Benjamin Kenwright

Transcription:

OOP design revisited design revisited 1 Goals of design usable software robust implementable understandable reusable generalizable extendable solves the problem, satisfies problem requirements, usable error free, resistant to incorrect input minimize complexity readable, not purposefully cryptic solves related problems (parameters, generics) can be modified to solve other problems others?

Abstraction, Inheritance, Polymorphism design revisited 2 Non OOP design's associated data and behavior from the perspective of the behaviors. Data was arguments of functions function (data structure parameters) sort (anarray) OOP Abstraction groups related attributes (data) and/or methods (behaviors) into a syntactical concept (class, struct, property, generic, and to a lesser degree interface, delegate). Inheritance allows ADTs to be factored with specific subclasses inheriting from more abstract superclasses -- type reuse and extension Polymorphism allows specific behaviors (extended from more abstract Behaviors in specific subclasses) to be invoked in the more abstract (general / nameless) context. Relaxes the coupling of the specification of the behavior from its usage. Minimizes errors, complexity, facilitates reuse and generalization.

Encapsulation design revisited 3 Separate model implementation from programming interface (view) get / set accessor / mutator methods C# Properties extends semantic constraints and hides the get / set programming interface. Usage is more transparent "overloads" the assignment operator Accessibility of ATD members: public, private, protected Minimizes errors: fewer side effects and propogation of changes

is - a design revisited 4 abstract factor and "raise" common attributes and behaviors "is - a" = inherit use specific modify customize + add new behaviors - hide (remove) behaviors

has - a design revisited 5 Composition (aggregation) represents the "has - a" relation. If objecta needs to reference a behavior of objectb it does not have to inherit from objecta. it can have a reference attribute the accessess objecta "has - a" relations can be inherited (once established). Object based languages (Modula, ADA) and non OOP languages (C, Pascal, Fortran) relied on composition for design. Compare is-a and has-a (usually more has-a than is-a ) Entertainment appliance - one box that has a monitor, TV, FM, AM receivers, VHS, DVD, and computer integrated subparts.) Separate components: monitor, TV, FM, AM receivers, VHS, DVD, and computer.

Interface Inheritance is an "implementation inheritance". design revisited 6 The superclass's attributes and behaviors are written and usuable in the subclass. An abstract class can have attributes and can provide all, partial, or no implementation of behaviors. Interfaces are a "definition inheritance" "mix ins" Interfaces define in the "superclass" what has to be implemented in the subclass. Implemented methods can be invoked in the interface's context Interfaces can not have attributes and provide no implementation of behaviors. Interfaces are a "contract" between the "interface superclass" and the "implementor subclass" that the compiler can enforce. Interfaces are a "must implement" subset of an "is-a" relationship An List<T> object is-an ennumerable object.

type membership design revisited 7 Class A Interface A Class B Class C Class D Class A Interface A aclass B aclass C aclass D object aclassc is-a ClassA and is-a InterfaceA Collections of as ClassA aclassb aclassc as InterfaceA aclassc aclassd

Containers / Collections design revisited 8 Languages Advantages Disadvantages Dynamically typed easy to define poor static (Smalltalk) reusable classes error detection Statically typed good static typing complicates (C# Java) error detection reusable abstractions Approaches subclassing && works for specific type required casting most types in cast expression (Object ancestor) (boxing) subclassing && no cast methods must be method overriding expression known in advance (event interfaces) Templates works with generics all types error messages cryptic?

element traversal Subclass && cast Easy to add objects to collections... Harder to work with, remove objects from collection... C# ArrayList and "as" operator foreach (AnObject tobj in anarraylist) { AnObject anobject = tobj as AnObject; if (anobject!= null) // do something with anobject Compare to Squeak / Smalltalk's visitor pattern with block abag do: [ :i 'do somthing with object i'.] C# generic List<AnObject> list = new List<AnObject>(); // add anobjects to list list.add(new AnObject( )); foreach(anobject ao in list) Console.WriteLine(ao.ToString()); design revisited 9

Initially few large unfocused classes factoring of classes more "conceptually consistent" classes in resulting design Correctness Assertions (Eiffel, C#) enable testing of boolean conditions that should always be true at run (or debug) time. design revisited 10 // C# int IntegerDivide ( int dividend, int divisor ) { Debug.Assert ( divisor!= 0 ); return ( dividend / divisor ); } Exception handling: try, catch, finally blocks Use of "tested", "validated" class libraries OOP design trade-off Initially develop many small classes w/ "future usage" capabilities assimilation / repackaging of classes fewer classes in resulting design

Patterns repetitive pattern use reduce design complexity: Creation, Structural, Behaviorial patterns (eg below) design revisited 11 Factories Adapters Chains Iterators Mediator Observor Visitor construction of objects modify API of one class to the expected interface of a client -- "protocol stacks", translator pass requests along a chain of receiving objects until the appropriate receiver responds. "ip to mac request" process collection of objects w/o knowing structure of collection promotes loose coupling by not having objects refer to each other directly (lookup table, behavior) one to many dependency, one change is propogated to many operation to be applied to members of a collection

design implementation design revisited 12 design application mirror of implementation decisions / tradeoffs Design is a plan that is projected onto a product / application Implementation distorts the reflection of the initial (possibly ideal) design onto the actual application. Software Engineering assumption: ideal of the design, implementation decisions, distortion

teach design? design revisited 13 Can design be taught prior to, or separate from, implementation? Study of technique / methods / media (algorithms, data structures, programming languages) proceeds design. Design patterns emerge from cannonical works. Do design tools shape designs? Can design be practised? Does one become more efficient at design? Is effort a constant? program effort = design effort + implementation effort does an in design effort cause a in implementation effort? Practise design Architects design structures that can t be built w/ current technology (eg. Paolo Soleri / Arcosonti)

Inheriting Software Metrics Barnes, G.M. and Swim, B.R., Journal of Object Oriented Programming, vol. 6, 7, 1993, pp 27-34. design revisited 14 Metrics enable software to be measured, software engineering assumptions to be experimentally tested. Abstraction of Software Metrics, automation of metric computation ActQool Actor, "smalltalk", prototype extended class browser to provide metrics & visual representation. developed, gathered, reported correlations of OOP metrics Object QOOLObject metric attributes metric methods {existing classes} self n: n i class inheritied

Qool Browser design revisited 15

OOP Metrics design revisited 16 n = number of operators n1 + operands n2 N = frequency of operators N1 + operands N2 LOC Volume Length V(G) Self Others Methods volume (V) = N (log2 n) Length (N) = N1 + N2 V(G) number of predicates Self Others Methods Variables.93.97.99.98.98.98.90.95.95.92.82.84.83.84.72.80.67.68.66.55.46.60.62.61.71.60.59.31 Self and Others are counts of messages sent to self or other methods Methods and Variables are counts of local methods and variables in a class LOC high correlation w/ all other metrics other metrics not needed