Answers to Study Questions

May 10, 2017 | Author: Alif Kap Wau Insan | Category: N/A
Share Embed Donate


Short Description

Download Answers to Study Questions...

Description

Solution notes: Maintenance becomes difficult, because the only way to understand the product as a whole is to read the source code of the entire product. Also, the sole documentation on an individual module is the source code of that module. In addition, lack of documentation means that the chance of a regression fault increases.

Answers to Study Questions -- Chapters 1 and 3

1.

What are the four important attributes which all software products should have ? Suggest four other attributes of software that you think are important for software engineering. Solution notes: For important attributes are maintainability, dependability, performance and usability. Other attributes that may be significant could be reusability (can it be reused in other applications), distributability (can it be distributed over a network of processors), portability (can it operate on multiple platforms) and inter-operability (can it work with a wide range of other software systems). Decompositions of the 4 key attributes e.g. dependability decomposes to security, safety, availability, etc. are also possible answers.

6.

7. 2.

Giving reasons for your answer based on the type of system being developed, suggest the most appropriate generic software process model which might be used as a basis for managing the development of the following systems: o a system to control Anti-lock braking in a car; o a virtual reality system to support software maintenance; o a university accounting system o an interactive railway timetable System

Solution notes: Because time lines for the development of modern software are getting shorter and shorter, customers are becoming more diverse (making the understanding of requirements even harder), and changes to requirements are becoming even more common (before delivery), we need a way to provide incremental or evolutionary delivery. The evolutionary process accommodates uncertainty better than most process models, allows the delivery of partial solutions in an orderly and planned manner, and most importantly, reflects what really happens when complex systems are built.

Solution notes:

o

3.

Anti-lock braking system: Safety-critical system so method based on formal transformations with proofs of equivalence between each stage. o Virtual reality system: System whose requirements cannot be predicted in advance so exploratory programming model is appropriate. o University accounting system: System whose requirements should be stable because of existing system therefore waterfall model is appropriate. o Interactive timetable: System with a complex user interface but which must be stable and reliable. Should be based on throwaway prototyping to find requirements then either incremental development or waterfall model. Explain how both the waterfall model and prototyping model of the software process can be accommodated in the spiral model. Solution notes: The waterfall model is accommodated where there is a low specification risk and no need for prototyping etc. for risk resolution. The activities in the 2nd quadrant of the spiral model are skipped. The prototyping model is accommodated when the specification phase is limited and the prototyping (risk resolution) phase predominates. The activities in the 3rd quadrant of the spiral model are skipped or reduced in scope.

4.

Explain why a software system that is used in a real-world environment must change or become progressively less useful. Solution notes: Systems must change because as they are installed in an environment the environment adapts to them and this adaptation naturally generates new/different system requirements. Furthermore, the system's environment is dynamic and constantly generates new requirements as a consequence of changes to the business, business goals and business policies. Unless the system is adapted to reflect these requirements, its facilities will become out-of-step with the facilities needed to support the business and, hence, it will become less useful.

Explain what is wrong with the notion that software engineering is too time consuming and interferes with a programmer's productivity. Solution notes: Producing a lot of code quickly is not the object of software development. The software needs to perform correctly or it will need to be rewritten. Most software products must be maintained for many years after they are developed, the time spent documenting a program and planning for changes is easily justified over the product's lifetime. Studies have shown the later a change is introduced in the development process, the more costly it is to implement. Why are evolutionary models considered by many to be the best approach to software development in a modern context?

Answers to Study Questions -- Chapters 5 and 6

1.

Explain why it is desirable to draw a distinction between a requirements definition and a requirements specification. Solution notes: The requirements definition describes the software from the end-user's view whereas the requirements specification has details of interest to technical people. Since there are these different constituencies who may read the requirements we want to accommodate both groups. By providing a relatively high-level conceptual description we can allow endusers or client management to find out what will be provided. When it comes to specifying lower-level details we want to be much more precise to cater to the technical people on both sides.

2.

Discuss ambiguities or omissions in the following statement of requirements for part of a ticket issuing system. An automated ticket issuing system sells rail tickets. Users select their destinations, and input a credit card and a PIN. The rail ticket is issued and their credit card account charged with its cost. When the user presses the start button, a menu display of potential destinations is activated along with a message to the user to select a destination. Once a destination has been selected, users are requested to input their credit card. Its validity is checked and the user is requested to input a PIN. When the credit transaction has been validated, the ticket is issued. Solution notes: Ambiguities and omissions include:

o o o o

5.

Due to a fire accident, all documentation for a product is destroyed just before it is delivered. What is the impact of the resulting lack of documentation ?

o

Can a customer buy several tickets for the same destination together or must they be bought one at a time? Can customers cancel a request if a mistake has been made? How should the system respond if an invalid card or PIN number is input? What happens if customers try to put their card in before selecting a destination (as they would in ATM machines)? Must the user press the start button again if they wish to buy another ticket to a different destination?

13. If the amount breaches either of these limits, then a message is issued which tells the customer of the maximum amount allowed and the transaction is cancelled. 14. If the amount is within limits, the requested cash should be dispensed 15. The customer’s account balance and daily card limit should be reduced by the amount of cash dispensed.

o

3.

Should the system only sell tickets between the station where the machine is situated and direct connections or should it include all possible destinations? Using the technique suggested here where natural language is presented in a standard way, write plausible user requirements for the following functions: o A unattended petrol pump system that includes a credit card reader. The customer swipes the card through the reader, then specifies the amount of fuel required. The fuel is delivered and the customer's account debited. o The cash dispensing function in a bank ATM. o The spell checking and correcting function in a word processor.

Specification: ATM/Customer functionality/FS. Section 2.1 7.2 Spell checking 7.2.1 The system shall provide a user-activated facility which checks the spelling of words in the document against spellings in the system dictionary and user supplied dictionaries.

Solution notes: 1 . Fuel delivery system

7.2.2 When a word is found in the document which is not in any dictionary, a user query should be issued with the following options:

1.1 The system should provide an unattended fuel delivery service where a specified amount of fuel is delivered to customers, The cost is deducted from the customer’s credit card account.

16. 17. 18. 19. 20.

1.2 The sequence of actions to dispense fuel should be: 4. 5. 6.

The customer selects the type of fuel to be delivered. The customer inputs either a cash limit or a maximum amount of fuel to be delivered The customer validates the transaction by providing credit card account details.

7.2.3 When a word is discovered which is not in the dictionary, the system should propose 10 alternative words based on a match between the word found and those in the dictionaries.

Rationale: The amount of fuel allowed depends on the credit limit but customers may wish to ‘fill up’ rather than have a specified amount of fuel. By specifying a maximum, the system can check if credit is available. Note that the definition does not set out how credit card details should be provided.

Specification: NewWP/Tools/FS. Section 7.2

4. 7. 8.

The pump is activated and fuel is delivered, under customer control. The transaction is terminated either when the pump nozzle is returned to its holster for 15 seconds or when the customers fuel or cash limit is reached. Rationale: Termination should not be immediate when the nozzle is returned as the customer may wish to restart the transaction e.g. to fill a fuel can as well as the car fuel tank. If a pump display is available, it may be appropriate to issue a ‘Please wait for your receipt’ message.

9. A receipt is printed for the customer. 10. The fuel stock is updated. Specification: PUMP_SYS/FS. Section 1

2 . Dispensing cash 2.1 The system must provide a facility which allows a specified amount to cash to be issued to customers. The amount is requested by the customer but the system may reduce this amount if the customer’s daily limit or overdraft limit is reached. 2.1.1 The sequence of actions to dispense cash should be: 11. The customer inputs the amount of cash required 12. The system checks this against daily card limits and the customer’s overdraft limit.

Ignore this instance of the word Ignore all instances of the word Replace the word with a suggested word from the dictionary Replace the word with user-supplied text Ignore this instance and add the word to a specified dictionary

Describe three different types of non-functional requirements that may be placed on a system. Give examples of each of these types of requirements. Solution notes: There are many possibilities here. Some suggestions are given below

Description

Non-functional

o Reviews should be held and documented as defined in process

Examples

standard 123.

o Goto statements should not be used in any programs. o The time taken by users with no previous system experience to

Requirement

Performance

Implementation

Performance requirements set out limits to the performance expected of the system. These may be expressed in different ways depending on the type of system e.g. number of transactions processed per second, response time to user requests, etc.

The system must process at least 150transactions per second.

Defines specific standards or methods which must be used in the development process for the system.

The system design must be developed using an object-oriented approach based on the UML process.

learn to use 75% of the system facilities should be less than 2 hours. (How do you measure this one?) 6. Suggest who might be stakeholders in a university records system. Explain why it is almost inevitable that the requirements of different stakeholders will conflict in some ways.

The maximum response time for any user request should be 2 seconds.

Solution notes: The stakeholders in a student records system include:

o University central administration including those responsible for registration, payment of fees, examinations and assessment and graduation. o The students whose details are recorded in the system. o University departmental administrators who supply information to the system and use information from it. o Academic staff who use information from the system. o Data protection officers (local and national). o Potential employers of students (who may require information from the system). 7. A software system is to be developed to automate a library catalogue. This system will contain information about all the books in a library and will be usable by library staff and book borrowers and readers. The system should support catalogue browsing, querying, and should provide facilities allowing users to send messages to library staff reserving a book which is loan. Identify the principal viewpoints which might be taken into account in the specification of this system and show their relationships using a viewpoint hierarchy diagram.

The system must be implemented in C++,Version 3.0. Usability

Defines requirements which relate to the usability of the system by end-users.

All operations which are potentially destructive must include an undo facility which allows users to reverse their action. (This is an example of a functional requirement which is associated with a nonfunctional requirement)

Solution notes: The viewpoints are given below. Note that system management (i.e. those responsible for installing and maintaining the computer system are a viewpoint as well as library staff and library users. Library users have been separately identified as browsers and searchers as these operations typically require different types of services.

All operations which are potentially destructive must be highlighted in red in the system user interface. Safety

5.

Safety requirements are concerned with the overall safe operation of the system.

Rewrite the following requirements so that they may be objectively validated. You may make any reasonable assumptions about the requirements. o The software system should provide acceptable performance under maximum load conditions. o The system interface should use a character set as available on the standard terminal. o If the system should fail in operation, there should be a minimal loss of data. o The software development process used should ensure that all of the required reviews have been carried out. o Structured programming should be used for program development. o The software must be developed in such a way that it can be used by inexperienced users. Solution notes: Some possible rewrites are:

o o o

All Viewpoints | | ----------------------------------------------------------| | | | | | System Library Library Management staff users | | | | -------------------------------------------------| | | | | | | | | | | | Library Cataloging Database Library Browsers Searchers Management Staff Administrator Assistants

The system must be certified according to Health and Safety Regulations XYZ 123.

The response of the software system should always be less than 2 seconds to any user request. The system interface should be based on the ASCII character set and should not include non-ASCII characters. If the system fails, only the date being processed by transactions current at the time of failure may be lost.

8.

For three of the viewpoints identified in the library cataloguing system, suggest services which might be provided to that viewpoint, data which the viewpoint might provide and events which control the delivery of these services. Solution notes: Possible viewpoints are: Viewpoint: Cataloging staff Services:Add book to catalogue Delete book from catalogue Amend classification details Find catalogue entry Check entry Data provided: Book details such as ISBN, title, date of publication, author, etc. Events: Delivery of copy of new book order Delivery of new book

Delivery of classification error form Delivery of request to delete book from stock Viewpoint: Browsers Services:Show classification structure Show library organisation Select item for browsing Show related items Display book details Data provided: Classification code Book title and author Events: None (not an event driven activity) 9.

For the services identified in the above question, identify what might be the most important nonfunctional constraints.

3.

Solution notes: Important non-functional attributes for the cataloging services might be:

o o o

Draw state machine model for a CD-player. Solution notes:

Availability (because the system may be required at any time) Security (because the books data base musn’t be corrupted) Efficiency (because the system must respond quickly to each transaction)

For the browsing services, usability is also very important as these services should be easy to use without extensive training.

Answers to Study Questions -- Chapters 7 and 8

1.

Draw a context model for a patient information system in a hospital. You may make any reasonable assumptions about the other hospital systems which are available but your model must include a patient admissions system and an image storage system for X-rays. Solution notes: There are obviously many different possibilities here depending on exactly what systems are included. One possible model is shown below

4.

Draw state machine model for an answering machine Solution notes:

2.

Based on your experience with a bank ATM, draw a data-flow diagram modelling the data processing involved when a customer withdraws cash from the machine. Solution notes: One possible model of the data processing is shown below. There are other alternatives depending on the details of the system. Note that this DFD has to include some control data as this is an event-driven system.

5.

Develop an object model including a class hierarchy diagram and an aggregation diagram showing the principal components of a PC and its system software. Solution notes: There are many possible organizations for the class hierarchy. I show a simple one below with only two levels. A three-level

hierarchy would also be OK but more than that would be too much. The aggregation diagram shows the part-of relationships between objects. This is shown in Figure 7.4. Obviously, further decomposition of the lowest level is possible.

} class ArticleStock { ... void reserve(Article article, int number) { ... } ... } class Order { ... OrderPosition giveOrderPos() { ... } ... }

6.

Consider the following Java code and draw a sequence diagram to show the execution scenario of reserve(o) in ArticleReservation class.

class OrderPosition

class ArticleReservation

{

{

...

ArticleStock as;

Article giveArticle()

void reserve(Order order)

{

{

...

OrderPosition opos = order.giveOrderPos();

}

Article art = opos.giveArticle();

int giveNumber()

int num = opos.giveNumber();

{

as.reserve(art,num)

...

}

}

...

...

}

o

Solution notes: 7.

8.

9.

Develop using C and X-windows

Explain why, for large systems development, it is recommended that prototypes should be "throw-away" prototypes. Solution notes: Large systems are usually developed by different teams and these require a common reference framework (the system requirements) for developing the system. Throwaway prototypes can be used to help develop and validate these requirements to increase confidence that these are appropriate. However, if an evolutionary approach to development is used then it is difficult to partition increments across the different teams that are involved in the system. Furthermore, large systems usually have a long lifetime and the problem with evolutionary prototyping is that it often leads to a system structure that is corrupted by change and is consequently hard to maintain. Under what circumstances would you recommend that prototyping should be used as a means of validating system requirements ?

Costs more.

o o o

Fewer problems with training. Known management strategy. Requirements likely to be wrong so needs post-delivery modification.

Evolutionary prototyping

o o o o o o

Fast feedback from users. Rapid system delivery. Readily adapted to evolving requirements. Hard to manage. Lack of standards for portability etc. Likely to be unstructured causing future maintenance problems. 11. You have developed a throw-away prototype system for a client who is very happy with it.

Solution notes: When a system that is new or unfamiliar to the organisation is being developed. In those circumstances, requirements stakeholders do not know what they require and appreciate the guidance they can get from a prototype system.

However, she suggests that there is no need to develop another system but that you should deliver the prototype and offers an excellent price for the system. You know that there may be future problems with maintaining the system. Discuss how you might respond to this customer.

Suggest difficulties that might arise when prototyping real-time embedded computer systems.

Solution notes: The problem which you are likely to face here is that customers have immediate requirements for a system and may be willing to accept long-term costs in return for short-term advantage. In the long-tern, the prototype is likely to be much more expensive to maintain (and will probably have to be scrapped after a relatively short time) and may not be reliable as a properly-engineered system. Customers, of course, should always be able to have what they are willing to pay for and, if there is no financial loss to the developer, there are no problems in delivering the prototype. However, as a professional it is important that you make clear the problems which the customer is likely to face with the system and emphasise that the system was intended as a demonstrator rather than a finished system. If possible, you should try to quantify the maintenance costs which are likely to be involved and warn the customer of the short lifetime of the system. You may wish to draw up some written agreement where you make clear that you do not take responsibility for system problems.

Solution notes: Problems in prototyping real-time systems resolve around the fact that such systems must often interact with hardware (which may be unavailable), have timing requirements which cannot be replicated in a prototyping language and have very high reliability requirements. The process structure may also have to be prototyped and this may be impossible if the prototyping language does not include concurrent programming facilities. These problems can be partially addressed by also prototyping the hardware using a simulator, and by using a model of time which corresponds to real-time but which is many times slower. Prototyping reliability requirements is very difficult. 10. A software manager is involved in a project development of a software design support system which is is intended to assist with the translation of sofware requirements to a formal software specification. The system must run on a personal computer but may be developed on another system and ported to that machine. Three possible development strategies are: o Develop a throw-away prototype using a prototyping language such as Smalltalk. Evaluate this prototype then review requirements. Develop the final system using C and X-windows. o Develop the system from the existing requirements using C and X-windows then modify it to adapt to any changed user requirements. o Develop the system using evolutionary prototyping with a prototyping language such as Smalltalk. Modify the system accorind to the user's requests and deliver the modified prototype. Comment on the advantages and disadvantages of each of these development strategies. Solution notes: Throw-away prototyping

o o o

Fast development and rapid feedback from users. Likely to result in reasonable requirements. Needs multiple development languages.

Answers to Study Questions -- Chapters 4 and 22

1.

Explain why the best programmers do not always make the best software managers. You may find it helpful to base your answer on the list of management activities given in Sommerville's section 4.1. Solution notes: Management activities such as proposal writing, project planning and personnel selection require a set of skills including presentation and communication skills, organisational skills and the ability to communicate with other project team members. Programming skills are distinct from these (indeed, it is a common criticism of programmers that they lack human communication skills) so it does not follow that good programmers can re-orient their abilities to be good managers.

2.

Explain why the process of project planning is an iterative one and why a plan must be continually reviewed during a software project. Solution notes: Project planning can only be based on available information. At the beginning of a project, there are many uncertainties in the available information and some information about the project and the product may not be available. As the project develops, more and more information becomes available and uncertainties are resolved. The project plan therefore must be reviewed and updated regularly to reflect this changing information environment.

3.

The table below sets out a number of activities, durations and dependencies. Draw and activity chart and a bar chart showing the project schedule.

Task

Duration (days)

Dependencies

T1

10

T2

15

T1

T3

10

T1, T2

T4

20

T5

10

T6

15

T3, T4

T7

20

T3

T8

35

T7

T9

15

T6

T10

5

T5, T9

T11

10

T9

T12

20

T10

T13

35

T3, T4

T14

10

T8, T9

o

T15

20

T12, T14

o o

T16

10

T15

Task bar chart

4.

In addition to the risks shown in Figure 4.12, identify six other possible risks which are likely to arise in software projects. Solution notes: Other possible risks are:

o o

Solution notes:

o

5.

Activity Chart

Technology: Communications network saturates before expected transaction limit is reached. People: Level of skill of available people is lower than expected. Organisational: Organisational changes mean that the project schedule is accelerated. Tools: CASE tools cannot handle the volume of data available for large systems. Requirements: New non-functional requirements are introduced that require changes to the system arhcitecture. Estimation: The difficult of the software is underestimated.

You are asked by your manager to deliver software to a schedule which you know can only be met by asking your project team to work unpaid overtime. All team members have young children. Discuss whether you should accept this demand from your manager or whether you should persuade your team to give their time to the organisation rather than their families. What factors might be significant in your decision? Solution notes: Issues which might be covered include the problems of finding a balance between family life and organisational demands, whether or organisations should expect people to behave as professionals. This perhaps implies working the number of hours required to complete some job but also implies that engineers should have a degree of autonomy about how they arrange their working lives (e.g. they may choose to work from home or their own working hours). Factors which affect this decision might be the financial state of the company, the general company culture and attitude, the availability of alternative local employment, particular personal circumstances (e.g. are people single parents, do they have babies which don’t sleep well, etc.)

o 6.

o

As a training manager, you are responsible for the initial programming language training of a new graduate intake to your company whose business is the development of defence aerospace systems. The principal programming language used is Ada, which was designed for defence systems programming. The trainees may be computer science graduates, engineers or physical scientists. Some but not all of the trainees have previous programming experience; none have previous experience in Ada. Explain how you would structure the programming training for this group of graduates. Solution notes: Divide group into two namely those with previous experience of an imperative programming language and those without. Teach the experienced group CHILL syntax by reference to known concepts such as assignments etc. teach the other group concepts before confusing them with syntax.

Wide selection of staff available. team members with about the same experience can be found. Critical problem so a democratic team brings a wide variety of expertise to it.

Chief programmer team should be rejected because it is too high risk. Although productivity can be as high or higher than with democratic team, the fact that a rival company is actively recruiting means that the loss of the CP or his/her deputy could critically damage the project.

9.

From a management point of view, discuss possible pros and cons of having a technical wizard in your development team. Solution notes: A major advantage of having a true wizard in the team is that he may boost team productivity. Other team members may profit from his knowledge and increase their own knowledge and skills. Potential disadvantages (which should be counteracted by proper management attention!) are:

Reason is because of knowledge organisation which separates syntactic and semantic knowledge. If you try and teach semantic knowledge when its already known it is boring. If you try and teach both at one, it is confusing.

o

7.

Explain why keeping all members of a group informed about progress and technical decisions in a project can improve group cohesiveness. Solution notes: In a cohesive group, all members have the same fundamental objective and, generally, recognise that this takes priority over other individual objectives. When there is good information exchange and a culture where problems and difficulties are shared, individuals are much more likely to be able to keep this common objective in sight and to work together to solve the problems. If information is hidden, there is a tendency for people to think that those hiding the information are doing so because of personal objectives and so they are seen as not being a subscriber to the overall group objective. This is a particular problem when the person hiding the information is the group leader - if the group leader does not promote a culture of openness, an atmosphere of suspicion is likely to arise.

Technical issues may get too much emphasis. The team may easily loose itself in beautiful technical solutions to problems that are hardly relevant to the users. o A less disciplined mode of operation may result. Proper procedures regarding documentation and configuration control may be discarded, since the team guru has all the necessary knowledge in his head. o The project may get into serious trouble if this person leaves the team. This holds especially if the previous point is not adequately dealt with. 10. Discuss the pros and cons of letting people rotate between projects from different application domains as opposed to letting them true experts in one particular application domain. Solution notes: Advantages of letting people rotate between projects from different application domains are:

o o

Of course, this doesn’t mean that everyone has to know everything. Information hiding is important. However, if people know that the information is there if they need to know it, then they will not be suspicious.

8.

You are a programming manager who has been given the task of rescuing a project that is critical to the success of the company. Senior management have given you an open-ended budget and you may choose a project team of up to five people from any other projects going on in the company. However, a rival company, working in the same area, is actively recruiting staff and several staff working for you company have left to join them.

o

The major advantage of letting people become true experts in a given application domain is their increased expertise within that domain. The productivity and quality of their work increases as their knowledge of that domain grows. Answers to Study Questions -- Chapters 9 and 10

1. Describe two models of programming team organisation that might be used in this situation and make a choice of one of these models. Give reasons for your choice and explain why you have rejected the alternative model. Solution notes: Possible team models are democratic team and chief programmer team. In a democratic team, all members participate in decision make and share out the work by consensus. In a chief programmer team, the chief programmer is very highly skilled along with a deputy and an administrator. Specialist help is drafted in as required. Chief programmer makes all the decisions. CP and deputy do most of the design work with the remainder of the team doing routine tasks. In this case, the best option is the democratic team because:

Their "stock" of useful knowledge chunks increases. They are more easily led to properly document things, since their work has to be handed over to other people. They become less easily dissatis_ed with their position, since they are regularly confronted with new challenges.

Suggest why the architectural design of system should precede the development of a formal specification. Solution notes: The architectural design is a means of structuring the system into (relatively) autonomous parts which can be separately specified using formal or other techniques. This serves to structure the specification as well as the system. Of course, the specification could be structured in some other way but then there is a problem of mapping the specification to the system structure.

2.

You have been given the task of 'selling' formal specification techniques to a software development organization. Outline how you would go about explaining the advantages of formal specifications to sceptical, practicing software engineers. Solution notes: To explain the advantages of formal specification to practicing engineers, it is important to focus on what it brings to the

Is_empty (New) = True Is_empty (Push (S, V)) = False

practice of software development rather than on more abstract advantages such as the ability to mathematically analyze the specification. Advantages that might be stressed are: 5. 1.

3.

The detailed analysis of the requirements that is necessary to produce a formal specification. This results in the discovery and resolution of ambiguities and errors at an early stage in the process. 2. The unambiguous specification of interfaces. Interface problems are one of the major problems in system integration and a reduction in such problems can significantly reduce software costs. 3. The ability to mix formal and informal specifications. The whole system need not be formally specified but only those parts where most benefit can be gained. Using the axioms given in the algebraic specification of sort List (Sommerville Figure 9.7, p.199) determine the meaning of the following expressions. Make sure at each stage you say which axiom you are using (number the axioms from 1 to 6 in the order given). o Tail ([42, 99]) o Head (Tail (Cons ([1, 2], 3))) o Length (Tail (Cons ([1], Head (Cons ([2], 3)))))

An abstract data type representing a Symbol_table has the following operations: o New: bring a symbol table into existence. o Enter: enter a symbol and its type into the table. o Lookup: return the type associated with a name in the table. o Delete: remove a name-type pair from the table, given a name as input. o Replace: replace the type associated with a given name by the type specified as a parameter. Define this abstract data type using an algebraic specification. The Enter operation fails if the name is already in the table. The Lookup, Delete, Replace operations fail if the name is not in the table. Solution notes: SYMBOL_TABLE (Name, Type) sort Symbol_Table imports NAME, TYPE

Solution notes: [x,y] == Cons (Cons (Create, x), y) This specification defines a sort Symbol_table as might be used in a compiler. It requires the specification of sorts Name and Type which are assumed to be defined in the specifications NAME and TYPE. Assume the sort TYPE has an associated Undefined value.

o

4.

Tail ([42, 99]) = Tail (Cons (Cons (Create, 42), 99)) (defn of []) = Cons (Tail (Cons (Create, 42), 99)) (axiom 6) = Cons (Create, 99) (axiom 6) = [99] (defn of []) o Head (Tail (Cons ([1, 2], 3))) = Head (Tail (Cons (Cons (Cons (Create, 1), 2), 3))) (defn of []) = Head (Cons (Tail (Cons (Cons (Create, 1), 2)), 3)) (axiom 6) = Head (Cons (Cons (Tail (Cons (Create, 1)), 2), 3)) (axiom 6) = Head (Cons (Cons (Create, 2), 3)) (axiom 6) = Head (Cons (Create, 2)) (axiom 2) = 2 (axiom 2) An abstract data type representing a stack has the following operations: o New: bring a stack into existence. o Push: add an element to the stack. o Top: evaluate the top element of the stack. o Retract: remove the top element of the stack and return the modified stack. o Is_empty: returns true if there are no elements in the stack.

The Create operation brings a symbol table into existence, the Enter operation puts a symbol into the table, the Lookup operation discovers the type associated with a name, the Delete operation removes a name, type pair from the table and the Replace operation replaces the type associated with a name. Create -> Symbol_table Enter (Symbol_table, Name, Type) -> Symbol_table Lookup (Symbol_table, Name) -> Type Delete (Symbol_table, Name) -> Symbol_table Replace (Symbol_table, Name, Type) -> Symbol_table Lookup (Create, N) = Undefined Delete (Create, N) = Create Replace (Create, N, T) = Create Lookup (Enter (S, N_1, T), N_2) = if N_1 == N_2 then T else Lookup (S, N_1) Delete (Enter (S, N_1, T), N_2) = if N_1 == N_2 then S else Enter (Delete (S, N_2), N_1, T) Replace (Enter (S, N_1, T_1), N_2, T2) = if N_1 == N_2 then Enter (S, N_2, T2) else Enter (Replace (S, N_2, T2), N_1, T_1))

Define this abstract data type using an algebraic specification. Solution notes: STACK (Elem) sort Stack imports BOOLEAN 6. This specification defines a sort called Stack which specifies an abstract data type. The operations on the stack allow a stack to be created (New), an element to be pushed onto the stack (Push), the Top of the stack to be evaluated (Top), the top of the stack to be removed (Retract) and the stack to be tested to see if it is empty. New -> Stack Push (Stack, Elem) -> Stack Top (Stack) -> Elem Retract (Stack) -> Stack Is_empty (Stack) -> Boolean Top (New) = Undefined Top (Push (S, V)) = V Retract (New) = New Retract (Push (S, V)) = S

ATMs rely on using information on the user's card giving the bank identifier, the account number and the users PIN. They also derive account information from a central database and update that database on completion of a transaction. Using your knowledge of ATM operation, write Z schemas defining the state of the system, card validation and cash withdrawal. Solution notes: The Z schemas are shown below. There are many different possibilities here depending on how much information is maintained. This is one of the simplest which assumes that customers may not withdraw money if there is an insufficient cleared balance in their account (a cleared balance is where all cheques paid in to the account have been cleared for payment). +----BankAccount-----------------------------------| | CustomerNumber: N | AccountNumber: N

| DateOpened: Date | DateClosed: Date | CustomerPIN: N | Balance: Money | ClearedBalance:Money | AvailabletoWithdraw: Money +--------------------------------------------------| DateOpened < DateClosed | ClearedBalance >= Balance | AvailabletoWithdraw
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF