Implementing Specifications CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides.

Slides:



Advertisements
Similar presentations
Chapter 11 Component-Level Design
Advertisements

Lecture 10: Part 1: OO Issues CS 540 George Mason University.
Chapter 1: Computer Systems
Introduction to Object Oriented Programming Java.
Introduction to Design Patterns What is Design Pattern? The Container Pattern. The Visitor Pattern. The SearchableContainer Pattern. The Enumeration Pattern.
CSCI 639 Topics in Software Engineering Assignment #3 Fall 2008.
CS 106 Introduction to Computer Science I 05 / 03 / 2010 Instructor: Michael Eckmann.
Introduction to Software Engineering Lecture 7 André van der Hoek.
1 Introduction to Design Patterns What is Design Pattern? The Container Pattern. The Iterator Pattern. The Visitor Pattern. The SearchableContainer Pattern.
What Is a Collection?  A collection (sometimes called a container) is simply an object that groups multiple elements into a single unit.  Collections.
Introduction to Design Patterns What is Design Pattern? The Container Pattern. The Visitor Pattern. The SearchableContainer Pattern. The Iterator Pattern.
1 ADTs, Collection, Iterable/Iterator Interfaces Collections and the Java Collections API The Collection Interface and its Hierarchy The Iterable and Iterator.
Introduction to Design Patterns What is Design Pattern? The Container Pattern. The Iterator Pattern. The Visitor Pattern. The SearchableContainer Pattern.
Sharif University of Technology1 Design and Use-case Realization Software Engineering Laboratory Fall 2006.
CS 106 Introduction to Computer Science I 04 / 30 / 2010 Instructor: Michael Eckmann.
Object-Oriented Analysis and Design
Analysis Modeling (cont’d) CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Analysis Modeling (cont’d) CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides.
Class Specifications CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides are intended.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
Chapter 1 Object-Oriented Analysis and Design. Disclaimer Slides come from a variety of sources: –Craig Larman-developed slides; author of this classic.
Lecture 17 March 24, 2011 Formal Methods 2 CS 315 Spring Adapted from slides provided by Jason Hallstrom and Murali Sitaraman (Clemson)
Generalized Containers CSIS 3701: Advanced Object Oriented Programming.
Computer Science and Engineering College of Engineering The Ohio State University Interfaces The credit for these slides goes to Professor Paul Sivilotti.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Copyright © 2002, Systems and Computer Engineering, Carleton University Patterns.ppt * Object-Oriented Software Development Part 11.
CPSC 102: Computer Science II Dr. Roy P. Pargas 408 Edwards Hall Office Hours 10:00-11:00 am MWF 2:00-3:00 pm TTh.
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,
CSE 222: Software Components in Engineering (SCE) – Introduction Instructor: Jimmy Voss Disclaimer: Not all material is original. Some is taken from the.
1 Introduction to Classes and Objects Chapter 3 Introduction to Classes and Objects Chapter 3.
Analysis Modeling (cont’d) CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides.
Introduction to Design (and Zen) CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These.
Behavioral Pattern: Iterator C h a p t e r 5 – P a g e 159 Software can become difficult to manage when a variety of different traversals of a variety.
Analysis Modeling CpSc 372: Introduction to Software Engineering
Chapter 3 Part I. 3.1 Introduction Programs written in C ◦ All statements were located in function main Programs written in C++ ◦ Programs will consist.
Introduction to Geospatial Metadata – FGDC CSDGM National Coastal Data Development Center A division of the National Oceanographic Data Center Please .
Week 2 - Friday.  What did we talk about last time?  Computing Big Oh.
Copyright (c) Systems and Computer Engineering, Carleton University * Object-Oriented Software Development Unit 13 The Collections Framework.
CSE 1201 Object Oriented Programming ArrayList 1.
CS-2852 Data Structures LECTURE 2 Andrew J. Wozniewicz Image copyright © 2010 andyjphoto.com.
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter Chapter 18 List ADT Animated Version.
The Software Process CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides are intended.
Representation Invariants CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides.
Object Oriented Programming in Java Habib Rostami Lecture 7.
CSC 243 – Java Programming, Spring, 2014 Week 4, Interfaces, Derived Classes, and Abstract Classes.
Copyright © 2007 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Java From Control Structures through Data Structures by.
 2016, Marcus Biel, ArrayList Marcus Biel, Software Craftsman
CSC 243 – Java Programming, Fall, 2008 Tuesday, September 30, end of week 5, Interfaces, Derived Classes, and Abstract Classes.
Java Interfaces CS 21a: Introduction to Computing I Department of Information Systems and Computer Science Ateneo de Manila University (see Chapter 9 of.
1 CS162: Introduction to Computer Science II Abstract Data Types.
Working with Java.
COP 3503 FALL 2012 Shayan Javed Lecture 8
More sophisticated behavior
Component-Level Design
Introduction to Design Patterns
Introduction to Java Programming
Text Structure English 7 & 8.
Introduction to javadoc
HTML 5 SEMANTIC ELEMENTS.
Classes CS 21a: Introduction to Computing I
CS2013 Lecture 7 John Hurley Cal State LA.
Text Structure English 7 & 8.
Software Design Lecture : 39.
Java Generics & Iterators
Zorah Fung University of Washington, Winter 2016
Introduction to Design Patterns
Introduction to Design Patterns
Presentation transcript:

Implementing Specifications CpSc 372: Introduction to Software Engineering Jason O. Hallstrom Authorship Disclaimer. These slides are intended to serve as teaching instruments for an undergraduate course in Software Engineering. While the slides were formatted by Dr. Hallstrom, the content is compiled from other sources, including the readings listed on the course website, Dr. Pressman’s Software Engineering textbook, and various internet materials. In almost every case, the ideas belong to someone other than Dr. Hallstrom. Indeed, text is often quoted verbatim without an explicit citation (to improve the readability of the slides). The original authors retain all copyrights. If you are interested in citing any of the material in these slides, please contact Dr. Hallstrom for the original source(s). DO NOT CITE THIS PRESENTATION. THE CONTENT SHOULD NOT BE ATTRIBUTED TO DR. HALLSTROM. SEE DR. HALLSTROM IF YOU HAVE ANY QUESTIONS.

CpSc 372 Interface Specifications An interface specification is a tool for describing an abstraction. An interface specification consists of four elements. A description of the abstract data model An initial value for the data model A specification says nothing about how the specification must be implemented. Hence, there can be multiple implementations of any specification. A list of exposed methods A list of method contracts

CpSc 372 Implementing an Interface Recall the interface specifications that we’ve discussed. public interface Set { void clear(); void add(Object x); void remove(Object x); Object removeAny(); boolean isIn(Object x); int getSize(); } public interface Sequence { void clear(); void add(int pos, Object x); Object remove(int pos); Object getElement(int pos); int getLength(); } modeled by: String of Object modeled by: Set of Object

CpSc 372 Representations modeled by: String of Object modeled by: Set of Object represents Consider implementing the Set interface using an implementation of the Sequence interface as the representation. (Representation = “private state”)

CpSc 372 Abstraction Functions <> Set of Object String of Object {}{3,1,2}{6,5} An abstraction function characterizes how an abstract model is realized by one or more concrete models. abstraction function abstract state space concrete state space

CpSc 372 The Code public class SetImpl1 implements Set { /* representation: self = elements(self.items) */ private Sequence items; public SetImpl1() { items = new SequenceImpl1(); } public void add(Object x) { items.add(0, x); } /* … */ public Object removeAny(x) { return(items.remove(0, x)); } /* … */ } Abstraction function

CpSc 372 Implementing Methods Set of Object String of Object {3,1,2} {3,1,2,0} abstract concrete s.add(new Integer(0)); this.items.add(0, x);

CpSc 372 Implementation Example #1 modeled by: String of Object modeled by: String of Object represents Consider implementing the Stack interface using an implementation of the Sequence interface as the representation. How would you define the abstraction function? StackSequence

CpSc 372 Implementation Example #1 (cont’d) String of Object abstract concrete

CpSc 372 Implementation Example #2 modeled by: String of Object modeled by: Pair of String of Object represents Consider implementing the Sequence interface using a pair of Stack objects as the representation. Stack (x2) Sequence

CpSc 372 Implementation Example #2 (cont’d) public class SequenceImpl implements Sequence { /* representation: self = ??? */ private Stack before, after; … private void moveToFront(int pos) /* requires: ??? ensures: ??? */ … } How would these be defined? How would the code be implemented?