Hacker News new | past | comments | ask | show | jobs | submit login

For that I prefer the ActionScript3.0 solution: methods that imitate attributes.

You replace

  public var myAttribute:int;
with

  public function get myAttribute():int;
The caller uses both with the same "object.myAttribute", so you can just replace one with the other when the need arrives, without changing any other code.

This allows you to use all sort of syntactic sugar ("object.myAttribute++", "+=" and other assignments), and for dynamic languages you can get and set values just from a reference to the object and the attribute's name. This last part is invaluable for animation engines.




Sure, but Java doesn't have that. =) Some of the Java.next languages (Scala among them) do, though.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: