Which derived class is it?

J

Jeremy Cowles

namespace Logic

Thats cool, but it is not what was described. Here is the solution that was
suggested:

namespace Logic
{
struct A { void draw( ) { } };
struct B : A { void draw( ) { } };
struct C : A { void draw( ) { } };
}


And this forces the logic to know how to draw, and my question is: isn't
this bad?


Jeremy
 
J

Jeffrey Schwab

Jeremy said:
Thats cool, but it is not what was described. Here is the solution that was
suggested:

namespace Logic
{
struct A { void draw( ) { } };

Method "draw" should be virtual if {B,C}::draw are to override it.
struct B : A { void draw( ) { } };
struct C : A { void draw( ) { } };
}


And this forces the logic to know how to draw, and my question is: isn't
this bad?

It's "bad" in the sense that it's semantically ugly, and slightly less
efficient than the alternative I suggested.

-Jeff
 
J

Jeremy Cowles

Jeffrey Schwab said:
Method "draw" should be virtual if {B,C}::draw are to override it.


It's "bad" in the sense that it's semantically ugly, and slightly less
efficient than the alternative I suggested.

Much more than symantically ugly, it is conceptually wrong. In order to
provide a different UI, you must redesign the classes or add a new draw
method - ie, it couples the business logic and the front-end. So I guess I
was just wondering if the designer knew something I don't.

Jeremy
 
J

Jeffrey Schwab

Jeremy said:
Much more than symantically ugly, it is conceptually wrong. In order to
provide a different UI, you must redesign the classes or add a new draw
method - ie, it couples the business logic and the front-end.

That doesn't make it "wrong," it's just monolithic. Lots of large
pieces of code have uglier couplings than this, but work well anyway for
a wide range of people. (Just ask any linux kernel or perl internals
developer.)
So I guess I
was just wondering if the designer knew something I don't.

I don't think so.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,156
Messages
2,570,878
Members
47,404
Latest member
PerryRutt

Latest Threads

Top