Timeline for Using static type checking to protect against business errors
Current License: CC BY-SA 4.0
12 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jul 6, 2018 at 20:19 | vote | accept | J-bob | ||
| Jul 6, 2018 at 20:16 | comment | added | J-bob |
@JohnWu yes your example will still compile, but that is the single point of failure for that logic. Once you declare your new Age(...) object you can't incorrectly assign it to a variable of type Weight in any other places. It reduces the number of places where mistakes can happen.
|
|
| Jul 4, 2018 at 19:00 | answer | added | Michał Kosmulski | timeline score: 2 | |
| Jul 3, 2018 at 13:41 | answer | added | Greg Burghardt | timeline score: 6 | |
| Jul 3, 2018 at 6:56 | comment | added | Euphoric | What you are talking about is great way to do design! Sadly, Java has so primitive type system that it is difficult do right. And even if you try to do it, it might result in side-effects like lower performance or lower developer productivity. | |
| Jul 3, 2018 at 5:47 | history | tweeted | twitter.com/StackSoftEng/status/1014022923563274240 | ||
| Jul 3, 2018 at 5:45 | history | edited | Toon Krijthe | CC BY-SA 4.0 |
edited body
|
| Jul 3, 2018 at 3:38 | comment | added | Theodoros Chatzigiannakis | Java's int type has a fixed range. Clearly you'd like to have integers with custom ranges, e.g. Integer<18, 110>. You're looking for refinement types or dependent types, which some (non-mainstream) languages do offer. | |
| Jul 3, 2018 at 0:04 | comment | added | John Wu |
Won't a.SetAge( new Age(150) ) still compile?
|
|
| Jul 2, 2018 at 22:31 | answer | added | null | timeline score: 12 | |
| Jul 2, 2018 at 21:07 | review | First posts | |||
| Jul 3, 2018 at 5:46 | |||||
| Jul 2, 2018 at 21:06 | history | asked | J-bob | CC BY-SA 4.0 |