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

  1. You would keep a pointer to the span, in each ChatUser object.
  2. You would have *some* unique ID passed from server->client
     to identify which user its talking about. A session ID say.
     this could be used to lookup the ChatUser object.
>> "It's a contrived example, but I hope it illustrates the importance of associations. There are multiple workarounds for this situation. But they aren't elegant, which is why I think JS sucks :]"

Nope, and I actually think your proposed method - mapping ChatUser->span is incredibly ugly and inelegant. Horrible design. A ChatUser object should know what UI elements it is in control of directly.



Why? The original library does not deal with GUI at all. The ChatUser object does not need to know what GUI HTML elements it's associated with. One component of a piece of software extending another should not have to tamper with the original; this is just bad design in general, not OO or any specific flavor.


Please read up on MVC before you write any more code, for the love of sanity.




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

Search: