Chair of Software Engineering OOSC - Summer Semester 2004 - 15 1 Object-Oriented Software Construction Bertrand Meyer.

Slides:



Advertisements
Similar presentations
Data Structures Through C
Advertisements

SCOOP: Simple Concurrent Object-Oriented Programming Extend the pure, strongly typed, object-oriented language Eiffel with a general and powerful concurrency.
Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 3: Abstract Data Types.
COMPSCI 105 S Principles of Computer Science 12 Abstract Data Type.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Data Structure Dr. Mohamed Khafagy.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 14: Container Data Structures.
Creating Custom Reports. 2 Design and create a custom report You can easily create custom reports based on a table or query. There are seven sections.
XP New Perspectives on Microsoft Access 2002 Tutorial 61 Microsoft Access 2002 Tutorial 6 – Creating Custom Reports.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Stacks Chapter 5. Chapter Objectives  To learn about the stack data type and how to use its four methods: push, pop, peek, and empty  To understand.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I.
Chair of Software Engineering OOSC Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Design by Contract. Specifications Correctness formula (Hoare triple) {P} A {Q} – A is some operation (for example, a routine body) – P and Q are predicates.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Bertrand Meyer Object-Oriented Software Construction Lecture 8: More on inheritance.
Stacks Chapter 5. Chapter 5: Stacks2 Chapter Objectives To learn about the stack data type and how to use its four methods: push, pop, peek, and empty.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 15: Exception handling.
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 14: Container Data Structures.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 2: Dealing with Objects I.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 20: Some design principles.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 12, 12 May Advanced Topics in Object Technology Bertrand Meyer.
1 Software Architecture Bertrand Meyer ETH Zurich, March-May 2009 Lecture 14: Designing for reuse.
Using Objects and Properties
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 12: Design by Contract™
Chair of Software Engineering OOSC Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Lecture 4 1 Object-Oriented Software Construction Bertrand Meyer.
CHAPTER 3 COLLECTIONS SET Collection. 2 Abstract Data Types A data type consists of a set of values or elements, called its domain, and a set of operators.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 4: The Interface of a Class.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering ATOT - Lecture 16, 26 May Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 14: Presentation of EiffelStudio.
Chair of Software Engineering ATOT - Lecture 11, 7 May Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer Lecture 6: Genericity.
Chair of Software Engineering ATOT - Lecture 14, 19 May Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering Object-Oriented Software Construction Bertrand Meyer Lecture 21: Agents and tuples.
1 ES 314 Advanced Programming Lec 2 Sept 3 Goals: Complete the discussion of problem Review of C++ Object-oriented design Arrays and pointers.
Chair of Software Engineering ATOT - Lecture 7, 23 April Advanced Topics in Object Technology Bertrand Meyer.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 20: Multiple inheritance.
Chair of Software Engineering Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Lecture 9: Abstraction.
Access Tutorial 3 Maintaining and Querying a Database
Implementing Stacks Ellen Walker CPSC 201 Data Structures Hiram College.
CHAPTER 05 Compiled by: Dr. Mohammad Omar Alhawarat Stacks & Queues.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Chapter 3 – Part 1 Word Processing Writer for Linux CMPF 112 : COMPUTING SKILLS.
1 Chapter 17 Object-Oriented Data Structures. 2 Objectives F To describe what a data structure is (§17.1). F To explain the limitations of arrays (§17.1).
Data Abstaraction Chapter 10.
Data Structures & Algorithms
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Collections Using Generics in Collections. 2 Chapter Objectives Define the concept and terminology related to collections Explore the basic structure.
Click to edit Master text styles Stacks Data Structure.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Chapter 3 Lists, Stacks, Queues. Abstract Data Types A set of items – Just items, not data types, nothing related to programming code A set of operations.
Stacks II David Lillis School of Computer Science and Informatics
Design by Contract Jim Fawcett CSE784 – Software Studio
Design by Contract Jim Fawcett CSE784 – Software Studio
Software Architecture
DB Implementation: MS Access Forms
DB Implementation: MS Access Forms
Cs212: Data Structures Computer Science Department Lecture 7: Queues.
Presentation transcript:

Chair of Software Engineering OOSC - Summer Semester Object-Oriented Software Construction Bertrand Meyer

Chair of Software Engineering OOSC - Summer Semester Lecture 15: Some design principles

Chair of Software Engineering OOSC - Summer Semester Container structures CONTAINER * BOX * COLLECTION * TRAVERSABLE * FINITE * INFINITE * * UNBOUNDED * COUNTABLE * RESIZABLE * BAG * SET * HIERARCHICAL * LINEAR * TABLE * ACTIVE * INTEGER_ INTERVAL * BILINEAR * INDEXABLE * CURSOR_ STRUCTURE * DISPENSER * SEQUENCE * STRINGHASH_TABLESTACK * QUEUE * … …

Chair of Software Engineering OOSC - Summer Semester The notion of dispenser  Examples:  Stacks  Queues  Priority queues ...

Chair of Software Engineering OOSC - Summer Semester How big should a class be?  The first question is how to measure class size. Candidate metrics:  Source lines.  Number of features.  For the number of features the choices are:  With respect to information hiding:  Internal size: includes non-exported features.  External size: includes exported features only.  With respect to inheritance:  Immediate size: includes new (immediate) features only.  Flat size: includes immediate and inherited features.  Incremental size: includes immediate and redeclared features.

Chair of Software Engineering OOSC - Summer Semester The features of a class Feature of a class Immediate Redeclared Redefined Effected Inherited Kept New in class From parentChanged Unchanged Was deferred Had an implementation Most useful measure is incremental size. Easy to measure.

Chair of Software Engineering OOSC - Summer Semester Incremental size Feature of a class Immediate Redeclared Redefined Effected Inherited Kept New in class From parentChanged Unchanged Was deferred Had an implementation Most useful measure is incremental size. Easy to measure.

Chair of Software Engineering OOSC - Summer Semester The shopping list approach  If a feature may be useful, it probably is.  An extra feature cannot hurt if it is designed according to the spirit of the class (i.e. properly belongs in the underlying abstract data type), is consistent with its other features, and follows the principles of this presentation.  No need to limit classes to “atomic” features.

Chair of Software Engineering OOSC - Summer Semester to 15 features to 20 features 9 Some statistics from EiffelBase  Percentages, rounded.  149 classes, 1823 exported features. (Includes Lex and Parse.) 0 to 5 features 45 6 to 10 features to 40 features to 80 features 4 81 to 142 features 1

Chair of Software Engineering OOSC - Summer Semester Some statistics from EiffelVision  Percentages, rounded. 546 classes, 3666 exported features. 0 to 5 features 6 to 10 features 11 to 15 features 16 to 20 features 21 to 40 features 41 to 78 features

Chair of Software Engineering OOSC - Summer Semester Including non-exported features  Percentage rounded. All features (about 7600).  Ratio of total features to exported features: 1.27 (EiffelBase), 1.44 (EiffelVision) 0 to 5 features 6 to 10 features 11 to 15 features 16 to 20 features 21 to 40 features 41 to 80 features 81 or more features BaseVision

Chair of Software Engineering OOSC - Summer Semester Minimalism revisited  The language should be small (ETL: “The language design should provide a good way to express every operation of interest; it should avoid providing two.”)  The library, in contrast, should provide as many useful facilities as possible.  Key to a non-minimalist library:  Consistent design.  Naming.  Contracts.  Usefulness and power.

Chair of Software Engineering OOSC - Summer Semester Average number of arguments to a feature The size of feature interfaces  More relevant than class size for assessing complexity.  Statistics from Base, Lex and Parse (exported features only): Number of features Percentage of queries Percentage of commands Maximum number No argument One argument Two arguments Three arguments % 41% % 37% 3% 0.3%

Chair of Software Engineering OOSC - Summer Semester The size of feature interfaces (cont’d)  Including non-exported features: Average number of arguments to a feature No argument One argument Two arguments Three arguments % 36% 5% 1% Maximum number Four arguments0.6% Five or six arguments0.2%

Chair of Software Engineering OOSC - Summer Semester The size of feature interfaces (cont’d)  Statistics from EiffelVision (546 classes, exported features only): Average number of arguments to a feature No argument One arguments Two arguments Three arguments % 32% 15% 3% Maximum number Four arguments0.4% Five to seven arguments0.4% Number of features Percentage of queries Percentage of commands % 61%

Chair of Software Engineering OOSC - Summer Semester Operands and options  Two possible kinds of argument to a feature:  Operands: values on which feature will operate.  Options: modes that govern how feature will operate.  Example: printing a real. The number is an operand; format properties (e.g. number of significant digits, width) are options. print (real_value, number_of_significant_digits, zone_length, number_of_exponent_digits,...) my_window.display (x_position, y_position, height, width, text, title_bar_text, color,...)

Chair of Software Engineering OOSC - Summer Semester Recognizing options from operands  Two criteria to recognize an option:  There is a reasonable default value.  During the evolution of a class, operands will normally remain the same, but options may be added.

Chair of Software Engineering OOSC - Summer Semester Operands and options  The Option Principle:  The arguments of a feature should only be operands.  Options should have default values, with procedures to set different values if requested.  For example: my_window.set_background_color ("dd-blue")... my_window.display

Chair of Software Engineering OOSC - Summer Semester Operands and options  Useful checklist for options: Option Window color Hidden? Default White No Set set_background_color set_visible set_hidden Accessed background_color hidden

Chair of Software Engineering OOSC - Summer Semester Naming (1) Class ARRAY STACK QUEUE HASH_TABLE enter push add insert entry top oldest value pop remove_oldest delete Features

Chair of Software Engineering OOSC - Summer Semester Naming (2) Class ARRAY STACK QUEUE HASH_TABLE put item remove Features

Chair of Software Engineering OOSC - Summer Semester Naming rules  Achieve consistency by systematically using a set of standardized names.  Emphasize commonality over differences.  Differences will be captured by:  Signatures (number and types of arguments and result).  Assertions.  Comments.

Chair of Software Engineering OOSC - Summer Semester Some standard names  Queries: count item, infix to_external, to_c, from_external  Commands: make -- For creation put, extend, replace, force remove, prune, wipe_out  Boolean queries: writable, readable, extendible, prunable empty, full capacity -- Usual invariants: -- empty = (count = 0) -- full = (count = capacity) -- Array access: a.item (i) or i -- Rejected names: if s.addable then s.add (v) if s.deletable then s.delete (v) end

Chair of Software Engineering OOSC - Summer Semester Grammatical rules  Procedures (commands): verbs, infinitive form. Examples: make, put, display.  Boolean queries: adjectives, e.g. full. Also (especially in case of potential ambiguity) names of the form is_some_property. Example: is_first.  In all cases, you should usually choose the form of the property that is false by default at initialization (making it true is an event worth talking about). Example: is_erroneous.  Other queries: nouns or adjectives.Examples: count, error_ window.  Do not use verbs for queries, in particular functions; this goes with the command-query separation principle (prohibition of side-effects in functions).

Chair of Software Engineering OOSC - Summer Semester Feature categories class C inherit … feature -- Category 1 … Feature declarations feature {A, B} -- Category 2 … Feature declarations feature {NONE} -- Category n … Feature declarations invariant … end

Chair of Software Engineering OOSC - Summer Semester Feature categories (cont’d)  Standard categories (the only ones in EiffelBase):  Initialization  Access  Measurement  Comparison  Status report  Status setting  Cursor movement  Element change  Removal  Resizing  Transformation  Conversion  Duplication  Basic operations  Obsolete  Inapplicable  Implementation  Miscellaneous

Chair of Software Engineering OOSC - Summer Semester Obsolete features and classes  A central problem in the computer field: how to reconcile progress with the protection of the installed base?  Obsolete features and classes support smooth evolution.  In class ARRAY: enter (i: V; v: T) is obsolete "Use `put (value, index)’" do put (v, i) end

Chair of Software Engineering OOSC - Summer Semester Obsolete classes class ARRAY_LIST [G] obsolete "[ Use MULTI_ARRAY_LIST instead (same semantics, but new name ensures more consistent terminology). Caution: do not confuse with ARRAYED_LIST (lists implemented by one array each). ]" inherit MULTI_ARRAY_LIST [G] end

Chair of Software Engineering OOSC - Summer Semester End of lecture 15