UML questions for Computer Science and MCA students

What are software architecture framework? How do you model them in UML?

What is Software Architecture Framework?
  • It is an abstraction, in which the software provides generic functionality that can be selectively changed by additional user-written code.
  • It is a universal, reusable software environment that provides particular functionality as a part of a larger software platform to facilitate the development of software applications, products and solutions.
  • It refers to the high level structure of a software system.
Definition of Architecture Framework:
  • “Architecture frameworks address what it means to define and document an architecture.”
Why is it important to use the Software Architecture Framework?
  • It provides a common universe and a vocabulary within which we can call cooperate together – to address a specific issue.
  • Frameworks do not have to be comprehensive, but they should be leveraged to provide at least a starter set of the issues and concerns that must be addressed in the development of an architecture.

Explain UML history in detail.
OR
What are the commercial applications of UML?

What is UML?
  • UML stands for Unified Modeling Language.
  • It is a standard notation for the modeling of real world objects as a first step in developing an object-oriented methodology.
  • It is a general purpose, developmental, modeling language in the field of software engineering, which is intended to provide a standard way to visualize the design of a system.
  • It is a standard visual modeling language which is used for modeling business and similar processes. Analysis, design and implementation of software based systems.
  • It is a standard modeling language, not a software development process.
  • It is intentionally process independent and could be applied in the context of different processes.
History of UML
  • It was developed by Grady Booch, Ivar Jacobson, James Rumbaugh at Rational Software in 1994-95.
  • It was motivated by the desire to standardize the disparate notational systems and approaches to software design.
  • It was adopted as a standard by the Object Management Group (OMG) in 1997 and has been managed by this organization.
  • It was also published by the International Organization for Standardization (ISO) as an approved ISO standard in 2005.
  • It is a standard language for specifying, visualizing, constructing, and documenting the artifacts of software systems.
Advantages of UML
  • It provides a standard for software development.
  • It reduces the cost to develop diagrams of UML using supporting tools.
  • It reduces the development time.
  • The past faced issues by the developers no longer exists.
  • It has a large visual element to construct and are easy to follow.
  • Working with a new developer will be easier.
  • Communication with programmers and outside contractors will be more efficient.
Types/Applications of UML Diagrams
uml applications

1. Use Case Diagram
  • It defines the detail description of a system's behavior from a user's point of view.
2. Class Diagram
  • It displays relationships, such as containment and inheritance.
  • It contains the model class structure and contents using design elements such as classes, packages and objects.
3. Sequence Diagram
  • It shows time-based dynamics of the interaction between objects.
4. Collaboration Diagram
  • It displays the interaction organized around the objects and their links to the one another.
5. State Diagram
  • It displays the sequences of states that an object of an interaction goes through during its life in response to received stimuli.
6. Activity Diagram
  • It displays a special state diagram where most of the states are action states and most of the transitions are triggered by the completion of the actions in the source states.
7. Component Diagram
  • It displays the high level packaged structure of the code itself.
8. Deployment Diagram
  • It displays the configuration of run-time processing elements and the software components, processes and objects that live on them.
Disadvantages of UML
  • It does not define a standard file format, that means each UML tool vendor stores the representation of its UML model in proprietary format.
  • This model is limited to what the vendor provides out of the box, which is usually some form of a code generator.
  • It is large and complex.
  • It is difficult to synchronize the code with models.
  • It is difficult to keep multiple models or diagrams consistent with each other.

Write a short note on UML metamodel.

What is UML metamodel?
  • It is a model of a model.
  • It is the process of generating such metamodels.
  • It is the analysis, construction and development of the frames, rules, constraints and models.
  • It is contained in packages, which logically separate into different design layers.
  • It is extended by using object-oriented principles to define the UML superstructure.
History of UML metamodel
  • The first version of UML that is UML 1.0 had a lot of semantic problems. The OMG tried to deal with these problems by formalizing the language.
  • The OMG realized that all the meta models was needed to use a subset of UML class diagram elements.
  • In the next version of UML that is UML 2.0, the OMG introduced the MOF (Meta Object Facility) to create a common approach to meta modeling.
  • A meta model which is defined using MOF is called MOF compliant.

  • MOF Architecture
  • In the above diagram, MOF defines a four-layer meta model hierarchy.
    1. Layer M3 : Meta-meta Model layer
    2. Layer M2 : Meta Model Layer
    3. Layer M1 : Model Layer
    4. Layer M0 : Information Layer
  • The UML infrastructure contains all the concepts needed for the specification of UML and MOF, both they are aligned.
  • We have seen the modeling sequence which is used in different model.

  • MOF Sequence

  • This sequence could be continued infinitely, but four models are enough for most modeling purposes.
  • MOF compliant can easily be compared. They can be exchanged in a standardized way.
  • The instances of MOF compliant can live in the same metadata repository that is data warehousing.
Features of metamodel
  • It defines the only structure that all UML models must have.
  • It defines a core metamodel which is used to define the MOF (Meta Object Facility), UML and profiles.
  • MOF (Meta Object Facility) defines the language for defining the meta-models.
  • MOF concepts and their relationships can be defined by a class program. The Meta-Meta Model is self defined.
  • These models are used to describe the grammar.
  • It allows to talk about semantics.

Write a short note on XMI.

What is XMI?
  • XMI stands for XML Metadata Interchange.
  • It is a proposed use of the Extensible Markup Language (XML) that provides a standard way for programmers and other users to exchange information about metadata.
  • It is a compressed file format created by XMiII.
  • It contains metadata information which has been compressed.
  • The XML files are very large, the compression used by XMiII into .XML files will make the files around half the size of other compression techniques.
  • The XMI files can be decompressed using XMiII.
Features of XMI
  • It helps programmer using the UML with different languages and development tools to exchange their data models with each other.
  • It can be used to exchange information about data warehouses.
  • It standardizes how any set of metadata is described and requires user across many industries and operating environments to see data the same way.
  • XMI can be used for any metadata whose metamodel can be expressed MOF(Meta Object Facility).
  • It can also be used for serialization of models of other languages that means meta-models.
  • The most common use of XMI is as an interchange format for UML models.
  • The main purpose of XMI is to enable easy interchange of metadata between UML based modeling tools and MOF based metadata repositories.

Show how stereotypes, tagged values, constraints can be used to extend XML.
OR
What are “Extensibility mechanisms in UML” ? Explain in brief.

  • The extensibility mechanism allows to extend and customize UML by adding new building blocks, creating new properties and specifying new semantics in order to make the language suitable for specific problem domains.
  • There are three types of extensibility mechanism:
    1. Stereotype
    2. Tagged Value
    3. Constraints
1. Stereotypes

What is Stereotypes?
  • It is a modeling element that has definitions for adding new properties and constraints to the standard UML modeling element.
  • It is a profile class that defines how an existing metaclass may be extended as part of a profile.
  • It enables the use of a platform or domain specific terminology or notation in place.
  • It cannot be used by itself, but always be used with one of the metaclasses it extends.
  • It cannot be extended by another stereotype.
  • It uses the same notation as a class with the keyword 'stereotype' shown before or above the name of the stereotype.
  • Name of the stereotype should not clash with the keyword names for the extended model element.
  • The servlet stereotype extends component.
  • It can change the graphical appearance of the extended model element by using attached icons represented by 'Image' class.
2. Tagged Value

What is Tagged Value?
  • It is an element that defines new properties that can be added to certain modeling elements.
  • It is a keyword-value pair that may be attached to any kind of model element.
  • The keyword is called a 'Tag'.
  • Each tag represents a particular kind of property applicable to one or many kinds of model elements.
3. Constraints
  • It is a condition which must evaluate to true by a correct design of the system.
  • It is used to express a condition, restriction or assertion related to some of the semantics of a model element.
  • It is usually written in curly braces using any computer or natural language, including English.
    For example: {account balance is possible}
  • It allows you to extend the semantics of UML building block by adding new protocols.

Explain following concepts in UML.

a) Activity
b) Guard condition
c) Swimlanes
d) Object flow

a) Activity
  • It is a diagram that represents graphical representation of the workflows of stepwise activities and actions.
  • It shows the overall flow of control.
  • These diagrams may be regarded as a form of flow chart.
  • It is related to program flow plans which is used to illustrate the activities.
  • It allows user to think functionally.
  • It can be developed in various degrees of detail.
  • These diagrams can be refined step by step.
  • It describes dynamic aspects of the system.
  • It is used to model the activities which are nothing but business requirements.
b) Guard condition
  • It is a boolean expression that evaluates dynamically based on the value of extended state variables and event parameters.
  • It affects the behavior of a state machine by enabling actions or transitions only when they evaluate to 'true' and disabling them when they evaluate to 'false'.
  • It is also called as an interaction constraint.
  • It contains two expressions that designate the minimum number of times that a loop combined fragment executes.
  • It determines whether a certain transition will occur in a state diagram when an event happens.
  • It is evaluated only when the associated event happens.
  • It appears at the start of the interaction.
  • It contains all the information that requires to make the decision about whether to execute the traces in the interaction operand.
c) Swimlanes
  • It is a visual element that is used in process flow diagrams.
  • It may be arranged either horizontally or vertically.
  • It differs from other flowcharts in that process and decisions are grouped visually by placing them in the lanes.
  • It is used in the same way, to create a cross functional flowchart to map a process within the functional units of a business.
  • It is a way to group activities performed by the same actor on an activity diagram or to group activities in a single thread.
d) Object flow
  • It is used in activity diagrams and state machine diagrams.
  • In activity diagram, an object flow connects two elements, with specific data passing through it.
  • In the state machine diagram, an object flow is a specification of a state flow or transition. This diagram implies the passing of an object instance element at run-time.
  • An object flow is an activity edge that only passes an object and data tokens.
  • It is a path along with objects or data can pass.
  • object flow
  • An object flow is shown as a rectangle.
  • It is shown as a connector with an arrowhead denoting the direction the object is being passed.
  • An object flow must have an object on at least one of its ends. A shorthand notation for the above diagram would be to use input and output pins.
    objectflow1

Explain the package diagrams in UML 2, the need, notations and Concept.

What is Package Diagram?
  • It is a UML structure diagram that shows packages and dependencies between the packages.
  • It shows the arrangement and organization of model elements in middle to large scale project.
  • It shows both structure and dependencies between sub-systems or modules.
Need of Package Diagram
  • It contains use cases to illustrate the functionality of a software system.
  • It represents different layers of a software system to illustrate the layered architecture of a software system.
  • The dependencies between these packages can be adorned by labels or stereotypes to indicate the communication mechanism between the layers.
  • It is used in large scale systems to picture dependencies between major elements in the system.
  • It represents a compile time grouping mechanism.
Notations

1. Access
  • The keyword <<access>> is shown to indicate private visibility.
  • It is shown using a dashed arrow with an open arrowhead from the importing namespace to the imported element.
Properties

NameIt is the name of access relationship.
SupplierUsers of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
ClientThe element is dependent on the supplier elements.
VisibilityIt specifies the visibility of the imported Packageable Element within the importing package.
DocumentationIt is a description of access relationship.

2. Constraint
  • It defines a condition or restriction expressed in natural language text or in a machine readable language for the purpose of declaring some of the semantics of an element.
Properties

NameIt is a name of the constraint. It is optional and commonly omitted.
ExpressionThe condition that must be true when evaluated in order for the constraint to be satisfied.
DocumentationIt displays a description of constraint.

3. Dependency
  • It is a relationship that signifies a single or a set of model elements requires other model elements for their specification or implementation.
  • It is a complete semantics of the depending elements are either semantically or structurally dependent on the definition of the supplier element.
Properties

NameIt is the name of the dependency.
SupplierUsers of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
ClientThe element is dependent on the supplier elements.
VisibilityIt determines where the dependency appears within different namespaces within the overall model and its accessibility.
DocumentationIt is a description of dependency.

4. Genralization
  • It is a taxonomic relationship between a more general classifier and a more specific classifier.
  • Each instance of the specific classifier is also an indirect instance of the general classifier.
Properties

NameIt is the name of the generalization.
GeneralIt references the general classifier in the generalization relationship.
SpecificIt references the specializing classifier in the generalization relationship.
VisibilityIt determines where the generalization relationship appears within different namespaces within the overall model and its accessibility.
DocumentationIt is a description of generalization relationship.
SubstitutableIt indicates whether the specific classifier can be used wherever the general classifier can be used.

5. Import
  • It is defined as a directed relationship that identifies a package whose members are to be imported by a namespace.
Properties

NameIt is the name of import relationship.
SupplierUsers of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
ClientThe element is dependent on the supplier elements.
VisibilityIt specifies the visibility of the imported PackageableElements within the importing Namespace.
DocumentationIt is a description of import relationship.

6. Merge
  • It is a directed relationship between two packages that indicate the contents of the two packages are to be combined.
  • It is very similar to generalization in the sense that the source element conceptually adds the characteristics of the target element to its own element characteristics resulting in an element that combines the characteristics of both.
Properties

NameIt is the name of the merge relationship.
SupplierUsers of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
ClientThe element is dependent on the supplier elements.
VisibilityIt determines where the merge relationship appears within different namespaces within the overall model and its accessibility.
DocumentationIt is a description of merge relationship.

7. Note
  • It gives the ability to attach various remarks to the elements.
  • It carries no semantic force, but may contain information that is useful to a modeler.
Properties

NameIt is the name of the note.
DocumentationIt specifies a string that is the comment.

8. Package
  • It is used to group elements.
  • It provides a namespace for the grouped element.
  • It is a namespace for its members and may contain other packages.
Properties

NameIt is the name of the package.
ParentThe element that contains the package.
VisibilityIt determines where the merge relationship appears within different namespaces within the overall model and its accessibility.
DocumentationDescription of package.
AbstractIf it's true, the package does not provide a complete declaration and can typically not be instantiated. It is intended to be used by other packages.
LeafIt indicates whether it is possible to further specialize a package.
RootIt indicates whether the package has no ancestors. (True for no ancestors)
ChildrenThe children of package.

9. Realization
  • It is a specialized abstraction relationship between two sets of model elements.
  • It can be used to model stepwise refinement, optimizations, transformations, templates, model synthesis, framework composition etc.
Properties

NameIt is the name of realization relationship.
SupplierUsers of UML may stipulate a sense of dependency suitable for their domain, which makes a more abstract element dependent on that which is more specific.
ClientThe element is dependent on the supplier elements.
VisibilityIt determines where the realization relationship appears within different namespaces within the overall model and its accessibility.
It is optional and may be omitted if the precise relationship between element is not specified.
DocumentationIt is a description of realization relationship.

10. Subsystem
  • It represents the boundary of the physical subsystem.
Properties

NameIt is the name of the subsystem.
ParentThe element that contains subsystem.
DocumentationDescription of subsystem.
AbstractIf it's true, the subsystem does not provide a complete declaration and can typically not be instantiated. It is intended to be used by other subsystems.
LeafIt indicates whether it is possible to further specialize a subsystem.
RootIt indicates whether the subsystem has no ancestors. (True for no ancestors)
OperationsIt is a behavioral feature of a subsystem that specifies the name, type, parameters and constraints for invoking an associated behavior.
It refers to the operations owned by the subsystem.
ChildrenThe children of subsystem.

Explain in brief new features of UML 2.0.

What is UML?
  • UML stands for Unified Modeling Language.
  • It is a standard notation for the modeling of real world objects as a first step in developing an object-oriented methodology.
  • It is a general purpose, developmental, modeling language in the field of software engineering, which is intended to provide a standard way to visualize the design of a system.
  • It is a standard visual modeling language which is used for modeling business and similar processes. Analysis, design and implementation of software based systems.
  • It is a standard modeling language, not a software development process.
  • It is intentionally process independent and could be applied in the context of different processes.
Highlights in UML 2.0
  • Increased level of precision to better support MDD.
  • Improved language organization.
  • Improved support for modeling large-scale software systems.
  • Improved support for defining domain-specific languages (DSLs).
  • Modularized structure.
  • Simplified compliance model for easier interworking.
  • Modeling complex software structure and end–to–end behavior.
  • More precise definitions of concepts and their relationships.
  • Modeling of distributed concurrent process flows.
Why UML 2.0?
  • It becomes the most successful modeling language in the history of computing technology.
  • It is widely known, used and supported in tools.
  • It is an international standard.
Features of UML 2.0
  • The UML 2.0 Infrastructure, defines the basic constructs of the language in which UML is based.
  • The UML 2.0 Superstructure defines the user constructs of UML 2.0, that means those elements of UML that users will use at the immediate level.
  • UML infrastructure provides a reusable meta-language core. It is used to define UML itself.
  • It provides a mechanism for adjusting the language.
  • UML superstructure provides better support for component-based development.
  • It constructs for the specification of the architecture.
  • It provides better options for the modeling of behavior.
  • It adds the definition of formal and completely defined semantics.

Which are the various structural diagrams in UML 2.0? Explain role of each diagram in brief.

What is UML?
  • UML stands for Unified Modeling Language.
  • It is a standard notation for the modeling of real world objects as a first step in developing an object-oriented methodology.
  • It is a general purpose, developmental, modeling language in the field of software engineering, which is intended to provide a standard way to visualize the design of a system.
  • It is a standard visual modeling language which is used for modeling business and similar processes. Analysis, design and implementation of software based systems.
  • It is a standard modeling language, not a software development process.
  • It is intentionally process independent and could be applied in the context of different processes.
Structural diagrams in UML 2.0

Structure types

1. Class Diagram
  • It is the main building block of object-oriented modeling.
  • It is a type of static structure diagram that describes the structure of a system by showing the system's classes, their attributes, operations or methods and the relationships among objects.
  • The class diagram is used both general conceptual modeling of the systematics of the application and for detailed modeling translating the models into programming code.
  • It can also be used for data modeling.
  • It shows the structure of the designed system at the level of classes and interfaces.
class diagram
  • In the above figure shows that a class with three compartments. The classes are represented with boxes.
  • The top compartment contains the name of the class <<EmployeeDetails>>.
  • The middle compartment contains the attributes of the class <<name:String>>, <<location:String>>.
  • The bottom compartment contains the operations or methods the class can execute <<accept()>>, <<display()>>.
  • A number of classes are identified and grouped together in a class diagram that helps to determine the static relations between them.
2. Component Diagram
  • It depicts how components are wired together to form larger components and software systems.
  • It is used to illustrate the structure of arbitrarily complex systems.
  • It has a higher level of abstraction than a Class diagram.
  • It shows components, provided and required interfaces, ports and relationships between them.
  • This type of diagrams is used in Component-Based Development (CBD) to describe systems with Service-Oriented Architecture (SOA).
component_diagram

3. Deployment Diagram
  • It is used to visualize the topology of the physical components of a system where the software components are deployed.
  • These diagrams are used to describe the static deployment view of a system.
  • It consists of nodes and their relationships.
  • It used for describing the hardware components where software components are deployed.
  • It helps to model the physical aspect of an object-oriented software system.
  • It models the run-time configuration in a static view and visualizes the distribution of components in an application.
deployment diagram

4. Object Diagram
  • It is derived from class diagram, so the object diagrams are dependent upon class diagrams.
  • It represents an instance of a class diagram.
  • It is used to render a set of objects and their relationships as an instance.
  • It shows a snapshot of the detailed state of a system at a point in time.
object diagram

5. Package Diagram
  • It is a namespace which is used to group together elements that are semantically related and might change together.
  • It shows the arrangement and organization of model elements in middle to large scale project.
  • It can show both structure and dependencies between sub-systems or modules.
package diagram

6. Profile Diagram
  • It is a structure diagram that describes a lightweight extension mechanism to the UML by defining custom stereotypes, tagged values and constraints.
  • It allows adoption of the UML metamodel for different platform or domains.
  • It does not allow to modify existing metamodels or to create a new metamodels as MOF does.
  • It can be dynamically applied to or retracted from a mode.
  • It uses the same notation as a package, with the addition that the keyword 'profile' is used.
profile diagram

7. Composite Structure Diagram
  • It is a static structure diagram that shows the internal structure of a class.
  • It visualizes the internal structure of a class or collaboration.
  • It is a kind of the component diagram mainly used in modeling a system at micro point-of-view.
  • It shows the configuration and relationship of parts, that together, perform the behavior of the containing classifier.

Explain aggregation and composition with example.
OR
Compare with concepts and examples aggregation and composition in class diagram.

Aggregation
  • It is a special case of association where all objects have their own lifecycle.
  • It represents 'whole-part' or 'a-part-of' relationship.
  • Aggregation is represented by an empty diamond followed by a line.
aggregation
Example
  • A relationship between 'Department' and 'Employee'. An 'Employee' may belong to multiple departments. Hence, the 'Employee' is a part of multiple departments. If we delete 'Department', the 'Employee' object will not destroy.
aggregation example
  • Aggregation shows their obvious difference in terms of strength of the relationship.
  • It implies a relationship where the child cannot exist independent of the parent.
  • When an object 'has-a' another object, then you have got an aggregation between them. Direction between them specified which object contains the other object.
  • It is also called as 'Has-a' relationship. There are no any restrictions.
Composition
  • Composition is a specialized form of aggregation.
  • Composition is a strong type of aggregation.
  • In composition relationship, child objects do not have their lifecycle without parent object.
  • If a parent object is deleted, all its child objects will also be deleted.
  • It represents 'death' relationship.
  • Composition is represented by filled diamond followed by a line.
composition
Example
  • A relationship between House and Rooms. The house can contain multiple rooms there is no independent life of room and any room cannot belong to two different houses, if we delete the house, the room will automatically delete.
composition example
  • Composition is stronger than Aggregation.
  • An object associated with a composition relationship will not exist outside the containing object.
  • It implies a relationship where the child cannot exist independent of the parent.
  • It is also called as 'Is-a' relationship.
  • It is more restrictive.

What is OCL? Explain with an example.

  • OCL stands for Object Constraint Language.
  • It is an expression language for the Unified Modeling Language (UML).
  • It is a declarative language for describing the rules that apply to UML models.
  • It plays an important role in the analysis phase of the software lifecycle.
  • It is a formal language which is used to express side effect-free constraints.
Characteristics of OCL

1. Expression Language
  • Object Constraint Language (OCL) is a pure expression language.
  • An OCL expression guarantees to be without any side effect.
  • It cannot change anything in the model, that means the state of the system will never change because of an OCL expression.
2. Modeling Language
  • Object Constraint Language (OCL) is a modeling language, not a programming language.
  • It is not possible to write a program logic or flow of a program in OCL.
  • As a modeling language, all implementation issues are out of scope and cannot be expressed in OCL.
  • Each OCL expression is conceptually atomic.
  • The state of the objects in the system cannot change during the evaluation.
3. Formal Language
  • Object Constraint Language (OCL) is a formal language, where all constructs have a formally defined meaning.
  • The specification of OCL is a part of the UML specification.
Usage of OCL
  • It is used for specifying the invariants on classes and types in the class model.
  • It is used for describing pre and post conditions on operations, methods and guards.
  • It is used for specifying the constraints on operations.
  • It is used as a navigation language.