---
# System prepended metadata

title: 'ESOF 422: Advanced Software Engineering Homework 4'

---

# ESOF 422: Advanced Software Engineering Homework 4

Sam Behrens and Karl Molina

## Singleton

### SPS With Realization

![](https://i.imgur.com/x9IuXAH.png)

### SPS With Near-Instance Realization

![](https://i.imgur.com/Udksi6J.png)

This near-instance realization violates the SPS model because it has an array of current presidents implying that more than one can exist.

## Visitor Pattern

### SPS With Realization
This SPS is from Figure 11 in France, Robert B., et al. "A UML-based pattern specification technique." IEEE transactions on Software Engineering 30.3 (2004): 193-206.
![](https://i.imgur.com/F0D3lLB.png)

### SPS With Near-Instance Realization

![](https://i.imgur.com/QRpQFCx.png)

This near-instance realization violates the SPS model because it has no Concrete Visitors that implement the Visitor interface. The SPS model specifies that there must be one or more Concrete Visitors.

## State Pattern

### SPS With Realization

![](https://i.imgur.com/b3ZdZNI.png)

### SPS With Near-Instance Realization

![](https://i.imgur.com/skrejbr.png)

This realization is a near-instance realization of the SPS model because it has two contexts (Poodle and Labrador) when the SPS model specifies that it can only have one.

## Iterator Pattern

### SPS With Realization

![](https://i.imgur.com/4aLVUk0.png)

### SPS With Near-Instance Realization

![](https://i.imgur.com/SdRIANF.png)

This example of a class diagram is a near-instance realization of the SPS model because the relationship between the ConcreteAggregate and the ConcreteIterator is composition and not aggregation.

## IPS diagram for the Visitor Pattern

This IPS implementation is from Figure 13 in France, Robert B., et al. "A UML-based pattern specification technique." IEEE transactions on Software Engineering 30.3 (2004): 193-206. 

![](https://i.imgur.com/eaeE3Y7.png)

## Question 3

### i) What does it mean to state that RBML characterizes pattern instances? (2 pts)

RBML defines how a pattern instance, or realization must be structured and how it interacts with itself.

### ii) What does it mean to say that RBML defines a specialization of UML at the M2 level? (2 pts)

There are a hierarchy of models and their metamodels which are labeled by different M levels. Object diagrams are at the M0 level. Object diagrams are instances of class diagrams which are at the M1 level. Class diagrams are instances of RBML diagrams which are at the M2 level. 

### iii) Select one RBML model from your answers in question 1, and provide two examples of operation templates with pre and post conditions. (2 pts)

Operation templates for the Iterator Pattern RBML model:

```
context |Aggregate::|Iterator()
    pre: true
    post: result.oclIsTypeOf(Iterator)
```

```
context |Iterator::|Next()
    pre: true
    post: result <> result@pre
```