Skip to content

Conversation

jcfandino
Copy link
Contributor

  • So other applications can use this class

@jcfandino jcfandino force-pushed the remove-actionapp-dependency branch from 6a2bc45 to 017c3eb Compare December 27, 2023 20:31
@jcfandino jcfandino changed the title Make DisplaySettings use LegacyApplication instead of ActionApplication Make DisplaySettings use Application instead of ActionApplication Dec 27, 2023
- So other applications can use this class
@jcfandino jcfandino force-pushed the remove-actionapp-dependency branch from 017c3eb to aa0d469 Compare December 27, 2023 20:33
@stephengold
Copy link
Owner

The intent is for applications that use Acorus to extend ActionApplication.
This is an assumption made throughout the library.
What applications can't extend ActionApplication?

@jcfandino
Copy link
Contributor Author

The intent is for applications that use Acorus to extend ActionApplication.

That's unfortunate IMO.
Except for this dependency on ActionApplication this DisplaySettings is highly cohesive, it is a single unit with a well defined functionality.
The strong coupling with ActionApplication forces the client to become dependent on another part of the library and without any benefit.

Extending a class is perhaps the strongest coupling relation in java. So if I have to extend my main class it has to be for a very good reason.
ActionApplication brings a lot of functionality that I don't need so I want to avoid extending it. Maybe I will extend it in the future but that should be independent of using DisplaySettings or maybe I want to extend another abstract Application made by someone else.

What applications can't extend ActionApplication?

I'm working on an AppState that I intent to use first with my game and then others. So I want it to be as self-contained as possible, so it consists of a simple nifty-gui with some generic options.
So to follow the current library's design I should downcast the Application in the initialize() to an ActionApplication. And also I need to force every game I add this AppState to extend ActionApplication, otherwise I would get a runtime class cast exception.

The client of my app state shouldn't need to know about Acorus, for them it's just an implementation detail. They should just attach the state and done deal, everything is taking care of.
But if I were to leak this dependency I would totally break the high-cohesion/low-coupling I try to keep in my design.

@stephengold stephengold merged commit 4abf458 into stephengold:master Dec 28, 2023
@stephengold
Copy link
Owner

Thank you for your contribution. I'll put out a new release soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants