From Module Breakdown to Interface Specifications Completing the architectural design of Map Schematizer.

Slides:



Advertisements
Similar presentations
Chapter 8 Technicalities: Functions, etc. Bjarne Stroustrup
Advertisements

EECE 310: Software Engineering Modular Decomposition, Abstraction and Specifications.
Cs205: engineering software university of virginia fall 2006 Specifying Procedures David Evans
Programming Languages and Paradigms
IT Requirements Capture Process. Motivation for this seminar Discovering system requirements is hard. Formally testing use case conformance is hard. We.
© 2010 Bennett, McRobb and Farmer1 Use Case Description Supplementary material to support Bennett, McRobb and Farmer: Object Oriented Systems Analysis.
API Design CPSC 315 – Programming Studio Fall 2008 Follows Kernighan and Pike, The Practice of Programming and Joshua Bloch’s Library-Centric Software.
ITEC200 Week02 Program Correctness and Efficiency.
Software Engineering and Design Principles Chapter 1.
From Module Decomposition to Interface Specification Software Architecture Part 2.
Testing: Who 3, What 4, Why 1, When 2, How 5 Lian Yu, Peking U. Michal Young, U. Oregon.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
Feb. 23, 2004CS WPI1 CS 509 Design of Software Systems Lecture #5 Monday, Feb. 23, 2004.
CS 330 Programming Languages 09 / 16 / 2008 Instructor: Michael Eckmann.
© 2006 Pearson Addison-Wesley. All rights reserved4-1 Chapter 4 Data Abstraction: The Walls.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
The Software Product Life Cycle. Views of the Software Product Life Cycle  Management  Software engineering  Engineering design  Architectural design.
Systems Analysis I Data Flow Diagrams
Introduction to Software Design Chapter 1. Chapter 1: Introduction to Software Design2 Chapter Objectives To become familiar with the software challenge.
Specifications Liskov Chapter 9 SWE 619 Last Updated Fall 2008.
Introduction SWE 619. Why Is Building Good Software Hard? Large software systems enormously complex  Millions of “moving parts” People expect software.
Cs205: engineering software university of virginia fall 2006 Semantics and Specifying Procedures David Evans
Computer Science 340 Software Design & Testing Design By Contract.
1 Design and Integration: Part 1 Nuggets about Design vs Project Management.
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
Lecture 16 March 22, 2011 Formal Methods CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
© 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley 1 Operation, Algorithm, and Data Structure Specification, and Design Finalization.
Computer Science School of Computing Clemson University Introduction to Formal Specification Murali Sitaraman Clemson University.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
SWE 619 © Paul Ammann Procedural Abstraction and Design by Contract Paul Ammann Information & Software Engineering SWE 619 Software Construction cs.gmu.edu/~pammann/
111 Protocols CS 4311 Wirfs Brock et al., Designing Object-Oriented Software, Prentice Hall, (Chapter 8) Meyer, B., Applying design by contract,
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
CSE403 Software Engineering Autumn 2001 Design (Information Hiding) Gary Kimura Lecture #8 October 17, 2001.
Oct 15, 2007Sprenkle - CS1111 Objectives Creating your own functions.
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
CS 350, slide set 5 M. Overstreet Old Dominion University Spring 2005.
Systems Analysis and Design in a Changing World, 3rd Edition
Applied Software Project Management
1 Design and Integration: Part 2. 2 Plus Delta Feedback Reading and lecture repeat Ambiguous questions on quizzes Attendance quizzes Boring white lecture.
Topic 1 Object Oriented Programming. 1-2 Objectives To review the concepts and terminology of object-oriented programming To discuss some features of.
Use Case Driven Analysis Requirements Use Case Use Case Description System Sequence Diagram Chapter 5.
© 2006 Pearson Addison-Wesley. All rights reserved2-1 Chapter 2 Principles of Programming & Software Engineering.
Object-Oriented Programming Chapter Chapter
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Copyright 2007 SpringSource. Copying, publishing or distributing without express written permission is prohibited. Testing Spring Applications Unit Testing.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
SWE 4743 Abstract Data Types Richard Gesick. SWE Abstract Data Types Object-oriented design is based on the theory of abstract data types Domain.
PROGRAMMING PRE- AND POSTCONDITIONS, INVARIANTS AND METHOD CONTRACTS B MODULE 2: SOFTWARE SYSTEMS 13 NOVEMBER 2013.
Formal Methods in Software Engineering1 Today’s Agenda  Mailing list  Syllabus  Introduction.
Object Design More Design Patterns Object Constraint Language Object Design Specifying Interfaces Review Exam 2 CEN 4010 Class 18 – 11/03.
Chapter 1 The Phases of Software Development. Software Development Phases ● Specification of the task ● Design of a solution ● Implementation of solution.
Interfaces CMSC 202. Public Interfaces Objects define their interaction with the outside world through the their public interface. A class' public interface.
Designing classes How to write classes in a way that they are easily understandable, maintainable and reusable 6.0.
 System Requirement Specification and System Planning.
Defects of UML Yang Yichuan. For the Presentation Something you know Instead of lots of new stuff. Cases Instead of Concepts. Methodology instead of the.
Principles of Programming & Software Engineering
Modular Decomposition, Abstraction and Specifications
Data Abstraction: The Walls
Input Space Partition Testing CS 4501 / 6501 Software Testing
Data Abstraction: The Walls
Software Engineering Fall 2005
Graph Coverage for Specifications CS 4501 / 6501 Software Testing
Specifications Liskov Chapter 9
CSC 143 Error Handling Kinds of errors: invalid input vs programming bugs How to handle: Bugs: use assert to trap during testing Bad data: should never.
CSE 303 Concepts and Tools for Software Development
Assertions References: internet notes; Bertrand Meyer, Object-Oriented Software Construction; 4/25/2019.
Computer Science 340 Software Design & Testing
Formal Methods Lecture 16 March 22, 2011 CS 315 Spring 2011
Presentation transcript:

From Module Breakdown to Interface Specifications Completing the architectural design of Map Schematizer

Defining module interfaces The module organization document describes each module very abstractly – Example: The coordinate mapping module has “region iterator” functionality, but doesn’t describe how to use it – It’s not enough for the implementer of that module or other modules that use it You need to design the concrete interfaces

Example: Region iterator What is it? – Does it return a list of regions? – Does it apply a provided method to each region (functional programming style) – Does it implement the Java iterable interface? Any of these would be possible concrete interfaces for the region iterator (but some are better than others)

What’s the interface spec? It includes the actual Java method signature(s) – So the user of the module knows how to call it It includes a precise description of what the method(s) do – Possibly in a formal notation like JML; more likely in (careful, precise) English comments – So the user of the module knows what to expect, and the implementor knows what must be done

What’s an abstract interface? Set of assumptions that the developers of one module can make about another (not just the signature) – What access methods can I invoke? What are their parameters? What exceptions can occur? – What is the effect of calling a method? What are legal sequences of invocations of access methods? – Push(a) – Push(a).pop – Push(a).top What is the effect on one access method of calling another? – Push(a).top returns a – Set(x).get returns x – What are the externally-visible states of the module? Definition of interface used within context of writing interface specifications is broader than definition used by languages such as Java

Goals for Creating Module Interface Specifications Clearly documents the behavior of the module – reduces time & knowledge required to adopt module Clearly documents the interfaces used by the module – Aids in creating stubs, mock interfaces and integration test scripts Improves the ability to isolate errors quickly Supports backwards compatibility Defines implementers work assignment – Interface specification is essentially a contract for the developer that specifies the implementer’s task and the assumptions that users can make Enables straight-forward mapping between use case requirements and methods – reduces effort required for requirements traceability

Module Interface Specifications Are not: – Completed at end of development as “after-thought” – Typical API which focuses on describing signature of interface – Lengthy, 100+ page document – Replacement for design documents What they are: – Critical step in design interval – Description of minimal set of methods Do not include extra methods unless clearly understand how additional functionality would be used – Description of how to verify behavior of module in addition to how to use module – Easy to read, maintain – Means for supporting module extensibility Can be documented using Javadoc or other means. – Interface specifications should be completed before implementation

Abstraction and Interface Specs We strongly prefer an interface spec that is abstract in the sense that it hides implementation details – Allows the implementation to change without affecting other modules BUT … you can’t really design a good interface without thinking about possible implementation(s)

A method for constructing abstract interfaces Define services provided and services needed (assumptions) Decide on syntax and semantics for accessing services In parallel Define access method effects Define terms and local data types Define states of the module Record design decisions Record implementation notes Define test cases and use them to verify access methods Cover testing effects, parameters, exceptions – Test both positive and error use cases Cover broader set of tests than typical unit tests Support automation Design test cases before implementing module – Who is responsible for designing test cases?

Example: Region Iterator Returning a list of regions would be simplest to implement But it’s apt to be wasteful: A list is constructed and then thrown away (pressure on the garbage collector) A map function is also fairly simple, but more work for the client The “iterable” interface is harder to implement but nicer to use

Simple to implement or simple to use? How much do we really care about efficiency? – Right now, we care a lot more about development schedule – But later efficiency might be an issue. We want a quick implementation now, and ability to improve efficiency later (if needed) without changing the interface

Abstraction to the Rescue Possible solution: – Implement the “iterable” interface – But do it quick and dirty: Internally, build a list Implement iterable by iterating over the list Not efficient, but good enough for now – Later, the implementation can be changed Implement the iterator methods directly, without building a list (but only if efficiency is an issue) The interface spec stays the same

Other things to be defined … What’s a region, anyway? Probably an object with four fields: x1, y1, x2, y2 And maybe one more: scale factor Public fields or getters and setters? – Is there really any reason for getters and setters here? How are they iterated? Probably in order, left-to-right and top-to-bottom. But do you want to specify that? Could it change? Do we iterate over all regions, or within a range? Is there an implicit region with scale factor 1.0 to the left of all the shrunk regions?

Possible solutions What’s a region, anyway? – Region has public x1, y1, x2, y2: int – ScaledRegion extends Region adds scale: float How are they iterated? – Arbitrarily (unless a need for knowing order arises Iterate over a specified area (min and max x,y) Does this require another class in Java? Maybe a ‘set-up’ call to set the bounds? Iterated regions completely cover the specified area, possibly with border areas (scaled 1.0)

Lots more … Each module needs a module interface spec – A module might be one class, or several Interface specs include Java classes with public method signatures (and public fields if any) Interface specs also include semantics – This is important. It’s not a spec if it doesn’t say what the methods actually do.

Describing Semantics Typical “contract” style: – Precondition: Caller responsibility – what must be true when this method is called Example: shrinkRegion(x1, y1, x2, y2, sf) might have precondition: y1 < y2, x1 < x2, 0.0 < sf ≤ 1.0 – Postcondition: What is true at return In OO, this typically requires having an abstract model of the information maintained by an object (e.g., the set of regions maintained by the coordinate mapping class). Don’t confuse this with the actual data structure!

More possible semantics Changes at most … – Promises not to change anything outside the list. Unchecked vs checked preconditions – Checked: if the client violates this, the module will notice (and throw an exception, for example) – Unchecked: the client better not violate this, ever Except … (describe what condition triggers each exception) Performance characteristics – E.g., is the “shrink” operation constant time, linear time, or does it depend on how regions overlap in a series of calls?

Map Interface Spec to Module Service Example: indicate the method(s) that correspond to “Iterate over regions” – In general, one “service” may map to multiple methods, which must be called in some sequence (e.g., set area bounds before iterating over regions) – One module may be implemented by more than one class (e.g., “ScaledRegion” as a way of delivering results)

Test cases, too! Test cases can (and should) be defined from the interface specification – And interface specifications should be testable. If you can’t distinguish correct from incorrect execution, the interface should be re-thought. Test cases should cover legal sequences of operations, and checked exceptional cases – Everything the module contract promises

Should you use UML? + UML is widely used and understood + UML can capture signatures and some relations reasonably well – UML doesn’t help much with semantics Unless you also use OCL. Good luck with that. – UML doesn’t help much with judging completeness, consistency, abstractness, or almost anything else important So go ahead if you want, but don’t confuse “nice UML” with “well-designed interface spec”

Summary You need to write module interface specs – Enough to form an agreement between developer of a module, and users of a module Interface specs require lots of design decisions, and some of them are hard You also need to express module interface specs clearly, precisely, and completely