Hacker News new | ask | show | jobs
by yason 3828 days ago
Just wondering, if you want code that reflects the way you think then how do you think about things and models that inherently don't map into objects?

I'm kind of the opposite: I rarely use objects (as in methods welded to holders of state) because they only fit in certain domains but when they do they are indispensable.

1 comments

Hmm, interesting question. I guess I don't see how there are a great many things that couldn't be called objects. Particularly anything you can build a data structure around can be thought of as an object. So if your code has data to process, that data can be instantiated into objects.

But in this scenario, I would simply leave the code in an uninstantiated class, called a module in Ruby. I'd organize it as best I can with methods and perhaps submodules. My classes evolve organically as my application grows. Many of my classes start off as modules before I figure out what their state should look like.