MVC and Accessor Methods
Posted May 16th, 2003 @ 11:35pm by Erik J. Barzeski
I was bored tonight, so I began work on MailDrop 2.0. Essentially, MD2 (unlike MD1) will follow a very MVC model. It's the easiest way towards eventual AppleScripting, easier document archiving, and a lot more.
Essentially, MVC is "The Right Way™" and our current method is, uhhh, well it's a hack. We learned a lot about how things should work, what we did wrong, and where to go from here. Nick's experiencing those issues right now in FTPeel and, like us, he'll be a better developer for having been through it. Our third app in production, PulpFiction, is going to be nicely MVC as well.
Anyway, I got what I'd say is about 5% of the code done tonight, and it's perfect. It's flawless! It's… purely accessor methods! The view calls a setter in the controller, the controller calls a setter in the model, the controller then says "view, update yourself" and calls a getter in the model for the latest data (the stuff we just set), etc. It all works. Yay. Perfect code. So far, anyway.
Posted 17 May 2003 at 6:45am #
Keep us posted on how long you're able to to stick to the paradigm. In my experience it works until you think of that one little feature you could add that'd take only minutes if you hack it in and much longer if you adhere to MVC.
If you're a good guy, you'll have the self-control to use MVC - but if you're more of an instant gratification type (or working under a looming deadline), that's where all good resolutions will break dwon... 🙂
Posted 17 May 2003 at 8:24am #
Well man, I've already put in time on those lame, boring parts. My UI triggers a method in my controller, which sets something in my data model. The controller then "updates" the UI to match the model, and so it asks the model what the values of some things are (including what was just changed) and sets it. I could have done this in 0 lines of code, and I've writen about ten per widget now, so… I'm off to a good start as you say. 🙂