• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???


  • Subject: Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???
  • From: mmalcolm crawford <email@hidden>
  • Date: Mon, 3 Jan 2005 10:36:04 -0800


On Jan 3, 2005, at 4:44 AM, Izidor Jerebic wrote:
First:
  [calculator add:someNumber] ;
Second:
  val = [calculator value] ;
  newVal = val + someNumber ;
  [calculator setValue:newVal] ;

What you've done has completely lost the encapsulation of the 'add' method to the calculator object.
You can still use [calculator add:someNumber], but inside the 'add' method you would do:


- (void) add:(float)addition
{
	float newValue = [self value] + addition;
	[self setValue:newValue forKey:@"value"];
}

Exactly. What I have done in the [second] example is really wrong. But, as you can see, it is easier to get bindings working that way. So if you write bad, un-encapsulated code, it is easier to use bindings. This is the harm I was talking about.


It's not clear what is wrong with Tim's suggestion. If you implement add: as he proposes, then your first example works as required.

If anything, to me bindings encourages you to write good, well-encapsulated code. If you want to minimise your own code, you use automatic KVO notification, which relies on you using standard accessor methods, rather than changing instance variables directly...

mmalc
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???
      • From: Izidor Jerebic <email@hidden>
References: 
 >Cocoa Bindings - nondebuggable, non-obvious, procedural ??? (From: Izidor Jerebic <email@hidden>)
 >Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ??? (From: Tim Lucas <email@hidden>)
 >Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ??? (From: Izidor Jerebic <email@hidden>)

  • Prev by Date: Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???
  • Next by Date: Re: Invisible characters in NSTextView
  • Previous by thread: Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???
  • Next by thread: Re: Cocoa Bindings - nondebuggable, non-obvious, procedural ???
  • Index(es):
    • Date
    • Thread