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

Non CRUD method on model level (was Product uri generation should be on usecase? ) #1

Open
wejick opened this issue Apr 7, 2019 · 4 comments

Comments

@wejick
Copy link
Collaborator

wejick commented Apr 7, 2019

func (p Product) getURL(baseURL string) (result string) {

I think product link uri generation should be on usecase. It needs several logic not related on how we store product, like web, mobile, applink generation.

In general I would say non crud operation should not be here, we should have it on usecase or repository level (I prefer on usecase level tho).

@wejick wejick changed the title Product uri generation should be on usecase? Non CRUD method on model level (was Product uri generation should be on usecase? ) Apr 7, 2019
@wejick
Copy link
Collaborator Author

wejick commented Apr 7, 2019

@regalius
Copy link
Owner

regalius commented Apr 7, 2019

For me, simple getter method for a model is fine because eventhough it would be placed in the usecase, it'll be behaving the same anyway, plus, putting the getter & setter method in the model itself would make no code duplication.

Or if we don't want to have it in the model, we 'll need to populate it on the repository level (but of course it'll consume more memory for the struct)

@wejick
Copy link
Collaborator Author

wejick commented Apr 8, 2019

memory usage would be negligible and each storage may have different way to do it.

@regalius
Copy link
Owner

Then it is better to put it in the repository? and if usecase/delivery wants to change it then they can simply override it

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