You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am following django style guide which proposes use services like person_create and classroom_create. This is all working great, except now I am having trouble with functions that can handle multiple type's of instances.
For example, previously, I could pass in a type like Person / Classroom and then the fn could blind use t = Type(**kwargs), then t.save().
But how do I do this following django style guide, where there are person_create and classroom_create. This limited example has only two types, but what if there are N types that the shared fn can take in.
The text was updated successfully, but these errors were encountered:
@eddielu Hello and thank you for opening this issue 👋
I am not a 100% sure I understand what you are asking / implying, but I'll answer based on what I think it is:
The general idea of the service layer is to wrap all the related business / app / domain logic in once place.
This can lead you to the following extreme: Every model creation is happening in a separate service function. This is not very readable nor maintainable.
So if you need to create a person & create related classrooms for that person upon creation - you place that code there & don't extract it to a separate classroom_create.
Generally speaking, if you have to do something only in 1 place, there's no need to extract it, so it's reasuable.
Again, I'm not sure I completely understand your question, so if you can provide an example - I may be able to give you a better answer.
I am following django style guide which proposes use services like
person_create
andclassroom_create
. This is all working great, except now I am having trouble with functions that can handle multiple type's of instances.For example, previously, I could pass in a type like Person / Classroom and then the fn could blind use t = Type(**kwargs), then t.save().
But how do I do this following django style guide, where there are
person_create
andclassroom_create
. This limited example has only two types, but what if there are N types that the shared fn can take in.The text was updated successfully, but these errors were encountered: