55

SUPERVISOR: You wrote this 140 lines method, it's too long. You should split it up, it's not readable
IHateForALiving: Bruh be serious, this is a single switch-case; I can't split it.
SUPERVISOR: Fine, I'll do it.

HIS CODE: He split the 140 lines method into 2 methods: the first is 4 lines long; it's a try-catch surrounding a call to the other method, 136 lines long.

Comments
  • 3
    Much better now.
  • 2
    I'm sorry. It's not 2 methods. It's 3.

    Side note, the config passed as a parameter is pissing me off beyond reason.
  • 6
    @lambda123
    This is correct.

    Max 6 lines, though there is no limit on how many characters >:D
  • 3
    100+ lines switch case?!
    That smells.
  • 3
    @lambda123 hell, no! 😆
    I like your sarcasm and I‘m with you about the misuse of design patterns and abstraction.
    But I consider 100+ lines of switch case not to be "clearly in one spot".
    It could be reasonable in some rare case but as I said: It smells.
  • 2
    @Lensflare it's 130 lines with logging, plenty of carriage returns, comments and stuff like that.

    The actual code is stuff like this; you receive a message from Line, those messages can have varying formats, you forward those messages to our own application. There's no black magic going on there.
  • 5
    @IHateForALiving thanks for showing the code. It’s not bad but personally I‘d extract each case into a function.
  • 5
    @Lensflare I agree with this. Because, if something breaks how it is now, the log will be “error in function bigassswitch” where as if you break the cases in to functions, it will be like “error in function specificCase”
  • 0
    @Lensflare or use this

    do[event.message.type](event.message)
Add Comment