Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

grandM

macrumors 68000
Original poster
Oct 14, 2013
1,574
331
Hi guys

I was wondering what you guys were doing in your factory? I was about to code a factory to generate an array of Items and saw that many people were using a method to create an Item instance. Seems to me you could just easily use a computed property in your Factory to generate the instance.

What's the best way to obtain this goal and why?

Tx!
 
I remember reading (not sure where) that although you can do either, it is a better style to use methods when there is some (expensive) computation involved and properties when there is not (basically just getting a value).

A good way of thinking about this would be the assumption that you do not know the implementation details of your objects, like you do not know how Apple’s objects work internally. The fact that something is a property or a method can hint at how much computation happens in the background, making you more aware of the performance costs.
 
  • Like
Reactions: grandM
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.