Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Advanced Software Design Techniques

Gamification Framework

Goal Frameworks are more important for the extension points that they have
than from the functionality that they provide. The goal of this lab is to create
a framework for gamification, using the techniques learned to create the
extension points.

Domain: The goal is to create a framework for an application to introduce a


Task gamification process in its execution. The framework should allow its
extension to introduce rules for adding points based on tasks executed.

General Vision: The following are some classes from the framework API:

• Task: an interface to be implemented by the application to add


domain-specific logic. It represents something in the application that
can worth rewards in the gamification system.
• User: represents a user from the system. It can have points and
badges.
• UserRegistry: this class is used to configure the user for the current
thread (see tips about how to do that).
• GamificationFacade: this class is used to configure the gamification
rules and execute the tasks. It should be a Singleton.
• GameRule: An instance of this interface can be associated with the
class of a Task, and should be executed every time that a Task of
that class is executed. For instance, the implementation can add or
remove points and gives badges for the current user.

Testing: It should be provided automated tests to test the framework.


Interface Task that should be implemented by the application that
implements the framework, should be mocked in the tests (use Mock
objects to replace them).

Test cases: These are some common usages of the framework that you can
use as a reference to create your tests: (a) gain points when you execute a
given task; (b) lose points depending on the task return; (c) win a badge
when the task throw an exception;
Spec Task (interface): Have an execute() method that return Object and can
throw FailedExecutionException.

User (class): Should provide the user name, how many points and the
badges that the user have. Should also provide methods to add and remove
points and add and remove badges. It also needs to be able to return the
last number of points set and the last badge that he got. The student should
design the class API.

UserRegistry (class): It should have the methods setCurrentUser(User) and


getCurrentUser(). Look on the tips to see how to use ThreadLocal for this
implementation.

GamificationFacade (class): This class should be a singleton and have the


following methods:
• void setGameRule(GameRule, Class<? extends Task>) -> associate a
GameRule the a Task class. More than one GameRule can be
associated with same Task class.
• Object execute(Task) -> Execute the Task with the implementations
of GameRule associated.

GameRule: An interface that should be able to execute logic to add or


remove points before and after a Task is executed. The execution might
depend on the return of the execute() method from Task, and even be
conditioned by the occurrence of an exception. The student should design
the interface API. At least 3 different implementations should be given as
part of the framework class library.

Delivery This exercise can be delivered with just the code and also with the
documentation:

Code – You should upload a .zip file with the complete source code
developed – also add a screenshot of the tests running.

Documentation - You should upload a .pdf file with the documentation of


your framework. It should be focused on framework users and not a
teacher. It needs to have a “hello world”, a description of the framework
features, a description of the classes provided with the framework class
library, examples of the frameworks usage and a class diagram presenting
the framework structure.
Tips ThreadLocal: The class ThreadLocal from the Java API can be used to set a
value that is valid for the current thread. It is like a “singleton for the
thread”. Encapsulate an instance of ThreadLocal inside UserRegistry to be
able to set and retrieve an user that is different for each thread.

Mock Objects: You can create the Mock objects yourself, but if you prefer
you can also use a mock framework such as JMock or Mockito.

Recursive Composition: There can be several implementations of GameRule


associated with one task. That is a good opportunity to use patterns that use
recursive composition such as Composite, Chain of Responsibility or
Proxy/Decorator.

Rules You cannot do: Copy any part of the code created by another student; Look
at the code of another student before finishing; copy the API design of
another student.

You can do: Ask help for debugging; help another student to debug after
finishing your own.

You might also like