BSc in Applied Computing Year 2

Software Systems DesignAutumn 2007

2 hour examination

Intern Examiner: Ian Downey

Question 1

(a)Explain what, in software development is meant by

(i)architecture,

(3 marks)

The software architecture of a program or computing system is the
structure or structures of the system, which comprise software
elements, the externally visible properties of those elements, and
the relationships between them. The term also refers to documentation
of a system's software architecture. Documenting software
architecture facilitates communication between stakeholders,
documents early decisions about high-level design, and allows reuse
of design components and patterns among projects.

(ii)abstract class and

(3 marks)

A class that should never be instantiated; only its subclasses should be instantiated. Abstract classes are defined so that other classes can inherit from them.

(iii)concrete class

(3 marks)

A class that can have direct instances.

(b)Now explain what is meant by a software framework

(8 marks)

A software framework is a reusable design for a software system (or
subsystem). This is expressed as a set of abstract classes and the way their instances collaborate for a specific type of software. All software frameworks are object-oriented designs. Although designs don't have to be implemented in an object-oriented language, they usually are.

For example, a software framework can be geared toward building
graphical editors for different domains like artistic drawing, music
composition, and mechanical CAD. Another software framework can help build compilers for different programming languages and target machines. Yet another might help build financial modelling applications or decision support systems.

(c)Discuss how a software framework could be designed to allow the

generation of board games such as noughts and crosses or chess.

(8 marks)

Based on one of four major case studies that we did in class.

The student might refer to the fact that each game involves a square squared board and tokens, each as two players. Each has proposed moves that will either by validated, and allowed, by the game or disallowed etc.

Question 2

(a)Explain what is meant by an assertion in software development?

(4 marks)

An assertion is a boolean statement that should never be false and, therefore, will only be false because of a bug. Typically, assertions are checked only during debug and are not checked during production execution.

(b)Name and describe three types of assertion.

(6 marks)

pre-condition, post-condition and invariant.

(c)Explain what is meant by subclassing.

(5 marks)

Subclassing is where a particular class is made to inherit some or all of the properties, whether attributes or behaviours, of another class. The subclass’s programmer can then chose to override some of the super class’s behaviours. An example of subclassing might be where we have a class to model washing machines and want another class for washing machines with a spinning function. The second class can be a subclass of the first.

(d) Designing assertions has implications for subclassing. Explain

carefully what they are.

(10 marks)

One of the dangers of polymorphism is that you could redefine a subclass's operations to be inconsistent with the superclass's operations. Assertions stop you from doing this. The invariants and post-conditions of a class must apply to all subclasses. The subclasses can choose to strengthen these assertions, but they cannot weaken them. The pre-condition, on the other hand, cannot be strengthened but may be weakened.

This looks odd at first, but it is important to allow dynamic binding. You should always be able to treat a subclass object as if it were an instance of the superclass (the principle of substitutability). If a subclass strengthened its pre-condition, then a superclass operation could fail when applied to the subclass.

Essentially, you must look at the assertions that go with thesubclass to ensure that theresponsibilities of any subclass are either as great as or greater than the superclass. Pre-conditions are a statement of passing a responsibility on to the caller; you increase the responsibility of a class by weakening a pre-condition. In practice, all of this allows much better control of subclassing and helps you to ensure that subclasses behave properly.

(Total 25 marks)

Question 3

(a) Explain the following terms: association, generalisation, dependency and

realisation and show the symbols used for each.

(5 marks)

Association is where an object of one class may be association with 0 or more objects of another class etc.

Association with navigability says further that that one object can tell you the 0 or more with which it’s associated

Generalisation is where one class has others inheriting from it.

Realisation is where a class realises an interface

Dependency of A to B means that if B changes, A may need to change as well but not the other way round. The line is
always from the class that is dependent to the one which it is dependent on.

(b) “The art of large scale design largely involves reducing dependencies.”
Discussthe previous sentence.

(5 marks)

This is to a large extent true. We want to achieve a situation where changes to one piece of code will have limited and traceable possible changes to other pieces of code. In the case of packages, we’d like to ensure that each package is cohesive and has limited coupling to other packages. We could go further and suggest that only a few classes in a package should have dependencies with other packages and act on behalf of their shyer companions in a package.

In small enough projects it doesn’t matter too much how you design the software; you’ll manage to trace all the dependencies. With larger projects, it can be shown, by mathematics, that dependencies, if left uncontrolled, can multiply exponentially, or worse, so conscious steps must be taken to limit dependencies.

(c)Describe all the elements of UML syntaxin the following diagram and hence

explain what it represents.

(15 marks)

We see packages within packages. There’s a customers package for instance and a broken arrow pointing at it from the Mailing List Application. This implies that there is at least one class in the Mailing List Application that depends on at least one class in the Domain package. Given that we don’t show the internals of all packages save for the Domain package, we could suppress the details of that one too and show only two arrows touching the periphery of the domain package. The details of what’s inside the domain package could then be shown on a separate diagram.

The diagram overall shows a four or five tier system where the top row of three packages shows the UI layer, with dependencies on Java’s Abstract Windowing Toolkit to provide the Windows elements such as frames and checkboxes. The layer below is the application layer which provides user applications both of which use the one domain layer to get information and to update information. Persistence is provided by the bottom layer which shows the domain interacting with an abstract database that can map on to a specific database. The left pointing closed un-shaded arrow shows inheritance. A constraint is shown in the Database Interface package, using the official UML notation for this, a set of braces. This constraint tells us that the Database Interface package is abstract. There’s a package containing general utility classes shown on the bottom left of the diagram. There are too many possible dependencies to that package to make it worthwhile showing them.

(Total 25 marks)

Question 4

Consider the following outline software.

public class PhenomenonType extends DomainObject{

public void phenomenonAdd(Phenomenon additionalPhenomenon){

phenomenaList.addElement(additonalPhenomenon);

}

public void setPhenomena(String [] names){

for (int i = 0; i < names.length; i++;)

new Phenomenon(names [i], this);

}

public Enumeration phenomena(){

return phenomenaList.elements();

}

private Vector phenomenaList = new Vector();

}

public class Phenomenon extends DomainObject{

public Phenomenon(String name, PhenomenonType type){

phenType = type;

phenType.phenomononAdd(this);

}

private PhenomenonType phenType;

}

(a)Draw a UML-compliant class diagram, at implementation stage, that

represents the software.

(8 marks)

Here is a diagram that the candidate might draw:

The candidate would have to add extra lines to this diagram to represent the methods and attributes, (but not setter and getter methods).

(b)Explain all the syntax elements of your diagram.

(8 marks)

The diagram shows that every PhenomenonType has zero or more Phenomema associated with it and that each Phenomenon is indexed by passing a String to PhenonemonType.

The top panel in each box is to contain the name of the Class, the second panel its attributes and the third panel its operations.

(c)Write fragments of Java code to use the outline class software above.

(9 marks)

PhenomenonType bloodGroup = new PhenomenonType();
new Phenomenon(“group a”, bloodGroup);
new Phenomenon(“group b”, bloodGroup);
String [] yetMoreBloodGroups = {"group c", "group d"};
bloodGroup.setPhenomena(yetMoreBloodGroups);

PhenomenonType sex = new PhenomenonType();
new Phenomenon(“male”, sex);
new Phenomenon(“female”, sex);

(Total 25 marks)

Question 5

(a)Describe how to use the two physical diagrams that UML makes available

to developers to help them represent their ideas.

(10 marks)

These are used when you want to show physical information that's different from the associated logical information, represented on a package diagram.

There are two types of physical diagram provided in the UML

  • component diagram
  • deployment diagram

Very often component diagrams are nested inside deployment diagrams.

Component diagrams have two main symbols: a rectangle with two little rectangles down the left side, representing a component, and a broken open-arrowed line. As in package diagrams, the line represents dependency, the non-arrowed end depending on the arrowed end. Very often components are identical to packages but sometimes they're not. A package may be spread across two or, exceptionally, three components according to how the system is delivered to the customer and eventually deployed on one computer or the other.

Deployment diagrams have two main symbols: a three dimensional box, representing a node, and a solid un-arrowed line. A node is a computational unit of some sort from a mainframe at one end of the scale down to a sensor at the other. Normally however a node has some sort of memory. The lines between the nodes represent wired or wireless communication pathways.

Lines may be stereotyped (using the UML approved <...> delimiters). For example, on the diagram below, you can see the stereotype:

<jdbc:mysql> meaning that the connection is the abstract java data base connectivity actually realised by a driver for the mysql data base package.

(b)Draw a physical diagram to represent a web site with a SQL based relational database backend while it is being tested in the place where it is being developed.

(10 marks)

(c) Draw a physical diagram to represent a web site with a SQL based relational database back end when it is in full deployment.

(5 marks)

(Total 25 marks)

BSc in AC Year 2 Autumn 20071Software Systems Design, Ian Downey