OOP isn't a savior

by rpgfan3233 (Login rpgfan3233)

OOP is made out to be a sort of one-size-fits-all solution to every problem. However, that just isn't the case. Even the C++ FAQ Lite says that one-size-fits-all solutions are something C++ programmers should be wary of.

After all, which makes more sense:
struct data_group {
int int_data;
float flt_data;
};

or

class data_group {
public:
int int_data;
float flt_data;
};

If you say the second one, I'll kick you! Classes are meant to be for OOP in C++. In contrast, structs (structures) were designed purely to group related data together. If a class requires the use of internal data members, then it is perfectly fine to put it in a class. To think of a class as the same thing as a struct with different default access privileges is ridiculous.

At one point, I believe there was some real movement behind AOP (Aspect Oriented Programming), but I haven't heard anything about it over the last few months.

In any case, there isn't a one-size-fits-all method, no matter what anybody tells you. I'm a gigantic advocate of C++, but that doesn't mean that it is better than Python or Ruby for a certain job, for example. All three of those programming languages (C++, Python, Ruby) support OOP in some way. It is just a matter of using it effectively! ^_^

------------------
Waiting patiently for Windows 7, XHTML 2.0, CSS 3.0, PHP 6.0, the ratification of C++0x, and the day that I can code without logic troubles.

Posted on Apr 17, 2008, 8:34 PM
from IP address 12.208.126.190

Respond to this message   

Return to Index


Response TitleAuthor and Date
I kinda like the 2nd example ;-)....But yeah... on Apr 18
 I wouldn't mind the interface idea.rpgfan3233 on Apr 18