47
Meei
8y

Normally I just read rants but my new assignments is just to much and I have to vent a bit.

So I was assigned on a new company to help them with their automated tests (I'm normally a developer) which was fine for me. Especially when they said a guy that have 10+ years of experience have worked on the framework for a couple of weeks so it should be fine and ready. So I though it would be a quick deal.

But then I got there and... it's the worst C# code I have ever seen. I can live with the overuse of static, long method and classes and overally messy classes that doesn't really seems to fit (it's bad but not unusual in test code it seems). My biggest problem is overuse of the damn "dynamic" keyword.

Don't get me wrong, dynamic can be good and it have it's uses but here they use "dynamic args" in every single method, every one! They don't care if the method only require one value or ten values, they use dynamic args. Then you follow this "dynamic args" parameter going in to sub method after sub method and you have no idea what they use.

And of course they don't know if anyone use the methods correctly (as you have no damn clue what to use without checking the source code) so in 75% of the methods they convert the dynamic to an object and check if it contains "correct argument".

So what I have here is a code that isn't just hard to use, it's a hell to maintain.

So I talked with this with other testers on the team and they agree, but as most of them lack experience they couldn't talk back to the senior that wrote it. So I hope to sit down with him this week and talk this through because it would be fun to hear the arguments for this mess.

/rant

Comments
  • 6
    Great first rant! I'm curious to hear what happens when you talk to him :)
  • 8
    I have been coding c# for fifteen years now and I had to google the dynamics keyword and I still don't see a use for it :-)
  • 3
    "what his arguments are" you got me there
  • 1
    Keep us updated ;)
  • 1
    What did he say?
  • 0
    Good luck
  • 0
    Wow, that's a special kind of hell.
  • 6
    So a bit of an update:

    I talked with him about it today and his reason was that he wanted the test to be readble, usable for "non-developers" and you shouldn't have to care about types or objects.

    But it didn't get as bloody as I though it would be and we had a lot of similar thoughts about other things. So in the end we're gonna change all dynamics and create regular objects.

    The problem is that I think he still think the dynamic-keyword-design is a good thing. But I will let the people in his next group handle that.

    As for the dynamic keyword in it self (as some asked why anyone would use it), I haven't used it much myself but it can be cool to use togheter with the DynamicObject class.
  • 0
    Absolutely crazy... I almost hate Tuples just as much.... Maybe give ReSharper a bash, might help with some intellisense and has great refactoring utilities.

    I know it can create concrete classes for anonymous types quite quickly, but don't know if it will survive that level of absurdity
  • 1
    I find that seniors at my place struggle to right good code too. It's like they've got where they need. I have one next to me who does 80% play and 20% work (the most terrible work) plus you'll find they don't want to move forward and learn new tech... the day I get to vent to him to his face will be an awesome day.
Add Comment