Jump to content
  • Advertisement
Sign in to follow this  
Wavarian

Does this fall under any particular design pattern?

This topic is 4898 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Quote:
Original post by Wavarian
Okay moving away from the unavoidable "this is bad .. so bad omg plz someone think of the children" posts, can anyone else answer my question?


I'll put in my 2 cents and agree with Deyja - it's runtime type traits, at least if it allways returns the same value for the same class.

Quote:
And thanks for your concerns MaulingMonkey and Blizzard, however I think I've programmed long enough to know where and when it'd be a bad idea to do this - hence why I didn't ask about that.


Still worth bringing up. It's a forum after all, with archives, which will eventually be read by someone.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by Wavarian
But has anyone come across it in the past, and might know what the name given to it is? Something to do with component engineering or plug-ins?


I would just call it an interface, instead of a base class... I get this from the way interfaces in the CLR cannot have member data.

It could be used anywhere.. It depends whether you want the functionality to be handled by the base class or just provide an interface.

Share this post


Link to post
Share on other sites
Quote:
Original post by Wavarian
Okay moving away from the unavoidable "this is bad .. so bad omg plz someone think of the children" posts, can anyone else answer my question?

And thanks for your concerns MaulingMonkey and Blizzard, however I think I've programmed long enough to know where and when it'd be a bad idea to do this - hence why I didn't ask about that.

Deyja thanks for your response, I'll look up that pattern after I've finished making dinner. Rating++

R++ to DigitalDelusion also. I'll check that one out too.


and --rate to the only one who has warned you about the subtle danger [lol]

Share this post


Link to post
Share on other sites
Yeah I think Java uses it for some of their GUI components.. Where you would derive from a base class, and override some property methods instead of using a setter method or exposing a member variable.

And sorry about my earlier post, it's just that I get tired of the same old posts about how there must be something wrong with the poster's way of thinking, his design or his sexual preferences - negativity doesn't sit well with me. We should be open to learn about where some things could be used, not to avoid the subject completely and look for an alternative.

But I guess since some other researcher might come across this post, then they might learn from your advice MaulingMonkey, so I was wrong to lash out.

Anyway, thanks again guys, I'm off to do some reading.

Take care.

Share this post


Link to post
Share on other sites
Quote:
Original post by blizzard999
and --rate to the only one who has warned you about the subtle danger [lol]


And posted two apparent lies/falsities/misleading bits of information (his code = bad, OOP = virtual), then complained about ratings off topic in the very same thread. I rate people on how (un)helpful they would be to me. If they have a tendancy to post as fact gross overgeneralizations , or downright lies, (or post horribly offtopic,) I rate them down, simple as that. Why? These things lead to misunderstandings, or even racism when those generalizations are based on race. And I view both these problems in similar light - very badly.

If you have a problem with this, feel free to rate me down - I don't care. I'm a jackass like that. Sorry. I probably deserve it for continuing on this off topic track of reply anyways.

Quote:
But I guess since some other researcher might come across this post, then they might learn from your advice MaulingMonkey, so I was wrong to lash out.


No worries, it's not like anyone actually googles stuff anymore v_v.

Share this post


Link to post
Share on other sites
Quote:
Original post by MaulingMonkey

And posted two apparent lies/falsities/misleading bits of information (his code = bad, OOP = virtual), then complained about ratings off topic in the very same thread. I rate people on how (un)helpful they would be to me. If they have a tendancy to post as fact gross overgeneralizations , or downright lies, (or post horribly offtopic,) I rate them down, simple as that. Why? These things lead to misunderstandings, or even racism when those generalizations are based on race. And I view both these problems in similar light - very badly.

If you have a problem with this, feel free to rate me down - I don't care. I'm a jackass like that. Sorry. I probably deserve it for continuing on this off topic track of reply anyways.

No worries, it's not like anyone actually googles stuff anymore v_v.


A part the fact you should contact a doctor (but very good) => racism ? hey kid, what are you talking about ? ... the racism is in other places...not here where I'm writing.
Have you seen my "lol" ? I was joking about my rate-- so you could avoid these tones.

I've quoted what it's written in cpp faq and read in different books; I've also written that there is not only one definition about OOP. But this the most common. Do you think that polymorphism is not necessary to define OOP ? Well...no problem for me.

-----------------

to the topic:

if Wavarian writes
Quote:

Where Temp just wants to do something slightly different if IsSizable() returns true


I suppose that Temp is the constructor otherwise he had written "a derived class"...so I posted the warning accordingly...no racism (???) in this...be sure.

More humor could make your life better...

Share this post


Link to post
Share on other sites
Here's what I do:

// Interfaces are pure virtual member functions only.
class IInterface
{
public:
virtual ~IInterface() = 0;

virtual bool IsSizeable() = 0;
};

// Impl classes are default implementations that provide "reasonable defaults" for member functions.
// Usually, they are meant to be derived from, not used directly. If a subclass does not agree with the
// Impl class on the definition of "reasonable," they are free to specify it themselves.
template<bool Sizeable>
class InterfaceImpl :
public IInterface
{
public:
virtual bool IsSizeable() { return Sizeable; }
};

class Box :
public InterfaceImpl<true>
{
};

Share this post


Link to post
Share on other sites
Quote:
Original post by blizzard999

"A part the fact you should contact a doctor (but very good) => racism ? hey kid, what are you talking about ?" - I'm talking about putting a stop to misinformation, a cause of racism, wars, fortunes lost on the stock market... and simpler things like wasting a lot of time in your programming.

"... the racism is in other places...not here where I'm writing." - It's called an analogy. Heard of it? Wikipedia: Analogy.

"Have you seen my 'lol' ? I was joking about my rate-- so you could avoid these tones." - Dosn't make it any more on topic (or funny). I point these problems out because you feel the ratings system is good enough to be given attention, and thus should know why your own rating is falling.

"I've quoted what it's written in cpp faq" - And then overgeneralized that, loosing the context of it appling only to the C++ language itself. Not programs written in C++, C++ itself.

"I've also written that there is not only one definition about OOP." - After being corrected. And it came off as though you thought it silly to bring up. With your grammar and weird choice of emphisis and qualifiers, it's hard to tell, though.

"More humor could make your life better..." - Less broad overgenralizations could make your entire world (and thus indirectly your life) better. Gotta have a bed to come home to after laughing yourself silly at the Comedy Underground, after all.

[Edited by - MaulingMonkey on September 12, 2005 7:19:07 PM]

Share this post


Link to post
Share on other sites
Aight. You two are to stop bickering right this very second. Blizzard999, if people are rating you down, consider that it may not be your information but your tone.

In any case, virtual function binding has very little to do with racism. Back on topic, guys.

Share this post


Link to post
Share on other sites
The first example is object-oriented, the second example is modular (i.e. not object-oriented).

I'm not convinced there is a design pattern here, but I would agree with DigitalDelusion that the Template Method is the closest one.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!