Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 2: Structured.

Slides:



Advertisements
Similar presentations
Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 14: Stepwise.
Advertisements

Prof. Dr. Max Mühlhäuser Dr. Guido Rößling
Programming with App Inventor Computing Institute for K-12 Teachers Summer 2012 Workshop.
Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 4: Evaluation.
Programmer-defined classes Part 2. Topics Returning objects from methods The this keyword Overloading methods Class methods Packaging classes Javadoc.
Getting started with ML ML is a functional programming language. ML is statically typed: The types of literals, values, expressions and functions in a.
מבוא מורחב 1 Lecture #7. מבוא מורחב 2 The rational number abstraction Wishful thinking: (make-rat ) Creates a rational number (numer ) Returns the numerator.
CS 355 – PROGRAMMING LANGUAGES Dr. X. Apply-to-all A functional form that takes a single function as a parameter and yields a list of values obtained.
מבוא מורחב 1 Lecture #6. מבוא מורחב 2 Primality testing (application) Know how to test whether n is prime in  (log n) time => Can easily find very large.
Fall 2008Programming Development Techniques 1 Topic 2 Scheme and Procedures and Processes September 2008.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 7. Data directed programming Section 2.4, pages ,2.5.2 pages (but with a different example)
מבוא מורחב - שיעור 10 1 Symbols Manipulating lists and trees of symbols: symbolic differentiation Lecture 10.
CS 201 Functions Debzani Deb.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 10. Data directed programming Message passing Section 2.4, pages ,2.5.2 pages (but with.
מבוא מורחב למדעי המחשב בשפת Scheme תרגול 7. Outline Symbols Data Directed Programming, Message Passing.
Functional programming: LISP Originally developed for symbolic computing First interactive, interpreted language Dynamic typing: values have types, variables.
CSC 160 Computer Programming for Non-Majors Lecture #3a: Stepper, Words, Sentences Prof. Adam M. Wittenstein
Chapter 2: Algorithm Discovery and Design
Arbitrarily Long Data Structures: Lists and Recursion CMSC Introduction to Computer Programming October 4, 2002.
6.001 SICP 1/ : Structure and Interpretation of Computer Programs Symbols Example of using symbols Differentiation.
Intermediate Algebra Prerequisite Topics Review Quick review of basic algebra skills that you should have developed before taking this class 18 problems.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
School of Computer Science & Information Technology G6DICP - Lecture 22 The Theory of Object Oriented Programming.
Scheme: Compound Data Chapter 6 of HTDP Ms. Knudtzon September 19.
Data Structures Chapter 1- Introduction Mohamed Mustaq.A.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Case Study - Fractions Timothy Budd Oregon State University.
Class Example - Rationals Rational numbers are represented by the ratio of two integers, a numerator and a denominator, e.g., 2/3. This is opposed to irrational.
P.1 Real Numbers. 2 What You Should Learn Represent and classify real numbers. Order real numbers and use inequalities. Find the absolute values of real.
Introduction CS 3358 Data Structures. What is Computer Science? Computer Science is the study of algorithms, including their  Formal and mathematical.
Compound Data. Last Lecture Booleans Only two elements Symbols Not to be confused with variables Strings Notions of equality on values.
Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 8: Accumulating.
1 Programming for Engineers in Python Autumn Lecture 6: More Object Oriented Programming.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Chapter 3 Top-Down Design with Functions Part II J. H. Wang ( 王正豪 ), Ph. D. Assistant Professor Dept. Computer Science and Information Engineering National.
Functional Programming Language 1 Scheme Language: part 2.
2 Objectives You should be able to describe: Object-Based Programming Classes Constructors Examples Common Programming Errors.
Java™ How to Program, 9/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Fall 2008Programming Development Techniques 1 Topic 5 Data Abstraction Note: This represents a change in order. We are skipping to chapter 2 without finishing.
1 Introduction  Algorithms  Data structures  Abstract data types  Programming with lists and sets © 2008 David A Watt, University of Glasgow Algorithms.
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
What is the main focus of this course? This course is about Computer Science Geometry was once equally misunderstood. Term comes from ghia & metra or earth.
1/33 Basic Scheme February 8, 2007 Compound expressions Rules of evaluation Creating procedures by capturing common patterns.
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
1 Data Abstraction. Pairs and Lists. (SICP Sections – 2.2.1)
מבוא מורחב שיעור 7 1 Lecture 7 Data Abstraction. Pairs and Lists. (Sections – 2.2.1)
Abstraction A way of managing complexity for large programs A means of separating details of computation from use of computation Types of Abstraction Data.
Functional Programming Language 1 Scheme Language: part 3.
Control Structures I Chapter 3
Basic Scheme February 8, 2007 Compound expressions Rules of evaluation
Pairs and Lists. Data Abstraction. SICP: Sections – 2.2.1
Chapter 3: Using Methods, Classes, and Objects
6.001 SICP Data abstractions
Higher-Order Procedures
The Metacircular Evaluator
Functional Programming
The Metacircular Evaluator
Lecture #6 section pages pages72-77
Lecture #6 מבוא מורחב.
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 12/25/2018.
6.001 SICP Further Variations on a Scheme
Computing in COBOL: The Arithmetic Verbs and Intrinsic Functions
Lecture 12: Message passing The Environment Model
What would be our focus ? Geometry deals with Declarative or “What is” knowledge. Computer Science deals with Imperative or “How to” knowledge 2/23/2019.
Let's Play "What's the Question"
Lecture #7 מבוא מורחב.
Today’s topics Abstractions Procedural Data
6.001 SICP Interpretation Parts of an interpreter
Introduction to the Lab
Rules of evaluation The value of a number is itself.
Presentation transcript:

Telecooperation/RBG Technische Universität Darmstadt Copyrighted material; for TUD student use only Introduction to Computer Science I Topic 2: Structured Data Types Data abstraction Prof. Dr. Max Mühlhäuser Dr. Guido Rößling

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Structures The input/output of a function is seldom an atomic value (number, boolean, symbol), but frequently a data object with many different attributes. –E.g. CD: title and price –We need mechanisms to put compounding data together One of these mechanisms is the structure –A structure definition has the following form –for example 2 (define-struct s (field1 … fieldn)) (define-struct point (x y))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Structure definitions This definition creates a series of procedures: make-s –a constructor procedure, which gets n arguments and returns a structure-value –e.g. (define p (make-point 3 4)) creates a new point s? –a predicate procedure, which returns true for a value that is generated by make-s and false for every other value –e.g. (point? p)  true s-field –for every field a selector, which gets a structure as an argument and extracts the value of the field –e.g. (point-y p)  4 3 (define-struct s (field1 … fieldn)) (define-struct point (x y))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Design of procedures for compound data When do we need structures? –If the description of an object consists of many different pieces of information How does our design recipe change? –Data analysis: Search the problem statement for descriptions of relevant objects, then generate corresponding data types; describe the contract of the data type –Definition of a contract can use the new defined type names, i.e. ;; grant-qualified: Student  bool –Template: Header + Body, which contains all possible selectors –Implementation of the bodies: Design an expression that uses primitive operations, other functions, selector expressions and the variables 4

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Example 5 ;; Data Analysis & Definitions: (define-struct student (last first teacher)) ;; A student is a structure: (make-student l f t) ;; where f, l, and t are symbols. ;; Contract: subst-teacher : student symbol -> student ;; Purpose: to create a student structure with a new ;; teacher name if the teacher's name matches 'Fritz ;; Examples: ;;(subst-teacher (make-student 'Find 'Matthew 'Fritz) 'Elise) ;; = (make-student 'Find 'Matthew 'Elise) ;;(subst-teacher (make-student 'Smith 'John 'Bill) 'Elise) ;; = (make-student 'Smith 'John 'Bill)

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Example (continued) 6 ;; Template: ;; (define (subst-teacher a-student a-teacher) ;;... (student-last a-student)... ;;... (student-first a-student)... ;;... (student-teacher a-student)...) ;; Definition: (define (subst-teacher a-student a-teacher) (cond [(symbol=? (student-teacher a-student) 'Fritz) (make-student (student-last a-student) (student-first a-student) a-teacher)] [else a-student])) ;; Test 1: (subst-teacher (make-student 'Find 'Matthew 'Fritz) 'Elise) ;; expected value: (make-student 'Find 'Matthew 'Elise) ;; Test 2: (subst-teacher (make-student 'Smith 'John 'Bill) 'Elise) ;; expected value: (make-student 'Smith 'John 'Bill)

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 The meaning of structures in the substitution model (1/2) How does define-struct work in the substitution model? This structure produces the following operations: –make-c : a constructor –c-f1 … c-f2 : a series of selectors –c? : a predicate 7 (define-struct c (f1 … fn))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 The meaning of structures in the substitution model We proceed like in every combination –Evaluation of the operator and the operands –The value of (make-c v1 … vn) is (make-c v1 … vn) this way constructors are self evaluating! –The evaluation of (c-fi v) is vi if v = (make-c v1 …vi … vn) An error in all other cases –The evaluation of (c? v) is true, if v = (make-c v1 … vn) false, otherwise Try it with the DrScheme Stepper! 8

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Data abstraction For procedures we have –primitive expressions ( +, -, and, or, …) –means of combination (procedure implementation) –means of abstraction (procedural abstraction) We have the same for data : –primitive data (numbers, boolean values, symbols) –compounded data (e.g. structures) –Data abstraction. 9

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Why do we need data abstraction? Example: Implementation of an operation for adding rational numbers –Rational numbers are composed of a numerator and a denominator, e.g. 1/2 or 7/9. –The addition of two rational numbers produces two results: the resulting numerator and the resulting denominator. –But a procedure can only return one value. –That’s why we would need two procedures: One returns the resulting numerator, the other the resulting denominator. –We have to remember which numerator is part of which denominator. Data abstraction is a method that combines several Data objects, so they can be used as a single object. How this works is hidden by means of data abstraction. 10

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Why do we need data abstraction? The new data objects are abstract data: –They are used without making any assumptions about how they are implemented. Data abstraction helps to... –elevate the conceptual level at which programs are designed, –increase the modularity of designs and –enhance the expressive power of a programming language. A concrete data representation is defined independent of the programs using the data. The interface between the representation and a program using the abstract data is a set of procedures, called selectors and constructors. 11

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Language extensions for handling abstract data Constructor: a procedure that creates instances of abstract data from data that is passed to it Selector: a procedure that returns a data item that is in an abstract data object The component data item returned might be –the value of an internal variable –or it might be computed. Constructors/Selectors generated by define-struct are a special case –The component data returned by these selectors is one of the values that was passed during the constructor call (never computed) 12

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Example: Rational Numbers Mathematically represented by a pair of integers: 1/2, 7/9, 56/874, 78/23, etc. Constructor: (make-rat numerator denominator) Selectors: (numer rn) (denom rn) That's all a user needs to know! –But it’s not quite enough for the programmer and DrScheme, as we have not defined the “rat” structure – this will follow in a couple of slides. 13

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 User-defined Operation for Rational Numbers Multiplication of x = n x /d x and y = n y /d y (n x /d x ) * (n y /d y ) = (n x *n y ) / (d x *d y ) 14 ;; mul-rat: rat rat -> rat ;; Multiplies two rational numbers ;; Example: (mul-rat (make-rat 1 2) (make-rat 2 3) ;; = (make-rat 2 6) (define (mul-rat x y) (make-rat (* (numer x) (numer y)) (* (denom x) (denom y))))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Another Operation on Rational Numbers Addition of x = n x /d x and y = n y /d y n x /d x + n y /d y = (n x *d y + n y *d x ) / (d x *d y ) 15 ;; add-rat: rat rat -> rat (define (add-rat x y) (make-rat (+ (* (numer x) (denom y)) (* (numer y) (denom x))) (* (denom x) (denom y)))) Subtraction and division are defined similarly to addition and multiplication.

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 A test Equality: n x /d x = n y /d y iff n x *d y = n y *d x 16 iff means: if and only if ;; equal-rat: rat rat -> bool (define (equal-rat? x y) (= (* (numer x) (denom y)) (* (numer y) (denom x))))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 An output operation ;; print-rat: rat -> String (define (print-rat x) (string-append (number->string (numer x)) "/" (number->string (denom x)))) 17 To output rational numbers in a convenient form, we define an output procedure using data abstraction. This is your first example with string manipulation! string-append puts several strings together. number->string turns a number in a string. This is not possible using symbols.

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Below the abstract data We implemented the operators add-rat, mul-rat and equal-rat using make-rat, denom, numer. –Without implementing make-rat, denom, numer! –Even without knowing, how they will be implemented… We still need to define make-rat, denom, numer. –Therefore, we have to glue together numerator and denominator. –To achieve this, we create a Scheme structure for storing pairs: 18 (define-struct xy (x y))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Representing rational numbers (define (make-rat n d) (make-xy n d)) (define (numer r) (xy-x r)) (define (denom r) (xy-y r)) 19 We can define the constructor and the selectors with the assistance of the xy structure.

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Using operations on rational numbers (define one-third (make-rat 1 3)) (define four-fifths (make-rat 4 5)) (print-rat one-third) “1/3“ (print-rat (mul-rat one-third four-fifths)) “4/15“ (print-rat (add-rat four-fifths four-fifths)) “40/25“ 20

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Levels of abstraction Programs are built up as layers of language extensions. Each layer is a level of abstraction. Each abstraction hides some implementation details. There are four levels of abstraction in our rational numbers example. 21 add-rat mul-rat equal-rat … make-rat numer denom Rational numbers as numerators and denominators Rational numbers as structures Rational numbers in the problem domain make-xy xy-x xy-y Whatever way structures are implemented Programs that use rational numbers

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Bottom level Level of pairs Procedures make-xy, xy-x and xy-y are already constructed by the interpreter due to the structure definition. The actual implementation of structures is hidden. 22 Rational numbers as structures make-xy xy-x xy-y Whatever way structures are implemented

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Second level Level of rational numbers as data objects Procedures make-rat, numer and denom are defined at this level. The actual implementation of rational numbers is hidden at this level. 23 make-rat numer denom Rational numbers as numerators and denominators Rational numbers as structures

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Third level Level of service procedures on rational numbers Procedures add-rat, mul-rat, equal-rat, etc. are defined at this level. Implementation of these procedures are hidden at this level. 24 add-rat mul-rat equal-rat … Rational numbers as numerators and denominators Rational numbers in problem domain

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Top level Program level Rational numbers are used in calculations as if they were ordinary numbers. 25 Rational numbers in the problem domain Programs that use rational numbers

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Abstraction barriers Each level is designed to hide implementation details from higher-level procedures. These levels act as abstraction barriers. 26

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Advantages of data abstraction Programs can be designed one level of abstraction at a time. Thereby data abstraction supports top-down design. –We can gradually figure out data representations and how to implement constructors, selectors and service procedures that we need, one level at a time. We do not have to be aware of implementation details below the level at which we are programming. An implementation can be changed later without changing procedures written at higher levels. 27

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Change data representation A few slides ago we saw: Our rational numbers are not always in reduced form. We decide that rational number should be represented in a reduced form. –40/25 and 8/5 are the same number. –Thanks to data abstraction our service procedures do not care in which form the number is represented. –The procedures like add-rat or equal-rat function correctly in either case. 28 (print-rat (add-rat four-fifths four-fifths)) "40/25"

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Change data representation (define (make-rat n d) (make-xy (/ n (gcd n d)) (/ d (gcd n d)))) 29 We can change the constructor......or the selectors. (define (numer x) (/ (xy-x x) (gcd (xy-x x) (xy-y x)))) (define (denom x) (/ (xy-y x) (gcd (xy-x x) (xy-y x)))) gcd is a built-in procedure that produces the greatest common divisor!

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data Up to this point, our procedures have handled only one type of data –Numbers –Booleans –Symbols –Types of special structures But we often want that procedures operate with different types of data We will also learn how to protect procedures from wrong use 30

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Example We have (define-struct point (x y)) for points Many points are on the x-axis In this case we want to represent these points just by a number –A = (make-point 6 6), B= (make-point 1 2) C = 1, D = 2, E = 3 31

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data To document our representation of points, we make the following informal definition of data types Now the contract, the description and the header of a procedure distance-to-0 is easy: How can we differentiate between the data types? –With the help of the predicates: number?, point? etc. 32 ;; a pixel-2 is either ;; 1. a number ;; 2. a point-structure ;; distance-to-0 : pixel-2 -> number ;; to compute the distance of a-pixel to the origin (define (distance-to-0 a-pixel)...)

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data Base structure: Procedure body with cond-expression that analyzes the type of the input We know that in the second case the input is composed of two coordinates … 33 (define (distance-to-0 a-pixel) (cond [(number? a-pixel)...] [(point? a-pixel)...])) (define (distance-to-0 a-pixel) (cond [(number? a-pixel)...] [(point? a-pixel) … (point-x a-pixel) … (point-y a-pixel) … ]))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data Now it is easy to complete the function… 34 (define (distance-to-0 a-pixel) (cond [(number? a-pixel) a-pixel] [(point? a-pixel) (sqrt (+ (sqr (point-x a-pixel)) (sqr (point-y a-pixel))))])) built-in procedures: (sqr x) : x square (sqrt x) : square root of x

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data Another Example: graphical objects –Variants: squares, circles,… –procedures: calculating the perimeter, draw, … 35 ;; A shape is either ;; a circle structure: ;; (make-circle p s) ;; where p is a point describing the center ;; and s is a number describing the radius; or ;; a square structure: ;; (make-square nw s) ;; where nw is the north-west corner point ;; and s is a number describing the side length. (define-struct circle (center radius)) (define-struct square (nw length)) ;; Examples:(make-circle (make-point 5 9) 87) ;; (make-square (make-point 20 5) 5)

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data Compute the perimenter: –Using our design-recipe… –Using our design-recipe… (continued) 36 ;; perimeter : shape -> number ;; to compute the perimeter of a-shape (define (perimeter a-shape) (cond [(square? a-shape)... ] [(circle? a-shape)... ])) ;; perimeter : shape -> number ;; to compute the perimeter of a-shape (define (perimeter a-shape) (cond [(square? a-shape)... (square-nw a-shape)..(square-length a-shape)...] [(circle? a-shape)... (circle-center a-shape)..(circle-radius a-shape)..]))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Designing Procedures for Mixed Data Compute perimeter: –Final result 37 ;; perimeter : shape -> number ;; to compute the perimeter of a-shape (define (perimeter a-shape) (cond [(square? a-shape) (* (square-length a-shape) 4)] [(circle? a-shape) (* (* 2 (circle-radius a-shape)) pi)]))

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 Program design and heterogeneous data The data analysis gets more important –Which classes of objects exists and what are their attributes? –Which meaningful groupings of classes are there? So called “subclass creation” –Yields a hierarchy of data definitions in general Templates –1. step: cond -expression that analyzes the types of data inside a group –2. step: add selectors accordingly for every branch –Alternative: call a procedure specific to the respective data type (i.e.: procedure perimeter-circle, perimeter-square ) Program body –Combine the available information in every branch of the case, depending on the purpose –Alternative: implement procedures specific to data types one by one using the normal design recipe For an overview of the new design process, see HTDP Fig

Dr. G. Rößling Prof. Dr. M. Mühlhäuser RBG / Telekooperation © Introduction to Computer Science I: T2 39 Get your data structures correct first, and the rest of the program will write itself. David Jones