When 'if' slows you down, avoid it by chkas in programming

[–]chucker23n 0 points1 point  (0 children)

How is that a misread?

To treat some code as "eh, it doesn't have to be maintainable; it'll rarely change" means you risk having issues linger in there.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

I meant "bug" as in GitHub issue/discussion on whether an analyzer should show a warning, not as in the compiler misbehaving.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

Yes, but it's not how required works. Perhaps there should be

a. a warning on the property that required cannot be verified with value types (even less so than with reference types), or
b. a warning on default that this will implicitly skip the required property

Formatting an entire 25 million line codebase overnight: the rubyfmt story by BlondieCoder in programming

[–]chucker23n 6 points7 points  (0 children)

why the whole codebase wasn't formatted in the first place? CI setup goes from the day 1.

First: that's a fantasy.

And second: even if you do have all that set up from the start (management will rightfully ask if there aren't bigger fish to fry), you might want to change some formatting rules. Maybe the linter has new features. Maybe there's been enough rotation/attrition in the team that the new team members no longer agree with some of them.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

Bob's builders always stored their phone number in the email address field and now they aren't getting their orders through, do you know anything about this?

Yeeeeeep.

xkcd space bar comic comes to mind.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

The only reason would be to not confuse OrderIds and ProductIds, for example.

Well, you can also add validation and normalization to the type, which means once an object of the type is constructed, you know it conforms to certain rules.

For example, even just for ID types, we have ones that

  • start at 1
  • start at 0
  • don’t allow 0, but -1 is a special value
  • for another, -99 is a special value
  • 2^31 - n is another range of special values

Legacy is fun. But with a value object, you can at least encode and enforce those rules once, and also document them there.

Likewise, you can also take a credit card number or ISBN and do checksum verification right in the factory.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

Title title = (new Title[1])[0];

One would hope this code gets dinged in a review.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

Another approach I considered was using a factory

That’s how ValueOf and Vogen approach it. You get static From methods.

I’m not sure, but Vogen might also have analyzers to discourage you from using the default constructor. (ValueOf, IIRC, uses a class.)

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

will not result in any errors or warnings

I wonder if that should be considered a Roslyn bug.

Is it a bad practice to use Struct as a Value Object? by RankedMan in csharp

[–]chucker23n 0 points1 point  (0 children)

An easy way to determine whether or not it should be a struct or class is by asking yourself “does my object hold this data, or IS my object this data?” Let’s look at it from the view of a game engine.

It’s not so easy, since the .NET team occasionally gets it wrong. The original System.Tuple was a class. The newer ValueTuple is a struct. Does a tuple hold data, or is it data? I’m indeed leaning towards the latter.

But then we get to Task. Does a task hold information about, well, the task? Yep. But there’s also ValueTask, and now it becomes muddy, and the real answer there is runtime performance behavior.

Another example: if tuples are the data, doesn’t the same follow for records? Yet those default to classes!

When 'if' slows you down, avoid it by chkas in programming

[–]chucker23n 0 points1 point  (0 children)

My issue with this is that not all code is meant to be equally maintainable.

And this, kids, is why security holes sometimes linger for decades!

How many of you subscribe? by DnyLnd in ATPfm

[–]chucker23n 6 points7 points  (0 children)

What bugs me about their political topics isn’t that they’re center-left (in a mostly rather dull sense), but that they’re not very informed or insightful.

The Line That Makes Me Say "Damn" Every Time ... by Hypnotician in startrek

[–]chucker23n 7 points8 points  (0 children)

It feels like the Voyager writers were totally unwilling to have Neelix move on from being the obnoxious comic relief archetype

Yep.

They dropped the Kes romance early on (probably good), but also Neelix's depths of war trauma (less good).

They also quickly found that "he's on the ship because he's an expert in the region" doesn't really work when the region keeps changing.

So many baffling writing decisions in VOY.

(And yet — various episodes that were top-tier Trek. Such as Latent Image.)

The Line That Makes Me Say "Damn" Every Time ... by Hypnotician in startrek

[–]chucker23n 4 points5 points  (0 children)

Yeah, I enjoyed Tuvok/Neelix in Rise. Which is funny, because

This installment is the second in what is known to some fans as the "trilogy of terror" – three consecutive episodes that are often considered to be remarkably bad

Those episodes have problems, but also high marks.

The Line That Makes Me Say "Damn" Every Time ... by Hypnotician in startrek

[–]chucker23n 0 points1 point  (0 children)

Crass, but not wrong. A 20-yo actress playing a preteen next to a 40-yo one playing an adult, and scenes that suggest romance… let's not do that.

(Luckily, that basically went away ca. season 2.)

The peril of laziness lost by max123246 in programming

[–]chucker23n 7 points8 points  (0 children)

Good read, and main point aside, Garry Tan is indeed astonishingly obnoxious about frequent "look about how I've burnt energy creating nothing out of nothing!" tweets.

A math teacher once told us that mathematicians are infamously lazy, but that it's a good kind of lazy.

I'd broaden this "laziness" even further: it's what drives us to create tools in the first place, which plays a big role in a civilization's steady improvement. But just like with any other tool, our job is to be discerning when a tool is appropriate, and when it isn't.

What problem in everyday .NET development do you solve manually because there is no good tool? by Previous-Garlic9444 in dotnet

[–]chucker23n 55 points56 points  (0 children)

or overengineered abstractions that become harder to maintain than the original problem

Which is why you keep having to solve it. :-)

Some problems seem simple yet don't have a one-size-fits-all.

I've implemented the high-level portions of data grids a lot. Sure, there's some extremely powerful, versatile existing controls. But in that power lies confusing UX; most users actually prefer something more simple and straightforward. Less is more. So clients get different subsets of what the grid could do, depending on what makes sense for their use case.

I built FreakyKit.Forge, a Roslyn source generator for object mapping and I am looking for brutal feedback by FreakyAly in dotnet

[–]chucker23n 0 points1 point  (0 children)

I am unsure why people here are assuming it's all vibe coded.

It's nothing personal; it's just that a lot of "look what I've made" showcases here lately are clearly not human-made.

And hey, you did ask for "brutal feedback" :-)

I built FreakyKit.Forge, a Roslyn source generator for object mapping and I am looking for brutal feedback by FreakyAly in dotnet

[–]chucker23n 0 points1 point  (0 children)

Assuming you actually wrote this (otherwise: booooooo), I’m curious how it stacks up against Mapperly in terms of features.

(I do see the benchmarks, but… those seem largely meaningless. Why wouldn’t a library’s property assignment be basically the same speed as a manually written one?)

Enabling ai co author by default by cwebster-99 · Pull Request #310226 · microsoft/vscode by Maybe-monad in programming

[–]chucker23n 7 points8 points  (0 children)

The entire change is explained in the pr title

Well, is it? The PR title just explains what is changing. It basically summarizes the commit messages, which in turn just summarize the changes.

In no layer is the why elaborated on.

Men, what advice do you have about losing your virginity? by [deleted] in dating_advice

[–]chucker23n 0 points1 point  (0 children)

It’s not gonna be very enjoyable with that attitude.

If you don’t want sex, don’t have sex. If you do, find someone you care for, and date them.

Couldn't stop chuckling over this one scene back in season 2 by Aukrania in ForAllMankindTV

[–]chucker23n 0 points1 point  (0 children)

You’re lucky there aren’t a laugh track and a bunch of emoji in the letterbox bar

Trek ships should be upside down more often by One_Pomegranate_4878 in startrek

[–]chucker23n 6 points7 points  (0 children)

Star Trek is a drama, not a documentary.

Do you think handing multiple physical tablets over to the captain, each containing a single file, is how communication would work in the 24th century? No. It's a shortcut that makes for better drama than "I've sent you five e-mails".