1 / 19

Case Study part 1: from UML to Java IM103 week 11 Part 1 p506

Case Study part 1: from UML to Java IM103 week 11 Part 1 p506. Learning objectives By the end of this lecture you should be able to:. specify system requirements by developing a use case model ; annotate a composition association on a UML diagram;

mark-silva
Download Presentation

Case Study part 1: from UML to Java IM103 week 11 Part 1 p506

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Case Study part 1: from UML to JavaIM103 week 11 Part 1 p506 Learning objectives By the end of this lecture you should be able to: • specify system requirements by developing a use case model; • annotate a composition association on a UML diagram; • develop test cases from behaviour specifications found in the use case model.

  2. System overview The application that we will develop will keep track of planes using a particular airport. So as not to over complicate things, we will make a few assumptions • there will only be four runways at the airport; • there will be no concept of gates for arrival and departure, passengers will be met at a runway on arrival and sent to a runway on departure; • planes entering airport airspace and requesting to land are either given permission to land on a free runway, or are told to join a queue of circling planes until a runway becomes available; • no planes are housed at the airport; planes boarding and subsequently requesting take-off must therefore have previously landed at the airport; • once a plane departs from the airport it is removed from the system; • the detail of arrival and departure times will not be addressed.

  3. Requirements analysis and specification A common way to document requirements in UML is to develop a use case model. A use case model consists of use case diagrams and behaviour specifications. A use case diagram is a simple way of recording the roles of different users within a system and the services that they require the system to deliver. Once a list of use cases has been identified, behaviour specifications are used to record their required functionality

  4. Register flight with airport Record flight’s request to land arrival Record flight landing Air traffic controller Allow passengers to board Record flight take off List arrivals Airport Information Officer List departures use case diagram for the airport application

  5. Plane flightNumber cityOfOrigin status upgradeStatus() Runway number allocated book() vacate() isAllocated() 0..1 0..1  permitted to land on Initial analysis of the airport application.

  6. Plane flightNumber: String cityOfOrigin: String status: int theRunway:Runway upgradeStatus() Runway number: int allocated: boolean book() vacate() isAllocated(): boolean 0..1 0..1  permitted to land on Initial design of the Plane and Runway classes.

  7. PlaneList -planes: Hashtable -circlingQ: Vector +PlaneList() +register (String, String) +circle (String) +descend(String, Runway) +land(String, int) +boarding(String, String) +leave (String) +listArrivals(): PlaneEnumeration +listDepartures(): PlaneEnumeration +isInList(String):boolean +getPlane(String): Plane +getRunwayNumber() -nextToLand():Plane Airport -list: PlaneList -runway: Runway[] +RUNWAY_TOTAL:int = 4 +Airport() +registerFlight(String, String) +arriveAtAirport(String): int +landAtAirport(String) +readyForBoarding(String, String) +takeOff(String): Plane +getArrivals():PlaneEnumeration +getDepartures:PlaneEnumeration -nextFreeRunway(): Runway nextFreeRunWay() : Runway 1 1  updates * 4 Plane -flightNumber: String -cityOfOrigin: String -status: int -theRunway: Runway +Plane(String, String) +getFlightNumber():String +getCity():String +getStatus():int +getRunway():Runway +getRunwayNumber(): int +isAllocatedARunway():boolean +allocateRunway(Runway) +vacateRunway() +upgradeStatus() +changeCity(String) Runway -number: int -allocated: boolean +Runway(int) +getNumber():int +isAllocated():boolean +book() +vacate() 0..1 0..1  permitted to land on Detailed design for the airport application

  8. Airport 4 Runway Composition in UML When an object from one class contains a fixed number of objects from another class, this special kind of association is called a composition The UML notation for composition is the same as that for aggregation, except that the diamond is filled rather than hollow

  9. Implementation It makes sense to bundle these classes together into a single package (airportSys). This means that all our classes will begin with the following package statement: package airportSys; It is a good idea to hide implementation level exceptions so define a general AirportException class. Outline of this and all other classes can be found in Charatan and Kans Chapter 20 section 20.5.

  10. Testing the airport application A useful technique to devise test cases during integration testing is to review the behaviour specifications of use cases, derived during requirements analysis. Often, there are several routes through a single use case. Different routes through a single use case are known as different scenarios. During integration you should take the place of the user and make sure that you test each scenario for each use case - this is often known as scenario testing

  11. "Record flight’s request to land" use case: “An air traffic controller records an incoming flight entering airport airspace, and requesting to land at the airport, by submitting its flight number. As long as the plane has previously registered with the airport, the air traffic controller is given an unoccupied runway number on which the plane will have permission to land. If all runways are occupied however, this permission is denied and the air traffic controller is informed to instruct the plane to circle the airport. If the plane has not previously registered with the airport an error is signalled.”

  12. Identifying scenarios Scenario 1 An air traffic controller records an incoming entering airport airspace, and requesting to land at the airport, by submitting its flight number, and is given an unoccupied runway number on which the plane will have permission to land. Scenario 2 An air traffic controller records an incoming entering airport airspace, and requesting to land at the airport, by submitting its flight number. The air traffic controller is informed to instruct the plane to circle the airport as all runways are occupied. Scenario 3 An air traffic controller records an incoming entering airport airspace, and requesting to land at the airport, by submitting its flight number. An error is signalled as the plane has not previously registered with the airport

  13. Current state of system DEPARTURES FLIGHT TO RUNWAY BA123 London 1 TK999 Tokyo 2 ARRIVALS FLIGHT FROM STATUS RUNWAY LF016 Moscow Landed 3 SP001 Madrid Not yet arrived US642 Florida Not yet arrived

  14. Testing Scenario 1 The first scenario should be the simple case of an arriving plane being told to land on a particular runway. So far, runways 1, 2 and 3 are occupied but runway 4 is unoccupied. If either flight SP001 or US642 arrives at the airport now, it should be told to land at the airport. Enter flight number: SP001 Land on runway 4 As expected this plane is asked to come in and land on runway 4.

  15. Testing Scenario 2 All runways are now occupied so we are in a position to test the second scenario of the "Record flight’s request to land" use case. In this scenario, the arriving flight should be told to circle the airport. Enter flight number: US642 No runway available, circle the airport The registered flight US642 arrives at the airport and is correctly told to circle the airport.

  16. Testing Scenario 3 In this scenario, a flight arrives at the airport without first registering; this should raise an error. Enter flight number: CK001 AirportException: this flight has not yet registered at PlaneList.getPlane(Compiled Code) at PlaneList.circle(PlaneList.java:32) at Airport.arriveAtAirport(Compiled Code) at RunAirport.option2(Compiled Code) at RunAirport.main(RunAirport.java:30) Here, flight CK001 has not previously registered with the airport; so an error is correctly flagged followed by a stack trace of the exception.

  17. The stack trace A stack trace lists the original method that generated the exception object (along with its associated class), then methods that received that exception object are listed. This trace can then help pinpoint errors quickly during the testing phase. The stack trace is obtained (and printed to the console) by calling a printStackTrace method as follows: catch (AirportException e) { e.printStackTrace(); }

More Related