Vous êtes sur la page 1sur 10

CAP-315T

OBJECT ORIENTED ANALYSIS AND DESIGN

SUBMITTED TO: Lec. Avinish Kumar

SUBMITTED BY: Prabhakar lal Reg: 10906880 Sec: RD 1901, A54

Ans:1 The four major principles that make a language object-oriented: Encapsulation : Encapsulation is the hiding of data implementation by restricting access to accessors and mutators. Accessor An accessor is a method that is used to ask an object about itself. In OOP, these are usually in the form of properties, which have, under normal conditions, a get method, which is an accessor method. However, accessor methods are not restricted to properties and can be any public method that gives information about the state of the object. Mutator Mutators are public methods that are used to modify the state of an object, while hiding the implementation of exactly how the data gets modified. Mutators are commonly another portion of the property discussed above, except this time its the set method that lets the caller modify the member data behind the scenes. Data Abstraction Data abstraction is the simplest of principles to understand. Data abstraction and encapuslation are closely tied together, because a simple definition of data abstraction is the development of classes, objects, types in terms of their interfaces and functionality, instead of their implementation details. Abstraction denotes a model, a view, or some other focused representation for an actual item. Its the development of a software object to represent an object we can find in the real world. Encapsulation hides the details of that implementation. Abstraction is used to manage complexity. Software developers use abstraction to decompose complex systems into smaller components.

Polymorphism Polymorphism means one name, many forms. Polymorphism manifests itself by having multiple methods all with the same name, but slighty different functionality There are two basic types of polymorphism. Overridding, also called run-time polymorphism, and overloading, which is referred to as compile-time polymorphism. This difference is, for method overloading, the compiler determines which method will be executed, and this decision is made when the code gets compiled. Which method will be used for method overriding is determined at runtime based on the dynamic type of an object. Inheritence. A very important concept in object-oriented design, inheritance, refers to the ability of one class (child class) to inherit the identical functionality of another class (super class), and then add new functionality of its own. Ans 2 When modeling a large scale system, we would probably be working with a high volume of model elements. They describe a model from different views and different phases, hence are in different types. UML package helps to organize and arrange model elements and diagrams into logical groups, through which you can manage a chunk of project data together. We can also use packages to present different views of the system's architecture. In addition, developers can use package to model the physical package or namespace structure of the application to build. Package diagram visualizes packages and depicts the dependency, import, access, generalization, realization and merge relationships between them. Package diagram enables you to gain a high level understanding of the collaboration among model elements through analyzing the relationships among their parent package. This also helps explain the system's architecture from a broad view.

Ans:3 A very important concept in object-oriented design, inheritance, refers to the ability of one class (child class) to inherit the identical functionality of another class (super class), and then add new functionality of its own. In a very non-technical sense, imagine that I inherited my mother's general musical abilities, but in my family I'm the only one who plays electric guitar. To model inheritance on a class diagram, a solid line is drawn from the child class the class inheriting the behavior with a closed, unfilled arrowhead (or triangle) pointing to the super class. Consider types of bank accounts: both CheckingAccount and SavingsAccount classes inherit from the BankAccount class.

Ans:4 In object-oriented terminology, a class is a template for defining objects. It specifies the names and types of variables that can exist in an object, as well as "methods"--procedures for operating on those variables. A class can be thought of as a "type", with the objects being a "variable" of that type. Multiple objects, or instances of a class can be created in a single UML program, just as you declare multiple variables of the same type in any program. For example, the TextItem class is a template for creating an object that contains a text string. This object will have a particular set of text attributes such as font, size, and color. If we set the values of the object variables--resources--in a certain way, we can create the TextItem object "Hello World". Resources that are available for objects of the TextItem class include the text string ("Hello World" in this case), the type of font, the color of the characters, the size of the characters, the line width of the characters, etc. A TextItem object is thus an instance of the TextItem class with a set of values assigned to the associated resources. We can create a second TextItem object if we want to with a new set of resource values such as: "THIS IS ALSO A TEXTITEM OBJECT."

The difference between class and object is simple and conceptual. A class is a template for objects. A class defines object properties including a valid range of values, and a default value. A class also describes object behavior. An object is a member or an "instance" of a class. An object has a state in which all of its properties have values that you either explicitly define or that are defined by default settings.

Ans:5 The UML specifies two types of scope for members: instance and classifier. Classifiers are a mechanism that is used to describe the structure and the behaviour of the modelling elements. Classifier members are commonly recognized as "static" in many programming languages. The instance defined the scope of a class, the different classes could be multiple, multilevel and single inherit. In the case of instance members, the scope is a specific instance. For attributes, it means that its value can vary between instances. For methods, it means that its invocation affects the instance state, in other words, affects the instance attributes. Otherwise, in the classifier member, the scope is the class. For attributes, it means that its value is equal for all instances. For methods, it means that its invocation does not affect the instance state. To indicate that a member has the classifier scope, its name must be underlined. Otherwise, as default, the instance scope is considered.

PART B Ans:6 One of the most important characteristics of OOP (Object Oriented Programming) is the data encapsulation concept, which means that there is a very close attachment between data items and procedures. The procedures (methods) are responsible for manipulating the data in order to reflect its behaviour. Another powerful feature of OOP, is the concept of inheritance meaning the derivation of a similar or related object (the derived object) from a more general based object. The major advantages of OOP.

Simplicity: software objects model real world objects, so the complexity is reduced and the program structure is very clear; Modularity: each object forms a separate entity whose internal workings are decoupled from other parts of the system; Modifiability: it is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods; Extensibility: adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones; Maintainability: objects can be maintained separately, making locating and fixing problems easier; Re-usability: objects can be reused in different programs.

Ans:7

Encapsulation is the process of keeping state and behavior of the object in a single unit and exposing public methods to act upon the state means hiding internal data of the object from the outside world. Encapsulation packages the data and method of an object and provides protection from external tampering by users. It implies that there is visibility to the functionalities offered by an object, and no visibility to its data. The best application of encapsulation is making the data-fields private and using public accessory methods. When an objects state and behavior are kept together, they are encapsulated.

Encapsulation is often referred to as information hiding. But although the two terms are often used interchangeably, information hiding is really the result of encapsulation, not a synonym for it. They are distinct concepts. Encapsulation makes it possible to separate an objects implementation from its behaviorto restrict access to its internal data. This restriction allows certain details of an objects behavior to be hidden.

Ans:8 A class is a representation of an object. An object is any person, place, thing, concept, event, screen, or report applicable to our system. Objects both know things (they have attributes) and they do things (they have methods). Classes form the main building blocks of an object-oriented application. The UML representation of a class is a rectangle containing three compartments stacked vertically. The top compartment shows the class's name. The middle compartment lists the class's attributes. The bottom compartment lists the class's operations. Diagram of class

Class diagrams are used for a wide variety of purposes, including both conceptual/domain modeling and detailed design modeling. .

Ans: 9

Association
Association is a relationship between two objects. In other words, association defines the multiplicity between objects. You may be aware of one-to-one, one-tomany, many-to-one, many-to-many all these words define an association between objects. Aggregation is a special form of association. Composition is a special form of aggregation.

Example: A Student and a Faculty are having an association.

Generalization
Generalization uses a is-a relationship from a specialization to the generalization class. Common structure and behaviour are used from the specializtion to the generalized class. At a very broader level you can understand this as inheritance. Why I take the term inheritance is, you can relate this term very well. Generalization is also called a Is-a relationship.

Dependency
Change in structure or behaviour of a class affects the other related class, then there is a dependency between those two classes. It need not be the same viceversa. When one class contains the other class it this happens.

Example: Relationship between shape and circle is dependency.

Vous aimerez peut-être aussi