This is applicable to any language, but I'm using Java for this so...
public class Egg {
...
}
public class BirdNest {
private List<Egg> eggs;
...
}
I also have database entities which match these classes. Basically, BirdNest
has 1:M relationship with Egg
.
To perform persistance/retrieval actions on these classes I also have a BirdNestService
and an EggService
.
Say I want to retrieve a list of eggs from a given bird nest.
I could have a method like List<Egg> getEggs (int birdNestId);
My question is, which service should methods like this belong to?
It's performing operations based on a particular bird nest so you could argue it should be part of the BirdNestService
.
Then again you could argue the item it is retrieving are Egg
's so it should belong to the EggService
.
Aucun commentaire:
Enregistrer un commentaire