solutions_to_exercis..

advertisement
Software Engineering: Modern Approaches by Eric Braude
Solutions to Exercises
Chapter 1
1.
Besides those listed in this chapter, what additional expectations do you think software
products may fail to meet?
Solution: Stated requirements don’t meet various user needs, even when the user has not specifically
mentioned them before.
3.
What are the four P’s of software engineering? (Recall them without consulting the book.)
Briefly describe each.
Solution: People, Product, Project, Process
4.
In a paragraph, name at least two of the most important deficiencies you can think of in the
reporting of project progress that contribute to an unsuccessful project outcome.
Solution: If project management is not aware in the first place of issues such as schedule slips and
undue test failures, corrective action cannot be taken.
5.
Explain in your own words why people are invariably the most important resource on a
project.
Solution: A project can have the right features, tools, resources, etc., but if the people aren’t (1)
skilled and (2) motivated, they will not be able utilize these resources effectively. Conversely, if highly
skilled and motivated people are on a project, they can intelligently compensate for many
shortcomings and issues.
6.
each.
For the stakeholder groups listed in the text, give an example of a project motivation for
Solution: Business: low cost; Project management: meet schedule; Development team: technical
innovation; Customer: meet requirements; End user: ease of use
7.
You are developing a second-generation custom order entry application for a particular
customer. Explain and give examples of at least two types of problems that can arise if the customer
is not involved in defining the new application, and their first use of the application is after it is
completed.
Solution: There are many. a. A user interface may be developed that is different than the firstgeneration interface, and the customer does not want to retrain its users.
8.
Why does the use of standards make it easier to generate useful, reliable documents? Why
isn’t their use a guarantee that high-quality documents will be produced?
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: Documentation standards help to ensure that all the necessary parts of a document are
present. However, they don’t ensure by themselves the quality of the content of the document.
Chapter 2
1.
In addition to the reasons stated in this chapter, name at least two other advantages to
producing quality software
Solution: a. It is easier to enhance with new features. b. Quality work results in higher employee
morale. (Think about the converse: when managers transmit a don’t-care attitude, employees tend
to follow suit.)
3.
(a) Describe in your own words the difference between verification and validation.
(b) What are the advantages and disadvantages of specifying a V&V plan before a plan for
conducting your specific project?
Solution to (b) An advantage of specifying a V&V plan before a project plan is that quality procedures
can be specified across the organization, thereby promoting uniformity in the organization's
products. This saves time by avoiding the continual re-creation of the procedures that are to be
followed from project to project. A disadvantage includes the fact that we cannot provide all of the
details of the V&V plan until the plan for the project has been settled. For example, we cannot specify
the V&V schedule until the project schedule has been specified in the project plan.
4.
(a) What are metrics?
Solution: Metrics are numerical measures for software development. Examples of metrics are the
amount of work done (measured in lines of code); the time taken to do the work and the defect rate
(defects per 1000 lines of code).
(b) Name a reason why you understand metrics to be important.
Solution: Metrics are important because they bring discipline to the software development process,
turning it from a mere activity into true engineering. The informed application of software metrics for
measurement and forecasting can result in an improved process and a better product.)
5.
(b) For each of the following objectives, state a metric you would use to help in achieving the
objective, state whether it is a product or process metric, and explain how it would be applied.
i. avoid project schedule delays
ii. measure continuous quality improvement from one project to the next
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
iii. identify software parts that are exhibiting quality problems
iv. establish a baseline for improving schedule accuracy
Solutions:
i. Metric: Actual vs. planned schedule progress; Project metric since the schedule within a project is
being measured; Project is monitored weekly to determine if schedule is meeting the plan.
ii. Metric: Defects/KLOC; This is partly a product metric since we are measuring the health of the
emerging product; number of defects discovered after software enters QA phase is used as a baseline
for quality. It is also a project metric when used to compare with defect rates on similar projects since
it indicates the health of the project compared with norms. Subsequent projects also collect this
metric and compare against baseline to measure improvement.
iii. Metric: Number of defects per software component; Project metric in showing the relative quality
of work in various parts; also product metric in measuring the quality of software components. We
refactor those exhibiting highest defect levels.
iv. Metric: Number of days schedule deviation vs. plan; Product metric; Collect metric for a project
and use as a baseline to measure against on subsequent projects.)
Chapter 3
1. During which process phase(s) would each of the following activities occur?
a. Creating a project schedule
b. Determining the need for a bar code reader
c. Requesting the addition of a file back-up capability
d. Performing a feasibility analysis
e. Documenting the software interface to an SQL database
f. Acceptance of the software application by the customer
Solutions:
a. Planning
b. Requirements analysis
c. Requirements analysis or Maintenance (if it’s an enhancement request)
d. Inception or planning
e. Software design
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
f. Testing
2.
Give an example of a software project that would benefit much more from using the
waterfall process more than from using most of the alternative processes. Explain your reasoning.
Solution: Adding a feature to a word processing application to import documents from a competing
word processing application. In this case the requirements are simple and can be fully specified up
front with a small probability of changing later in the project.
3. Describe the difference between iterative and incremental development. Describe the ways in
which they are related.
Solution: Iterative means that the waterfall process phases are executed in multiple and successive
cycles. Incremental means that at the end of each iteration, working software is produced. Both have
iterations, in which some implementation is carried out.
4. Give an example of a software project that would benefit from using an iterative and incremental
process more than from using most of the alternative processes. Explain your reasoning.
Solution: A new inventory control application for a customer who is not sure of all the features he
needs. An iterative and incremental process allows working software to be given to the customer
early in the development cycle that implements a subset of requirements. This allows the customer to
use the application and determine the additional features they desire.
5. (a) In your own words, explain how the Spiral model utilizes risk analysis and risk mitigation.
(b) Explain why the outer spiral of the Spiral model utilizes the Waterfall process, and how the Spiral
model mitigates the inherent disadvantages of the Waterfall process.
Solutions:
a. At the beginning of each of the early spirals, risk analysis is performed and the highest risks
identified. The highest risks are dealt with by either building prototypes, performing feasibility studies
or running simulations.
b. Once all major risks have been addressed, each outer spiral is executed using a waterfall-like
process. By performing risk analysis and mitigation in the earlier spirals, the probability of
requirements changing is minimized.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
8. Describe the pros and cons of each value listed in the Agile Manifesto.
Solutions:
Individuals and interactions over processes and tools – Pros: capable people can figure out how to
accomplish tasks without need of process. Cons: without process, productivity gains cannot easily be
repeated on future projects.
Working software over comprehensive documentation – Pros: without the need to document
extensively, can develop software more quickly. Cons: harder for people who did not originally
develop the software to maintain it.
Customer collaboration over contract negotiation – Pros: Can adapt more easily to changing
requirements. Cons: customer representative my not have adequate knowledge of what is needed by
their organization.
Responding to change over following a plan – Pros: adaptability leads to producing what the
customer really wants. Cons: customer may keep changing requirements, leading to longer delivery
time.)
Chapter 4
1. The Agile Manifesto favors working software over extensive documentation. Under what
circumstances can this cause problems if taken to an extreme?
Solution:
Adequate documentation is important for people who maintain software, so they can understand
how the software is designed and implemented. There is no assurance that such documentation is
created.
3. Name three benefits of the XP practice of testing software from “day one,” always having working
software available.
Solution:
(1) There is always something to demonstrate to customers.
(2) Developed software is tested repeatedly throughout development.
(3) Working software is a motivation for developers who do not care for the process of creating
documentation.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
4. During the daily 15-minute Scrum meeting, the leader is only allowed to ask the same three
questions. What two additional questions might you want to ask? For each, explain its benefit
toward achieving the goals of the meeting.
A Solution:
(1) Do you understand what’s expected of you during this sprint? Benefit: a more focused
version of the regular scrum questions; helps the engineer to focus.
(2) Will you be able to complete your planned tasks during this sprint? Benefit: a more
focused version of the regular scrum questions; helps the engineer to focus.
(3) Are you up-to-date on the documentation level that we agreed on? Benefit: document-asyou-go is much more efficient than document-later.
Chapter 5
2. The number people attending an inspection can have a direct impact on the effectiveness of the
review. List the disadvantages of having either too few or too many people attend an inspection.
Solutions:
Too few: not enough people to cover the material, meaning that defects can go undetected. Also,
insufficient expertise regarding specialized parts.
Too many: there may be too many different opinions as to what is a defect, leading to confusion. Too
many attendees can lead to more comments than are needed, causing the inspection to take longer
than scheduled.
3. Give two advantages and two disadvantages to using standards for documentation of the various
software phases.
Solutions:
An advantage of using standards for documentation is that they save us the time of having to devise
headings. They tend to remind us of important issues we may not have thought about. The use of
standards for documentation provides uniformity across projects.
A disadvantage of standards includes the fact that users of standards sometimes feel obligated to
provide material for every heading, even when the heading is not relevant or useful for the job at
hand. This can lead to cynicism, and contempt for "boilerplate" and "paperwork". The use of
standards can also blind us to the inclusion of additional sections that we need to address because of
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
the unique characteristics of our job. For example, the IEEE standards do not address certain issues
that are peculiar to Web development.
4. Why is it generally a good idea to have a cross-functional group be part of an inspection team?
What type of review (that is, during what development phase) might it not be a good idea?
Solutions:
Cross-functional groups represent the different project stakeholders, each providing a different
perspective of the artifact under inspection. This is particularly useful for inspections of requirements.
Code reviews are usually best done with developers only since other groups are not familiar with the
details of the implementation and therefore not able to provide meaningful feedback.
6. Give an example of a defect that might be classified with a high severity but a low priority. Be
specific with your answer.
A Solution: A word processing application crashes when importing a document that is saved in a
format used by another application, but the requirement to support that other application is listed as
“non-essential” in the requirements specification.
Chapter 6
1. In your own words, define the term configuration item and describe its purpose.
Solution: A configuration item is any artifact that may be produced in the course of a software
project, that may need to be modified or retrieved after its creation, and whose versions need to be
tracked.
2. Why is it necessary for compilers to be identified as configuration items? Describe a scenario that
illustrates when this is necessary.
Solution: Suppose version 1.0 of a software application is shipped to a customer, and was built using
version 1.0 of a compiler. In the meantime the project team is developing a new software release 2.0,
and has moved onto a newer version 2.0 of the compiler. If a problem is reported by the customer
running version 1.0, which was built using compiler version 1.0, maintenance engineers must be able
to recover and use the older compiler version to recreate problems and fix defects.
4. If you are developing a software application using an incremental process, at what points would
you minimally create baselines?
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: At the end of those iterations at the conclusion of which a working version of software is
produced.
5. Explain the difference between change control and version control.
Solution: Change control is related to the processes required to manage configuration items, such as
their identification, evaluation of changes, and verification of correctness. Version control is related
to the tools and management of configuration items, such as the creation of a repository, the
mechanism for checking files into and out of the repository, and the ability to branch and merge files
in the repository.
6. Agile processes promote continuous integration, which results in branching and merging at very
frequent intervals (as often as every few hours). Describe one advantage and disadvantage of
branching and merging so frequently. Describe one advantage and disadvantage of branching and
merging less frequently.
Solutions:
Frequent interval: Advantage – easier because less of a chance of having conflicts when merging,
Disadvantage: higher overhead due to more frequent merging.
Infrequent interval: Advantage: less time performing branching and merging. Disadvantage: merges
can be harder since more code may conflict.
Chapter 7
1. (b) Name two long-term disadvantages of a project-based organization.
Solution: Individuals find it more difficult to keep up with their field since they do not spend enough
working time with others in it. Some are more motivated when working with others in the same filed.
2. (b) Name two long-term disadvantages of a function-based organization.
Solution: Employees tend to lose track of the context of their work. This organization can sometimes
promote an us-vs.-them atmosphere between departments.
3. (b) Name two long-term disadvantages of a matrix organization.
Solution: Employees have, in effect, more than one supervisor. The organization becomes complex.
4. Write a paragraph explaining why adding people to a project does not necessarily improve its
schedule – and may worsen it.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: Increasing the number of people increases project overhead, especially the amount of
communication required. Consider also the time and effort involved in bringing a new team member
to a point where he contributes usefully.
6. Consider a software project under development, with half of the engineers in one time zone, and
the other half in another times zone twelve hours away. How would you recommend the project
team be organized? Describe two challenges that need to be overcome due the time-zone
difference.
Solution: The project should be split so that each team is responsible for their own part of the project,
with well defined and stable interfaces. The number of interfaces should be kept to a minimum.
7. (b) Suppose you are managing a project that has the following goals:
- Cost: 100K
- Schedule: 12 months
- Quality: 12 defects/Kloc
- Functionality: 90% requirements implemented
Draw a bulls-eye diagram that shows only one of these goals being met or exceeded.
Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
8. Why plan for risk identification and retirement when developing a project plan? In a paragraph or
two, answer this in your own words.
Solution: A risk is something that can negatively impact the project cost, capability, quality or
schedule. There are two types of risk. One type can be avoided or worked around ("retired"), while
the other type cannot be avoided. Trying hard to identify them at the very beginning provides the
maximum amount of time to retire them by avoidance or conquest. This minimizes the damage that
such risks can inflict.
9. Describe a kind of project under which risk identification and retirement would probably not pay
off. Explain.
Solution: Risk identification and retirement would probably not pay off when only a few risks are
identified and the circumstances for their retirement would have been encountered early on anyway.
In such cases, one would have wasted the time spent on this activity, and the only tangible result
would be peace of mind. The time wasted on this activity is hard to foresee without taking the time
to imagine what risks could arise.
Chapter 8
1. Describe in at least one paragraph at least two consequences of failing to develop a written
project plan.
Solution: A written project plan is an agreement between the participants about what to do and
when to do it. The written project plan can be used as a reference to hold people accountable for
project cost, capability, quality and delivery date. Time and effort will be wasted without a written
plan. A plan that is not written exists only in the minds of several engineers. There is no assurance
that each has the same image. These have to be conveyed by word of mouth. This approach may
result in an inferior product. In passing information by word of mouth, it is more difficult to hold
people accountable on larger projects. In addition, issues become distorted on all projects. Some of
the issues that become distorted include the following: what is the development process, who does
what and when, and what risks loom in the future? Without a risk identification and retirement plan,
the development effort is at the mercy of unknown future obstacles.
3. Cost estimation is important, but can you cite a circumstance under which it is probably not
worthwhile performing at all? Explain your answer.
Solution: One is tempted to answer this question by saying that for very small projects cost
estimation is not worthwhile because the both the project and its costs are small. One could argue
that the time taken to make the estimate for a small project would cut too much into the time taken
to perform the job. However, even this argument does not justify skipping cost estimation. You can
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
think of cost estimation as a required step in the project management process that absorbs a
necessary fraction of the time taken to execute the job. Nevertheless, if the practitioner is completely
unpractised and unschooled in the art of estimation, then it may indeed be unjustified to do cost
estimation on a small project. The estimate would have no value. Alternatively, it cannot be a good
thing for engineers to learn about estimation for a number of weeks, then apply what they have
learned, when the job is a 2-person-month effort in the first place. For large jobs, on the other hand,
such time spent learning about cost estimation is much less of a problem.
4. Give one major advantage and one major disadvantage to the use of function points in estimation.
Solution:
One major advantage to the use of function points is the ability to make estimates about the number
of lines of code at a very early stage of the project before any design work has been performed.
Another is the standard form of function points.
A major disadvantage of function points is the potentially wide variation in function point
calculations that may be generated by inexperienced practitioners and/or in response to unique
programming applications.
5. List a part of the SPMP that your student team is probably unable to supply at this stage of
project. This refers to a part you will have to return to after more work has been performed on the
project.
Solution: At this stage, Section 5 of the SPMP would be sketchy. The schedule in Section 5.2.2 can
only be provided in outline without many details. This is because details require us to know how the
job breaks down, and we do not know this yet, because we have not done any architectural design
work. Since the application's architecture has not yet been determined then in Section 5.2.3, work
packages that describes the work to be apportioned and delivered, would be sketchy.
6. Explain why project planning is considered one of the phases in the software life cycle, and also
an umbrella activity that stretches across several phases.
Solution: One reason is as follows. The early part of a project requires a project planning phase in
which initial estimates are made for resources, risks and scheduling. As a project progresses through
the rest of the phases and more information is learned, these estimates are continually revisited and
refined.
Chapter 9
1. In your own words, define “project metrics” and explain how they are used in managing a project.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: Project metrics are objective measurements of the state of a project. They allow project
managers to assess the quality, schedule and progress of a project, and to take action accordingly.
2. The defect plan in Figure 9.3 shows the number of open defects falling behind plan starting in
week 1. Assuming that you are the project manager, at what point would you start taking corrective
action? Would it be after the first week, or would you wait a number of weeks to see if the situation
improves? Are there any other metrics you might collect to help decide? Write a paragraph to
explain your answer.
Solution: First week raises a red flag, but would wait until more data is available as there should be
enough time to take corrective action if necessary. After second week, would still not take action as
number of submitted defects has diminished from previous week. Would take action by the end of
the third week, continuing until the defect resolution rate has decreased below plan.
3. Describe in your own words how a project manager could utilize a project dashboard in managing
a project.
Solution: Project dashboard provides an easy-to-read summary of project status. Project manager
can focus only on areas that are not meeting expectations, and investigate metrics in those areas
more closely to ascertain reasons for being behind plan.
4. What metrics related to software testing might you include in a weekly project metrics report to
provide insight into the status of the testing process? Explain your choices.
Solution: Test case execution rate, test case success rate, types of failed tests, software subsystems
failing tests, defect rate, defect resolution rate, time per defect resolved, # testing resources, # bug
fixing resources. These provide a broad view of the health of the project and its progress towards
defect resolution. One or two alone usually fails to give the big picture.
Chapter 10
1. Explain why a defective requirement could be 100 times more expensive to fix after software is
deployed versus being fixed during requirements analysis?
Solution: Fixing a defective requirement during requirements analysis involves only the stakeholders
that are responsible for generating the requirements, and an update to the requirement itself. If the
problem isn’t detected and fixed until the software is deployed, many more people and artifacts are
involved. The requirement needs to be changed, the design and implementation based on the
requirement may need modification and the software would need to be retested.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
2. Give an example of a software application in which the customer is the same as the end-user.
Give an example in which they are different. In each case, identify the customer and end-user.
Solution: i. A student purchases a word processor for her laptop. The student is both the customer
(since she purchases the software), and the end-user (since she uses the software). ii. The Federal
Aviation Agency has a contract with a vendor to supply an air traffic control system. The customer is
the FAA since they are buying the system. The end-users are the air traffic controllers since they use
the system.
3. In your own words, explain the difference between high-level and detailed requirements. Give an
example of a high-level and detailed requirement for a typical word processing application.
Solution: High level: “Shall allow users to create, edit and print documents.” Detailed: “When the
search button is pressed, a screen appears allowing the user to enter a string of up to 50 characters.
The application searches the document for the first occurrence of the string and highlights the found
text in purple (RGB value = …).”
4. In your own words, describe the difference between functional and non-functional requirements.
Solution: Functional requirements describe the functionality an application is intended to provide, as
specifically related to the relevant business domain (e.g. order-entry, word processing, social
networking). Non-functional requirements describe qualities of an application (e.g. performance,
reliability, etc.) that are not necessarily related to the business domain. They qualify functional
requirements.
5. Explain why the following requirement is not sufficient. How would you amend it?
“ The order entry system shall not crash more than 5 times per year. The system shall recover from
each crash as quickly as possible to avoid down time.”
Solution: The first part of the requirement is sufficient because it states a specific number of times the
system can crash. The second sentence needs modification because it is not quantifiable. A better
way of stating the second sentence is: “The system shall recover from each crash in 1 minute or less”.
6. Brackett makes the point that the more constrained an application, the less reliance we have on
people as the source of requirements. (Refer to his graph in Error! Reference source not found.3
comparing "approximate percent of requirements gathered from people" with "type of application".)
Can you think of any applications that do not fall on the graph's diagonal?
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: Find an application that is relatively unconstrained, but whose requirements are to be
gathered mostly from sources other than people. Suppose that we are building a simulation of cat
behavior in houses. This is an unconstrained problem, but we could gather the requirements by
observing cat behavior directly, without the aid of human intermediaries.
7. Agile requirements gathering calls for a customer representative to work continually with the
development team generating requirements. Describe a scenario where this type of arrangement
may produce poor requirements.
Solution: If the customer representative is not knowledgeable enough about the target market for
the application, the requirements generated may be inadequate.
8. What are three major advantages and disadvantages of describing detailed requirements with
unit tests?
Solution: Advantages: If requirements changes, a unit test is more likely to keep in sync with the
implementation than a documented requirement. A unit test tends to be unambiguous. The customer
may understand the purpose of a unit test more easily than a formal statement. Disadvantage: It is
easier to read and understand a written requirement than a unit test. Written requirements are more
complete. Unit tests accumulate into a significant quantity that is hard to absorb.
Chapter 11
1. Describe in your own words the difference between customer wants and customer needs.
Provide an example that illustrates the difference.
Solution: Customer wants are those things that customers desire, but are not necessarily required.
Customer needs are those things that are required to meet a specific business objective. For example,
a customer may want a word processor with the ability import files from other word processing
programs using different file formats, but what they really need is a program that allows them to
create and edit documents.
4. What is a use case? Is the following a use case? Why or why not?
"The system shall provide advice for the beginning Windows user on how to execute Windows
operations."
Solution: This is not a use case since there is no sequence of actions on the user’s or the application’s
part.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
6. Why is it important to show customers preliminary sketches of GUIs as early in the development
cycle as possible? Give what you consider to be one or two of the most important reasons.
Solution: GUI appearance and usability are very subjective, and the process of finalizing a GUI is very
interactive. If you give customers early access to the GUI, you have more time to react to their
desires.
7. Your customer needs to specify user interfaces. Discuss two or three of each of the pros and cons
of the following means for doing this in the context of the application (large or small) and the nature
of the GUI (complex or simple).
a. Sketching using hand drawings - your own or drawn by a graphic artist
b. Sketching using graphics tools, such as Paint or PowerPoint
c. Using the GUI-building features of the target language of the application
Solution: For small or simple applications, sketching the GUI by hand or with a graphics tool may
suffice. However for large applications, using the GUI-building features can provide a more realistic
example of the GUI and be ultimately used in the software implementation, saving development
time.
9. Consider an application that manages patients in a doctor’s office. Patients call for an
appointment and their information is entered into the application. Patients can call to reschedule or
cancel appointments. After a patient is seen by a doctor, they may be referred to another doctor for
treatment if necessary. Draw a state-transition diagram to express the high-level requirements for
this application.
A Solution:
Chapter 12
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
1. To what audience are detailed requirements primarily targeted?
Solution: developers
2. Name five ways of organizing detailed requirements.
Solution: Feature, class, state, GUI, use case.
3. What is wrong with the following detailed requirements? Explain how you would fix them.
a. HomeBudget shall display a convenient interface for entering personal data.
b. SatControl shall compute the predicted time it takes to circle the Earth on the current orbit,
and the actual time taken to circle the Earth on the previous orbit
c. InvestKing shall determine the best investment strategy.
Solution:
HomeBudget: not precise; not testable. Show the actual interface.
SatControl combines two requirements: separate them.
InvestKing: not testable. Better: InvestKing shall determine the best investment strategy
according to the International Investment guide, section 14.3.8.
4. What are three advantages and three disadvantages of organizing detailed requirements by class
rather than by feature.
Solution: Organizing by class is advantageous in an object oriented system. The classes defined in the
requirements can be used in the design. It is easier to trace requirements to code. Arranging
requirements by feature is simple. The disadvantage is it may be hard to locate individual
requirements in the requirements document.
5. Suppose that you are defining the requirements for an application that simulates the movement
of customers in a bank. List five classes that can be used to organize the requirements.
Solution: Customer, Bank, Teller, BankWindow, Line.
7. When identifying domain classes (as in Error! Reference source not found.), why is it useful to
denote the relationship between them (i.e. inheritance, aggregation)?
Solution: Relationships imply collaboration between classes, which help further define requirements.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
9. For each detailed requirement listed in Exercise 3, assign a priority (e.g. essential, desirable,
optional) and explain why you chose them.
Solution: This solution leaves the requirements statements in their un-repaired state.
a. HomeBudget shall display a convenient interface for entering personal data. (In its repaired
form) this is essential – otherwise the product would be hard to sell.
b. SatControl shall compute the predicted time it takes to circle the Earth on the current orbit,
and the actual time taken to circle the Earth on the previous orbit (In its repaired form) this
is essential or desirable, depending on the context of the application.
c. InvestKing shall determine the best investment strategy. (In its repaired form) this is
essential or desirable, depending on the context of the application. Advice may or may not
be in the business plan for this product.
Chapter 13
1. [This is intended to be a closed book exercise] List the qualities that requirements should possess
(one example: precise). In your own words, describe the meaning of each.
Solution: Accessible, comprehensive, consistent, prioritized, secure, self-complete, testable, traceable,
understandable, unambiguous.
2. Explain why the following requirement for a book sales site is ambiguous. Modify the
requirement to make it unambiguous.
“Orders that include special edition books and overnight delivery or exceed $100 must be processed
over the phone.”
Solution: The use of “and” and “or” is ambiguous. One corrected version is “Orders that exceed $100
or that include both special edition books as well as overnight delivery must be processed over the
phone.”
3. Provide an example of three requirements for an order entry system that are inconsistent. How
would you modify them to make them consistent?
Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
a. Customers shall purchase an item by going to the “order screen” and specifying the item name,
quantity and preferred vendor. b. The “preferred vendor” field in the “order screen” can only be
modified by administrators. c. Customers shall not be allowed administrator status
Chapter 14 – Online Chapter
2. Give (a) Z-specifications and (b) pre- and postcondition forms for the maximum of an integer
array t, and the index of that maximum element.
Solution:
1. In your own words, explain some key advantages and disadvantages of B-specifications.
Solution: Advantages: precision; potential for harnessing mathematics; potential for automated code
generation. Disadvantages: requires significant mathematical sophistication; transformations
potential rather than real.
Chapter 15
4. Can a design be cohesive and exhibit a high degree of coupling? Explain your answer and provide
and example.
Solution: Yes. Just because software parts each contain extensive related information doesn’t mean
they can’t depend on each other a great deal. An automobile engine is an example. The
components, such as the engine block, are cohesive but there is high interdependence among it and
the other components.
5. How might coupling and reusability be related? How might cohesion and reusability be related?
Explain your answer and provide one example for each.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: The less a module depends on others (low coupling), and the more is contains related
information (high cohesion), the easier it is to extract it for reuse.
6. In your own words, explain what is meant by robustness. Below is code for a method divide().
Make the method more robust in at least two ways.
public double divide( Double aNumerator, Double aDenominator )
{
return aNumerator.doubleValue() / aDenominator.doubleValue();
}
Solution: One alternative is to change the type of aDenominator to an instance of a class which does
not allow a zero value (e.g., with a name such as NonZero). Another alternative is to throw an
exception, forcing callers to deal with the problem of division by zero. A third is for the method to
check for a zero denominator.
8. Provide a modularization for an application that advises clients on stock picks, and enables them
to transfer funds among various stocks and savings accounts. Explain your solution. Hint: One
reasonable solution employs four packages.
Solution: One can use the packages stocks, userInterfaces, savingsAccounts, and control. This is the
model/view/controller architecture, especially if stocks and savingsAccounts are colleceted as subpackages of an investments package. Otherwise, one could include user interface classes with the
model classes and use two overall packages: control and investments. Some designers prefer to call
out storage facilities in a separate database package but this author prefers to include database
access in respective domain packages.
Chapter 16
1. Name three major relationships that could exist between classes A and B. Describe them in your
own words. Express each in UML and in a typical Java implementation.
Solution: inheritance, aggregation, composition, and reference. Strictly speaking, inheritance and
aggregation are themselves types of object references. Association is often included, which is a
generalization of object reference.
3. Which of the following classes inherit from which? Explain your reasoning.
Worm, Ellipse, Animal, 2DFigure, Circle
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution:
Worm inherits from Animal
Ellipse inherits from 2DFigure
Circle inherits from 2DFigure
5. A library has a collection of items (books and magazines) available to loan patrons. For each item
in the collection, the system maintains data about its title, author, and unique id. In addition, the
copyright year is maintained for books, and the edition number is maintained for magazines. Draw a
UML class diagram representing the library items. Be sure to include the required attributes. Hint:
Use inheritance in your model.
Solution:
7. Suppose that your car has a built-in application that displays the status of the engine parts at all
times. Draw a UML state diagram for the Starter class that describes the automobile’s starter only.
Explain your reasoning.
Note that the starter is sometimes connected to, and sometimes disengaged from, the car’s motor.
The starter reacts to actions involving the car key. The key can be in one of three positions: vertical,
90o and 180o.
Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
8. Consider an application used at a doctor’s office. The application schedules patient appointments
and maintains patient medical histories. Suppose the application design contains an Appointment
class to track appointments, and a MedicalHistory class for each patient. How would you draw the
UML class relationship between these two classes?
Solution: The relationship is not inheritance or aggregation but the classes do have a relationship
(when Appointments are created we would want to associate them with the patient’s medical
history), so they would be drawn with an association or object reference.
9. Consider the following use case for a web e-commerce application:
Use Case Name: “Select Item”
Actor: Shopper
Precondition: Actor has requested product list
Scenario:
1. Application displays product list
2. User selects item on product list
3. User clicks “add item to shopping cart” button
4. System acknowledges item placed in shopping cart
Draw a UML sequence diagram for this use case. Explain your reasoning.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Chapter 17
1. Which of the following are applications of design patterns? Explain your conclusions.
(a) An object-orientated design
(b) The ability to vary the order in which a print() method is applied to the elements of a Vector
(c) Varying the order in which a method is applied to the elements of a collection of objects by
introducing a class whose methods include a method like goToNextElement()
(d) Capturing the mutual behavior of a pair of objects of two classes
(e) Capturing the mutual behavior of a pair of objects of two classes by introducing a third class
aggregating the two classes.
Solution: (c) and (e). Options (b) and (d) are purposes or goals, but are not actual patterns
for fulfilling the purpose. Option (a) is a paradigm or way of organizing designs in general.
Design patterns are usually object-oriented but not every object-oriented design relates to a
pattern.
2 Characterize the following design purpose as creational, structural or behavioral. Explain your
conclusion clearly.
We must build an application with 15 different screens involving various combinations of 6 user
interface controls (e.g., list boxes) arranged in a simple grid. Performing a mouse action or text
entry on a control (e.g., a button) in a screen affects other controls on the same screen. In all other
respects the screens are not related and are not similar in appearance. The composition of these
screens is very unlikely to change.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: We need to capture the mutual behavior of the controls in multiple screens. We want to do
this in a way that does not cause the controls to depend on each other. So it’s a behavioral purpose.
Mediator makes it possible to capture mutual behavior. We could make each page the mediator
object for the controls that it contains.
3. Characterize the following design purpose as creational, structural or behavioral. Explain your
conclusion clearly.
We must build a human resources application dealing with the management structure at a large
company. We need to represent the organization chart within the application.
Solution: We have to represent the organizational chart, so there is a structural purpose here. To do
this we can use the Composite design pattern.
4. Characterize the following design purpose as creational, structural or behavioral. Explain your
conclusion clearly.
We must build an application that allows a user to build and change his stock portfolio with a various
kinds of mutual fund picks from specified sub-categories. The mutual fund categories are
technology, old industries, utilities, real estate, and mining. The application allows users to pick
categories: It then makes portfolio recommendations depending on the user’s choice. For example,
the user can ask for a low-risk portfolio of utilities and mining stocks, and the application describes
its recommendations within these constraints.
The portfolio recommendation is a client of the design pattern application, and should deal only with
the classes Technology, OldIndustries, etc. We will need to build a complex portfolio object for each
client. Each Portfolio object is the same in overall structure: The user picks funds from subcategories
of Technology etc. but the client software should be designed so that it does not have to know about
subcategories. Our purpose here is creational because we need to create complex (portfolio) at
runtime.
Solution: To create new Technology investments, we could have the client code clone the prototype
created when the user specifies the fund, and we could use the Prototype pattern. Alternatively, if
the overall risk were selected, we would use Abstract Factory. The notion of “style” mentioned in the
notes is risk in this case.
6. The following figure shows the Observer design pattern class model. Group the classes to show
abstract and concrete levels. Group the classes to show the three roles described in this chapter.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: The abstract and concrete levels are shown in the following figure.
The roles of Client, Setup and Design Pattern Application are shown in the following figure.
7. (a) What two design pattern forms are mentioned in this chapter?
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
(b) Which of the two forms is more likely to use virtual functions? Explain your answer and give
an example.
(c) Which of the two forms is a linked list of objects likely to be? Explain your answer.
(d) Which of the two forms is the Observer pattern in Exercise 6?
Solution:
(a) Delegation and Recursion
(b) The Delegation form is very likely to use virtual functions. The Recursive form may do so as
well when it is employed for functional reasons. Error! Reference source not found. uses the
virtual function property in the sense that the version of doIt() executed at runtime depends on
the class to which the DoerBase object doerObject belongs.
(c) Recursion. A linked list of objects can be represented with a class model like Error! Reference
source not found. in which each element in the list is a RecursiveClass object which points to
another RecursiveBase object. The last object in the linked list is a NonrecursiveClass object.
(d) The Delegation form because calls to notify() are delegated to the update() method of the
Observer subclass.
Chapter 18
2. Suppose that you are designing a batch simulation of customers in a bank. Being a batch
simulation, the characteristics of the simulation are first set, then the simulation is executed without
intervention. How could you describe this as a data flow application? Use a simple skeleton
consisting of four parts to the diagram. (Identify your four parts, and then look at how you could
describe this application as a state-transition diagram.) Which perspective offers more value in
describing the architecture?
Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
The simulation as a whole does not appear to have interesting or valuable states. One can think of a
customer as being in various states, as in the figure. This is of value if the simulation accounts for
interactions among customers.
3. When designing a client-server architecture, there are generally two alternatives: thin and thick
clients. A thin client implies that client functionality is kept to a minimum; most of the processing
being performed via the server. A thick client implies that much of the functionality is contained in
the client; the functionality on the server is kept to a minimum. Discuss the one or two major
advantages and disadvantages to each of these approaches.
Solution: Advantage of thin clients is they are simpler to implement, which is important since there
are many more copies of client software than server software. Disadvantage is they result in more
complex servers in which performance can be an issue. Advantage of thick clients is they result in
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
simpler server software, which can make them more efficient. Disadvantage is the client can be more
difficult to upgrade regularly.
4. Operating systems are frequently designed using a layered architecture. Research the Linux
operating system on the Internet, and explain how it utilizes a layered architecture. What are the
benefits of such an architecture?
Solution: An explanation of the parts of a figure like the following.
(Source: http://www.ibm.com/developerworks/linux/library/l-linux-kernel/)
7. Some design patterns are particularly relevant at the architectural level. Name two of these and
explain their relevance.
Solution: Façade and State
8. Which software architecture is the best candidate for each of the following applications?
a. An application for reordering auto parts from hundreds of stores
b. A real-time application that shows the health of an automobile
c. An application that provides advice to stock customers. It uses a multi-platform design
consisting of several websites. One website continually collects and stores prices and other
information about stocks; a second site continually collects stock advice from analysts; a
third recommends portfolio suggestions to users.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
d. A scientific instrument company builds equipment for analyzing molecular structures.
The application you are to design analyzes the structure of DNA molecules, which are very
large.
Solution: a. client/server; b. event system using state pattern; c. independent components; d.
layered
Chapter 19
1. Explain the following
(a) The purpose of detailed design (list three benefits)
(b) How it differs from software architecture
(c) Why it is generally a questionable idea to go directly from architecture to
implementation.
Solution: (a) The purpose of detailed design is to define design components such as classes and
methods in sufficient detail that they can be implemented. (b) Software architecture defines higher
level design elements and how they relate to each other. (c) It is not a good idea going directly to
implementation from architecture since, for example, algorithms may not be thought through in
enough detail before coding, making them susceptible to error.
2. Your company produces software that controls a robot arm for manufacturing. Name four
classes that would be appropriate members of your company’s software framework. Explain your
reasoning.
Solution: We look for classes that would apply to many of a company’s applications. Examples are
Arm, Control, Position, and Sensor. If there is a possibility that the company designs products other
than robots, there might be a framework sub-package including RobotArm, RobotControl,
RobotPosition, and RobotSensor.)
3. Estimate the number of lines of Java code for the following set of methods. The methods are
ordered from smallest to largest. Assume that there is nothing unusual about the job except as
indicated in the information below.
Method 1 -- I/O; Method 2 – Text; Method 3 – Calculation ; Method 4 – Logic;
Method 5 – Data; Method 6 – Calculation; Method 7 – Text; Method 8 – Data;
Method 9 -- Set-up; Method 10—Calculation; Method 11 – Text; Method 12 -- Data
Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
We use Error! Reference source not found. to obtain the required estimates. As mentioned
elsewhere, LoC estimates for Java and C++ are similar. We need to decide whether the methods are
“very small”, “small” etc. Our only basis for this is their ranking. Without knowing specifics of the
job, it is safest to assume that the distribution of methods is normal, so that we can use Error!
Reference source not found. that indicates the percentage of “very small”, “small” methods.
We have 12 methods, so that each method is 1/12, or about 8% of the total. Thus, we can consider:
Method 1: “VS” (about 8% of the total)
Methods 2,3, and 4 “S” (about 24% of the total)
Methods 5,6,7 and 8 “M” (about 32% of the total)
Methods 9,10, and 11 “L” (about 24% of the total)
Methods 12 “VL” (about 8% of the total)
Method number
1
2
3
4
5
6
7
8
9
10
11
12
Description
I/O, VS
Text, S
Calculation, S
Logic, S
Data, M
Calculation, M
Text, M
Data, M
Set-up, L
Calculation, L
Text, L
Data, VL
TOTAL:
Number of lines
9.01
8.00
5.13
10.98
8.84
11.25
17.07
8.84
8.53
24.66
36.41
30.09
------178.81
4. Complete the following, explaining under what circumstances you would use the following in
detailed design.
a. Use activity diagrams when the logic _____________.
b. Use pseudocode for a method when _______________.
Solution:
(a) Use activity diagrams when the logic consists of multiple branching.
(b) Use pseudocode when an algorithm needs to be described in detail and these details should not
be left up to the programmer.
5. Define appropriate interfaces that the following class exhibits (or “implements” in Java terms).
Assume that additional methods will be required as the application grows. Explain your reasoning.
Hint: The interfaces indicate what kind of transaction this is.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
There is a good answer with three interfaces.
class BankTransaction ….
{
void debitAccount( int anAmount ) { … }
String getCustomerBalance()( … )
int computeDebitAmount() ( … )
void void setTransactionTime(){ … }
void setLocation( Loction aLocation ){ … }
Customer getCustomer(){ … }
Account getAccount(){ … }
void setCoordinator( Person aPerson ) { … }
. . .
}
Solution:
This transaction involves generic transaction methods, as well as an account and a customer.
Collecting methods under these headings, we get the following
interface Transaction
{
. . .
void setTransactionTime();
void setLocation( Location aLocation );
void setCoordinator( Person aPerson );
. . .
}
interface AccountTransaction
{
void debitAccount( int anAmount );
Account getAccount();
int computeDebitAmount();
. . .
}
interface CustomerTransaction
{
. . .
Customer getCustomer();
String getCustomerBalance();
. . .
}
class BankTransaction implements Transaction, AccountTransaction,
CustomerTransaction
{
. . .
}
7. Perform a design (both architectural and detailed) for a check-balancing application with the
following requirements. Fix defects in the requirements if you find them. You can play the role of
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
customer if and when the customer's input is required. Report the time you spent on significant
activities to the nearest five minutes.
1. The system shall display the current balance in the system window.
2. The system permits the user to record deposits of up to $10,000.
3. The system permits the user to withdraw any amount from the current balance. An error
message "This withdrawal amount exceeds your balance" is displayed when the user
attempts to withdraw an amount exceeding the balance.
Solution beginnings:
The requirements need to be made much more specific before we can proceed with a design. We can
do this in the OO style, first identifying domain classes: CheckCustomer, CheckAccount,
CheckAccTransaction, and CheckTransDisplay....
Chapter 20
2. Consider an application that helps manage a fabric store. Assume that the stores sell
fabrics and associated items such as buttons and ribbons. Give three to four robustness
issues specific to this application. Explain your choices.
Solution:
For all of the following, ensure that each cannot readily be performed by accident or by
making entries that are close to legitimate but not actually legitimate.
a. Ensure that new stocks legitimately entered into the application remain there until
legitimately removed, with the ability to reconstruct these transactions.
b. Ensure that items legitimately sold are removed from the application’s inventory records,
with the ability to reconstruct these transactions.
c. Ensure that the user can’t “remove” items that are not in the inventory.
d. Ensure that prices are accurate despite potentially complex and error-prone user actions.
3. Below is code for a method divide(). Make the method more robust in at least two ways.
public double divide( Double aNumerator, Double aDenominator )
{
return aNumerator.doubleValue() / aDenominator.doubleValue();
}
One Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
/** ===============================================================
* More robust divide(). Protects against two types of anomalies.
*/
class Divide
{
/** *********************************** class DivisionByZeroException
*
*/
public static class DivisionByZeroException extends Exception{
public DivisionByZeroException(){
super( "Division by zero attempted." );
}
}
private static DivisionByZeroException divisionException =
new DivisionByZeroException();
/** *********************************** class OverflowException
*/
public static class OverflowException extends Exception{
public OverflowException(){
super( "Division attempted that would result in too large a result." );
}
}
private static OverflowException overflowException = new OverflowException();
/** *********************************** Divide()
*/
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
public Divide(){
super();
}
/** *********************************** divide()
*
*
Returns: aNumerator / aDenominator if 'aDenominator' is non zero
and if the quotient <= Double.MAX_VALUE
*
* Throws: Exceptions if either of these is violated
*
* Known issues: Unspecified behavior if the quotient is too small for
*
the accuracy of 'double'.
*/
public static double divide( Double aNumerator, Double aDenominator )
throws DivisionByZeroException, OverflowException{
if( aDenominator.doubleValue() == 0.0 )
throw( Divide.divisionException );
else // nonzero denominator
if(
( aDenominator.doubleValue() <= 1.0 ) && // would enlarge the numerator ..
// and quotient would be too large (note that following left side within limits):
( aDenominator.doubleValue()*Double.MAX_VALUE < aNumerator.doubleValue() )
)
throw( Divide.overflowException );
else
return aNumerator.doubleValue() / aDenominator.doubleValue();
}
4. Consider a design for a video store application.
(a) Suppose that we use just one class VideoStore, which allows the entry and removal of a video
name assigned to a customer – stored via a telephone number as key. What exactly is inflexible
about this design?
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: This design is a single block of methods. If we want to expand the application to deal with
stocking new videos or dealing with customer accounts, for example, the existing structure would be
of little value. It would have to be broken apart.
(b) Give an alternative UML class model that would accommodate the inclusion of additional
operations.
A solution: The solution in the Figure separates out a Video class. It also separates out the various
operations that can be performed. We may also want to add a Customer class.
(c) Which of the classes you introduced are likely to be reusable in other applications?
Solution:
Definitely: Video
Possibly: Add, CheckIn, CheckOut.
(d) How can you make more reusable the classes that reference Video?
Solution: The design in part (b) has Operation aggregating Video, which restricts its use to videos. To
extend the applicability of Operation, we could have it aggregating a more abstract class such as
TemporaryUseItem. The resulting design could be used for library management, for example.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
(e) Which classes are unlikely to be reusable in other applications in any case?
Solution: VideoStore is tied to this application only.
Chapter 22
2. Suppose that you are about to code a method. What are the major sources describing for you
what this method is to do?
Solution: Either a detailed requirement in the SRS, or specified by the design.
3. Provide an example of a domain class, a design class, and an implementation classes that might
be used in the implementation of a bank ATM application. Explain why you chose each class.
Solution:
domain: BankCustomer, design: CustomerTransaction implementation: Session
4. Specify the intent, preconditions and postconditions of a function that computes the square root
of an input parameter x.
Solution:
Intent: Compute the square root
Precondition: x >= 0.
Postcondition: The square root of x is returned for legal input parameter. If the input parameter is
illegal, -1 is returned
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
5. Explain why the use of global variables works against the principle of information hiding. Give an
example of when this can lead to program errors.
Solution: Information hiding means that data are inaccessible to other parts of a program that don’t
need to know them. Global variables violate this rule because they are accessible to the entire
program. This can be a problem because any part of the application – and their programmers – can
modify a global variable, and others that use it may not know it was changed.
6. The following function returns the correct value, but violates one of the implementation
practices described in this chapter. Which implementation practice is violated and how might it lead
to a problem in the future? How would you fix the problem?
// compute amount of interest and return
float computeInterest (float balance, float interestRate)
{
// compute interest earned
balance = balance * interestRate;
return balance;
}
Solution: The input parameter balance is used as a working variable. If additional functionality is
later added to this function, balance will not contain the correct value. Instead, a local variable that
stores the calculated interest should be used.
7. Describe two to four advantages and one or two disadvantages of enforcing coding
standards.
Solution:
Pros: (a) The resulting code is easier to understand because readers can more readily appreciate the
context of its parts. (b) Standards oblige programmers to be more deliberate about what they are
doing. (c) Standards save time in that they enable programmers to create names without having to
take the time to develop their own conventions. (d) Standards enable each programmer to be selfconsistent.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Cons: (a) Some developers feel that standards restrict their creativity. (b) Standards can result in a
lack of flexibility. For example, a standard might lead to unanticipated problems. Since the standard
has been written down, mandated, and already applied to several applications, it could discourage
changes for the better.)
9. What does the following function compute? How would you modify the function using
comments and more descriptive variable names to make it easier to understand its purpose?
int compute (int a )
{
int result = 1, num = 1;
while (num <= a) {
result *= 1;
num++;
}
return result;
}
// Intent: Compute factorial
// Precondition: 0 <= factorialNumber
// Postcondition: Return factorialNumber!
int computeFactorial (int factorialNumber )
{
int current = 1; factorial = 1;
while (current <= factorialNumber) {
factorial *= current; // include current integer in product
current++;
}
return factorial;
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
}
10. Describe how the principle of “Enforce Intentions” leads to improved code quality. Provide at
least three examples to support your answer.
Solution: It helps a great deal in preventing programmers from exceeding the bounds of intention for
methods and variable and identifies errors made in specifying those bounds. This reduces the
number of errors.
Examples: (i) Making methods and variables as private as possible; (ii) Making them as local as
possible (iii) Introducing classes to constrain the extent of parameters (e.g.,
computeInsurancePremium(Age) rather than computeInsurancePremium(int).
Chapter 23
1. List the qualities that implementations should possess. In your own words, describe the meaning
of each quality.
Solution: Sufficiency, robustness, flexibility, reusability, efficiency, reliability, scalability and security.
3. Describe six factors that increase the flexibility of an implementation, and provide an example of
how each contributes to increased flexibility?
Solution: Documentation, named constants, information hiding, collect common code, avoid global
variables, code at general level, understandable variable and function names.)
4. The code inspection checklist in Section Error! Reference source not found. is not an exhaustive
list. Specify three additional items you think would be useful to add to the checklist, and explain why
you have added each.
Solution:
a. Are function parameters used as working variables?
b. For each loop, do all statements inside the loop need to be there? Can any be placed outside the
loop?
c. Is dynamically allocated memory properly de-allocated?
6. Chapter 22 contains a code listing for a part of the Encounter video game. Where feasible, apply
the informal and formal metrics mentioned in this chapter to measure its robustness. Explain
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
whether the use of a relevant robustness metric is not feasible in this case and describe the
reliability of the metrics’ use in this case.
Solution: Apply the same process as the robustness measure for RobustRectangle in Section 23.1.2.
For example, assess each method in the EncounterCharacter class on a scale of 0 to 1 as follows.
EncounterCharacter (): Robustness = 1/2
Although this method (constructor) takes no parameters, its arithmetic computation involves
values obtained elsewhere, as well as division. We can use the convention of assessing at
1/2 the robustness of a method with no obvious problems but which does raise questions.
EncounterCharacter (String nameP, String imageFileP): Robustness = 1/8
There are no checks for the legitimacy of the parameters or remedies if they make no sense.
Instead of making robustness zero, we can acknowledge a small amount present by using
1/8.
EncounterCharacter (String nameP): Robustness = 1/8
There are no checks for the legitimacy of the parameter.
adjustQuality (String nameP, float qualityValueP): Robustness = 1/8
There are no checks for the legitimacy of the parameters
setQualityTypes (): Robustness = 1/2
(same argument as before; values are changed by this method)
getQualityTypes (): Robustness = 1
(no value changed)
getTolerance (): Robustness = 1
indexOf (String qualityP): Robustness = 7/8
(does return a default)
maxNumCharsInAName (): Robustness = 1
setQuality (String quality, float valueP): Robustness = 1/8
showCharacter (Component comp, Graphics drawP, Point posP,
int heightPixP, boolean faceLeftP): Robustness = 1/8
(many parameters; few checks)
sumOfQualities(): Robustness = 1
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Applying the averaging process, we obtain
(1/2+1/8+1/8+1/8+1/2+1+1+7/8+1+1/8+1/8+1)/12
= 6.5/12 = 54%
Chapter 24
1.
One refactoring is to “separate domain from presentation.” Explain what this means, and apply
it to a calendar application.
Solution: Domain for calendar includes appointment information (e.g., as a database); Presentation
includes a GUI displaying the calendar.
2.
Write a single that computes the roots of a quadratic equation. Apply “extract method” to it.
Solution: select the portion for √(b2-4ac), for example, to be computed by a separate method.
4. Apply “Extract Class” to the following.
class Rental{
String customer;
String dvd;
int customerLicense;
Sring director;
Date date;
…
}
Solution: Extract Customer with customer and customerLicense.
6. Give an example where the addition of a method to a calendar application would cause the
software engineer to apply Pull Up Method.
Solution: There will probably be classes Month, Week, and Day. If one finds a method
occurring in all of them, one would pull it up. An example is getHoursBilled().
7. Explain where Introduce Façade was used in the Encounter video game case study.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: A façade class was used for each package as the only access point. For example, the
class EncounterCast is the façade to the encounterCharacters package. These façade objects
were actually built into the design from the beginning rather than introduced later.
8. Section Error! Reference source not found. cited two stages at which refactoring is used in
agile projects. Give examples of each in the evolution of a calendar application.
Solution: Imagine beginning the project with a single Calendar class. The first reason for
refactoring, shown in Figure 24.25, is to pave the way for new features. An example here could
be to show images of a calendar day. This leads naturally to the need to Extract Class Day from
the class Calendar. The developer then implements the new requirements. The second reason
for refactoring is to “clean up.” For example, in the effort to concentrate on fulfilling additional
requirements, the programmer may ignore for the present practices such as making fields
private. The refactoring in this case is to apply Self Encapsulate Field.
Chapter 25
1. Why not wait for many parts to be built, and then test them together? This seems to kill
several birds with one stone.
Solution: Because when a test fails it will be much more difficult to establish its source and much
more expensive to repair the fault and alter parts that depend on the faulty aspect, now
replaced.
2. Suppose that you have a developing application, tested so far, to which you add code. Why
not, as the next step, test the combined result?
Solution: Because you need first to ensure that your additions and changes did not compromise
the existing functionality.
3. Explain (a) why white box testing, by itself, is not enough and (b) why black box testing, by
itself, is not enough.
Solution:
(a) Because you must test for the required functionality (black box)
(b) Because common causes of failure are associated with the manner in which the application
was constructed.
4. Why is unit testing most commonly performed by software engineers who program and
post-unit testing by QA personnel?
Solution: Because unit testing requires intimate knowledge of the smallest testable units of code
and QA people can seldom be required to know them well enough to test them. On the other
hand, QA people are more skilled in testing and so should be the ones to test where possible.
5. Why should test planning be specifically identified as an activity rather than being pursued
informally when the time comes?
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution: Because the various activities involved in testing, from identifying the types to be
carried out to documenting the results, are complex and important in themselves.
Chapter 26
1. In your own words, describe the difference between white box and black box testing. Why is
each important and necessary?
Solution:
Black box: testing that treats the object under test as a “black box”, that is without using any
knowledge of the internal design and construction. Black box is needed to test against requirements
(e.g. may be implemented correctly, but the wrong thing is implemented.) Black box testing ensures
the right thing is implemented.
White box: test a module based on the knowledge of its design and code. Tests designed to exercise
algorithms, ensure all code executed, all branches executed for true and false; typically performed
during unit testing. White box is needed to ensure all code functions correctly (e.g. error conditions,
no extraneous code). If you don’t check internals it may not be obvious that errors are there.)
2. Why do you think unit testing is usually conducted by the developer who implemented the unit?
Solution: Developers have the most knowledge of the internals of a program. Unit testing is
sometimes thought as part of implementation, implying that coding and unit testing are done
together, making it more efficient for the developer to do both.
3. (a) What is equivalence partitioning? Why is it important to partition the test space into
equivalence classes? Please use your own words in responding.
(b) For the following function, describe five different test cases and for each describe the type of
test case it represents. The application is based on Myers’ triangle problem [5]:
// x, y and z are the lengths of the sides of a triangle. This function classifies the
// triangle and returns either “scalene” (all sides unequal), “isosceles” (two sides
// equal) or “equilateral” (all sides equal). If x, y and z don’t form a triangle
// (i.e. either (a) x, y or z is <= zero, or (b) (x+y) < z) the null string is returned
// Assumption: x, y and z are in ascending order (i.e. x <= y <= z) so you do not need
// to test for this
char * triangle (int x, int y, int z)
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
{
...
}
Solutions:
(a) There are too many combinations of input data to test a program exhaustively. Equivalence
partitioning divides input data into classes of equivalent values, with values in each class expected to
produce the same test result. Thus, one test case is run per equivalence class and the total number of
test cases is reduced to a manageable number.
(b)
Test case 1: x, y and z all less than 0 – illegal side lengths
Test case 2: x+y < z – illegal triangle
Test case 3: x = y = z = 10 – equilateral triangle
Test case 4: x = 3, y = 4, z = 5 – scalene triangle
Test case 5: x = 4, y = 4, z = 5 – isosceles triangle, equal sides < third side
Test case 6: x = 4, y = 5, z = 5 – isosceles triangle, equal sides > third side)
5. Why is path coverage a stronger form of testing than statement coverage? Give an example of a
defect that would be detected by path coverage but not by statement coverage.
Solution: Suppose that the program contains the following statements.
if( condition1 )
do1A();
else
do1B();
if( condition2 )
do2A();
else
do2B();
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
A test for which condition1 and condition2 are both true, together with one for which they are both
false would cover every statement. But path coverage requires, in addition, a test for which
condition1 is true and condition2 false.
7. Write the code for a class Account with attribute balance, accessor methods, and method add().
Assume that Account has states Sound, Empty and Arrears, and that these are implemented using
the State design pattern. Write a complete set of unit tests for Account, including state-oriented
tests.
Solution:
In Account, the code for add() is accountState().add().
In Arrears, the code for add() adds to the balance and replaces accountState by a Sound object is the
balance is now non-negative. Keep in mind that the parameter is add() can be negative.
In Sound, the code for add() adds to the balance and replaces accountState if applicable.
State-oriented tests would transition among the states. An example is add 10, subtract 12, add 1,
add 1, add 3.
9. You intend to implement a Rectangle class using test-first development. Suppose the class is
defined during design with the following characteristics:



Constructor with parameters length and width
Methods getLength() and getWidth() to retrieve length and width
Method to calculate area of rectangle
Write a unit test class to test the as yet unwritten class Rectangle. Next, write the code to implement
the class.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Solution:
public class TestRectangle
{
public static void main( String[] args )
{
// Regular rectangle
Rectangle r = new Rectangle( 2.0, 3.0 ); // length, width
System.out.println( "Compare 2.0<-->" + r.getLength() );
System.out.println( "Compare 3.0<-->" + r.getWidth() );
System.out.println( "Compare 6.0<-->" + r.getArea() );
}
}
public class Rectangle
{
double length = 0.0, width = 0.0;
public Rectangle( double aLength, double aWidth )
{
length = aLength;
width = aWidth;
}
public double getLength()
{
return length;
}
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
public double getWidth()
{
return width;
}
public double getArea()
{
return length * width;
}
}
Chapter 27
1. In your own words, describe incremental integration. Name and explain two benefits of
incremental integration.
Solution: Incremental integration is when small parts of a system are tested together, and other
parts are incrementally added. One benefit is that it is easier to isolate problems when only a small
amount of code is added to an already functioning part.
2. In your own words, explain how a project schedule is affected by the method of integration used
on the project.
Solution: Bottom-up: low level software is scheduled first, followed by software moving up the levels
of program control. Top-down: software at the highest levels of control are scheduled first.
2A. Consider the Health Monitoring application described in Figure 27.11. Describe with examples
how you would integrate it bottom-up and how you would test the integration process.
Solution: Test Mobile Phone Module separately as well as the other modules making up the Health
Data Transmission Module. We then work upwards to another module such as Emergency
Notification from Ambulance and the other modules on which Emergency Notification depends.
When the others (Diabetic Analysis, Cardiac Analysis etc.) are complete, we are ready to integrate
and test Health Monitoring.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
3. In your own words, describe how bottom-up integration works. List and explain two advantages
and disadvantages of bottom-up integration.
3A. The case study in Section Error! Reference source not found. does not describe a continuous
integration process. But suppose that the document did prescribe one instead. What would that
document say?
Solution: What process each engineer follows each day – like Section Error! Reference source not
found.; what the general order of integration will be, class by class. A simple version describes the
process for a single engineer. A more challenging version describes it for two or three. There is no
assumption that the classes are completed at a specified time. Instead, the process is tied to use
cases or user stories as in agile methods.
5. Consider a point-of-sale system that is under development. Assume that the hardware platform
and device drivers that control it are brand new. The rest of the software is being ported from an
existing system. What appropriate method of integration might you recommend be used, and why?
Solution: Since the hardware and drivers are new, they may present a high risk. A bottom-up
approach may be warranted so they are tested first.
6. In your own words, explain how daily builds facilitate the isolation of defects in a build.
Solution: If a problem is found while testing a daily build, the source files that were modified can be
code reviewed to more easily isolate the problem.
Chapter 28
Answer the following exercises in your own words.
1. Why are black box tests (rather than white box tests) used in system testing?
Solution: System tests verify that software meets its requirements and behaves as expected. This is
accomplished by providing inputs and observing outputs, which is the purpose of black box tests.
White box tests are concerned with internal behavior.
2. What is the purpose of acceptance testing and why is it necessary? Give an example of an
application and a defect that could go undetected in system testing yet be caught by acceptance
testing.
Solution: Acceptance tests are executed after system testing is completed, and ensure that the
system meets the customer’s needs.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
3. A company is developing an application, and thinks it has discovered a novel way to speed up its
testing cycle. It decides to dispense with system testing, and instead deliver the application to
customers just after integration testing is completed. The company will therefore rely on its
customers to discover problems in the application. What are the advantages and disadvantages of
this approach? Be specific and explain your answer.
Solution:
Advantages
Disadvantages
1. If simple application and unit test and
integration testing done thoroughly, (may)
reduce overall time
1. May be quicker to customer, but more
defects will be found by customer than if system
testing performed. The result is total testing
time will be longer.
2. Into customer hands quicker, for real
world testing and their feedback
2. More difficult to isolate and fix defects
3. May need to give customers something
early for business reasons (e.g. confidence in
company, schedule)
3. Customer will have a lower opinion of
software since they’ll see defects that should
have been caught by vendor.
4. Customers aren’t professional testers
4. What is the purpose of soak testing? Give an example of a defect this type of testing is likely to
uncover.
Solution: Tests software over an extended period of time (e.g. 2 weeks) to uncover defects that take
time to manifest. Examples are slow memory leaks and timing related problems.
5. Load and stress testing is often conducted on individual units during unit and integration testing.
In this testing, units are subjected to high levels of stress to ensure that they do not exhibit any
problems. Why is it necessary to conduct system-level stress tests even if all of the unit stress tests
are successful?
Solution: Execution times and storage patterns are very difficult to predict based on that of
constituent units. For example, a method may execute in a tolerable amount of time and may use a
tolerable amount of storage; but at runtime, it may be called so frequently that the application’s
behaviour is intolerable.
7. For each of the black-box tester qualities listed in Section Error! Reference source not found.,
give an example of how that quality could be counterproductive if taken to an extreme.
Solution:
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Willingness to learn the goals of the application: This is overwhelmingly a positive attribute.
However, it is possible to impose one’s own interpretation of a goal where none is indented.
Willingness to put one’s self in user shoes: Again, an overwhelmingly a positive attribute.
However, it is possible to impose one’s own interpretation how a user feels and behaves where it
is not the case.
Determination, doggedness, and fearlessness can be overdone to the point of becoming
stubbornness.
Imaginative and “outside the box” thinking can be overdone to the point of imagining
capabilities that the application is not intended to possess.
Curiosity can be overdone so as to waste time on irrelevancies.
Meticulousness can be overdone so as to waste time on irrelevant details.
Chapter 29
1. Define the term "software maintenance" in one sentence.
Solution: Software maintenance refers to those activities performed on the application which begin
after the product has been delivered.
2. Describe in your own words four types of software maintenance. Is there an example of a
maintenance request that might overlaps two of the categories?
Solution: Example: a customer uses a software application with a new operating system version, and
experiences a problem. The source of the problem is a change in the new operating system version.
The solution can either be classified as corrective, since the problem is a defect, given an environment
that could have been anticipated, or as adaptive, since the cause of the problem is a result of a
change in the operating system.
3. Give examples of corrective, adaptive, perfective and preventative changes for the Encounter
case study.
Solution: For the Encounter video game
Corrective : In the current implementation, the image of the player’s main character sometimes
appears briefly in duplicate on the monitor.
Adaptive : With the increasing prevalence of computers with small screens, a version of Encounter is
required which is less memory-intensive.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Perfective : The thumbnail figure currently shows the entire maze, and is a single hard-coded image.
As the maze grows, however, the thumbnail should show only the areas adjacent to the current area.
The design needs to be changed to accommodate this probable future requirement.
Preventative : A large number of defects have been reported in the GameCharacter class. The class
will be refactored in the next release of the software.
4. Suppose that a proposal is made to change the length of an array in an application to
accommodate requirements that were not previously satisfied. What activity is required before
actual changes in the code can be made?
Solution: Impact Analysis, an activity that identifies those artifacts that will be impacted by the
proposed change.
5. Describe a practical scenario in which the rather lengthy maintenance flow illustrated in Error!
Reference source not found. might need to be circumvented?
Solution: If a critical problem is reported by a customer, an emergency patch may have to be
developed and inserted as quickly as possible.
6. A proposal has been made to implement the following requirement for the Encounter case study,
which was initially designated optional.
PlayerCharacter Requirement [desirable] ("Player character image") The player shall have
the option to choose the image representing her main character from at least 4 GIF files
a. What type of Maintenance Request (MR) is this?
b. Provide an impact analysis for this MR.
Solution:
a. This maintenance request (MR) is an enhancement, since the application currently does not
allow choosing from one of several images, and since the original SRS did not commit us to
implementing this requirement.
7. Which of the following would require reengineering. Explain.
a. Convert a simulation of the operations of a bank into an automated bank security system.
b. Add to a simulation of the operations of a bank so that it handles the movements of security
personnel.
c. Modify an online tutoring system so that it can to provide multiple-choice quizzes at any
time to permit students to assess their understanding of what they are currently reading.
Solution:
a. This would require re-engineering because the purposes of these two applications are different.
Parts can be used for both applications, but the architectures would be different.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
b. Provided that the existing application has been well designed, this change may not require reengineering because it can probably be accommodated by adding functionality to the simulation. The
basic purpose of the application is unchanged.
c. This modification adds separate functionality to the application, and does not change its basic
operations. The existing architecture need not be changed, and so re-engineering is probably not
required.
Software Engineering: Modern Approaches by Eric Braude ©2011 John Wiley and Sons
Download