Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialShaun Kelly
5,648 PointsDifference between attributes and properties?
I thought properties were things about the puppy in object-oriented programming? like shown below...
@property (nonatomic, strong) NSString *name;
1 Answer
Michael McDonald
2,877 PointsIt's a rather thin difference and the subject of many circular debates in programming forums. The convention I usually use is to declare as properties the values I expect are most likely to be changed by other objects and declare as attributes the values not likely to be changed by other objects. Either can be changed, so the readability of the external call is somethings the determining factor. Does it make better sense to write 'yourObject.input(info)' or to write 'yourObject.input = info' ? Does it make better sense to write 'yourObject.output(report)' or to write 'report = yourObject.output' ? There may have been a more transparent difference at one point but both approaches usually work equally well.