Re: IB, exclamation points, and targets
Re: IB, exclamation points, and targets
- Subject: Re: IB, exclamation points, and targets
- From: "Erik M. Buck" <email@hidden>
- Date: Fri, 5 Oct 2001 17:10:29 -0500
Nil targets are extremely common. That is how messages are sent to the
responder chain. Nil actions are not very common. As a general rule, you
should not store state in the user interface. If you have a check box that
represents a Boolean value, it is best to store the Boolean value in your
model or control layer somewhere and use the check box to set the value via
a message to the control layer. Any model code dependency on the existence
of the check box is a bad idea because it makes a non-obvious coupling.
Some other programmer will go into IB and remove the check box to replace it
with a user default ,or a text field, or a combo box, or a radio button, or
any other non-check box button. At that time, your program will break
because it made a non-obvious undocumented assumption that a check box exits
to store a Boolean value essential to the correct function of the
application.
It should be possible to use the model part of an application with an
infinite number of different user interfaces including textual interfaces,
scripting interfaces, and graphical interfaces. It should be possible to
use a user interface with an infinite number of different models. The
control layer exists to be a translator or bridge between the user interface
(view) and the model so that they do not depend on each other.
>
So, is it considered poor Cocoa programming practice to have controls
>
with nil targets? Or should I create a "do nothing" action and use
>
that? One thing I don't want to do is create instance variables for
>
every possible setting and then create individual methods that update
>
these variables when the user updates the control (code-clutter).
>
>
-cb
>
>
________________________________________________________________________
>
Carl W. Bell <http://www.baylor.edu/~Carl_Bell/index.html>
>
Sr. Analyst/Programmer Baylor University Academic Technology Center
>
_______________________________________________
>
cocoa-dev mailing list
>
email@hidden
>
http://www.lists.apple.com/mailman/listinfo/cocoa-dev