Timeline for Does using the strategy pattern for persistence methods make it "okay" to include CRUD methods in a business object?
Current License: CC BY-SA 3.0
14 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
May 8, 2017 at 21:24 | audit | Close votes | |||
May 8, 2017 at 21:25 | |||||
Apr 20, 2017 at 14:28 | vote | accept | TheCatWhisperer | ||
Apr 20, 2017 at 14:28 | comment | added | TheCatWhisperer | Alaun, this is an academic discussion. I always just use an external repository ;) | |
Apr 20, 2017 at 2:44 | comment | added | Aluan Haddad | The main reason I didn't write it as an answer is that I want to see an example use case before coming to a conclusion. | |
Apr 19, 2017 at 15:44 | history | tweeted | twitter.com/StackSoftEng/status/854722446246772736 | ||
Apr 19, 2017 at 15:34 | comment | added | TheCatWhisperer | Aluan, I like the points in your first comment, I am not sure why you did not post it as an answer? Yes, I think it is partly premature optimization, but also just plan not understanding how to separate business logic and what it constitutes. | |
Apr 18, 2017 at 23:35 | comment | added | Aluan Haddad | By the way, I really like this question and I agree with you about the repository pattern. The business logic creep oft comes from premature optimization. | |
Apr 18, 2017 at 23:29 | comment | added | Aluan Haddad |
Since you have inverted control by using the strategy pattern, what is the benefit of having a reference to the persister, which probably should just be a function, inside the business object? Basically when you call Save you are just raising, as you say, a TimeToSave event. However, a smart persister is going to batch this request, cache it, and may in fact decide not to call it because some other state has changed. This could lead to confusing code where from the entity's point of view it has been persisted but it actually hasn't been. I'd be curious to see your intended usage pattern.
|
|
Apr 18, 2017 at 21:16 | answer | added | Ben Cottrell | timeline score: 6 | |
Apr 18, 2017 at 20:08 | answer | added | Andy | timeline score: 8 | |
Apr 18, 2017 at 19:56 | history | edited | TheCatWhisperer | CC BY-SA 3.0 |
deleted 15 characters in body
|
Apr 18, 2017 at 18:20 | history | edited | TheCatWhisperer | CC BY-SA 3.0 |
deleted 1 character in body
|
Apr 18, 2017 at 18:17 | answer | added | TheCatWhisperer | timeline score: 3 | |
Apr 18, 2017 at 18:13 | history | asked | TheCatWhisperer | CC BY-SA 3.0 |