3 ms·
- How the Code Probably Got There The login names are very specific, despite the use of 'like' and wildcards. It looks like an exception list that is added to
by kcartlidge 5y ago
- How the Code Probably Got There
The login names are very specific, despite the use of 'like' and wildcards. It looks like an exception list that is added to as login names are chosen, spotted, and banned. Which means someone just pops into the code and adds a new entry as a 'bad' login comes to light. It isn't expected that it will proactively block bad ones but that it will stop already-used bad ones from recurring. Which explains why it looks as it does; it has just grown from a quick hack way back when.
- About the Code Quality
I'd guess none of us would set out to write it like this if we knew how it would grow, but for those original handful of exclusions a database would have been overkill.
There comes a point where you start considering refactoring, but in a business with priorities it isn't unusual to look at code like this and say it's encapsulated, efficient, version-controlled, and in just one place, so other things are more important than changing what isn't actually broken (meaning the location of the code/data; I'd probably have issues with the actual logic but that's a different thing).
- And the Straw Men
As for the article this thread is discussing I'm not a big fan. The second half says "This whole validation should not even be in SQL". Yet the only reason that's even up for discussion is because the first half suggests it. The code certainly didn't. Which makes most of the article pointless.
And the reasons to complain include "how can you manage that txt file of or statements?", "What do you do if you want to change it to something else?", and "copy paste each phrase in a 1000 lines?".
It's simple - you manage the txt file (actually a file of source code, but whatever) by editing it and versioning it. Want to change it? Then change it. There is no reason whatsoever that it would result in copy/pasting 1,000s of lines when only the ones changing need changing.
- And the Overhead of the Proposed Change
A tool? To maintain a database list? Why waste sprint time creating a tool to replicate basic textual operations in code that is simple, isolated, and fast.
- Summary
Sorry for the rant. There's good code and bad code, but there's also good enough code and whilst as I said I'd never set out to write this there's no real reason to change it.
YMMV. Five developers have five opinions plus a sixth for the consensus. We won't all agree. I can live with that.