38
frugant
2y

When a method has all the truth.

Comments
  • 11
    True true ******fucker
  • 9
    That's why that dev should have used named arguments, MS added that to C# for a reason, apparently he doesn't get it yet
  • 3
    The truth lies within the tickets search helper 🙏
  • 8
    @gitpush Or this other really cool thing C# can
  • 2
    @inaba Of course not to forget setting values to default acceptable ones in constructor so that if a smartass dev forgets a property, it doesn't go to null or whatever its default is, especially for int and bool
  • 1
    @inaba it is not exactly the same thing. That one is to initialize the fields.
    Parameters could have also been used for other purposes, without saving them in a field.

    But you're right, that is cool! Sometimes that could help.
  • 2
    @frugant Never said it was the same thing. I said it was a thing, it's cool, and a lot cleaner as well!

    Probably also my number one favourite feature in the language. Closely followed by LINQ and async/await :v
  • 2
    I can't see how that'd be a helper
  • 6
    Any method that takes that many arguments is a wrong method.
  • 5
    Where my bitflags at?
  • 1
    This is horrible. Even more in terms of quality. And yeah c# has named and optionals etc but that doesn't mean you should do stuff like this. A nice technique is to refactor this to use a parameter object to encapsulate all parameters and use that instead of so many arguments.
  • 1
    @CodeMasterAlex and what, use a parameterObjectFactory to instantiate it? :v

    Jokes aside could you come with an example of what you're talking about? It sounds messier that setting an objects properties pr my previous example
  • 1
    this gives a whole new meaning to "Single Source of Truth"....
  • 1
    @inaba Of course! Check out the e-book 'Building Maintainable Software - Ten Guidelines for Future-Proof Code' that you can get for free at the Software Improvement Group's website at https://softwareimprovementgroup.com/...

    I believe they have a c# and java version available. It also explains how and why to use a parameter object, look for 'introduce parameter object' in the pdf's index.
  • 1
    @CodeMasterAlex send me the example. I am not going to sign up :v
  • 1
    @inaba I took some effort to provide you a link where you can download it. Now you take the effort to fill in that simple form and click the download button! Or stay ignorant, the choice is yours.
Add Comment