INTERNAL ASSESSMENT TEST III Answer Schema Subject& Code: Object-Oriented Modeling and Design (15CS551) Sem: V ISE (A & B) Q. No. Questions Marks 1. a. Ans Explain the steps or iterations involved in object oriented design process. 1. Create a Preliminary version or a first-cut model of the design class diagrams. 2. Develop interaction diagrams for each use case or scenario: Sequence diagram and communication diagram. 3. Update the design class diagrams 4. Partition the design class diagrams into related functions using package diagrams b. Ans Explain with an example the standard stereotypes found in design model. Stereotypes: UML notation to categorize a model element as a certain type Standard stereotypes: Entity, control, boundary, data access Entity class: Comes from the domain model. Normally passive- wait for business events to occur. Persistent class- data must persist after the system is shut down Boundary class: Specifically designed to live on the system s automation boundary Example: Classes associated with the user interface Control class: Class that mediates between the boundary class and the entity classes Responsibility to catch the messages from the boundary class objects and send them to the correct entity class objects Data access class: Class that is used to retrieve data from and send data to a database 2 Define the following: a. Encapsulation and Information hiding Each object is a self-contained unit containing both data and program logic. Data associated with an object is not visible i.e., object attributes are private. Methods provide access to data and to modify them. b. Navigation visibility Describes which objects can view and interact with each other. c. Coupling Measures how closely classes are linked. Number of navigation arrows on the DCD
Low coupling better than high coupling. Fewer navigations indicate that a system is easier to understand and maintain. d. Cohesion: Measures the consistency of functions in a class 3 Develop a complete three layer sequence diagram for Look up item availability use case. 4 a. b. Ans Describe the major difference between sequence diagram and communication diagram. Communication Diagram focuses on Object themselves. Drawing an Communication Diagram is an effective way to get a quick overview of the collaborating objects. However, You have to hunt to find the numbers to see the sequence of the Messages. Communication Diagrams are used to sketch out a solution. If the Use Case is small and not too complex a simple Communication Diagram may suffice. For more complex situations, Sequence Diagram may be required to allow you visualize the flow and Message sequence. You can mix the usage of both Interaction Diagrams within the same set of specifications. What are the major implementation issues for a three layer design? The Problem with IDE Tool approach is the difficulty of maintaining the System Codes since they scattered throughout the Graphical Use Interface (GUI) Classes, that becomes very hard to find and maintain. If a Network-based System needs to be enhanced to include Web- front end then a Programmer must rebuild nearly the entire System. If two User Interfaces are desired, then all of the Business Logic is programmed twice. We recommend that the would be Analysts and Programmers should use Good Design Principles in the Development of new Systems. 5 Explain with an example the purpose of package diagram along with the UML notations used. Package Diagram is a high level Diagram that allows the Designer to associate classes of related groups. A Package Diagram can group Classes by Subsystem or by Layer (View Layer, Domain Layer and Data Access Layer). To develop Package
Diagram extract information from Updated Design Class Diagram and Interaction Diagram (Sequence Diagram) for each Use Case. Place the Classes inside the appropriate Packages based on the Layer or Subsystem to which they belong. Dependency Relationships (Dashed arrow line ) shows which elements affect other elements in a System. The arrow tail is connected to the Package that is dependent. And the arrow head is connected to the independent Package. Dependence Relationship may exist between Packages, or between Classes within Packages. Dependency Relationship help designer to track the carry-through effect of changes. Package Diagrams can also be nested to show different level of Packages. The Benefit of using the Package Diagrams for Documentation is that different Packages can be assigned to different Programming teams to program the Classes. Dependency arrow will help Designers recognize where communication among teams must occur to ensure a totally integrated system. 6 What is a design pattern? Explain the four essential elements of design pattern. A design pattern is a general reusable solution to a commonly occurring problem in software design. Object-oriented design patterns typically show relationships and interactions between classes or objects, without specifying the final application classes or objects that are involved. four elements. Pattern name: A handle used to describe: a design problem, its solutions, its consequences. Increases design vocabulary. Makes it possible to design at a higher level of abstraction. Enhances communication Problem: Describes when to apply the pattern. Explains the problem and its context. May describe specific design problems and/or object structures. May contain a list of preconditions that must be met before it makes sense to apply the pattern. Solution: Describes the elements that make up the: design, relationships, responsibilities, collaborations. Does not describe specific concrete implementation. Abstract description of design problems and how the pattern solves it Consequences: Results and trade-offs of applying the pattern. Critical for: evaluating design alternatives, understanding costs, understanding benefits of applying the pattern. Includes the impacts of a pattern on a system s: flexibility,
extensibility, portability. 7 How design patterns solve design problems? Discuss. 1. Finding Appropriate Objects 2. Determining Object Granularity 3. Specifying Object Interfaces 4. Specifying Object Implementations 5. Putting Reuse Mechanisms to Work 6. Relating Run-Time and Compile-Time Structures. 7. Designing for Change What are the common causes for redesign? Explain in detail Creating an object by specifying a class explicitly. Dependence on specific operations. Dependence on hardware and software platform Dependence on object representations or implementations Algorithm dependencies Tight Coupling Extending functionality by subclassing Inability to alter conveniently 9 With an example discuss the implementation issues considered when using a singleton design pattern. Ensuring a unique instance: The Singleton pattern makes the sole instance a normal instance of a class, but that class is written so that only one instance can ever be created. A common way to do this is to hide the operation that creates the instance behind a static class operation that guarantees that only one instance is created. class Singleton { private static Singleton instance; static Singleton Instance() {if (instance == null) // if not created yet instance = new Singleton(); // create once return instance; } Sub classing the singleton class: registry of singleton: Instead of having Instance define the set of possible Singleton classes, the Singleton classes can register their singleton instance by name in a well-known registry. The registry maps between string names and singletons. When Instance needs a singleton, it consults the registry, asking for the singleton by name. The registry looks up the corresponding singleton (if it exists) and returns it. This approach frees Instance from knowing all possible Singleton classes or instances. All it requires is a common interface for all Singleton classes that includes operations for the registry: class Singleton { public:
static void Register(const char* name, Singleton*); static Singleton* Instance(); protected: static Singleton* Lookup(const char* name); private: static Singleton* _instance; static List<NameSingletonPair>* _registry; }; 10 Write Short notes on: a. Adapter: Convert the interface of a class into another interface clients expect. Adapter lets classes work together that couldn't otherwise because of incompatible interfaces. It is also known as wrapper. Use the Adapter pattern when you want to use an existing class, and its interface does not match the one you need. you want to create a reusable class that cooperates with unrelated or unforeseen classes, that is, classes that don't necessarily have compatible interfaces. (object adapter only) you need to use several existing subclasses, but it's impractical to adapt their interface by subclassing every one. An object adapter can adapt the interface of its parent class. Structure: A class adapter uses multiple inheritance to adapt one interface to another: implementation of Adapter: Implementing class adapters in C++. Pluggable adapters : Using abstract operations, Using delegate objects, parameterized object b. Proxy: Provide a surrogate or placeholder for another object to control access to it. It is also known as surrogate.
Proxy pattern is applicable: remote proxy, virtual proxy, protection proxy and smart references Structure: Proxy pattern can be implemented by Overloading the member access operator in C++. Using doesnotunderstand in Smalltalk Proxy doesn't always have to know the type of real subject