Re: Object specific behavior?
Re: Object specific behavior?
- Subject: Re: Object specific behavior?
- From: Erik Buck <email@hidden>
- Date: Thu, 25 Oct 2007 05:55:17 -0700 (PDT)
Cocoa ubiquitously uses the Model-View-Controller design pattern to organize the roles of collaborating objects within an application.
In the specific instance cited, the role of a button is to receive user input and provide feedback to the user. Buttons do not beep. Instead, buttons send messages to other objects that implement application specific behavior such as beeping. This separation of roles has numerous benefits. First, the button class is reusable largely because it is not application specific. Second, the generic ability to send almost any message in response to user input reduces the number of times button has to be subclassed to nearly zero. Third, when the application behavior is more complex than just beeping, the flexibility to send messages to anonymous receivers that may be determined at run-time by the current application state and user selections etc. becomes extremely powerful and flexible.
Naively adding scripts to be performed when a user clicks a button is (in larger applications) fragile and leads to spaghetti code. There are advantages to extremely rapid specification of behavior. A system like pyObjC or Ruby or F-Script might be exactly what you are looking for. I highly recommend http://www.fscript.org/. Each of these combinations of scripting and Cocoa enable (more) rapid development without sacrificing the benefits of Cocoas design.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden