News for hackers. Stuff that matters.
Re:Ten Years of Git: An Interview with Linus Torvalds by squeaky-clean on Monday April 06, 2015 @06:14PM (#9331005)
> So even with the types, you have exactly the same problem as in python, and creating a special class to wrap up percentages is something I find quite heavy.

Yep, I agree completely and was hoping to make that point. The typing makes it clear that meal is going to be a single price, and that tip won't be a String or something unexpected, but it is still unclear whether it is a percentage or a amount.

I guess what I mean to say is that while static typing certainly helps, it isn't the be-all and end-all of code clarity, and descriptive names can really help code readability regardless of your typing system.

Also, admittedly the example I provided is rather simple. And in any language, you should be using a proper Currency type or library when dealing with money, which would make most of my argument moot:

    Currency calc_total(Currency meal, Double tax, Double tip)
And now specifying tax and tip as percentages isn't necessary. But not all examples are so friendly!

There are no comments on this comment yet.