5 Pages

tutorial1answers

Course: CPSC 4360, Fall 2008
School: Lamar
Rating:
 
 
 
 
 

Word Count: 1402

Document Preview

Engineering, Software CPSC-4360-01 and CPSC-5360-01 Tutorial 1. Answers Exercise 1. (Farmer and Cow, Created by Centre for Instructional Technology, NUS, with the support of Dr. Bimlesh Wadhwa, Gerald Ng, Prasad Iyer, adapted from an example of Gary K. Evans, www.evanetics.com) Once upon a time, there was a farmer called Jones. He owned a cow called Bessie. Everyday morning, he would milk his cow and sell the milk...

Register Now

Unformatted Document Excerpt

Coursehero >> Texas >> Lamar >> CPSC 4360

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
Engineering, Software CPSC-4360-01 and CPSC-5360-01 Tutorial 1. Answers Exercise 1. (Farmer and Cow, Created by Centre for Instructional Technology, NUS, with the support of Dr. Bimlesh Wadhwa, Gerald Ng, Prasad Iyer, adapted from an example of Gary K. Evans, www.evanetics.com) Once upon a time, there was a farmer called Jones. He owned a cow called Bessie. Everyday morning, he would milk his cow and sell the milk to the Milk Collection Centre (MCC). The MCC also collect milk from other farmers. Define a model for this application requirement: On a particular day, find the total milk collected from the farmers. Any cow accepts to be milk only by its owner. Try to model this application under the procedural approach and object-oriented approach. Answer. Here it is a comparison between modeling using procedural and object-oriented techniques. 1. In the procedural world, we would have a function Milk( ): float Milk (struct cow, float amount); To milk a cow (i.e., remove milk from it): struct cow { char name[30]; float currentMilkVolume; const float maxMilkVolume = 5.0; //assume gallons }; struct Cow Bessie = {Bessie, 4.0}; // . . . other code here . . . // now . . . milk the cow fReturned = Milk (Bessie, 1.3); Let us do some analysis of this implementation: The Milk( ) operation is stand-alone, because there is no requirement that a Farmer does the milking. Milk( ) must be told through a parameter what cow to operate on. This is error-prone. Milk( ) must directly access the struct contents, because Milk( ) is, therefore, coupled to the struct. The conclusion is that, in the procedural world, the milk is taken directly from the Cow (i.e., a language data structure is directly manipulated), and there is no concept of a Cow as an intelligent entity. 2. In the object-oriented world, milking a Cow may involve the entities (also called classes) Farmer, and a Cow. The relationship is that a Farmer, say Jones, is responsible for a Cow. Obviously, there are many benefits of the object-oriented model against the procedural one, such as: - if there is a change to the way the cow determines how much milk to yield, then these changes to implementation are hidden behind the public interface. Moreover, if the interface is not disturbed, the Farmer is unaware of any change. Of course, if another farmer has to milk the cow, a possible solution is to provide to that farmer the cows interface, so that he can milk the cow, too. Compared to the procedural world, any potential farmer would have to contain code to do the milking. Instead, in the object-oriented world, the milking code is in the Cow, that is in one place for reuse. Let us now do the design of the object-oriented model. In the real world we say the Farmer milks the cow, so the Farmer owns the result of Milk(amount). Since the farmer is doing the milking, a first attempt is to put the Milk( ) operation in the Farmer class. However, if an application invokes Farmer.Milk( ), this operation cannot milk the cow, because it is a Farmer operation, and the milk is in the cow, not the farmer! This does not make any sense, because Farmer.Milk( ) still has to access a Cow-scope operation. Therefore, we proceed to a different approach, namely to put Milk( ) directly in Cow. Now the Farmer invokes the Cow.Milk( ) operation in order to obtain the milk. All the struct information (the data) is hidden inside Cow. So, in the object-oriented model the Farmer doesnt take milk from the cow. The Farmer asks the Cow to milk itself. That is, the Cow manipulates its own data values. The analysis model for it is: The Milk( ) operation is part of Cow, so in the absence of Cow, there is no Milk( ) operation. The Milk( ) operation does not have to be told what Cow to operate on, so every Farmer is milking his own Cow. The Milk( ) operation is an opaque interface, and hides the implementation of Cow from Farmer. In conclusion, in the object-oriented world, the milk is requested from the Cow, and the Cow determines how much to yieldmaybe none! In order to see that class Cow is the most important one, we wrote the following series of questions/answers. a) Who should know how much milk the Cow has? The cow. b) Who should know how to determine whether the Cow is even milkable at the time of the request? The cow. c) If the Farmer asks for 3 gallons, and the Cow only has 2 gallons to offer, who should determine if 2 gallons, 1 gallon, or 0 gallons, returned? is The cow. d) Whos state might change with the invocation of the Milk( ) operation? The Cows state changes, not the Farmers. The Cow may give up the 2 (i.e. the maximum) gallons she has, and then transition to the unmilkable state until a new store of milk is generated. The Farmer has a bucket of milk that he didnt have before, but his state has not changed. Recommendations: Dont get too distracted by reality. A literal translation of the way the real world works, and the way we talk about it working, are often an impediment to software modeling and implementation. Here it is a possible complete Java code for this problem (this is only to make an image of how this course is about). class Farmer { private String name; private Cow c; { public void setFarmer(String n, String cowName, double initialAmount) this.name = n; c = new Cow(this, cowName, initialAmount); } void milkTheCow(double amount) { c.milk(amount); } void display() { c.displayMilk(); } { Farmer f; String name; double currentMilkVolume; final double maxMilkVolume = 5.0; } class Cow private private private private protected Cow (Farmer f, String name, double initialAmount) { this.f = f; this.name = name; if (initialAmount > maxMilkVolume) System.out.println(name + ": I cannot have so much milk!"); else currentMilkVolume = initialAmount; } public void milk(double amount) { if (amount > maxMilkVolume || currentMilkVolume < amount) System.out.println(name + ": I don't have so much milk!"); else currentMilkVolume -= amount; } public void displayMilk() { System.out.println(name + ": I have now " + currentMilkVolume + " gallons."); } } public class Milking { public static void main(String args[]) { Farmer f1 = new Farmer(); f1.setFarmer("Jones", "Bessie", 4.0); f1.display(); f1.milkTheCow(1.3); // f1.display(); f1.milkTheCow(4.3); f1.display(); f1.milkTheCow(2.2); f1.display(); Cow c2 = new Cow("Cow2", 5.0); Farmer f2 = new Farmer(); f2.setFarmer("Farmer2", "A new Bessie", 4.0); // f2 has a different cow object with the same name f2.display(); f2.milkTheCow(2.2); f2.display(); f2.milkTheCow(0.3); f2.display(); } } Exercise 2. (Genericity versus custom, [Sommerville, 2007], Exercise 1.2, page 18) What are the differences between generic software product development and custom software product development? Answer. The main difference lies in the end user of the software product. Generic Software Product: Product specification owned by product developer The client is not the end user, who may not have a good understanding of what the end user ...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

Lamar - CPSC - 4360
Software Engineering, CPSC-4360-01 and CPSC-5360-01 Tutorial 8. AnswersExercise 1. (10.3, page 231, [Priestley, 2004]) Draw a revised version of Figure 10.12 (page 221 of [Priestley, 2004]) and in slide 35 of Lecture 7 modelling the requirement that
Lamar - CPSC - 4360
Software Engineering, CPSC-4360-01 and CPSC-5360-01 Tutorial 4Exercise 1. (Modified from [Priestley; 2004], ex. 2.5) Suppose that one particular environmental monitoring station contains three sensors, namely a thermometer, a rain gauge, and a humid
Lamar - CPSC - 4360
CPSC4360-01 - Software Engineering Spring Semester, 2008 Project Specifications and InstructionsSubmission date: Tuesday, April 22 and Thursday, April 24, 2008 Submission venue: MA111 Time venue: 12:30-13:45Project Description (Car Renting):This
Lamar - CPSC - 5320
CPSC 4320/CPSC 5320 Advanced Topics in Networks Summer 2007 INSTRUCTOR: DR. LAWRENCE OSBORNE OFFICE: 201 MAES OFFICE HOURS: 2:30 p.m. to 4 :00 p.m. MTWTF, and by appointment. Email: ljosborne@my.lamar.edu TEXTBOOKS: Wireless Sensor Networks: An Infor
Lamar - PEDG - 3320
PEDG 3320 College of Education and Human Development Lamar UniversityDispositions Teacher Education ProgramIt is a very important decision to want to become a teacher. Successful teaching requires a stable personality, one who can be entrusted wi
Lamar - PEDG - 3350
PEDG 3350 Teaching Lesson RubricA Classroom Environment That Promotes Equity, Excellence, and LearningStudent: _ Mentor: _Elements Communicating Clearly and Accurately (3.1s, 3.3s) Directions and Procedures: Oral and/or written directions and pr
Lamar - PEDG - 3350
PEDG 3350 Unit Plan RubricPlanning for Learner-Centered InstructionStudent: _ Instructor: _ Circle performance level. If D, check reason. D C EElements Demonstrating Knowledge of Content and Pedagogy (1.8s-1.10s, 3.10s) Content Knowledge: Displa
Lamar - PEDG - 3351
PEDG 3351 Teaching Lesson RubricA Classroom Environment That Promotes Equity, Excellence, and LearningStudent: _ Mentor: _Elements Communicating Clearly and Accurately (3.1s, 3.3s) Directions and Procedures: Oral and/or written directions and pr
Lamar - PEDG - 3351
PEDG 3351 Evaluation of Field Experience Student: _ Evaluator: _6Excellent observation skills and comprehension were reflected in report. High level of participation in valuable activities was described. Good account of many learning outcomes wa
Lamar - PEDG - 3380
PEDG 3380 Unit Plan RubricPlanning for Learner-Centered InstructionStudent: _ Instructor: _ Circle performance level. If D, check reason. D C EElements Demonstrating Knowledge of Content and Pedagogy (1.8s-1.10s, 3.10s) Content Knowledge: Displa
Lamar - PEDG - 3380
PEDG 3380 Evaluation of Field Experience Student: _ Evaluator: _6Excellent observation skills and comprehension were reflected in report. High level of participation in valuable activities was described. Good account of many learning outcomes wa
Lamar - PEDG - 4340
PEDG 4340 College of Education and Human Development Lamar UniversityDispositions Teacher Education ProgramIt is a very important decision to want to become a teacher. Successful teaching requires a stable personality, one who can be entrusted wi
Lamar - PEDG - 4340
PEDG 4340 Teaching Lesson RubricA Classroom Environment That Promotes Equity, Excellence, and LearningStudent: _ Mentor: _Elements Creating an Environment of Rapport and Respect (2.1s-2.2s, 2.20s-2.21s, 3.2s) Interactions with Students: Classroo
Lamar - PEDG - 4340
PEDG 4340 Evaluation of Field Experience Student: _ Evaluator: _6Excellent observation skills and comprehension were reflected in report. High level of participation in valuable activities was described. Good account of many learning outcomes wa
Lamar - PEDG - 4380
PEDG 4380 College of Education and Human Development Lamar UniversityDispositions Teacher Education ProgramIt is a very important decision to want to become a teacher. Successful teaching requires a stable personality, one who can be entrusted wi
Lamar - PEDG - 4380
PEDG 4380 Evaluation of Field Experience Student: _ Evaluator: _6Excellent observation skills and comprehension were reflected in report. High level of participation in valuable activities was described. Good account of many learning outcomes wa
Lamar - PEDG - 5330
PEDG 5330 Teaching Lesson RubricA Classroom Environment That Promotes Equity, Excellence, and LearningStudent: _ Mentor: _Elements Communicating Clearly and Accurately (3.1s, 3.3s) Directions and Procedures: Oral and/or written directions and pr
Lamar - PEDG - 5345
PEDG 5345 Unit Plan RubricPlanning for Learner-Centered InstructionStudent: _ Instructor: _ Circle performance level. If D, check reason. D C EElements Demonstrating Knowledge of Content and Pedagogy (1.8s-1.10s, 3.10s) Content Knowledge: Displa
Lamar - PEDG - 5345
PEDG 5345 Teaching Lesson Meaning of Competent (C) and Exemplary (E)Elements Communicating Clearly and Accurately Competent (C) Oral and written communication is generally clear and accurate. Occasionally, students must ask for clarification. Intern
Lamar - PEDG - 5345
PEDG 5345 Teaching Lesson RubricA Classroom Environment That Promotes Equity, Excellence, and LearningStudent: _ Mentor: _Elements Communicating Clearly and Accurately (3.1s, 3.3s) Directions and Procedures: Oral and/or written directions and pr
Lamar - PEDG - 5345
PEDGG 5345 Unit Assessment Report RubricEvidence of Student SuccessStudent: _ Instructor: _Elements Pre-Assessment (1.28s-1.29s, 3.15s) Assess Prior Knowledge: Intern made no attempt to determine students' prerequisite knowledge and skills. Asse
Lamar - PEDG - 5350
PEDG 5350 Evaluation of Field Experience Student: _ Evaluator: _6Excellent observation skills and comprehension were reflected in report. High level of participation in valuable activities was described. Good account of many learning outcomes wa
Lamar - PHYS - 4301
SPSC 4301 Human Exploration of the Solar SystemWeek 10The Physics of Space Exploration Launch, Entry and LandingGetting Into OrbitLaunch Windows A launch window is the period during which we can launch directly into a desired orbit from a pa
Lamar - EDLD - 5334
LAMAR UNIVERSITY Beaumont, TEXAS 77710 Syllabus for EDLD 5334 TESTS, MEASUREMENT AND EVALUATION (Three credit hours) FALL, 2003 Instructor: Lamar Office: Email: Lamar Phone: Office Hours: Class Location: Class Time: Classroom Management Policies: Req
Lamar - POLS - 4319
Lamar University Department of Political Science POS 4319: Advanced Research Methods Dr. Thomas E. Sowers, II Office: 201L SBSB Phone: 880-8539 E-mail: SOWERSTE@hal.lamar.edu Office Hours: M-F 11:00-12:00 or by appointment Web Page: http:/hal.lamar.e
Lamar - POLS - 5352
Syllabus - Political Science 5352-01 Fiscal Administration Spring 2006Instructor: Dr. James L. True Time: Tuesday 5:30-8:15 p.m. Room: SBS 204 E-mail: truejl@hal.lamar.edu Office: SBS Room 201G Phone: 880-8813 Office Hours: TWR 2:00-4:00 and by app
Lamar - ELEN - 4304
ABET Syllabus ELEN 4304 Digital Signal Processing Fall Semester 2008ELEN4304DigitalSignalProcessingCatalog Description: Analysis, design, and realization of digital filters, Discrete Fourier Transform algorithms, digital filter design procedures,
Lamar - ELEN - 5346
SACS Syllabus ELEN 5346 Digital Signal Processing Fall Semester 2008ELEN5346DigitalSignalProcessingCatalog Description: Analysis, design, and realization of digital filters, Discrete Fourier Transform algorithms, digital filter design procedures,
Lamar - ENGR - 4301
SPSC 4301 Human Exploration of the Solar SystemHuman Physiology/Psychology and the Space EnvironmentWeeks 5 &amp; 6Intro The human body has developed within the gravity field of Earth and the mind has been conditioned by its effects (William Pogue,
Lamar - ENGR - 4307
COMP 412: Topics in Compiler ConstructionProfessor Keith D. Cooper Department of Computer Science Rice University Houston, Texas, USA This course serves as the introduction to compiler construction for both undergraduates and graduate students. It h
Lamar - ENGR - 4307
The Procedure Abstraction Part I: BasicsCopyright 2003, Keith D. Cooper, Ken Kennedy &amp; Linda Torczon, all rights reserved. Students enrolled in Comp 412 at Rice University have explicit permission to make copies of these materials for their persona
Lamar - ENGR - 4307
CS 406/534 Compiler Construction Scanner Part IIProf. Li Xu Dept. of Computer Science UMass Lowell Fall 2004Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy and Dr. Linda Torczons teaching materials at Rice Univer
Lamar - ENGR - 4307
CS 406/534 Compiler Construction IntroductionProf. Li Xu Dept. of Computer Science UMass Lowell Fall 2004Part of the course lecture notes are based on Prof. Keith Cooper, Prof. Ken Kennedy and Dr. Linda Torczons teaching materials at Rice Universit
Lamar - ENGR - 4360
Software Engineering, CPSC-4360-01, CPSC-536001, Lecture 14 01/18/09CPSC-4360-01, CPSC-5360-01, Lecture 141Review of Last LectureProfessional Ethics, Responsibilities, and Social ImplicationsSara Baase: From A Gift of Fire, Second Editi
Lamar - ENGR - 4360
Software Engineering, CPSC-4360-01, CPSC-536001, Lecture 8 01/18/09CPSC-4360-01, CPSC-5360-01, Lecture 81Review of Last LectureStatechart State-dependent behaviors, events, transitions Initial and final states, guard conditions Actions
Lamar - ENGR - 4360
Software Engineering, CPSC-4360-01, CPSC-536001, Lecture 11 01/18/09CPSC-4360-01, CPSC-5360-01, Lecture 111Review of Last Lecture Implementing a Statechart Review of Java programming concepts Inheritance Polymorphism Type Casting Inte
Lamar - ENGR - 5301
SACS Syllabus ELEN 5301-37: Stochastic Signals and Systems Fall Semester 2008ELEN530137:StochasticSignalsandSystemsCatalog Description: Engineering applications of probability theory, random variables and random processes. Topics include random s
Lamar - SOCI - 4301
Real-Time Systems,COSC-4301-01,Lecture 9Stefan Andrei01/18/09COSC-4301-01, Lecture 91Reminder of the last lecture Counting true instances Incremental verification of the real-time systems specifications01/18/09COSC-4301-01, Lecture
Lamar - SOCI - 4301
Real-Time Systems,COSC-4301-01,Lecture 11Stefan Andrei01/18/09COSC-4301-01, Lecture 111Reminder of the last lectureOptimization of Specifications expressed in path-RTL01/18/09COSC-4301-01, Lecture 112Overview of This Lecture
Lamar - GEOL - 1403
Geology 1403 - General Geology I (a.k.a. Physical Geology) Fall 2007, Lecture, Sect. 4, Tu Th, 11:00 AM - 12:15 PM Dr. Joe Kruger, Geology Room 113C, 880-8233, joseph.kruger@lamar.edu, Office Hours by appointment Text: Earth, An Introduction To Physi
Lamar - GEOL - 1403
Monday night lab class. Remember to meet at Lamar Geology Building Second Floor.Wednesday night class will meet at Westbrook.Chapter 6Weathering and SoilRead Chapter six in textbook Use the notes provided to take notes from the text book.
Lamar - GEOL - 1403
Crustal DeformationChapter 10Structural geologyStructural geologists study _A working knowledge of rock structures is essential to our modern way of lifeDeformationDeformation is a general term that refers toMost crustal deformation
Lamar - GEOL - 1403
Chapter 21Energy and Mineral ResourcesFor classPlease have these slides filled out from the book. For class.Renewable and nonrenewable resourcesRenewable resources Can be replenished over _ Examples include_ _ _Renewable and nonrenew
Lamar - HIST - 3301
Tips for passing my classHere is a list of things that may help you to pass my class. You may not agree with all of these and some may not help you but I suspect that most of these will help at least some folks pass my class. Background A lot of pe
Lamar - HIST - 3302
Links to course-related pagesohttp:/www.nasa.gov/ - NASA's organization, history, current and future missions. Many links to other NASA Web sites.ohttp:/spaceflight.nasa.gov/home/index.html -Info on current and upcoming Shuttle missions and t
Lamar - HIST - 3302
SPSC 3302 Space Transportation SystemsWeek 3 Space Transportation Systems Concepts and Architectures &amp; Spacecraft and Launch Vehicle DesignDeveloping a Space Mission All space missions consist of a combination of physical and functional elements
Lamar - HIST - 3302
Atlas V for Commercial Passenger TransportationJeff A. Patton1 and Joshua B. Hopkins2 Lockheed Martin Space Systems Company, P.O. Box 179, Denver Colorado 80433The Atlas and Centaur Programs have enjoyed a rich history as a trusted vehicle for a l
Lamar - SPSC - 3302
The Voskhod SpacecraftThe Voskhods were adaptations of the single place Vostok spacecraft meant to conduct flights with up to three crew, conduct space walks, and fly manned missions of up to three weeks duration in advance of the U.S. Gemini progr
Lamar - SPSC - 3302
SPSC 3302 Space Transportation SystemsCourse Syllabus Spring 2007Course Description: This course is designed to give an undergraduate student a general overview of the design and operation of space transportation systems. The focus will be on huma
Lamar - SPSC - 4301
SPSC 4301 Exam # 2 Due April 7, 2008Name: _1. Describe the rocket equation (also known as the Tsiolkovskii fromula). (Dont just list the equation describe the terms of the equation and why theyre important).2. During launch, the loss of veloci
Lamar - SPSC - 4301
SPSC 4301 Sample Essay Questions1. Do you think the decision to draw the first astronauts from the ranks of military test pilots was a good one? Why?/Why not? 2. What were some of the factors that led to the decision to launch the Apollo 8 flight t
Lamar - SPSC - 4301
SPSC 4301 Human Exploration of the Solar SystemThe Space Environment Weeks 3 &amp; 4The Space EnvironmentThe Space Environment Radiation Electromagnetic radiation Heats exposed surfaces Can degrade/damage surfaces and electronic components Sol