2 ms·
Really? Classes never made source more readable? How on earth is `Vector<Int64>` or whatever less readable than rolling a custom struct and functions?
by duaneb 14y ago
Really? Classes never made source more readable? How on earth is `Vector<Int64>` or whatever less readable than rolling a custom struct and functions?
- rayiner 14y agoBasic logic error (that it doesn't make things more readable doesn't mean that it's less readable). I just don't see the big readability win going from vector_push_back(my_vec, 53) to my_vec.push_back(53)
- duaneb 14y agoOh, well the dot syntax is just, well, syntactic sugar, and arguing that THAT is the reason anyone (who knows what they are doing) uses C++ is silly. It's because of inheritance and DRY so you write less code.
- rayiner 14y agoRight, and my point is that I've never seen a situation where inheritance really makes things dramatically clearer versus the alternatives (indeed, the mantra in C++ these days is that you should have "has-a" relationships with composition versus "is-a" relationships with inheritance). I think inheritance/OOP encourages you to draw module boundaries in the wrong place. It encourages you to spread the logic of an object over several modules of code. If you find yourself using inheritance, you'd better ask yourself: could I instead abstract my base class into a self-contained object that my new object could hold a reference to? See: http://www.paulgraham.com/noop.html http://www.paulgraham.com/noop.html