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

[FEEDBACK] Can cover your thoughts on value object? #23

Open
simkimsia opened this issue Apr 23, 2020 · 2 comments
Open

[FEEDBACK] Can cover your thoughts on value object? #23

simkimsia opened this issue Apr 23, 2020 · 2 comments

Comments

@simkimsia
Copy link
Contributor

Hi there, i like what you're trying to do with modernising django to use DDD

There's another DDD related book called cosmic python whose authors recommend this DDD pattern called value object

They use python 3.7 dataclass and froze it.

Was wondering if you will cover on how to use value object in Django context. (At least >= Django 2.2)

Here's the relevant line https://github.com/cosmicpython/book/blob/3008a8a4be52e8dcaf5cb7447dd7f2b26f5d9b7d/chapter_01_domain_model.asciidoc#dataclasses-are-great-for-value-objects

@phalt
Copy link
Owner

phalt commented Apr 27, 2020

I'll give it a read and give my opinion. From a brief glance I can't see what more it provides than a Django model, but it does provide a way to make a typed object nicely.

@simkimsia
Copy link
Contributor Author

simkimsia commented Apr 28, 2020

Thanks. I have a related follow up question.

Which is that how do you handle certain "types" or "status"? Do you store them in database as standalone tables? I posed a similar question to the cosmicpython team as well at cosmicpython/book#288

But I want to hear your thoughts as you're more familiar with Django whereas they're more familiar with Flask.

An example

let's say you have a Batch Django model, needs to have an attribute of string type called state with the following values: fulfilled, partial, unfulfilled, cancelled as the only possibilities. Do you have the state as its own individual data table and therefore Django model? If so, do you use the primary key inside Batch table or simply the value itself?

What happens if two entities (in the DDD sense) share the same state field?

Thank you. Looking forward to your reply :)

Awesome style guide by the way 🙏 I think it's great especially the part abt the philosophy on how Django should focus on being a great REST or GraphQL server. That's what attracted me to your styleguide. i.e. the two big problems in the intro. https://github.com/phalt/django-api-domains#introduction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants