Assignment Week 4 + 5

Assignment: Library Application: Working with other media besides book

Continue with the programming exercises from last weeks, if you haven't finished them yet. Here is the solution to exercise from the first week.

Up to now, the library application is only suited to deal with books, but not CDs, DVDs and journals. The next step will be to introduce CDs into the system and how to borrow them. CDs have a different behaviour from books, as they can only be borrowed for 1 week and not 4 weeks as with books. In addition, the fine need to be payed for overdue books is 200 kroner instead of just 100 kroner for books. Thus this week exercises contains in

Task: Add CDs to the library

Create a feature file similar to the add_book.feature file. Implement the corresponding step-definitions and the production code.

Task: Refactor LibraryApp

After implementing the tests for adding CDs to the library, one finds out that the current interface for the library application mentions books and CDs explicitly, although they should work for books as well as CDs, i.e. in principle, they work for the more general concept of medium (plural media). Thus, the goal is to \textbf{refactor} the application to cope with general media instead of just books

Steps

  1. Rename the operations and fields in LibraryApp and also any possible local variables and parameters from containg book/books to medium/media; Run all tests; fix any errors in the tests. Use the rename command of Eclipse (e.g. menu refactor::rename in the code view), which automatically also renames all uses of the method/field/variable.
  2. Rename Book to Medium; Run all tests. Use the rename command of Eclipse, which automatically also renames all uses of the class
  3. Make Medium an abstract class. A medium should not be instantiated, i.e. only for books (and later CDs) it should be possible to create objects
  4. Fix the compile time errors in the tests by replacing Medium with Book. This means, among others, to change the tests so that they create books again instead of just media (due to the renaming of Book to Medium)
    1. Use Eclipse to create a new class Book as subclass of Medium
    2. Use Eclipse to create the missing constructor for Book; Run all tests
  5. Make Cd a subclass of Medium (if it is not already).
  6. Redefine methods addCd and getCds to use addMedium and getMedia: This looks as follows:
       public void addCd(Cd aCd) { addMedium(aCd); }
       public List<Medium> getCds() { getMedia(); } 
    
    1. Note the change of the return type of getCds from List<Cd> to List<Medium>
    2. Don't forget to run the tests
    3. Select addCd and getCds in turn and select Refactor::inline in the code view. This will then replace addCd and getCs with their bodies addMedium and getMedia. Run the tests.

Task: Overdue CDs

Implement the feature "Overdue CDs", "Pay fine for overdue media", and "send e-mail reminder for overdue media". Create new Cucumber feature/scenarios and change existing ones as needed.

Assignment: Domain Model

Based on the description of the user requirements of the library application, create a domain model of the important terminology, i.e. a glossary and a class diagram showing the relationship between the terms of the glossary.

Here is a list of tools that you can use to create UML diagrams (class diagrams, as well as activity diagrams, and use case diagrams).

Assignment: Business Processes

Model the life cycle of a book using an activity diagram. Starting with the librarien getting the idea of aquiring a book, ordering $x$ copies of the book, registering the copies of the book in the library system, borrowring and returning the book by the user, to finally deregistering the book (maybe because it is damaged) to throwing the book away. Identify where within the life cycle of the book, an interaction with the library application happens.

Assignment: Use Case Diagram and Detailed Use Cases

  1. Provide a use case diagram showing the use cases of the library application based on the complete user requirements.
  2. Take one or two use cases (not trivial ones and not those for which you have already written Cucumber scnearios) and present detailed use case description for them as Cucumber features with main-, alternative-, and exceptional scenarios. Think about how the step definitions would look like.


On to Assignment Week 3 Part of Programming Exercise: A library application
Hubert Baumeister
April 23, 2018