differing behavior of Domain vs Command objects leads to problems.
- Dominant language
- Groovy
- Stars
- 2.9k
- Forks
- 975
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 92
Description
It seems to me, that the different interface of domain objects vs command objects arbitrarily breaks things that should not break. Surely the aim of object design is that objects that do similar things accept the same messages.
So domain objects have a member "constrainedProperties" that lists the constraints of that object.
Command objects have a member "constraintsMap" which appears to be the same thing, a Map between property name and a ConstrainedProperty object.
This is problematic. For example, let's say I'm using the fields plugin, and I write a template for a particular type of object that accesses the Nullable constraint...
` `
It works fine for domain objects. But now let's say I add a command object to my application, that happens to have a member of the type that triggers this template. Now the app will crash. If I change it from constrainedProperties to constraintsMap, now it will work for command objects, but not domain objects.
In my opinion the grails.validation.Validateable class should be changed to rename the constraintsMap member to be called constrainedProperties, to provide the same interface as domain objects. The old name could be left there for a while as a deprecated accessor.
- **Grails Version:** 4.0.11
### Example Application
Contributor guide
Research direction
Start at grails.validation.Validateable and inspect how its constraintsMap is exposed, comparing it with the constrainedProperties interface used by domain objects. Done means Validateable provides the common constrainedProperties name while retaining constraintsMap as a deprecated accessor, with behavior suitable for the fields-plugin example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- groovy
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100