- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
The only way this mess makes sense is if at one time there were more values to the
NoteDurationType
enum. All of which exceptLengthOfStay
are now deprecated and should now be updated (if touched in the normal course of handling) to the new default.For that case I can see some maintenance programmer pulling out their "fix deprecated legacy values" mental code pattern. Which looks a lot like:
Here's hoping my code formatting is close to correct ...
Admin
This seems like the kind of thing that made sense at one point and kept getting changed until it didn't make sense any more.
Admin
Sadly, in production code, it is often necessary to make the most minimal possible change to get the change through change control boards. Yes this causes crud to accumulate but if you consider how long a full test cycle might take for a large complex product to be tested, you can see why no one just fixes nonsense like this. Do your time in hell them move on. There are better jobs out there
Admin
The only reason I can think of even going here is asking the question, Is note nullable? But this is certainly not the way to check that.
Admin
I also like the "Note.Note." prefix. This looks like C#, so types cannot contain members with the same name as the type, so the only possibility is that first Note. is the namespace, and the second Note. is the type. No company name, no product name, just a Note class inside a Note namespace and - of course! - a static method to do some business logic operation.
Admin
Also, shouldn't it be:
Note.Note.CreateNewTaskNote(oc, note.NoteId, trimmedNote, scheduleTask.AssetTreeId, ScheduleStartDate, NoteDurationType.ExpireToday);
Admin
Are we not gonna talk about the final function call passing six parameters and relying on getting the order correct, rather than "noteId: note.NoteId, ..."? (I've been guilty of that sort of thing in the past, and some past cow-orkers have done far worse, but at least I've been cleaning up instances as I happen across them for other reasons.)
Admin
This seems like a high school assignment where one of the tasks is to get above a certain amount of SLOC. Horrific and incredible at the same time!
Admin
Even more likely - some contractor was getting paid on a per-SLOC basis. THere's always ways to make the code longer.
Admin
Doesn't seem like a lot of bloat, but when you actually count the lines, it's an order of magnitude of waste.
Admin
And this is why mature teams focus on reducing the cost of testing. For the reasons you have just said and many more, expensive-to-test code is on a freight train ride to becoming hard-to-maintain code.
Admin
Just like my life....
Admin
Sounds like a loss of rhythm. 🎶
Admin
Admin
10 lines to write a ternary. Wow!
Admin
Enums come in two main varieties: those that are modelled as numbers (as in C, C++, and C#), and those that are modelled as classes (as in Python and Java). Those based on integers are more implicitly open to extension than those based on classes (as the classes in question are usually not open to subclassing).
There are other solutions in this space, but they're much less common.