






















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!























































D2: Analyze how a class diagram can be derived from a given code scenario using a UML tool M4 Reconcile the most appropriate design pattern from a range with a series of given scenarios. ........................................................................................................................................................ 58
Creation of an object as a member of a class is called instantiation. Thus, object is an instance of a class. The constituents of a class are −
Inheritance: child classes inherit data and behaviors from parent class Polymorphism: many methods can do the same task Abstraction Abstraction is to focus on the important and discard the irrelevant. In simple way it can be defined as making user interacts with only selected attributes and methods of an objects. It uses simplified high-level tools to access a complex object. For an example; You don’t have to know all the details of how the engine works to drive a car. A driver only uses a small selection of tools: like gas pedal, brake, steering wheel, blinker. The engine is hidden from the driver. The benefits of abstraction are summarized below: Simple, high level user interfaces Complex code is hidden Security as only displaying selected pieces of data, and only allowing data to be accessed through classes and modified through methods Easier software maintenance Code updates rarely change abstraction Encapsulation Encapsulation can be simply defined as containing all the important information inside an object and only exposing selected information to the other. Attributes and behaviors are defined by code inside the class template. It hides the internal software code implementation inside class and hides internal data if inside objects. For an example; Let’s use a car as a metaphor for encapsulation. The information the car shares with the outside world, using blinkers to indicate turns, are public interfaces. In contrast, the engine is hidden under the hood. The benefits of encapsulation are summarized here: Adds security: Only public methods and attributes are accessible from the outside
The benefits of Polymorphism are: Objects of different types can be passed through the same interface Method overriding Method overloading
This reusability is possible due to the relationship b/w the classes. Object-oriented programming generally supports 4 types of relationships that are: inheritance, association, composition, and aggregation. All these relationships are based on “is a” relationship, “has-a” relationship, and “part-of” relationship.
Inheritance is an “IS-a” type of relationship. The “IS-A” relationship is based on inheritance which can be of two type Class Inheritance or Interface Inheritance. Inheritance is a part-child relationship where we create a new class by using the existing class code. It is just like saying that “A is a type of B”. for example, is “Apple is fruit”, “Lamborgini is a car”. Composition is a "part-of" relationship. Simply composition means mean the use of instance variables that are references to other objects. In a composition relationship, both entities are interdependent of each other for example “engine is part of the car”, “heart is part of the body”. Association is a “has-a” type relationship. Association establishes the relationship b/w two classes using their objects. Association relationships can be one to one, One to many, many to one, and many to many. For example, suppose we have two classes then these two classes are said to be a “has-a” relationship if both of these entities share each other’s object for some work and at the same time they can exist without each other’s dependency or both have their lifetime. Aggregation is based is on a "has-a" relationship. An aggregation is a special form of association. In association, there is not any classes (entity) work as the owner but in aggregation one entity work as owner. In aggregation, both entities meet for some work and then get separated. Aggregation is a one-way association.
Generally, these four types of relationships (Inheritance, Composition, Association, and Aggregation) are used in OOPS. If you have any doubts or questions then mention them in the comment section. M1 Determine a design pattern from each of the creational, structural and behavioral pattern types. Design pattern A design pattern is a general reusable solution to a commonly occurring problem within a given context. What does that mean? In simple terms, programmers often encounter the same problem repeatedly. Rather than have everyone come up with their own solution to common programming issues, we use a best practice type solution that has been documented and proven to work. It is a template or description of how to solve problems that can be used in many situations. Here the word general is important as we cannot just copy and paste a design pattern into our code. (sourcemaking,
Benefits of using Design pattern in application development; It uses object-oriented concepts like decomposition, inheritance and polymorphism. 00Appropriate design patterns used in development of applications make development fast and easily documented. The benefit of design patterns lies in reusability and extensibility of the already developed applications. They are more sophisticated and advance approaches than basic data structures such as arrays, linked lists, and binary trees. These are more sophisticated and sophisticated approaches than basic data structures such as arrays, linked lists, and binary trees They improve software development process. There are lots of design pattern that are currently being discovered among them most used common three design pattern are as follow;
As a simple example, consider how multiple inheritance mixes two or more classes into one. The result is a class that combines the properties of its parent classes. This pattern is particularly useful for making independently developed class libraries work together. Adapter Match interfaces of different classes Bridge Separates an object’s interface from its implementation Composite A tree structure of simple and composite objects Decorator Add responsibilities to objects dynamically Facade A single class that represents an entire subsystem Flyweight A fine-grained instance used for efficient sharing Private Class Data Restricts accessor/mutator access Proxy An object representing another object Behavioral Patterns Behavioral patterns describe interactions between objects and focus on how objects communicate with each other. They can reduce complex flow charts to mere interconnections between objects of various classes. Behavioral patterns are also used to make the algorithm that a class uses simply another parameter that is adjustable at runtime. Behavioral patterns are concerned with algorithms and the assignment of responsibilities between objects. Behavioral patterns describe not just patterns of objects or classes but also the patterns of communication between them. Chain of responsibility A way of passing a request between a chains of objects
Command Encapsulate a command request as an object Interpreter A way to include language elements in a program Iterator Sequentially access the elements of a collection Mediator Defines simplified communication between classes Memento Capture and restore an object's internal state Null Object Designed to act as a default value of an object Observer A way of notifying change to a number of classes State Alter an object's behavior when its state changes Strategy Encapsulates an algorithm inside a class Template method Defer the exact steps of an algorithm to a subclass Visitor Defines a new operation to a class without change D1 Analyses the relationship between the object-orientated paradigm and design patterns. In my view, design pattern and OOP are not necessarily related but it so happens that design patterns are common approaches for solving problems that come upon OOP. Knowing about design patterns can save some time when determining how to approach a situation. In the Java and .Net frameworks programmers use design pattern all the time without ever studying them since they are extensively used. As just like a recipe book doesn’t make one master chef, knowledge of OO design pattern does not necessarily make one an OOP expert so I would not go so far to say that someone who knows design patterns is an expert OOP though.
respond to the click of a mouse button, or keyboard, which will trigger the execution of an application or utility and redraw the screen appropriately. The mouse click event will result in one or more objects responding. Each object is otherwise independent. Each object is able to respond only to certain events. The advantage of the pattern is that the Subject and Observer are independent of each other, and the subject does not need to know anything about the handling of the notification by the observers (i.e., how update () works). This means that any type of broadcasting communication could be implemented in this way. Presentation
Part 2 P2 Design and build class diagrams using a UML tool Importance of UML UML diagrams may be used to illustrate a project before it begins or as documentation for a project after it has begun. However, the overarching objective of UML diagrams is to assist teams to envision how a project is or will operate, and they may be utilized in any industry, not just software engineering. The diagrams will allow teams to collaborate on visualizing how a