Design Issue

I have the following forms and the MDIparent can open 3 different types of child forms.

MDImain form.
   ChildForm1
   ChildForm2
   ChildForm3

So the MDI has to transfer fileNew() or fileOpen() to each childform since the child knows best how to handle this.

Should I use a property to trigger this event from the MDi fileNew_click event
Something like
   ChildForm1 childform = new ChildForm1;
   childform.MdiParent = this;
   childform.setNewFlag(true);  <<===== trigger event in child which can invoke
                                                         the real FileNew() process
   or
   childform.setOpenFlag(true);  // I guess I could combine and send New or Open
                                                instead of true

All 3 children need database resources but seldom connected.  If it is New, they need the connection when Saved.  If Open, they need it when opening and Saving.  Should the dbConnection be in the MDImain form class or another class by itself

Thanks
Mike D  the newbie to oop


Answer this question

Design Issue

  • rxbrooks

    Pardeep,
    I could place these methods in a class lib and pass in the the childform.

    I was trying to hand off the control to the correct class.

    Do you mean have fileNew actually open the childform   Would this best practice

    Thanks,
    Mike


  • Chibos

    Have a look at this article, it might be helpful with your design issues

    Implement a Microsoft Word-like Object Model for Your .NET Framework Application
    http://msdn.microsoft.com/library/default.asp url=/library/en-us/dndotnet/html/automationmodel.asp

    You should seperate your code by functionality. Code in your Forms should not be concerneed with database access. Your forms should contain code that is necceassry for only for any user interface actions. You should move all other code into class libraries or utility classes.

    Also have a look at this patterns and practices article, it should help you with your overall design.

    Application Architecture for .NET: Designing Applications and Service
    http://msdn.microsoft.com/practices/ArchDes/default.aspx pull=/library/en-us/dnbda/html/distapp.asp

    hope this helps

  • TraGib

    HI mike,

    Please excuse my full knowledge about your project. But if I were in your place I would have created a class library and put fileNew() and fileOpen()  methods inside it. This is a good idea rather than creating the same two methods inside a form.

    cheers!!
    pradeep_tp

  • David Bentz

    Hibri,
    Thank you for the pointers to the articles.  I'm reading them now.

    Mike d


  • Design Issue