Skip to content
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

Class under the domain/model path is "Anemia model"? #50

Open
johnlee175 opened this issue Mar 16, 2021 · 4 comments
Open

Class under the domain/model path is "Anemia model"? #50

johnlee175 opened this issue Mar 16, 2021 · 4 comments

Comments

@johnlee175
Copy link

johnlee175 commented Mar 16, 2021

Like:
class Cargo { public TrackingId trackingId() { return trackingId; } public Location origin() { return origin; } public Delivery delivery() { return delivery; } public RouteSpecification routeSpecification() { return routeSpecification; } }

Additional, I‘m newer, and I found Entity interface, why no Aggregate interface?

@wtjones
Copy link

wtjones commented Mar 16, 2021

The getters listed allow for private setters.

  • Location may only be set in the ctor.
  • Delivery is set in either the ctor or via specifyNewRoute().

This pattern relates to anti-corruption of the domain model.

@wtjones
Copy link

wtjones commented Mar 16, 2021

In this example the aggregates are implied rather than explicit via interfaces. A matter of preference I suppose.

The domain layer is the heart of the software, and this is where the interesting stuff happens.
	There is one package per aggregate, and to each aggregate belongs entities, value objects, domain events,
	a repository interface and sometimes factories.

The domain layer is the heart of the software, and this is where the interesting stuff happens.

@johnlee175
Copy link
Author

In this example the aggregates are implied rather than explicit via interfaces. A matter of preference I suppose.

The domain layer is the heart of the software, and this is where the interesting stuff happens.
	There is one package per aggregate, and to each aggregate belongs entities, value objects, domain events,
	a repository interface and sometimes factories.

The domain layer is the heart of the software, and this is where the interesting stuff happens.

I see, thanks very much!

@johnlee175
Copy link
Author

johnlee175 commented Mar 18, 2021

The getters listed allow for private setters.

  • Location may only be set in the ctor.
  • Delivery is set in either the ctor or via specifyNewRoute().

This pattern relates to anti-corruption of the domain model.

specifyNewRoute() is ok. But here( application layer),
CargoInspectionServiceImpl.java:

public class CargoInspectionServiceImpl implements CargoInspectionService {
// ...
    if (cargo.delivery().isMisdirected()) {
      applicationEvents.cargoWasMisdirected(cargo);
    }

    if (cargo.delivery().isUnloadedAtDestination()) {
      applicationEvents.cargoHasArrived(cargo);
    }
// ...
}

is the following approach bad? (Law of Demeter, Encapsulate logic to the target object)

public class CargoInspectionServiceImpl implements CargoInspectionService {
// ...
    cargo.misdirectedIfNeeds(); // and publish event in domain
// ... or
    if (cargo.isUnloadedAtDestination()) { // should application know delivery?
      applicationEvents.cargoHasArrived(cargo);
    }
// ...
}

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

No branches or pull requests

2 participants