3 ms·
I'm a Java fan so I'm contractually required to dis c#, but actually I kinda like this. It reduces boilerplate. Yes, it could be abused but this is what code re
by peterashford 1y ago
I'm a Java fan so I'm contractually required to dis c#, but actually I kinda like this. It reduces boilerplate. Yes, it could be abused but this is what code review is for.
- moomin 1y agoYou’re not wrong. Every language feature that gets added there’s someone who wants to stop the clock and hold the language definition in place because “people might misuse it” or “people might not be familiar with it”. It’s not language specific, it’s everywhere.
- ffsm8 1y agoStill, enabling ?. Access on the left side of the equals (assigning) feels like a serious anti pattern to me I struggle to even see how anyone would prefer that over an explicit if before assigning. Having that on the right side (attribute reference) is great, but that was already available as far as I understood the post...
- rkomorn 1y agoAs someone who comes from a language with no ? (or equivalent) who only dabbles in C#, it actually seemed a little weird to me that this was one of the contexts where it wasn't usable. So as a casual observer, I'd say it brings more consistency. But also as a casual observer, my opinion is low-value.
- fakwandi_priv 1y agoThe point the article is trying to make is that it reduces boilerplate, wouldn't be surprised if this gets added to TS in the next year of two.
- hahn-kev 1y agoWithout it there's some silly inconsistency. For example I could call `person?.SetName(name)`, but if you wanted to refactor that into `person?.Name = name` you can't.
- ffsm8 1y agoThat's a great point I didn't think about. From that perspective, it does make sense. Maybe my feeling is just rooted in the fact I've never used a language which allowed ?. on assignment
- moomin 1y agoMy take is that it’s pretty minor. Modern C# has across the board null checking and for the most part you’re not designing things where this even comes up. You are, however, correct, in that I have 100% seen the ?SetName thing used by devs who just wanted to make the null checker go away and didn’t actually think about what the correct behaviour was.
- pjmlp 1y agoWhy the requirement, because of J++ and how Ext-VOS alongside Cool became .NET? Most companies don't care about this kind of stuff. I work across Java, C#, JS/TS, C++, SQL, and whatever else might be needed, even stuff like Go and C, that I routinely criticise, because there is my opinion, and then there is the job market, and I rather pay my bills.
- cemdervis 1y agoReminds of something I read somewhere: "I don't love Java, but I love the house it bought me."
- pjmlp 1y agoIndeed. :)
- peterashford 1y agoYeah, I work with lots of languages too. Including c#, as it happens. It was a joke.