C
Chocawok
Hi I've recently designed and implemented a menu system.
Basically I have several classes:
Menu - this contains MenuItems
MenuItems(base class) - can be either a SubMenu or a Switch (Sub menus
display a new menu, switches allow the user - by pressing the space bar
say - to toggle between the switches "options")
Now, Menus are basically a collection of MenuItems. Ones creates MenuItems
(either Submenus or Switches or some future types) and the does a
Menu.AddItem ( new switch());
Problem: when I came to creating a Menu in my code, I realised I had to not
only include Menu.h, but also submenu.h and switch.h.
Also I have to specifically create Switch/Submenu objects then add them to
the menu (menu.additem).
Now all this is fine, but what i was really going for was a more
"encapsulated" type solution.
Really I want to just include one header "menu.h" and also not have to
create separate objects whose only purpose is to be added to the menu
object.
My main reason to think I have made a design "gaff" is that MenuItems have
no meaning on their own! The only point of their existence is as a part of a
Menu object
Any thoughts on this?
Dean
P.S. thanks for all the response to my previous post(s) about the tightly
coupled graphics objects. I'm realising that 1) i still have a LOT to learn.
2) This is a great place to do it!
Basically I have several classes:
Menu - this contains MenuItems
MenuItems(base class) - can be either a SubMenu or a Switch (Sub menus
display a new menu, switches allow the user - by pressing the space bar
say - to toggle between the switches "options")
Now, Menus are basically a collection of MenuItems. Ones creates MenuItems
(either Submenus or Switches or some future types) and the does a
Menu.AddItem ( new switch());
Problem: when I came to creating a Menu in my code, I realised I had to not
only include Menu.h, but also submenu.h and switch.h.
Also I have to specifically create Switch/Submenu objects then add them to
the menu (menu.additem).
Now all this is fine, but what i was really going for was a more
"encapsulated" type solution.
Really I want to just include one header "menu.h" and also not have to
create separate objects whose only purpose is to be added to the menu
object.
My main reason to think I have made a design "gaff" is that MenuItems have
no meaning on their own! The only point of their existence is as a part of a
Menu object
Any thoughts on this?
Dean
P.S. thanks for all the response to my previous post(s) about the tightly
coupled graphics objects. I'm realising that 1) i still have a LOT to learn.
2) This is a great place to do it!