Skip to content

Work with abstractions instead of concrete classes. #602

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
andreygfranca opened this issue Jan 25, 2022 · 1 comment
Closed

Work with abstractions instead of concrete classes. #602

andreygfranca opened this issue Jan 25, 2022 · 1 comment
Assignees
Labels
status: declined A suggestion or change that we don't feel we should currently apply

Comments

@andreygfranca
Copy link

Expected Behavior
Hello, first of all, nice work you guys are doing,
That being said it would be very interesting to be able to expose some classes as interfaces so that we can create our own implementation and then the respective repositories would not be coupled to any concrete class (current behavior), as we would be working with abstractions. For example, the following classes could be interfaces:

  • RegisteredClient
  • OAuth2AuthorizationConsent
  • OAuth2Authorization

Current Behavior
We have the repositories/services coupled to concrete classes instead of abstractions: OAuth2AuthorizationService, OAuth2AuthorizationConsentService, and RegisteredClientRepository.

Context
I'm implementing the domain entities with JPA, but the services and repositories are coupled with concrete classes which makes it difficult for me to extend the current behavior

@andreygfranca andreygfranca added the type: enhancement A general enhancement label Jan 25, 2022
@sjohnr sjohnr self-assigned this Jan 25, 2022
@sjohnr
Copy link
Member

sjohnr commented Jan 25, 2022

@andreygfranca thanks for your interest in the project!

Please see this comment, which states:

Interfaces allow for multiple implementations but RegisteredClient is not intended to have multiple implementations. However, you'll notice that RegisteredClient has a protected constructor as well as the Builder, allowing for extension outside of the framework. At this point, I don't see more than one implementation of RegisteredClient within the framework.

Furthermore, RegisteredClient is a domain-specific model and is not intended to serve as a one-to-one mapping to an entity model. I personally don't like to mix domain model with entity model. The underlying implementation that manages the RegisteredClient ( the RegisteredClientRepository) would be responsible for mapping the domain object to an entity object suitable for the datastore, eg. JPA, Redis (key-value store), etc.

Also, see the following github gists for examples of how to do this:

We are also working on two additional efforts that you may be interested in. The above gists are being incorporated into a how-to guide. See #545 for a rough draft of the guide. Also, see #558 for discussion on supporting transformations to/from JSON, and #588 for a possible solution that could also provide support for JPA implementations.

As I don't believe it is our intention to switch these classes to interfaces, I'm going to close this issue for now. But we do appreciate the feedback, and welcome thoughts on the above links which may be of interest to you.

@sjohnr sjohnr closed this as completed Jan 25, 2022
@sjohnr sjohnr added status: declined A suggestion or change that we don't feel we should currently apply and removed type: enhancement A general enhancement labels Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply
Projects
None yet
Development

No branches or pull requests

2 participants