October 09, 2004
Ant wrote:
> On Sat, 09 Oct 2004 11:31:53 +0100, Matthew Craig wrote:
> 
> 
>>As Sjoerd has just pointed out I think templates are the answer
> 
> 
> No, this is a simple school like case where
> the OO paradigma fits perfectly.
> 
> 
> 

I am not quite convinced that the SDL_Surface and Surface types are the same type. I think it is imported from a header file or something like that. If so, You can't use the standard OO paradigma (although it seems the most obvious way).

At the other hand, it is possible to wrap up SDL_Surface and Surface in their own wrapper classes. This would reinstantiate the use of full blown OO programming.

Were I previously mentioned thay (be it lazy) templated behaviour, it is very well possible to rewrite it to full OO:

----- *PREVIOUS* -----

interface Graphics(T) {
    T getScreen();
}

class SDL : Graphics(SDLSurface) {
    SDLSurface screen;
    SDLSurface getScreen() {...}
}

class OpenGL : Graphics(Surface) {
    Surface screen;
    Surface getScreen() {...}
}

----- *NEW* -----

interface Graphics {
    Surface getScreen();
}

interface Surface {
    // ... generic surface methods
}

class SDLSurface : Surface {
    SDL_Surface instanceSDL;
    // ... overridden surface methods from the interface
}

class OpenGLSurface : Surface {
    OpenGL_Surface instanceOpenGL;
    // ... overridden surface methods from the interface
}

class SDL : Graphics {
    Surface screen;

    this() {
        screen = new SDLSurface();
    }

    Surface getScreen() {...}
}

class OpenGL : Graphics {
    Surface screen;

    this() {
        screen = new OpenGLSurface();
    }

    Surface getScreen() {...}
}

There are even much better solutions to this problem, but it is proven that both template programming and full OO programming can be used. It's up to you though.

Regards,
Sjoerd
October 09, 2004
On Sat, 09 Oct 2004 21:17:05 +0100, Matthew Craig wrote:

> fair enough and you agree another class could control the switching right,

of course.

> I think what's thrown you is that i had
> 
> class Gfx : IGfx
> 
> which I agree is unnecessary if not plain wrong.

agree.


> Imagine your using someone elses library lets say it handles buffers.
> It's a great
> library and you've used it for a while and all is well until you
> suddenly wish it had
> another function.

doesn't that shows your design to be faulty or incomplete? ;)
but I agree the raw structures should be made available
some how.


> If your an OO purist

oh!... I see you're new here :)

> 
> I think I got your point ;-)

I think you did!

Ant

October 10, 2004
> 
>>If your an OO purist
> 
> 
> oh!... I see you're new here :)
> 
> 

Ha Ha HA!  :D  Funny, Ant!

Matthew, it may take awhile to get used to Ant's... err... style of critiquing, but Ant's okay. ;-)

Although, I think Ant's going to have to eventually drop his notorious "English-is-my-second-language" excuse for being so direct with people.  I'm beginning to think that he has become somewhat adept with the language now. :)

Later,

John
October 10, 2004
On Sat, 09 Oct 2004 22:56:11 +0200, Sjoerd van Leent wrote:

> Ant wrote:
>> On Sat, 09 Oct 2004 11:31:53 +0100, Matthew Craig wrote:
>> 
>> 
>>>As Sjoerd has just pointed out I think templates are the answer
>> 
>> 
>> No, this is a simple school like case where
>> the OO paradigma fits perfectly.
>> 
>> 
>> 
> 
> I am not quite convinced that the SDL_Surface and Surface types are the same type.

It doesn't look that bad, in fact...

> 
> There are even much better solutions to this problem,

where, where, how?

> but it is proven that both template programming and full OO programming can be used. It's up to you though.

yes, and now he has a choice.

Ant

October 10, 2004
> > Imagine your using someone elses library lets say it handles buffers.
> > It's a great
> > library and you've used it for a while and all is well until you
> > suddenly wish it had
> > another function.
>
> doesn't that shows your design to be faulty or incomplete? ;)
> but I agree the raw structures should be made available
> some how.

Language design is always a balance between too little or too
much flexibility. C++ has loads of flexibility (too much) which is
the cause of its popularity and ultimately its (probable) demise.
However in aiming to  reduce c++'s flexibility care needs to be
taken not to overshoot the mark. I'm not saying D is one way
or the other yet, I've not used it long enough to even begin to judge.

As you can see from my initial post it is possible however you have to make quite a mess to do it. IMHO the type keyword I suggested would prevent you being penalised for doing this and give it a touch more flexibility. Just a thought.

>
>
> > If your an OO purist
>
> oh!... I see you're new here :)
>

I sure am, there's an interesting line in my Game Programming Gems book that goes

"Game programmers are a slightly different breed than the typical
application
programmer, because their work is always expected to be cutting edge,
pushing
hardware constraints to the limit, game developers tend to be much more
willing
to bend or even break traditional programming design rules."

Guess that rules me out of the purist camp ;-)

> >
> > I think I got your point ;-)
>
> I think you did!
>
> Ant
>


October 10, 2004
I've worked with people much more 'direct' he didn't even swear ;-)

I'm all for good constructive criticism it's how you separate the chaff from the wheat so to speak.

"John Reimer" <brk_6502@NOSP_AM.yahoo.com> wrote in message news:ck9ugl$1cc9$1@digitaldaemon.com...
>
> >
> >>If your an OO purist
> >
> >
> > oh!... I see you're new here :)
> >
> >
>
> Ha Ha HA!  :D  Funny, Ant!
>
> Matthew, it may take awhile to get used to Ant's... err... style of critiquing, but Ant's okay. ;-)
>
> Although, I think Ant's going to have to eventually drop his notorious
> "English-is-my-second-language" excuse for being so direct with people.
>   I'm beginning to think that he has become somewhat adept with the
> language now. :)
>
> Later,
>
> John


October 13, 2004
John Reimer schrieb:

>> oh!... I see you're new here :)
>>
> 
> Ha Ha HA!  :D  Funny, Ant!

:>

> Matthew, it may take awhile to get used to Ant's... err... style of critiquing, but Ant's okay. ;-)

I haven't seen Ant being wrong on such questions. In fact, any runtime discrimination using switch or if statements is very much slower than function pointers, and OO provides a very nice wrapper for these. So OO is very applicable where performance engeneering comes into play, to a certain degree of course.

> Although, I think Ant's going to have to eventually drop his notorious "English-is-my-second-language" excuse for being so direct with people.  I'm beginning to think that he has become somewhat adept with the language now. :)

I think it doesn't really matter. I live in a country where i day for day speak in my third (or was it fourth?) language, and almost noone notices that i could be a foreigner. :>

So i started thinking up excuses for myself, but i don't think they limit themselves to my personality.

* I have bipolar disorder. Leave me alone! ELSE I SCRREAM!
* Hey, me comes from south! Let us *hug* each other and then nothing was ever wrong anyway!
* I have multiple sclerosis. What did you just say? What's up anyway?

Don't hesitate to add more.

In fact, over these all years i have not simply been too harsh to some people, i have even offended some due to some strange condition of mine combined with ignorance. May those forgive me.

-eye/photoAllergics
1 2
Next ›   Last »