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
let's say your Batch in the book, needs to have an attribute of string type called state with the following values: fulfilled, partial, unfulfilled, cancelled as the only possibilities
How do you represent those values?
Do you use value objects? Do you use them as value objects and also store the values in the database in their own tables? I know for sure you will have to store the value within the Batch table
If these should be value objects, maybe that might make #237 issue more solvable
Because it's natural to think that fulfilled is > partial and partial is > unfulfilled though cancelled is not meant to be meaningfully compared with any of the three.
I would usually store the values in the database in the same row as the containing entity, and map those back to value objects in code. Enums, for example, are a kind of value object, and SqlAlchemy has support for converting them to and from database tables.
What if the same enums are used in more than one containing entity?
E.g. you have Batch and also Order in the same domain context using the enum days. Sorry I know this is a very forced example because your book separates teh allocation domain from the customer purchasing domain. But I'm thinking out loud.
SO basically both Batch and Order has a string attribute called day_of_week and both entities allow that attribute to have any value from Monday to Sunday.
Would you still handle it the same way?
What if one containing entity only allows a subset of the full list of the possible values?
And does this mean that when you use value object and not stored in database, you're essentially saying that the user cannot define new values for that particular value object?
How do you handle "types" or "states"?
Let me give you an example:
let's say your
Batch
in the book, needs to have an attribute of string type calledstate
with the following values:fulfilled
,partial
,unfulfilled
,cancelled
as the only possibilitiesHow do you represent those values?
Do you use value objects? Do you use them as value objects and also store the values in the database in their own tables? I know for sure you will have to store the value within the
Batch
tableIf these should be value objects, maybe that might make #237 issue more solvable
Because it's natural to think that fulfilled is > partial and partial is > unfulfilled though cancelled is not meant to be meaningfully compared with any of the three.
Perhaps the use of dry-python and result container might be interesting here https://github.com/dry-python/returns#result-container
The text was updated successfully, but these errors were encountered: