Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Joel tells a pretty compelling story about two types of Hungarian notation: http://www.joelonsoftware.com/articles/Wrong.html


From that article:

"used in my example above where we decided that us meant “unsafe string” and s meant “safe string.” They’re both of type string. The compiler won’t help you if you assign one to the other"

Assuming you have the luxury of a language with a good type system (either because it's designed for the task in hand or it's extensible), the compiler can help you, and you would be much better off having unsafe and safe strings as separate types. Then the encode function simply becomes a function of type unsafe -> safe. I believe Michael Snoymann touches on this in his presentation, "Designing Type-Safe Haskell APIs"[1].

I'm not arguing that Joel's method isn't a good idea. However, if you can it's better to leave hints for the compiler, not just the programmers.

[1] https://docs.google.com/presentation/d/1K7smIeqmca-fY8qgQUKr...




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

Search: