Hide menu

TDDE45 Software Design and Construction

Lab 2 — Reading Design

Code

You will be working with the FreeCol codebase, which resides locally at gitlab.

Assignment

The lab consists of finding out what design decisions have been made within the part of the application you are assigned to.

First, you will investigate the Java package that belongs to you and analyze it with respect to the design patterns you find, and detect three instances of design patterns in your parts designated packages. If you are unsure which packages belong to your part please see the table below.

Trivially, we may find examples of where the developers have used functionality from the base Java API to access elements of compound structures through the use of an Iterator, but what we would like to see if they have designed any part of the application-specific code according to existing design patterns.

To help you with the distinction, here is an example of what is interesting:

An implementation of the Iterator pattern for a custom data structure, where the developers of FreeCol have created the encapsulation of iteration logic in a custom Iterator class.

And here is an example of what is NOT interesting:

Simply listening for mouse events by using built-in listener interfaces in Java, or iterating over built-in Iterable collections in Java.

  1. That is, we would like you to identify at least three places in the code where it seems that the developers have solved a problem particular to FreeCol by implementing a good solution that also follows some design pattern. Identify at least three such locations. By location, we mean either a particular class and a (set of) methods in that class, or a collection of classes together.
  2. Second, we would like you to identify at least two locations where design decisions have been made that seem to violate the principles of SOLID, or general object-oriented programming principles.

Each group shall submit to the other two groups the locations where you have identified both good design and things you would like to improve. You shall NOT, however, reveal to one another WHAT DESIGN PATTERN OR DESIGN VIOLATION you believe you found at each location in the code base, only that you found A DESIGN PATTERN OR DESIGN VIOLATION. When you have received submissions from your peer groups, you shall review these suggested locations and try to find patterns or violations of some OOP design at these spots. During the seminar, you will get to sit down with your peer groups and have a discussion about each location, and what different subgroups found at each location. Even if you end up being wrong about some of your design patterns initially, it is not necessary to find new ones, rather it is the discussion of how and why your findings differed that is of importance. In your summary report, you shall reflect upon the findings you made as well as your peer groups.

Lastly, you shall write a summary regarding your own subgroup’s specific area, reflect on the possible differences in evaluating the code base, and submit your report to your teaching assistant.

In summary your task is the following:

  1. Together with your partner, inspect the code relevant to your subgroup area (you decide in your groups which pair performs which task):
    1. "Missions and Resources"
    2. "Model"
    3. "Communication and Stuff"
    Note the occurrences of where you find design patterns as well as where you find violations of SOLID or general OOP design.
  2. Notify the other subgroups in your project group (for instance, if you are in the "Model" group you notify the "Missions and Resources" and the "Communications and Stuff" group) about the location of your findings, but not what your findings were.
  3. Receive the notification about the other subgroups' findings, and see what you can find there.
  4. During the seminar for the lab, you will sit together with the three subgroups and discuss your findings all together. Did everyone find the same patterns and make the same observations? Remember to write down what your findings were so that you can discuss this during the seminar.
  5. Write a report regarding your findings and the other subgroups’ comments.
Missions and Resources Model Communications and Stuff
A list of packages belonging to each part. You do not have to consider sub-packages of the packages listed below, but you may need to understand some other sections of the code base to understand what is going on in your specific section of the code.
common.resources, common.model.mission, common.model.pathfinding common.model (not subpackages of common.model) common.networking, common.option, net.sf.freecol.util.test* (* in the test/src source folder)
A list of patterns that you are most likely to find (look for other patterns as well; you are allowed to find them)
  Facade Facade
Strategy Strategy Strategy
State State State
Template Method Template Method Template Method
  Memento  
Iterator Iterator Iterator
Composite Composite Composite
Builder Builder Builder
Factory method Factory method Factory method
Decorator Decorator Decorator
If you have trouble finding a starting point, look for inspiration in these questions (you do not need to answer these questions in the lab report; they are just here to guide your search for design patterns)
How does the game decide which path to take from one tile to another in the application? How are movements decided? How can the application switch from one way of calculating the cost of movement to another? Look at the common.model.pathfinding package for more information on this. How are game elements in the model serialized and deserialized when saving and loading a game, respectively? Look at the methods called read-something or write-something. How are server requests from a client to the server? Look at the methods in class common.networking.ServerAPI and the way methods in this class are invoked by other classes in the game. Find a suitable behavioral design pattern to describe the function of the class.
Look at the structure of (common.model.mission.CompoundMission). Is there a structural design that you recognize? How is the class model.TransactionListener used? What is its purpose? What is the purpose of the clone method in the common.option.AbstractOption class?

Use the questions above as a starting point, but do not expect them to show you all that you need to find in order to pass the assignment.

Tips

  • ObjectAid seems to no longer be active (domain expired during the course HT2021); it might work with older Eclipse versions if you can find the plugin. ObjectAid is a an Eclipse plugin that can help you create UML diagram from your project. This may help you with finding what you look for.
  • There is a plugin for IDEA that might work. module add prog/idea/2020.3.3 idea.sh. Use the UML generator plugin. However, the classes chosen to generate UML for need to be chosen carefully or the diagram explodes in size.
  • You may also want to try Papyrus Java reverse engineering (we did not test it since ObjectAid used to work very well).
  • If you need some inspiration for what SOLID violations are, watch Uncle Bob go through a few of them

Reporting your results

The submission of the lab report is done after the corresponding seminar (see the corresponding seminar for information to submit to the groups and seminar assistant). The report should contain:

  • A short description of the design patterns and SOLID violations that you believed that you found in your part of the code base and submitted to the two other pairs.
  • A description of how the code you found differed from canonical representations of the design patterns that are found as examples in the literature, on Wikipedia, and in the lecture material.
  • A reflection section should include a summary of whether your peers found the same patterns and SOLID violations in your section of the code base as you did, and if so, if they described their details in the same way. You do not need to write how the differences were solved in the other pairs' code.

Report your results to your teaching assistant. Consult the Staff page if you are unsure what this address is, and consult WebReg if you are not sure who your assistant is. In the subject line of your email, state clearly the name of the course and the name of the assignment as exemplified below:

Subject: [TDDE45] Submission Lab 2
(...)
Regards,
Name (student ID) and
Name (student ID)
Also clearly state your names and student IDs in any PDF (preferred format), linked files, or other submissions.

Page responsible: Adrian Pop
Last updated: 2022-08-13