3 ms·
Yeah I think it's a bit of a stretch to try to combine all these ideas under a single name. One guideline I would follow is: Statically type everything that a
by Diggsey 4y ago
Yeah I think it's a bit of a stretch to try to combine all these ideas under a single name.
One guideline I would follow is:
Statically type everything that a service needs to inspect to do its job, and no more, but without introducing a layering violation.
So, for example if a component accepts this input:
{
"timestamp": "2022-06-17 00:00:00",
"data": {
...
}
}
If it only uses "timestamp" to decide whether to discard the input, and then passes "data" to some other service, you would definitely want to make timestamp be a "datetime" type rather than a string. "data" should be an arbitrary JSON value, but it should still be parsed as JSON, just no additional structure enforced.
- swatcoder 4y agoI wish real projects were so simple! Guidelines like this are operating on something like the Platonic ideal shape of problems. In any real world project, you need to consider the cost of handing a malformed `data` blob downstream, as it's never free. Architectural model or pattern might be a better word than guideline. You benefit by collecting a catalog of patterns more than you do by trying to internalize guidelines.