Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
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
-
@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
-
frugant1646y@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. -
inaba45896y@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 -
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.
-
inaba45896y@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 -
@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. -
@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.
Related Rants
When a method has all the truth.
rant
method
parameters
c#