Vous êtes sur la page 1sur 13

SWEN 4432 Assignment 4 Name Put your answer to each of the questions below immediately after the question.

n. Chapter 14: 1. Object-oriented Design. 1. Explain why adopting an approach to design that is based on loosely coupled objects that hide information about their representation should lead to a design that may be readily modified.

If the design doesnt rely on other parts of a system and nothing else can modify data hidden in the encapsulated section, it can be altered drastically, so long as the inputs and outputs remain consistent with the system.

2. Using an example explain the difference between an object and an object class?

The simplest example Ive seen is that the class is a cookie cutter, and the object is a cookie. A cookie may be chocolate or plain, with chocolate chips or butterscotch or sprinkles, but they can all come from the same cookie cutter. This describes that while their properties are different, they were instantiated from the same class.

3. Using the UML graphical notation for object classes, design the following object classes identifying attributes and operations. Use your own experience to decide on the attributes and operations that should be associated with these objects: i. A telephone

Telep
ii. A printer for a personal computer.

iii. A personal stereo system

Last Dialed: Current Time Prin Current Date Name ID: [L Caller : Strin Spooled Jobs
2

Stereo S

Current Stati Stereo Mode CD Present : CD Track : In CD Player Mo


3

iv. A bank account

Bank A
v. A library catalogue

Account Num Library C Balance : Int Last Deposit Book ID : St Last Withdra Title : String Publication D Description : Check Balanc
4

4. Develop the interface design of the weather station in detail by proposing interface descriptions of the objects shown in figure 14.11? They may be expressed in java, C++ or in the UML
Class WeatherStation { private: int identifier; public: void reportWeather(); void calibrate(); void test(); void startup(); void shutdown(); }

class WeatherData { private: float airTemperatures; float groundTemperatures; float windSpeeds; float windDirections; float pressures; float rainfall; public: void collect(); void summarise(); }

class Groundthermometer {

private: float temperature; public: void test(); void calibrate(); }

class Anemometer { private: float windSpeed; float windDirection; public: void test(); }

class Barometer { private: float pressure; float height; public: void test(); void calibrate(); }

Chapter FD: No Questions

Chapter 22: 2. Verification and validation. 1. Discuss the differences between Verification and validation, and explain why validation is a particularly difficult process.

Verification is the process of determining if the product is being built according to the requirements, and that each part meets its individual requirements laid out by the design document. Validation is a broad process of making sure that the system will meet the customers expectations. Unfortunately, customers are often unsure of exactly what they want and need, so it may be entirely possible to build a system that doesnt do everything the customer expects that it should.

2. Explain why it is not necessary for a program to be completely free of defects before it is delivered to the customers.

Ensuring that a program is completely free of defects is an exceedingly long process that may not even be feasible to perform. Many defects may not be discovered until a specific course of events is taken after the product is in use, despite extensive defect testing.

i. To what extent can testing be used to validate that the program is fit for its purpose?

With a clearly defined set of requirements, a program can be tested to ensure that it complies with every requirement, but some requirements may not be explicitly expressed, and the program will not fit the customers needs.

3. The test plan in Figure 22.4 has been designed for custom systems that have a separate requirements document. Suggest how the test plan structure might be modified for testing shrink wrapped software products.

With general purpose software, the requirements traceability should remain the same, as all functions still need to be individually tested, but also tested in a manner that would group the functions together as they would be used by an average person. The testing schedule would likely be extended significantly, as there are usually a much broader amount of testing that needs to be done with general purpose software. The hardware and software requirements may be the most expensive modification to the test plan, as several hundred configurations of hardware need to be tested, as users of generic software will rarely have the same hardware.

4. Explain why program inspections are an effective technique for discovering defects in a program.

Inspections are effective as they inspect the actual code for errors. Code omissions can be found simply by scanning through the code, and improper use of variables or objects, as well as problems that can cause inefficiencies can be found through program inspections.

i. What kind of errors are unlikely to be covered in program inspections?

The most common type of error that is unlikely to be found by inspections is errors that hide other errors. A simple logic error can look perfectly fine in the code, but that logic error can cause another part of the program to fail, that is written correctly. For example, seeing something like >= when it should be > can cause problems, but in the code it could look correct. 8

5. Suggest why an organization with a competitive, elitist culture would probably find it difficult to introduce program inspections as a V&V technique?

Those who are highly competitive, and believe their code to better than others, often take offense when their code is scrutinized by others, as well as when simple errors are discovered. In my personal dealings with other coders, it is the humble ones who are easier to work with, and will allow others to help fix their code.

6. Using your java, C++ or other programming language skill, derive a checklist of common errors (NOT syntax errors) that could not be detected by a compiler but that could be detected in a program inspection?

Dynamic variables are cleared properly when theyre no longer needed Recursive functions have logic to prevent infinite recursion Iterative loops have logic to prevent infinite loops Variables are not in danger of being too limited with large numbers Logic statements are defined correctly Chapter 23: 3. Software Testing. 1. Explain why testing can only detect the presence of errors, not their absence. Without performing completely exhaustive testing of a program, you will never be completely sure that every possible action will result error free. When you test a program and you find no errors, all you can be sure is that what you did with that specific test had no errors, not that other combinations of what was tested would be error free. 9

2. Compare top down and bottom up integration and testing by discussing their advantages and disadvantages for architectural testing, demonstrating a version of the system to users and for the practical implementation and observation of tests.

Top down testing can be used for architectural testing, to see if a system as a whole is working well, while bottom-up can test the individual components and make sure theyre working properly. Demonstrating a version of a system to users puts top-down at a disadvantage, unless there were major revisions to the software, not much of the system as a whole will have changed, bottom up however will show the specific changes that have been made in the new version of the software. For the practical implementation and observation of tests, bottom up is at a disadvantage, because testing an individual component is not a practical way the program will be used. Top down would be much better suited for that.

10

i.

Explain why most large system integration, in practice, has to use a mixture of top down and bottom up approaches.

Its important to make sure the system as a whole is working, but to test the entire system using only top down approaches would simply take too long to make sure all the functionality is working properly. To be efficient, the bottom up approach may be used to test the individual components to ensure theyre working properly, and may be assumed that theyre working with the rest of the system appropriately.

3. What is regression testing?

Regression testing is rerunning an existing set of tests on a system. With this approach, if any problems are exposed, you need to determine if the problems are from the previous run exposing the new problems, or if they are due to the added increment of functionality.

i. Explain how the use of automated tests and a testing framework such as JUnit simplifies regression testing.

Using automated tests allows the program to be repeatedly tested, and solves the problem of manually repeating these tests that turn regression testing into an expensive and impractical process.

4. Write a scenario that could be used as the basis of deriving the tests for weather station system that was used as an example in chapter 14.

A researcher needs to access current weather information, and must start up the weather station system. Upon starting the system up, 11

he must test the instruments to make sure they are all functioning, and then calibrate them according to recent information gathered by the system. Upon successful calibration, the information may be gathered and then the system can finally be shut down.

5. Explain why interface testing is necessary even when individual components have been extensively validated through component testing and program inspections.

The components may have been tested successfully on their own, but when incorporated into a system they may have adverse reactions with other components that have been introduced into the system.

6. Using the approach discussed here for object testing, design test cases to test the states of a microwave oven whose state model is defined in Figure 8.5.

Current State Waiting Full Power Half Power Set Time Disabled Enabled Operation

Expected Input Full Power Half Power Half Power Timer Full Power Timer Number Open Door Door Closed Door Closed Start Door Open Cancel

Expected Result Go to Full Power Go to Half Power Go to Half Power Go to Set Time Go to Full Power Go to Set Time Go to Set Time Go to Disabled Go to Enabled Go to Enabled Go to Operation Go to Disabled Go to Waiting

7. Give 3 situations where the testing of all independent paths through a program may not detect program errors.

12

If a combination of paths yield data in an alternate path, then without testing paths that rely on others, the test may not find an error.

If one path passes erroneous data to another path, without testing the sub path, the test may not find that error either.

Finally if one path that is not related to, but uses the same data as another path corrupts that shared data, then testing independent paths would not find that error.

13