Skip to content

Package By Architecture

Do This First...

Be sure to have completed prior labs before starting. You can also use the solution from the repository on GitHub and do a checkout of the tag lab3-start.

git checkout lab3-start

Start With Passing Tests

Make sure all tests pass before getting started on this lab.

Goal

Move classes (including tests) into separate packages, according to the Hexagonal Architecture.

Why: This will prepare us for the final step in separating the console I/O from the code in the Game class.

A. Re-package

Move Class Refactoring

You can use the F6 Move Class automated refactoring to move the classes to the new packages. You can also drag-and-drop the classes in the Project Window.

  • To see the roles of the classes in the codebase more clearly, move the classes to one of the following packages:

    • com.r2ha.blackjack.domain -- domain classes containing core entities with behavior.
    • com.r2ha.blackjack.adapter.in.console -- classes responsible for dealing with console I/O
  • Make sure to move the Test classes into their respective, matching packages as well.

B. Code Visibility

Violations

Game is still "polluted" with console I/O, so will continue to violate Hexagonal Architecture until we purify it in an upcoming lab.

You will find visibility issues as you do this, so be sure to fix up the code so everything compiles and all tests pass. You may have to temporarily compromise visibility problems, e.g., Game code will need to depend on code in the Console Adapter package, which is a violation of Hexagonal Architecture.

All Tests Should Pass

Make sure the code compiles and all tests pass when you're done.


You're Done

That's the end of this lab. Well done!

If you want to compare your solution with mine, you can checkout from the main repository using the tag lab3-solution.

git checkout lab3-solution