Object-Oriented Software Engineering

This is an archived version of https://www.jhu-oose.com that I (Leandro Facchinetti) developed when teaching the course in the Fall of 2019. Some of the links may be broken.

Assignment 2: Design Principles

Working on the Assignment

OLID

60 points (15 points per principle)

In lecture we covered the S from SOLID. In your own words, explain the other four principles, OLID. Include an example in the explanation of each principle. Prefer examples extracted from TODOOSE, either because TODOOSE follows the principle, or because TODOOSE violates it. Examples may be class diagrams, code, or both. Discuss under which conditions you’d follow the principle, and under which conditions you wouldn’t.

Technology

⚠️  In this part of the assignment you’re going to work on the TODOOSE code base. Don’t Fork that repository on GitHub! Otherwise there’s a high probability that you’ll end up pushing your answers for the whole world to see, which violates the Academic Integrity policy. Work on the version of the code base you cloned by following the steps from Assignment 0.

Let’s explore some design principles in practice.

Add an Abstraction

20 points

The JSON response produced by the getAll action in the ItemsController relies on the internal representation of the Item model: the model includes the attributes identifier and description, so the JSON response looks like { "identifier": ___, "description": ___ }. The translation from model fields to JSON comes for free with the JSON mapper we’re using—we didn’t have to write any code for it.

This is good for a number of reasons:

But it can also be bad:

For this exercise you must modify the TODOOSE code base to introduce an explicit View abstraction:

  1. Create a com.jhuoose.todoose.views package.
  2. Create a ItemView class in that package. This class looks pretty much like the Item model, including the same attributes and getters and setters. It must also include a constructor that receives an Item and initializes the attributes accordingly.
  3. Modify the getAll() action in the ItemsController so that it passes to ctx.json() a list of ItemViews instead of a list of Items.

In your submission, show what changed in the code base. Then answer the following questions:

  1. Why does this change solve the issue of adding a password attribute to the model and not having it accidentally appear in the JSON response?
  2. Go over the list of principles on the lecture notes (including all of SOLID, not just the S that we covered in lecture). What principles were previously followed and are now violated?
  3. Go over the list of principles on the lecture notes (including all of SOLID, not just the S that we covered in lecture). What principles were violated and are now followed?
  4. If you had to choose, on which version of the code base would you prefer to work?

Remove an Abstraction

20 points

The ItemsController is very slim (few lines of code), and you may argue that it confuses you when trying to make sense of TODOOSE. Since for now the application is so small, you may be right. Change the code base to inline the actions directly into the Server class. This is similar to how the action is written in the first example of the Javalin webpage.

In your submission, show what changed in the code base. Then answer the following questions:

  1. Go over the list of principles on the lecture notes (including all of SOLID, not just the S that we covered in lecture). What principles were previously followed and are now violated?
  2. Go over the list of principles on the lecture notes (including all of SOLID, not just the S that we covered in lecture). What principles were violated and are now followed?
  3. If you had to choose, on which version of the code base would you prefer to work?

Submission

⚠️  Your assignment is submitted only when you submit the form below.

Assignment

For example, jhu-oose-example-student.
Don’t include an @ sign at the beginning—this isn’t a mention.
GitHub identifiers do not start with 2019-student-.

For example, 48092726db45fd4bcde21e3712ac2d8e4a094797.
Graders will look at the code base as of this commit.
The code base as of this commit must include the filled in template at assignments/2.md.
You may find the commit identifier on the commits page at https://github.com/jhu-oose/2019-student-<identifier>/commits/master. Usually you want the most recent commit.

Anonymous Feedback on Lecture 2

Confidence


Relevance


Difficulty


Pace


Anonymous Feedback on Assignment 2

Confidence


Relevance


Difficulty


Load


⚠️  Don’t submit this form multiple times.

If you run into problems, send an email to assignment-submission@jhu-oose.com. Include the information about the submission: your GitHub Identifier and the Commit Identifier. Don’t include any information about the feedback—it’s anonymous.