Require constructor parameters to avoid temporal coupling
Opened this issue · 4 comments
At this time the POJOs do not require any specific details on creation. However, the API calls require certain values to be present.
My suggestion would be to request the values required in the constructor to avoid temporal coupling and runtime errors.
@janoszen I think currently supported has validations for the required parameters. If I misunderstood your suggestion, could you please provide some code snippet to explain the idea?
For example:
class Droplet {
public Droplet(
String name,
String region,
String size,
String image
) {
//...
}
}
This would make it easier to use the API.
More about temporal coupling: https://hackernoon.com/api-design-temporal-coupling-2c1687173c7c
@janoszen Thank you for sharing your suggestion. It is helpful to define a constructor in the respective POJOs. I'm not sure when I can get to this suggestion; there are feature(s) should be added is in pending state.
FYI, the library already has validations in almost all methods I believe, for example -
@jeevatkm the point of not having temporal coupling is that you don't find out runtime that something is missing, the compiler tells you immediately that you are missing something. It reduces friction and the possibility of making a mistake. Anyway, it's just a suggestion because I ran into this issue.