Chair of Software Engineering OOSC - Summer Semester 2005 - 15 1 Object-Oriented Software Construction Bertrand Meyer Lecture 20: Some design principles.

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.
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.
CS Data Structures II Review COSC 2006 April 14, 2017
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.
Tutorial 5: Working with Excel Tables, PivotTables, and PivotCharts
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.
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.
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 10: Project Presentation Ilinca.
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.
Mgt 240 Lecture MS Excel and Access: Introduction to Databases September 23, 2004.
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.
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 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 - Lecture 21 1 Object-Oriented Software Construction 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 ATOT - Lecture 23, 23 June 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.
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
October 18, Algorithms and Data Structures Lecture V Simonas Šaltenis Nykredit Center for Database Research Aalborg University
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Analyzing Data For Effective Decision Making Chapter 3.
S511 Session 7, IU-SLIS 1 DB Implementation: MS Access Forms.
1 Compiler Construction (CS-636) Muhammad Bilal Bashir UIIT, Rawalpindi.
Data Abstaraction Chapter 10.
1 CSCD 326 Data Structures I Software Design. 2 The Software Life Cycle 1. Specification 2. Design 3. Risk Analysis 4. Verification 5. Coding 6. Testing.
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.
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
Extracting Information from an Excel List The purpose of creating a database, or list in Excel, is to be able to manipulate the data elements in ways that.
Topic 2 Collections. 2-2 Objectives Define the concepts and terminology related to collections Discuss the abstract design of collections.
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.
Set Collection A Bag is a general collection class that implements the Collection interface. A Set is a collection that resembles a Bag with the provision.
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 Lecture 20: Some design principles Ilinca Ciupa

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 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 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