Tuesday, February 1, 2011

Tutorial & Answers-Design Patterns(CS407)

1. Software designing is hard and good designing is even hard. Explain why?       In this Problem we are asked two things.1) Why Hard  2) What is good design  According to the Design Patten book by gang of four

Designing object-oriented software is hard, and designing reusable object-oriented software is even harder. You must find pertinent objects, factor them into classes at the right granularity define class interfaces and inherited hierarchies, and establish key relationships among them. Your design should be specific to the problem at hand but also general enough to address future problems and requirements. You also want to avoid redesign, or at least minimize it. Experienced object-oriented designers will tell you that a reusable and flexible design is difficult if not impossible to get "right" the first time. Before a design is finished, they usually try to reuse it several times, modifying it each time.

Yet experienced object-oriented designers do make good designs. Meanwhile new designers are overwhelmed by the options available and tend to fall back on non-object-oriented techniques they've used before. It takes a long time for novices to learn what good object-oriented design is all about. Experienced designers evidently know something inexperienced ones don't. What is it?

2. Discuss the following statements.                                                                                        (a) Following design rules and guidelines may not produce good designs.
(b) Software development is a team work than an individual work.

3. (a) What does mean by the pattern selection problem?.                                      Pattern selection problem is How we select the best pattern to our software design 
(b) Do you think that existing pattern organizations address this problem? Justify
your answer.
4. In a certain organization, employees are allowed to access information objects,
but the direct access may cause several problems. Therefore, it is required to
solve this problem by applying a design pattern. Suggest an appropriate design
patterns to achieve this task. Describe your method in terms of class diagram.
For simplicity consider only one information object that consists of the following


5. There are two design patterns that can be applied in designing variants of an
algorithm that can be interchanged independently. What are those patterns?
Explain how you could use these patterns to design elementary sorting algorithms.

6. Some of the existing design patterns are large in scale whereas some others are small in scale. If any small-scale pattern addresses a sub-problem of a large scale pattern, the first one can be used to complement the second. Do you think that the Factory Method pattern complements the Strategy pattern? If not explain why. If yes, explain how you could use them in designing an application that traverse a Binary search Tree by using one of the four traversal methods: pre-order, in-order, post-order and level order traversals. Description should be provided by means of a class diagram or by means of a code in any object oriented programming language.

7. State and discuss the two Adapter patterns. You should explain the advantages and disadvantages of each pattern when applying to solve a candidate problem.

8. There are two patterns with similar solution structures. State those two patterns and explain how they differ.

9.Assume that you have an application with two sets of objects so that the states
of many objects depend on the state of another object. Do you think that you can
design such a system with patterns? If so propose suitable pattern(s) for this task. Demonstrate the application of the proposed patterns by means of class diagram and code fragments.

10 .(a) Give a brief account of each of the following:

i) Creational patterns

creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

ex:Abstract Factory ,Factory Method,Prototype,Singleton

ii) Structural patterns

structural design patterns are design patterns that ease the design by identifying a simple way to realize relationships between entities.


iii) Behavioral patterns

behavioral design patterns are design patterns that identify common communication patterns between objects and realize these patterns. By doing so, these patterns increase flexibility in carrying out this communication.

ex:Integrator,Strategy,Template method


(b) Discuss the statement “Pattern descriptions are informal and ambiguous”.
Describe how such informal descriptions effect on optimal usage of patterns.
Can you suggest a solution for this problem? Explain how your method assists