loading...

re: Intro to OOP: Ruby 'One to Many' vs 'Many to Many' VIEW POST

FULL DISCUSSION
 

Thank you for taking the time to write this. There are a few problems with this approach though if you don't mind.

  • User objects know about the Account class, Account.all, and Account.all.select, causing three couplings.
  • Exposed class variables are effectively global variables and global variables cause a lot of tricky errors when you least expect it. Any globally accessible thing should be constant at runtime.
  • It seems like a re-implementation of an object-relational mapping but without the relational database. ORMs are more of a necessary evil than a good pattern. OOP prefers direct references between objects rather than filtering through global lists.

Hopefully that is helpful. I would recommend, if you haven't already, Sandi Metz for learning more about OOP as her writing is very accessible and informative.

Regards,
kwstannard

Code of Conduct Report abuse