Guys, I am programming a GUI for an application, a cd container for inserting cd, and currently I am not very clear, and I think I need help to clarify my understanding of object oriented design.
So, firstly, I use the observer pattern to create the abstract Model and View classes, as well as specific models (cd container) and specific representations (cd container view). Then I start using the wxwidget structure for design and graphic design or layout (CDContainerWidget, from wxPanel) for the cd container and other gui MainFrame controls (from wxFrame), etc.
So now I have three classes: CDContainerModel(container cd), CDContainerView(class for observer pattern) and CDContainerWidget(gui controls). then I donβt quite understand what should I do with CDContainerViewand CDContainerWidget?
It seems to me that CDContainerWidget and CDContainerView need a CDContainerModel. I think of four approaches, but I donβt know which one is suitable:
1). associate a CDContainerWidget with a CDContainerView as a member variable, and then put the CDContainerView in the main frame as a member variable.
class CDContainerView:
def __init__:
self.gui=CDContainerWidget
class MainFrame:
def __init__:
CDContainerView
2). Subclass of CDContainerView CDContainerWidget:
class CDContainerView(CDContainerWidget):
class MainFrame:
def __init__:
CDContainerView
3). Subclass of CDContainerWidget CDContainerView:
class CDContainerWidget(CDContainerView):
class MainFrame:
def __init__:
CDContainerWidget
4). instead of using CDContainerWidget and CDContainerView, use only one CDContainerBig class, which subclasses the abstract View class and wxPanel
class CDContainerBig(View, wxPanel)
- ? wiki- MVC, descrption , , , approoriate .
, . , , , 2) . , , 3) . (CDContainerWidget MainFrame). . , , , awkard. , 4, , , . , , .
, 3) - . CDContainerWidget (, ..), - , 1), , CDContainerWidget CDContainerView, CDContainerView . 2) , CDContainerWidget CDContainerView. 3) CDContainerWidget - CDContainerView, . 4) , , . , , .
!!