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

> I don't know what an AccountID, UserID, etc. is. Now I need to know what those are (and how to make them, etc. as well) to use your software.

Presumably you need to know what an Account and a User are to use that software in the first place. I can't imagine a reasonable person easily understanding a getAccountById function which takes one argument of type UUID, but having trouble understanding a getAccountById function which takes one argument of type AccountId.



UserID and AccountID could just as well be integers.

What he means is that by introducing a layer of indirection via a new type you hide the physical reality of the implementation (int vs. string).

The physical type matters if you want to log it, save to a file etc.

So now for every such type you add a burden of having to undo that indirection.

At which point "is it worth it?" is a valid question.

You made some (but not all) mistakes impossible but you've also introduced that indirection that hides things and needs to be undone by the programmer.


Well...yeah. That's the point. We want there to be a layer of indirection to prevent mistakes. Otherwise you get things like this: https://www.columbia.edu/~ng2573/zuggybuggy_is_2scale4ios.pd...

> There is a UI for memorialising users, but I assured her that the pros simply ran a bit of code in the PHP debugger. There’s a function that takes two parameters: one the ID of the person being memorialised, the other the ID of the person doing the memorialising. I gave her a demo to show her how easy it was....And that’s when I entered Clowntown....I first realised something was wrong when I went back to farting around on Facebook and got prompted to login....So in case you haven’t guessed what I got wrong yet, I managed to get the arguments the wrong way round. Instead of me memorialising my test user, my test user memorialised me.


I recommend adding a serialization method to your types, namely to text, but optionally to JSON as well.




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

Search: