I'm working on a winforms project that involves 3d models, Opengl graphics, hierarchical project files and uses an MVP approach. Currently i have things setup such that when the user manipulates objects the view is updated using events triggered by the object. For each object that is added to the hierarchy in e.g. a list, i need to add handlers (since i do not have a variable assigned to the object, which could be declared withevents). When storing (serializing) this hierarchy the handlers are not included. So when a project file is opened these handlers need to be setup again, or nothing works anymore. This is cumbersome and i am considering either :
- removing all methods and functions from the respective classes to libraries, so that in the end only data is stored in the hierarchy, and avoiding the use of internal events all together. or
- moving all methods, functions and events into inheritable classes that are not serialized
Since this project has reached a certain 'critical mass' and my limited experience does not allow me to see past my design choices, I am starting to become reluctant to change the setup again and again. So I am wondering if someone with some experience on larger projects can give me some advice ? or perhaps tell me if this approach is going to cause problems in the long run, or better yet give some pointers on handling these issues. In any case, all help is welcome.
Update :
Hi, Thanks for taking the time to answer the question. Based on the input I recieved below I started to read up on topics like Data tranfer objects DTO, Data value or access objects, Domain objects, Business layer, Persistence layer/Data layer and the works. Unfortunately most examples deal with databases and tables, which is not very fitting for 3d worlds, but the essence is now clear to me.
In effect I have now created a data-only representation of my project hierarchy which holds all the data and can be serialized easily. All data objects are plugged into domain objects which add functionality to manipulate the data and provide behavior (i.e. events and handlers). Herein all setters and getters point to the variables in the data object The domain objects also form a hierarchy, similar to that of the data layer. To avoid maintaining lists of handlers, i've hard wired the events for a single object and only change the reference to the one which is active/being manipulated/needs updating etc.
Thus now I have a Model View (passive)Presenter + Data/persistence layer arrangement, which will do what I need. Thanks for the input.
Best PeteByte