Hacker News new | past | comments | ask | show | jobs | submit login

> Essentially, making them separate is a physical infrastructure form of making incorrect states non-representable.

Huh, that's a great example, because it also shows why making light poles double as bollards is an alluring idea. A scenario I see somewhat often is when you need to change some existing code working on a piece of state, because now that piece of state actually has two mutually exclusive substates. Say, Auth = {username, password} becomes Auth = {username, password or path to certificate }.

The easy solution would be to add the new properties and perhaps mark them and their conflicting counterparts optional - this means you have to refactor only the type definition and maaaybe some points of use of the now-conflicting substate. In our example, Auth = {username, password?, certificate? = nullopt}.

The proper solution would be to "make incorrect states non-representable", representing the substates directly -- Auth = {username, {password | certificate }. Or perhaps, Auth = {PasswordAuth | CertificateAuth}, PasswordAuth = {username, password}, CertificateAuth = {username, path to certificate}. Now this is a much more substantial change, and you'll end up touching and possibly changing every place Auth is used.

Under resource constraints (such as time), the easy option is very, very tempting :).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: