• WTFGuy (unregistered)
    var noteFrist = NoteDurationType.FILE_NOT_FOUND
    

    The only way this mess makes sense is if at one time there were more values to the NoteDurationType enum. All of which except LengthOfStay 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:

    var newEnumValue = Enumtype.ReplacementValueforDeprecatedValues ;
    switch (someBizObject.EnumValue)
    {
        case Enumtype.FristStilllValidValue :
            newEnumValue =  Enumtype.FristStilllValidValue ;
            break ;
    
        case Enumtype.SecnodStilllValidValue :
            newEnumValue =  Enumtype.SecnodStilllValidValue ;
            break ;
    // etc. for however many still-valid values there are.
        default : 
            break ;
    } 
    
    SomeBizObject.Update( ... newEnumvalue ...)
    

    Here's hoping my code formatting is close to correct ...

  • RussellF (unregistered)

    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.

  • Lowell (unregistered)

    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

  • (nodebb)

    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.

  • (nodebb)

    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.

  • (nodebb)

    Also, shouldn't it be:

    Note.Note.CreateNewTaskNote(oc, note.NoteId, trimmedNote, scheduleTask.AssetTreeId, ScheduleStartDate, NoteDurationType.ExpireToday);

  • (nodebb)

    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.)

  • (nodebb)

    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!

  • cellocgw (unregistered) in reply to liaml17

    Even more likely - some contractor was getting paid on a per-SLOC basis. THere's always ways to make the code longer.

  • Yikes (unregistered)

    Doesn't seem like a lot of bloat, but when you actually count the lines, it's an order of magnitude of waste.

  • (nodebb) in reply to Lowell

    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.

    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.

  • Randal L. Schwartz (google) in reply to RussellF

    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.

    Just like my life....

  • Chris (unregistered)

    Sounds like a loss of rhythm. 🎶

  • (nodebb)
    1. Enums (in nearly every language can have many possible values (perhaps even billions!) beyond what is declared.
    2. Named parameters have their own problems, strongly typed parameters can be a good solution that mitigates "opps I got the order wrong" errors)
  • nunya business (unregistered)

    10 lines to write a ternary. Wow!

  • (nodebb) in reply to TheCPUWizard

    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.

Leave a comment on “Switching Notes”

Log In or post as a guest

Replying to comment #:

« Return to Article