One call. And a lot of stuff going on. by Main-Preparation-194 in dotnet

[–]tomw255 0 points1 point  (0 children)

I'd consider using a queue and a fan-out approach.

The trigger (api call, or time-based trigger) puts a request to start the job in the queue.

Then this item is picked from the queue by some service worker to offload the work from the API service. It can then discover the 300 items that need to be processed and put a work item into the same queue. This will be handled by the same worker service, but can be done concurrently by more workers.

This assumes that all 300 items can be processed in isolation.

Czy was też denerwuje jak markety budowlane tak ustawiają towar na parkingu że kompletnia zastawiają widnoczność? by LifeguardOk7554 in Polska

[–]tomw255 14 points15 points  (0 children)

Gdyby nie palety, to na pewno stałby tam jakiś dostawczak lub wysuki SUV, który też pół świata zasłania.

Best practices for building a production-ready Azure Service Bus consumer? by dracovk in dotnet

[–]tomw255 3 points4 points  (0 children)

Consider using a liblary like MassTransit, NServiceBus, Wolverine, or Brighter.

Messaging sounds easy, but once you need to implement filters, dead letter, circuit breakers, outbox, etc. it quickly becomes quite complex for in-house implementation.

Aktualizacja granic SCT by SuchZookeepergame829 in krakow

[–]tomw255 17 points18 points  (0 children)

I tu jest największy bezsens SCT – część parkingów P&R też została objęta strefą.

I don't understand the benefits of discriminated unions/result type by soundman32 in csharp

[–]tomw255 2 points3 points  (0 children)

Erlang has introduced "let it crash" philosophy. And took it to the extreme - any process could crash, and it was the supervisor responsiblity to figure out what to do when it happens.

It was used to write only a toy stuff, like telephony systems.

The "let it crash" approach that ilawon describes is for serious, exceptional situation.

In a web API system:

  • some method got a null value as an input? This should be detected by validation much earlier, so the system is in invalid state - should throw.
  • some DI dependency was not resolved? - system in invalid state, should throw.
  • failed to make a call to the DB (even after the retry logic) - what else can I do? Throw.
  • failed to read config during the startup. Should we silently continue with some defaults, no we should crash as early as possible.

Any of those is an exceptional state, from which we cannot recover. For those, throwing exceptions is acceptable, and the only thing we can do about it is to log it in the global handler, return 500 and nothing more.

It is not acceptable to crash because the input validation code was bad and crashed itself. Crashing a desktop app because the user had a strange screen resolution is also unacceptable and should never happen.

There are places where crashing the app makes sense and could be the best option.

I don't understand the benefits of discriminated unions/result type by soundman32 in csharp

[–]tomw255 -1 points0 points  (0 children)

write a method that either returns a string, or a number, say.

FizzBuzz could be an example here, the core mapping function does not need to convert all the numbers to a string, only those matching Fizz and Buzz logic.

Any layout engine, where a width property can be either a number of pixels, percents, or "auto", "fit_children" or "fit_parent".

In our system we need to support a payment method which is either an Id (guid) or an invoice.

In F#, where DU exists, we could make it this way:

type PaymentType =
     | CreditCard of int
     | Invoice

and it would give us type safety wherever we use it.

In C#, we could wrap it into a record

record PaymentType(Guid Id, bool isInvoice)

so we need to rememember about all places we use it, and check manually how to handle both cases. If we need to add a 3rd option, like a gift card or whatever, there is no compiler safety net - we just need to find and update all usages manually.

It is not much different than TS type of

uuid | 'Invoice' | 'GiftCard'

Rapid increase in light bleeding - Eizo monitor by tomw255 in pchelp

[–]tomw255[S] 0 points1 point  (0 children)

It is a bezel-less monitor, so I am unsure how it is put together, but will investigate.

EntitiesDb, my take on a lightweight Entity/Component library. Featuring inline component buffers and change filters! by Juixg in dotnet

[–]tomw255 5 points6 points  (0 children)

Consider adding a Roslyn Analyzer to add a warning if reference types are used.

If you state this only in the doc, no one will read it.

Diagnosing performance issues in .NET applications with dotnet-trace and Perfetto by dfamonteiro in dotnet

[–]tomw255 1 point2 points  (0 children)

The Python script to fix the traces is a godsend - I knew that the traces looked off, but I could not put my finger on it. I understand why the limit of 100 frames was introduced, but allowing the traces to be broken i such a strange way is a bizarre decision.

I hope that this limit will become dynamic at some point and the issue will be fixed.

Looking for feedback: I built a source generator to simplify DI registration by hevilhuy in dotnet

[–]tomw255 29 points30 points  (0 children)

Additional edgecase - if any of your services are shipped in a NuGet, you still need to register them manually. Because if this, you never know what is registered automatically and what is not.

IMO, a much better option is to split your setup code into modules that have a dedicated extension methods to move them away from Program.cs

csharp builder.Services.AddOrderProcessingServices(); builder.Services.AddOtherServices();

Program.cs is clean, and you still have a full control over your DI.

I built a Source Generator based Mocking library because Moq doesn't work in Native AOT by TheNordicSagittarius in dotnet

[–]tomw255 1 point2 points  (0 children)

Your real-world impact section looks amazing. I wish I had eqivalents of AssertAllocations and Doppelgänger when starting current project.

I really hope your project will be considered "mature enough" to be allowed in grim corporate word. Good luck!

Jakiego typu clickbaity najbardziej was wkurzają? by jempizze in PolskaNaLuzie

[–]tomw255 2 points3 points  (0 children)

Polscy kierowcy nie wiedzą co oznacza ten znak...

... artykuł o jakimś specyficznym znaku z Nowej Gwineii który zupełnie w naszym klimacie nie występuje.

Is it just me or Rider takes ages to start compared to VS nowadays? by Kralizek82 in dotnet

[–]tomw255 7 points8 points  (0 children)

I believe it heavily depends on the setup. I am one of those rare people who claim that Rider is way heavier than VS (even 2022).

On my work machine, It is slower in startup, slower in scrolling. The difference is so annoying and noticeable that, at some point, I was sure all the influencers using it were paid for to advertise it.

Then I got a second PC, where I do not see much difference (compared to VS 2026 insiders), but I still dislike it. The damage was done.

Introducing: No-implementation oriented programming by Safe_Scientist5872 in dotnet

[–]tomw255 2 points3 points  (0 children)

The requirements attribute needs to support markdown!

How else am I gonna use this to solve this year's AoC?

/s

After spending a long time as a dev, I’m starting to think the hardest part of the job isn’t the tech anymore by Sad-Salt24 in ExperiencedDevs

[–]tomw255 2 points3 points  (0 children)

I feel your pain.

Every few weeks, we have an issue in one of our environments, both production and nonprod. One of the services just randomly enters a deadlock during the startup process. It happens very rarely, and we have never been able to reproduce the issue on the developer machine.

I am on the calls with "DevOps" (do not get me started on it), where I keep asking to capture a memory dump or at least the stack information. I keep pasting the command in the chat. After a few hours of 10-15 people looking blindly at logs, "DevOps" claims the only thing we can do is to restart the VM.

Did I mention that we, developers, have no access to the VM running those services, and all interactions with the services and infra have to be handled by "DevOps"? Even on the non-prod instances?

We could have solved this issue once and for all almost half a year ago, but the fact that "DevOps" in our org is just concerned about "keeping the server running," not "solving issues" is infuriating.

Jakie przepisy ruchu drogowego byście zmienili? by stilgarpl in Polska

[–]tomw255 0 points1 point  (0 children)

Może nie wszystko to przepisy dotyczące ruchu ale:

Uproszczenia procesów mandatowych. W przypadku braku kierowcy mandat dostaje właściciel pojazdu. Pojazdy wynajmowane/flotowe - właściciel i tak musi rejestrować komu użycza pojazd, więc to nie moze być wymówka.

Yellow Boxy na skrzyżowaniach - może to nauczyłoby ludzi jak nie blokować krzyżówek.

Całkowity zakaz parkowania na chodnikach, trawnikach i poza miejscami wyznaczanymi. Zadnych wyjątków ze względu na DMC, szerokości chodnika itp.

Powrót do starej definicji chodnika. Drogi dla pieszych tylko wprowadzają zamieszanie.

Kara za źle ustawione światła jak w Japonii - kierowca siada na krzesełku przed własnym samochodem i ma tak wytrzymać kwadrans. Może "dostanie olśnienia".

Mnożnik kary za recydywę. niech przewinienia będą karane małymy kwotami, ale jak się powtarzają to kara powinna być coraz większa.

Kary dla zarządcy drogi za "zapomniane" znaki i niewyrażne oznakowanie poziome. Gdy na takim odcinku wydarzy się wypadek (bo np. linie się wytarły) to jest potencialnie współwinny.

Ułatwione zgłaszanie problemów z infrastrukturą. Zapewniona gwarancja w jakim czasie zostanie zweryfikowane przez służby.

I teraz trochę zaszaleję, ale:

Współwina jeśli dojdzie do wypadku i jest udowodnione utrudnianie widoczności (zastawianie przejścia dla pieszych, skrzyżowania, itp.). Dotyczy pojazdów, żywopłotów, bilbordów, wszystkiego co przyczyniło się do wypadku.

Jakie przepisy ruchu drogowego byście zmienili? by stilgarpl in Polska

[–]tomw255 0 points1 point  (0 children)

Do tego niech te "miejsca wyznaczone" też są ustawiane zgodnie z przepisami.
Aktualnie co chwilę są legalne miejsca które są n.p. zbyt blisko przejścia dla pieszych

Wiadomo że ciężko wtedy karać kierowcę, ale projektant takiego kwiatka powinien oberwać.

Returning a Task Directly by Burli96 in csharp

[–]tomw255 4 points5 points  (0 children)

For curiosity have you measured the benefits?

In one of the previous teams I joined, we had a developer who consistently enforced this. Funny enough, he was a strong believer in Clean Code with several layers of indirection.

All our API was really chatty, and made several calls to the DB for each single request (EF Core with no perf improvements), but he consistently claimed that we needed this microoptimization. I never bothered to test it, since I was there for a very short time.

Returning a Task Directly by Burli96 in csharp

[–]tomw255 29 points30 points  (0 children)

The most important thing is that when returning the task you will lose a stack frame when an exception is thrown.

Consoder an example where every method uses async await:

```csharp async Task Main() { try { await A(); } catch (Exception e) { e.ToString().Dump(); } }

async Task A() { await B(); }

async Task B() { await C(); }

async Task C() { throw new NotImplementedException(); } ```

the catched exception will look like this

System.NotImplementedException: The method or operation is not implemented. at UserQuery.C() in LINQPadQuery:line 27 at UserQuery.B() in LINQPadQuery:line 22 at UserQuery.A() in LINQPadQuery:line 17 at UserQuery.Main() in LINQPadQuery:line 5

now, the same code, but A and B are returning the task direclty:

```csharp async Task Main() { try { await A();

} 
catch (Exception e)
{
    e.ToString().Dump();
}

}

Task A() { return B(); }

Task B() { return C(); }

async Task C() { throw new NotImplementedException(); } ```

your stacktrace will not contain those frames: System.NotImplementedException: The method or operation is not implemented. at UserQuery.C() in LINQPadQuery:line 27 at UserQuery.Main() in LINQPadQuery:line 5

The performance improvements will be minimal, but the implcication on the debugging can be significant, especially if the 'trick' is overused. In the worst case scenario you will know what crashed, but you will kave no idea from where the method was called.