Page 1 of 1

how should a console be implemented

Posted: Thu Feb 10, 2011 8:45 pm
by Void Mapper
I made a console using win32 controls but I'm not sure how to implement it. I had the idea of making a pure static class because I can't think of a situation where I would need multiple console windows. Does anyone have any better ideas?

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 2:06 am
by adikid89
I can think of many cases where you need multiple consoles. Don't makes it static. Make some base class, and virtual the functions you'll probably change in other consoles, like parseComand() or something.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 3:55 am
by D-e-X
adikid89 wrote:I can think of many cases where you need multiple consoles. Don't makes it static. Make some base class, and virtual the functions you'll probably change in other consoles, like parseComand() or something.
I'm going to have to agree with adikid89 here, making a "pure static class" is rarily necessary or good design. For example, you can have two consoles, having them to be able to pass information to each other would be a nifty little thing for example, which would need you to pass a pointer or reference to another console object.

At all, being able to instantiate more than one console is seldom "bad", it totally depends on what you want to do with it, or need. :]

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 10:03 am
by N64vSNES
I don't really understand, I didn't think you could have a "pure static class". You mean a singleton? If you don't need more instances then just don't create any more.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 11:07 am
by adikid89
I think he means by "pure static" a class that only has static members/methods.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 11:14 am
by N64vSNES
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 2:01 pm
by pubby8
If you are ever doing enough console writing to demand use of multiple windows, then you should not be using default windows console as you have outgrown it.

I will reccommend you write a simple class that creates a new window and another one that lets you write into it. Then you can create a single global-scoped version of the window, and create writers when needed (or globally).

N64vSNES wrote:
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.
You wouldn't pass a class that contains all statics (monostate) by reference.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 2:51 pm
by adikid89
pubby8 wrote:
N64vSNES wrote:
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.
You wouldn't pass a class that contains all statics (monostate) by reference.
He didn't say the class should be all static.. in fact he was referring to make a class without statics, and just pass that one by reference.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 2:57 pm
by N64vSNES
pubby8 wrote:If you are ever doing enough console writing to demand use of multiple windows, then you should not be using default windows console as you have outgrown it.

I will reccommend you write a simple class that creates a new window and another one that lets you write into it. Then you can create a single global-scoped version of the window, and create writers when needed (or globally).

N64vSNES wrote:
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.
You wouldn't pass a class that contains all statics (monostate) by reference.
Read what I said.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 3:20 pm
by pubby8
N64vSNES wrote:
pubby8 wrote:If you are ever doing enough console writing to demand use of multiple windows, then you should not be using default windows console as you have outgrown it.

I will reccommend you write a simple class that creates a new window and another one that lets you write into it. Then you can create a single global-scoped version of the window, and create writers when needed (or globally).

N64vSNES wrote:
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.
You wouldn't pass a class that contains all statics (monostate) by reference.
Read what I said.
Oh, I misread.

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 3:42 pm
by Falco Girgis
:lol:
pubby8 wrote:
N64vSNES wrote:
pubby8 wrote:If you are ever doing enough console writing to demand use of multiple windows, then you should not be using default windows console as you have outgrown it.

I will reccommend you write a simple class that creates a new window and another one that lets you write into it. Then you can create a single global-scoped version of the window, and create writers when needed (or globally).

N64vSNES wrote:
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.
You wouldn't pass a class that contains all statics (monostate) by reference.
Read what I said.
Oh, I misread.
:lol:

Re: how should a console be implemented

Posted: Fri Feb 11, 2011 6:35 pm
by Void Mapper
pubby8 wrote:If you are ever doing enough console writing to demand use of multiple windows, then you should not be using default windows console as you have outgrown it.

I will reccommend you write a simple class that creates a new window and another one that lets you write into it. Then you can create a single global-scoped version of the window, and create writers when needed (or globally).

N64vSNES wrote:
adikid89 wrote:I think he means by "pure static" a class that only has static members/methods.
Oh I see. :lol:

I don't think this is needed, just have a single instance and pass it by reference.
You wouldn't pass a class that contains all statics (monostate) by reference.
I'm not using the windows console. The console I'm working is made up of one parent window and two edit controls.