Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I don't know the author's intention specifically, but I generally use a pattern of:

1.) If a value read/write, then it's a property via getters/setters

2.) If a value is computed, then it's a function

Specific to this case, area is 'generally' a computed value of other attributes of a 'shape':

  c.radius() = 10 'Bad, overwrote the radius function
  
  c.area = 314.15 'Ok, radius is settable from just area. But doesn't match the area signature of other "shape"-like objects.
  
  let rect = new Rectangle(10, 30);
  c.area = 200 'Bad, which do we change, width or height?


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

Search: