3 ms·
I like it! Free your mind (from OO tyranny). Sometimes, data is just stupid, and doesn't deserve anything more than an associative array between plucking it f
by Roboprog 12y ago
I like it! Free your mind (from OO tyranny).
Sometimes, data is just stupid, and doesn't deserve anything more than an associative array between plucking it from the DB and casting it off as some JSON. Writing a bunch of do-nothing classes and then bitching about deserializing and reserializing them seems like folly to me.
Classes make sense when you use polymorphism and have a set of behaviors clumped together and multiple implementations. If it's just one call with multiple strategies, use a function call with a defined signature (func pointer type, delegate, whatever). If the "class" is nothing but magic bean "[sg]et-foo; [sg]et-bar; [sg]et-blah; ..." (with no validations, calculations or any other kind of value added), why are you writing it? (and why do I have to read it?) Use a struct/record/tuple if there is a lot of code that might typo the property names, or just an associative array if the usage is an automated pass-through with little to no looking inside.
Some parts of an app benefit much more from functional composition than a big bunch of make-work objects that make a loud clunk when you whack 'em with a stick.
- gress 12y agoExactly. And the swift designers realize this which is why they added these language features.