Develop with style
-
I write apps in C++ (using VC++) and often I'm not sure where to palce the classes. For example, if I have a class that interact with a database (CDaoMyClass) I put a reference to this class in the CMyDocument class. Is it right? I have some trouble in design the class hirerchy for my applycation. Is there a book that teach how to design a GOOD application with an Object Oriented approach? I mean the Style of programming is important!!! Thanks!
-
I write apps in C++ (using VC++) and often I'm not sure where to palce the classes. For example, if I have a class that interact with a database (CDaoMyClass) I put a reference to this class in the CMyDocument class. Is it right? I have some trouble in design the class hirerchy for my applycation. Is there a book that teach how to design a GOOD application with an Object Oriented approach? I mean the Style of programming is important!!! Thanks!
For example, if I have a class that interact with a database (CDaoMyClass) I put a reference to this class in the CMyDocument class. Is it right? What do you mean by a 'reference'? Something like this? // member of CMyDocument CDaoMyClass &m_rDaoMyClass; Is there a book that teach how to design a GOOD application with an Object Oriented approach? 'Design Patterns' by Gamma et al. Tomasz Sowinski -- http://www.shooltz.com
-
I write apps in C++ (using VC++) and often I'm not sure where to palce the classes. For example, if I have a class that interact with a database (CDaoMyClass) I put a reference to this class in the CMyDocument class. Is it right? I have some trouble in design the class hirerchy for my applycation. Is there a book that teach how to design a GOOD application with an Object Oriented approach? I mean the Style of programming is important!!! Thanks!
The 'Orthodox' way is to store all persistent data in the applications document. There are problems with doing this: Eg. You have an SDI application, with a control bar, nested in control bar is a custom list ctrl. Now from the list ctrl you need to display data stored in the document, this is where MFC becomes very messy. You do the following, 1/ Get the MainFrame (AfxGetMainWnd and cast to CMainFrame*) 2/ Get the ActiveDocment (GetActiveDocument and cast to CMyDoc) This completely sucks, however I have lived with this for 7 years. The other solution is a MVC (Model/View/Controller) pattern, Stingray have developed a class framework implementing MVC (unfortunately I haven't used this). MVC is a much OOD way of the DOC/View metaphor. Regards Norm