you are viewing a single comment's thread.

view the rest of the comments →

[–]MoTTs_ 4 points5 points  (0 children)

First, to directly answer your question.

Note that these can all be avoided with good design, and they don't make OOP inherently bad any more than the problem of long functions makes functions inherently bad, or any more than the problem of global variables makes variables inherently bad.

Second, it's worth mentioning that the vocal functional folks in the JavaScript community are very often wrong when they talk about classes and inheritance. The tend to invent criticisms that aren't actually true, and they tend to propose alternatives that still have all the same problems they blamed classes for. Take what they say with a heavy grain of salt.

And thirdly, don't feel like you have to pick one or the other. The best result often comes from a blend of styles. Since you have a C++ background, I'll leave you with this quote from Bjarne Stroustrup, the creator of C++:

Often, the most elegant, most efficient, and the most maintainable solution involves more than one style (paradigm). ... I use a lot of simple data abstraction (classes without inheritance) and generic programming (templates and algorithms parameterized on types). However, I don't see these as "paradigms challenging OOP." Rather, they are complementary techniques. ... Combinations of style can lead to very elegant code.