top | item 28425053

(no title)

jeremycw | 4 years ago

The problem with these types of gems is that they're good for refactoring functional style code that takes an input and produces a result and has "few side effects" as they mention, but this is generally not the type of code you find in an old legacy rails application that you want to refactor. The whole thing that makes these refactors tricky is that they can just write to the db anywhere in a non obvious way.

If you naively go about refactoring something like:

POST /users

Thinking all you need to do is match the output of the current request and match the record it makes in the users table you're potentially missing a ton of side effects you didn't even know about.The problem has always been the side effects and until one of these gems can track and compare side effects in an intelligent way I don't see how they are that useful.

discuss

order

emodendroket|4 years ago

Really this is what drives me nuts about Rails. You can never really know what exactly any line of code is going to do.

weaksauce|4 years ago

Do you have an example of such code that does something off label or tricky to intuit?

Mikeb85|4 years ago

I mean, this can be any highly expressive language. Common Lisp macros can get crazy, Haskell has sugar on sugar, Perl all looks like code golf to me, etc...

BurningFrog|4 years ago

Yeah, as much as really like Ruby, there is just too much Magic going on.

I'm a programmer, not a wizard!

aeontech|4 years ago

You are right, but there are many many methods in any codebase that really are, for all intents and purposes, read-only - ie, get a bunch of data from data sources, stitch it together, and return a json blob.

These tools would make me feel a lot more confident refactoring code like this (actually, right now I use Postman automated API response recordings with a manually extracted dataset of representative query parameters from production logs to validate our changes) - so this indeed looks like it might make my life easier :)

joelbluminator|4 years ago

How do u stitch your logs params with Postman? And btw arent controller/request tests better for that?