2D1385 Programutvecklingsteknik

Prutt-07

2007-05-24

Take Home Exam (tentamen)

NOTES: (Please read these carefully!)

(i) Clearly mark at the top of each sheet you use: (a) your name, (b) the page number.

(ii) On the front page indicate (a) how many pages are contained in your work in total. Clearly mark: (b) your name (c) your personnummer, (d) your e-mail address (in case I need to contact you)

(iii) There are two ways to submit your work. (a) Your work may be handed in to NADA's studentexpedition no later than Friday 25th May 2007 at 11.00 am. After this time it will be marked as late, and marks will be subtracted pro-rata. (b) If for any reason your are unable to reach the studentexpedition yourself (for example if you are at work) then you may post your manuscript to: Studentexpeditionen, NADA, KTH, 100 44 Stockholm. The date and time on the postmark will be taken as the date and time of your submission. The same deadline applies to manuscripts submitted by post.

(iv) If manuscripts are submitted in any other place or by any other means than those described in Part (iii) then the examiner and NADA cannot be held responsible in the case that manuscripts are lost.

(v) If you have any questions about the exam (for example, if you do not understand a question) you may call my mobile number 076 223 86 79. Please do not call before 9.00 am or after 7.00pm!

(vi) You may use your kursbunt, and any course books. You are allowed to use the internet including search engines. However, any work which you download and use must be credited to its source. You are not allowed to discuss or develop your answer with anyone else before all manuscripts have been handed in. You are not allowed to copy anyone else's work. By handing in your manuscript you are declaring that you have abided by these rules. In the case that cheating is suspected, actions will be taken against all students involved.

(vii) Write clearly. No marks will be awarded for work that I cannot read. You can write your answers in swedish or in english.


Answer all questions. Maximum marks are 50 points. A grade 3 will be awarded for 25 points or more, grade 4 is awarded for 30 points or more, grade 5 is awarded for 35 points or more.

Question 1 . Read this whole question before you begin to answer!

The crazy Italian computer science professor Carlo Meinche decides that he would make more money from selling pizzas than from teaching computer science. So he begins to study the pizza business.

On the consumption side, Carlo learns that a pizza can be eaten in up to 8 slices, and that diners often like to eat from several different pizzas.

On the production side, Carlo learns that to create a pizza it is necessary to create dough, sauce, cheese, and clams and that the result depends upon the types of dough, sauce, etc that one uses. (Of course more ingredients will be needed later when Carlo's business gets bigger.) Carlo learns that pizzerias in the USA (which make the most money) specialise in either the New York Style or the Chicago style. The creation of a New York style of pizza depends on distinctive ingredients like thin-crust dough, marinara sauce, Reggiano cheese and (since they are close to Boston) fresh clams. On the other hand, the creation of a Chicago style of pizza depends on special ingredients like thick crust dough, plum tomato sauce, mozzarella cheese and frozen clams. Carlo decides he needs his own speciality flagship pizza called a "Carlo Speziale". This Chicago style recipe for one pizza uses one portion of dough, two portions of plum tomato sauce, and optionally two portions of mozzarella sauce and also optionally ten to fifteen frozen clams. If the mozzarella is used in this recipe then the clams must also be used to provide that authentic "Carlo" taste. In addition, Carlo's "speziale" recipe must have either pineapple or garlic, (but never both!) as a garnish.

Carlo teaches software engineering, and he knows that two design patterns would be helpful to organise his model of pizza creation. On the one hand, he sees how the Abstract Factory pattern could be used to organise two types of pizza ingredient factory: namely an NY style pizza ingredient factory, that would create the pizza ingredients (dough, sauce etc) using the New York style of ingredients, and a Chicago style pizza ingredient factory that would do the same with the Chicago style of ingredients. This approach would allow Carlo to flexibly add whole new styles of pizzas as his business gets bigger.

Another pattern that Carlo has studied is the Singleton Pattern. He realises that all pizzas of any style can depend on the same pizza ingredient factory, so there should be exactly one ingredient factory of each style to create pizzas. Carlo will create both NY style and Chicago style pizzas since he does not know which style will sell best in Sweden.

(i) (10 points) Rearrange the above information into a data dictionary consisting of nouns, verbs and relational phrases. Your data dictionary must satisfy the following requirements: (a) Your dictionary entries under each category must be alphabetically ordered, (b) it is not necessary to define a word unless you think its meaning is unclear from the text, (c) every entry in your data dictionary must be used somewhere in your class diagram for part (ii) below, (d) every entity used in your class diagram for part (ii) below must appear somewhere in your data dictionary.

(ii) (15 points) Using your answer to part (i), arrange all these nouns, verbs and relations into a UML class diagram. By using additional classes where necessary and inheritance, carefully avoid repeating the same attributes or methods within several classes. Be careful to include multiplicity and logical information (including asymmetry) on relations, as well as dependencies between classes, where these can be clearly identified. Use the abstract factory and singleton design patterns to structure the information and include any interfaces and public/private attributes and methods.

(iii) (3 points) Using your answer to part (ii), instantiate the pizza class "Carlo speziale", together with its ingredient classes, by means of a UML object diagram, to show what this delicious recipe might look like in practise.You do not have to actually make one!

(iv) (2 points) Draw a UML sequence diagram which correctly models the end-users creation of ten "Carlo Speziale" pizzas, where some have cheese toppings and some don't. Your sequence diagram may only use method calls that appear in your UML class diagram for part (ii).

Question 2. (8 points) Professor Meinche decides to put his pizza store online and allow customers to place orders over the internet. For this purpose he has identified both the client-server and the model/view/controller architectures as being useful. Explain his thinking, including any drawn and labelled sketches of the architectures that he might have used, as well as describing some typical components and functionalities of the architectures.

Question 3.

(i) (5 points) Write a DTD that is suitable for making pizza orders consisting of several pizzas over the internet. Your DTD should allow for one standard recipe namely the "Carlo speziale" (obviously one could add more standard recipes) and fully customised recipes, where the customer makes up their own pizza. You should use only the ingredients described in your answer to Question 1.

(ii) (2 points) Write a short XML file that correctly instantiates your DTD to part (i) and which accurately models your object instantiation of the "Carlo speziale" that you gave in your answer to Question 1 part (iii).

(iii) (1 point) Would it be possible to capture all the constraints of Question 1 on the standard pizza recipe "Carlo speziale" using DTD constraints alone?

(iv) (1 point) What practical implications does your answer to part (iii) have if you are building a software implementation of an online pizza ordering system?

(v) (3 points) Should it be possible to capture all the constraints on any standard pizza recipe using DTD constraints alone? Explain your answer carefully and with reference to the DTD language.