New User Special Price Expires in

Let's log you in.

Sign in with Facebook


Don't have a StudySoup account? Create one here!


Create a StudySoup account

Be part of our community, it's free to join!

Sign up with Facebook


Create your account
By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

Obj Orient Sftware SpecifCons

by: Consuelo Schultz

Obj Orient Sftware SpecifCons SWE 619

Marketplace > George Mason University > Information technology > SWE 619 > Obj Orient Sftware SpecifCons
Consuelo Schultz
GPA 3.6


Almost Ready


These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Preview These Notes for FREE

Get a free preview of these Notes, just enter your email below.

Unlock Preview
Unlock Preview

Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

View Preview

About this Document

Class Notes
25 ?




Popular in Course

Popular in Information technology

This 19 page Class Notes was uploaded by Consuelo Schultz on Monday September 28, 2015. The Class Notes belongs to SWE 619 at George Mason University taught by Staff in Fall. Since its upload, it has received 33 views. For similar materials see /class/215069/swe-619-george-mason-university in Information technology at George Mason University.

Similar to SWE 619 at Mason

Popular in Information technology


Reviews for Obj Orient Sftware SpecifCons


Report this Material


What is Karma?


Karma is the currency of StudySoup.

You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 09/28/15
S Abstraction Information and Software Engineering SWE 619 Fall 06 00 Software Spec amp Construction hffn39lip nmll quot 39 39 19hfml SI Agenda Motivation Examples of abstractions Understand procedural abstractions Benefits Specify procedural abstractions SWE 619 Fall 06 c Saket Kaushik SI Software construction Usually written in teams ownership of code for maintainence etc changes ClientServer software architecture Contractual obligations Need a way to express what a piece of code does or what is it designed for Within the code block supplementary doc not sufficient SWE 619 Fall 06 c Saket Kaushik I Software construction Need a methodology for High Quality software reliability minimizing bugs robustness Code should be extendable flexible SWE 619 Fall 06 c Saket Kaushik I Monolithic code Imagine a monolithic code block No procedures used No comments within code How easy is it to understandremember what this code does Figuring out correct states is tough How flexible is this code Break down code into compartments State of a program much more manageable Compare with classic divide and rule strategy SWE 519 Fall 05 c Saket Kaushik 5 Divide and Rule Principal to I the rescue Decompose problem into many small problems Easier to solve Many times solutions are known Independent modules for smaller probs Combine modules to solve original prob SWE 519 Fall 05 c Saket Kaushik 5 SI Example 1 Merge Sort PROB Sort an array in incdec order Example sort 427598 in inc order Several ways to do so Bubble sort bucket sort merge sort etc Bubble sort monolithic finds successive minimums Merge sort uses divide and rule principle reduces execution time SWE 519 Fall 05 c Saket Kaushik 7 SWE 519 Fall 05 c Saket Kaushik 8 Example 2 Play Problem Create a play by assembling a group of writers Decomposition Each writer is given a list of characters general plot and is required to write dialogues for one of the characters Individual solutions may not combine properly SWE 519 Fall 05 c Saket Kaushik 9 I Abstraction Improper decomposition is harmful Abstraction changes level of detail to be considered Helps to decompose a problem effectively Abstracts from irrelevant details Focus on the essence of the problem Hence simplifies analysis SWE 519 Fall 05 c Saket Kaushik 10 Example 2 Play Problem Create a play by assembling a group of writers Abstraction Play is viewed as a set of ACTS rather than a set of dialogues Decomposition Each writer is given a list of characters general plot before and after and is required to write an ACT ACTS can be better combined than dialogues SWE 519 Fall 05 c Saket Kaushik 11 l Example 1 Merge Sort Merge Sort Abstraction Forget about how comparisons will be done Decomposition Reduce size of original problem till trivial solution Combine solutions merge to sort complete array Advantage over Bubble sort End up with lesser number of comparisons faster SWE 519 Fall 05 c Saket Kaushik 12 SI Abstraction in programs Fundamental principal in program development Makes programs much more manageable and easier to understand Reduces the detail to be considered Each abstraction is an independent entity in itself Procedures breaking a program into a set of small tasks SWE 619 Fall 06 c Saket Kaushik l Example 3 Task Abstraction Consider a software for a bank that allows its members to log in check their account balance deposit and withdraw money 0 Four top level tasks can be further broken down Consider one public int locateint accts int k fonNard search forint i0 iltalength i Calling program int iArray12568 if acctsik int var 384 return i at position i int index locateiArray var return 1 not in array abstract from a task SWE 619 Fall 06 c Saket Kaushik l Example 3 cont We can change the implementation without affecting calling code public int locateint accts int k backward search forint ialength igt0 i if acctsik return i at position i return 1 not in array Search Method SWE 519 Fall 05 Calling program int iArray12568 int var 384 int index locateiArray var abstract from a task calling code thus combines the available functionality as required c Saket Kaushik Abstraction one to many I mapping SWE 519 Fall 05 4 Speci cation c Saket Kaushik SI Abstraction other uses Allows us to treat dissimilar things as if they were the same Hierarchical organization Everything below a node will exhibit similar properties as the root Basis for type hierarchy SWE 519 Fall 05 c Saket Kaushik 17 SI Example 3 Hierarchy Higher level of abstraction Lower level m o All female mammals produce milk ignoring lower level differences 0 Size and weight of brain in primates is more than that of rodents 0 Size and weight of brain in apes is less than that of humans SWE 519 Fall 05 c Saket Kaushik 18 SI Benefits of abstraction Locality Each implementation can be understood in isolation An abstraction can be used without having to understand how it is implemented it can be implemented without having to understand how it is used Modifiability One implementation can be substituted for another without disturbing the using programs SWE 519 Fall 05 c Saket Kaushik 19 I Kinds of Abstraction Procedural Abstraction Lecture 2 In short procedures How to design specify write procedures Properties of procedures Data Abstraction Lecture 45 Iteration Abstraction Lecture 6 Type Hierarchy Lecture 7 Polymorphic abstraction Lecture 8 SWE 519 Fall 05 c Saket Kaushik 20 l Abstraction Mechanisms Abstraction by Parameterization Abstracts identity of the data by replacing them with parameters Generalizes modules Abstraction by Specification Abstracts from the implementation details to the behavior users can depend on Isolates modules from one another s implementations Language independence SWE 519 Fall 05 c Saket Kaushik 21 Abstraction by l Parameterization Generalizes modules How Separate definition from invocation Example Write a program to add two integers 1441 and 984 Approach 1 int sum 1441 984 Invocation Approach 2 int sum add1441 984 Definition public int addint x int yreturn xy Multiple invocations with same definition SWE 519 Fall 05 c Saket Kaushik 22 An example add method public int addint x int yimplementation Example 54 513 513 63 612 61 2 72 711 71 1 81819 Successorx The smallest number greater than x Predecessorx Largest number smaller than x Successor5 6 Successor6 7 SWE 519 Fall 05 c Saket Kaushik 23 I add method contd Suppose you want to calculate 54 Clearly 54 is the same as the fourth successor of 5 39e Successorsuccessorsuccessorsuccessor5 In java successor of an int a is obtained by a Predecessor of int a is a SWE 519 Fall 05 c Saket Kaushik 24 SI Abstraction by Specification Associate a specification with each procedure Meaning of procedure call is understood from this specification not the body of the procedure No need to look at implementation to realize what the procedure is designed to accomplish SWE 519 Fall 05 c Saket Kaushik 25 Parts of a Procedural SI Specification 39puBli Cz sitfc lint rsjorte d39Searcbhi inf 39Ja int x Requi r 51 a is sorted in asae ding10rder Ef e gts hihf x is in a retgiins 9 Linde39x wmgfe 39 39x39 is sftb dquot fbth rv rissi ri turif 39quot1 SWE 519 Fall 05 c Saket Kaushik 26 Example Liskov fig 13 oat sqrt oat coef REQUIRES coef gt 00 EFFECTS Returns an approximation to the square root of Specification coef float ans coef20 int i 1 One of the Whileilt7 Implementations ans ans ansans coef20ans i i1 return ans SWE 519 Fall 05 c Saket Kaushik 27 I Procedures an Abstraction What are procedures May accept inputs usually produce output Side effects For same inputs same output Output for all possible inputs Procedures Tasks By writing a procedure you abstract from a task Behavior of a procedure what it does is descrlbed a Specl catlon Abstraction interested in the behavior only SWE 519 Fall 05 c Saket Kaushik 28 l Specifications Define the behavior of a procedure Specification is a way to define an abstraction It is the only record of its abstraction Formality An aid to humans natural language preferred Must be formal enough avoid ambiguities try to be as precise as possible We will be close to industry standard ie Javadoc Using comments not optional anymore SWE 519 Fall 05 c Saket Kaushik 29 I Another example p ubli static rintys e39ar h in Ha iiit x Effectsz if x is in a returns an index where x is stored otherwise returns 1 SWE 519 Fall 05 c Saket Kaushik 30 l Yet Another Example public static void sort int 39 Va Modifies a Effects rearrange the elements of a injto ascending order Egg if a 3161 before the call then a 1136 after the can c Saket Kaushik SWE 519 Fall 05 l Yet Another Example public static void CopyLiheU Requires Systemin contains a linegpf text 39Modifies System in and Systemout Reads a line of text from Systemin advances the cursor in Systemin to the end of the 139in e and writes the lih e39 o n Sy s temo u t H H1 H1 0 0 rr III SWE 619 Fall 06 c Saket Kaushik I RequiresModifiesEffects Must be suf ciently informative Requires states conditions that must be true at the beginning of execution Effects describes the conditions that will hold after execution rovided conditions stated in Requires were satis Ied Modifies modifications to input parameters If Requires conditions were satisfied by the caller Effects conditions are guranteed by the callee Software contracts SWE 519 Fall 05 c Saket Kaushik 33 What does a Contract Look I Like Consider the triple P S Q P is the precondition Requires clause Q is the postcondition Effects clause S is the program text Fl39he Customer client is obligated to establish The Implementor service may assume P The Customer is entitled to Q The Implementor is obligated to provide Q That s it SWE 519 Fall 05 c Saket Kaushik 34 Meyer s take on breaking l contracts If everyone does their job there is no problem If the precondition is not satisfied the Customer is wrong The client has a bug If the precondition is satisfied but the postcondition is not then the Service is wrong The server has a bug The Client can t do the Server s job The Server can t do the Client s job SWE 519 Fall 05 c Saket Kaushik 35 SI Defensive Programming Safety vs Efficiency A tradeoff Eliminate preconditions provide defaults Safe code total procedure duplicate checks bulky code defaults can be difficult to figure out Print error message What could be a reasonable return value SWE 519 Fall 05 c Saket Kaushik 36 Defensive Programming cont Meyer Don t do it You should look at the context who calls the procedure general use safety very important it might not be possible to check all inputs local use or limited context easy to establish constraints on input SWE 519 Fall 05 c Saket Kaushik 37 Designing Procedural l Abstractions Simplicity Minimality minimal means fewer constraints on behavior what does this say about the post condition Underdetermined behavior More than one possible result per input allowed Deterministic implementation Only one result per input produced Generality More general if specification can handle a large class of inputs What does this say about the precondition SWE 519 Fall 05 c Saket Kaushik 38


Buy Material

Are you sure you want to buy this material for

25 Karma

Buy Material

BOOM! Enjoy Your Free Notes!

We've added these Notes to your profile, click here to view them now.


You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

Why people love StudySoup

Jim McGreen Ohio University

"Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Kyle Maynard Purdue

"When you're taking detailed notes and trying to help everyone else out in the class, it really helps you learn and understand the I made $280 on my first study guide!"

Steve Martinelli UC Los Angeles

"There's no way I would have passed my Organic Chemistry class this semester without the notes and study guides I got from StudySoup."

Parker Thompson 500 Startups

"It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!

Refund Policy


All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email


StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here:

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.