Home > Uncategorized > Coding Model-View in C# – Accessor Notes

Coding Model-View in C# – Accessor Notes

October 1st, 2004

Thanks to a suggestion by Greg Knauss, i’ve learned how to split a Windows Component Library into frontend and backend, with namespaces for each. Here are some notes about my process:

  1. Different Views (User Controls) should each have a private variable equivalent to your Model (backend Class) class.

  2. To propagate Accessor method settings that you might be able to modify when adding components onto a test form, you should use the get{} and set{} accessors that show up when adding a component as Misc properties. These should modify local View private properties. Then, in the View Class’s Load method, you can call a constructor of the backend with these private values, which should be set by the time you hit the Load method. Note that you can’t do this in the constructor of the View Class itself, which i’m sure is a technicality due to class startups and instantiation order that i’m just not familiar with in C#.

  3. By providing your backend with public properties via accessors, it simplifies your life when building varied frontends, because you can access backend properties at any time with your View’s copy of the backend class.

Uncategorized

  1. No comments yet.
  1. No trackbacks yet.