News for hackers. Stuff that matters.
Re:My most common code review suggestions by bonesss on Thursday December 07, 2017 @07:09AM (#15869368)
I find it kinda odd that a fundamental principle of OOP is information hiding, yet most mainstream languages make it a matter of pure discipline if you want to pass around a "CustomerId" instead of an "Int32" or alias any value type. In your own code it's not too bad, but there's constant conversions at api and library boundaries...

In general I lack the Smalltalk ideal of being able to subclass any type, like 'Int', call it something new and attach behaviour to it, while preserving API & DB compatibility.

Type aliasing in F#, ie `type Customer = int`, or discriminated unions with the same info, like `type CustomerId = CustomerId of int`, are wonderfully useful in that regard.

Re:My most common code review suggestions by alanfranzoni on Thursday December 07, 2017 @01:36PM (#15872678)
In Python you can subclass builtin types and override __new__. Not every method can be subclassed with success, though, because of optimizations.

I agree it's the way to go, though. My typical tiny type in Python just has preconditions on string content.