Fantastic email to wake up to from @stripe! 🎉
I purchased onemonth.com (where I used to work) a few months ago and have been working on relaunching it.
What an awesome little game Replicube is. It’s like Picross 3D meets shader programming. The puzzles are a fun challenge and the interface is charming. Thanks @walaber! walaber.com/replicube
@xymbol@pragdave That’s a great article, thanks for sharing. I basically code in a similar style that Dave does here. Create modules with class methods for the behavior. Use classes/objects as bags of data with minimal logic.
90% of the Ruby code I’ve written the past few years has been class methods without shared state. The code has clearer dependencies and is easier to read, test and maintain. OOP has its place, but I don’t think it fits the majority of web-app logic.
@MorriceGavin@ismasan I generally don’t follow the functional core approach. Having a pure method is great, but I don’t go too far out of my way. I find most web apps rely so heavily on the database that a functional core leads to a lot of layers and indirection. I don’t like layers.
@ismasan@rbates I appreciate that this is more of a functional approach, and that has its strengths.
But a lot of these wouldn’t be “pure” functions would they? In the context of a Rails app, you’re still going to be mutating a lot of the arguments passed to these functions?
@MorriceGavin@ismasan Exactly, those dependencies are very clear. You can see what is being called and follow them. It’s also easy to reverse-lookup to see what is calling a given method.
@rbates@ismasan I understand that part. But then surely you’ll have as many or more hard dependencies in the forms of classes/modules that you are referencing inside your singleton methods?
ModuleA.thing
ModuleB.other_thing
etc?
@gagsdfhy There is some repetition but it isn’t bad with the Ruby shorthand for named arguments. I thought this would be a bigger issue but it really isn’t.
@mahdix I’m actually not the greatest fan of functional programming either. I’m fascinated by it but the constraints are a little too much for me. I often find functional code harder to read and follow compared to a more procedural style.
Whenever you’re tempted to reuse a method that *almost* does what you want: Stop, duplicate the method, make the modifications, and then refactor the actual duplication.