Wednesday, January 27, 2010

My venture into OOP Javascript pt2: MVC?

At this point I’ve tried to break out the code into classes that loosely mimic my MVC classes.  A view that deals with setting up the calendar onload with the proper dropdowns and so on, a controller that deals with the events or “actions” that come from the calendar, and various services. 

One immediate issue that comes up is that  while the calendar is the starting point, once you click on it you get a dialog box which is not unlike an entire new and mostly unrelated module that has all manner of view setup, events or “actions”, data, rules and services.  It’s almost like whenever an event or a time is clicked it the calendar controller should call a calendarEventController with it’s seperate view and data.  But then I wonder if every dialog box should have it’s own controller.  There could be several stages to creating an Event.  If the event is in the past you have to justify it.  That’s one dialogbox, then you get the regulare add/edit dialog, if it’s edit and recurring you have a new dialog asking if you want to change all future events or just this one. and so on. 

Ok so upon writing this it’s starting to make me think about fubumvc’s “controller-less actions”.  basically it does away with the idea of a proper controller and makes each action it’s own class.  This class references the view it wants to write to and the model it’ll use.  However, I’m not sure I want to use this pattern in Fubu, much less in my javascript code.  I mean views generally have several calls that are all related and if each call requires it’s own class/controller then things can get kind of dispersed.  Hmmm.

No comments: