#How to distribute responsability across controllers and services

36 messages · Page 1 of 1 (latest)

dark kestrel
#

Hi everyone , I am pretty new to this and I was wondering how do you separate your services and controller ? , let me explain for example i have a module called profile with contains a profile entity linked to a user(in a separate module) and then to a education[] and position[] entities (Think like a linkedin profile). So this module has only one service and one controller called ProfileService and ProfileController respectively and are interacting with the education and position entities through the service. Is it okay to handle those entities in one module , or should i create two more modules with their respective controllers and services for those entities ?

If you have any resources that could give me a better understanding on how to distribute the logic across controller and services i would gladly read them ! Thank you for reading 🙂

vestal grotto
#

Hi a good rule of thumb is one feature == one module

#

Just have a different module+service+(if needed)controller for each entity

#

Then you can have a profile service making calls to all other services

#

You can then import your profile module wherever you need

dark kestrel
#

Thank you for the response i will try that then 😄

fathom pulsar
#

I think your first solution is good @dark kestrel .
It's not like you need a service for each entity. If those entities are used only internally within ProfileModule then it's a perfect cohesion, and it's not true that you can call other services from profile service and let them call it other way because this sounds like you build highly coupled stuff

dark kestrel
#

Thanks Maciek ! Would you have any resources i could read , or public repos with examples to recommend ? I would greatly appreciate it !

fathom pulsar
#

This is also about Screaming Architecture.
Can you guess what an application with modules: Cats, Dogs, Users does?
Isn't it easier if we have Adoption, PetsRegistry, PotentionalOwners modules?
And we can change the purpose of the app by just changing Adoption to Sales!
#nestjs

GitHub

Contribute to Sikora00/ddd-by-examples-library-nestjs development by creating an account on GitHub.

dark kestrel
#

Thank you 😄 !

vestal grotto
#

I'm really into innovative paradigms but this tweet is somewhat half-baked

#

Can you guess what an application with modules: Cats, Dogs, Users does?
Not sure this is the decisive question to ask when defining your global architecture but ok

#

Isn't it easier if we have Adoption, PetsRegistry, PotentionalOwners modules?
This screams "hell incoming" to me

#

And we can change the purpose of the app by just changing Adoption to Sales!
Since when changing the purpose of the app is an upside of anything

#

Will read the github though 👍

#

Separating entities gives you dedicated spaces to handle upcoming features like having pages or stats about businesses/schools it's never a bad choice

fathom pulsar
fathom pulsar
fathom pulsar
# vestal grotto I'm really into innovative paradigms but this tweet is somewhat half-baked

It's also about DDD obviously (as the repo's name says). It's about bounded contexts, and also what can be easier distributed between different teams? Completely separated business sub-domains.
Or can you make a decision to put just part of the system into a different microservice when everything is so coupled with ProfileService?
A lot of patterns talk about it

vestal grotto
# fathom pulsar So you will you the same model for different purposes even if you different feat...

Have you ever look at a linkedin profile ? There is more than a User profile at work here. How would you ever display a list of known school or businesses?

Like Uber
Uber is the exact opposite of linked in terms of architecture and usage. Also I'll be damned if Uber renamed the TransportUser to DeliverFoodToUser, lol
Maybe from the ordinary Software Developer
Put your head down a little bit
Why
Show the entire content of one of these folder in one of your app

fathom pulsar
#

How would you ever display a list of known school or businesses?
You can create a different module that collects those data (maybe based on events, maybe other way). I definitely would not use the same School Service/Entity to do everything related to them

#

Uber is the exact opposite of linked in terms of architecture and usage.
No one is talking about LinkedIn here. I was just answering to your Since when changing the purpose of the app is an upside of anything

Also I'll be damned if Uber renamed the TransportUser to DeliverFoodToUser, lol
True, that is what I exactly said. You can change the purpose by an easy switch. Just modules have to be like Transport and Delivery, not based on entities like User and Food

#

I mean. Ok, I'm hiding something. Ofc there will be Food/User/Schoold module, but just for CRUD of those entities. Associations already have a purpose like Recruitment process and this is another module, not a part of Schools but I mentioned that already in the TT thread.

vestal grotto
#

Also I never said it was a bad paradigm (#1030727231099633704 message) I said the tweet you're quoting probably (hopefully) had understood nothing of it

fathom pulsar
#

Which paradigm do you mean and how do you think it should be understood?

vestal grotto
#

If the main selling point of a paradigm is "you can completely change what the app is about by renaming folder" it is a bad paradigm

#

Which tells me the tweet author didn't get it

#

hopefully

fathom pulsar
#

I never said that xd

#

In a single sentence you put 2 lies. I've never said it's the main selling point and all the more that it has anything to do with renaming folders.
I don't know who you're arguing with, but I guess I'll leave you alone

vestal grotto
#

Which is a pitch for the paradigm you linked just above

#

"ordinary Software Developer ", "lies" ... that's not a sane way to talk friend

#

Anyway if you have ever written a real-world app with this paradigm (which I'm not sure you did) you could share a bit of it would be interesting