c# - Is this good design? -


i creating text editor. text-box control subclass of textbox called editor. main form, mainform, has instance of editor.

when mainform wants to, say, load text document, calls editor.loaddocument(string path). editor.loaddocument calls document.load(string path).

the same kind of thing happens save: mainform --> editor.savedocument --> document.save.

it seems editor acting middleman unnecessarily here, i'm thinking of letting mainform access document directly: editor.document.load(path). editor still create , maintain document; provide direct access it.

note create bidirectional association: editor have document , document have editor (document uses editor.text , subscribes editor.textchanged).

i have 2 questions:

  1. is design?

  2. do bidirectional associations create slowdown pertaining garbage collection when app exits?

you need read patterns such model-view-controller.

generally, ui should activate operations directly on model (document in case), , view (editor) should subscribed events , act observer.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -