3 ms·
I'm at a point in my career where I see "magic" and wince hard. This is so hard to reason about and fix at scale. If you let other engineers run wild with this
by echelon 5y ago
I'm at a point in my career where I see "magic" and wince hard.
This is so hard to reason about and fix at scale. If you let other engineers run wild with this and build features with it, the time will eventually come to decom your service and move functionality elsewhere. Having to chase down these rabbits, duplicate magic, and search large code bases without the help of an AST assisted search is slow, painful, and error prone.
I spent several years undoing magic method dispatch in Ruby codebases. Tracing through nearly a thousand endpoints to detect blast radiuses of making schema changes impacted by CRUD ops on lazily dispatched "clever code".
I'm sure there are valid use cases for this, but be exceedingly careful. Boring code is often all you need. It doesn't leave a mess for your maintainers you'll never meet.
Python users tend not to behave this way, but seeing posts like this requires me to urge caution.
- jhgb 5y agoWasn't the idea behind this to make most code boring, and have only a small part of it exciting? Just like when structured programming was created, or even local variables introduced, etc. (Of course, the exciting part had to be moved into the compiler in those cases.)
- radicalbyte 5y ago..and there was me thinking that it was only Java which suffered from that problem. That kind of code is great if: (a) you wrote it (b) you knew what you were doing when you wrote it and (c) you also wrote an extensive set of tests to cover the entire domain of whatever you were doing.
- tentacleuno 5y ago(d) and you used comments! Comments are underestimated. I'm not saying they should be used as an excuse to use "magic" esoteric code, but sometimes such solutions are needed and it's much better to document them for future maintainers.