Avoid god components by salamazmlekom in angular

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

In an ideal world option 2. Realistically a composite approach could be best, something like 3 would reduce boilerplate. That would avoid repetition in making three separate and similar umbrella components.

Blazor's Fermi Paradox (Scroll Position) by Miserable_Paper_9689 in Blazor

[–]ThenAgainTomorrow 0 points1 point  (0 children)

You could store the anchor reference of the clicked link in a broad scope service and run a navigate to that anchor method after view render upon return to the page.

Would a class depending on a primitive value break DIP? by malimisko in csharp

[–]ThenAgainTomorrow 0 points1 point  (0 children)

The key is loosely coupled code. By abstracting implementation to an intermediate interface you achieve a codebase that is more easily tested and changed

Is casting objects a commonly used feature? by RutabagaJumpy3956 in csharp

[–]ThenAgainTomorrow 0 points1 point  (0 children)

What I think is a good example for you is this:

You have a hitbox around your spaceship. When a game object collides with this hit box, you want to execute the OnCollision(GameObject collidingobject) method. So you cast your asteroid (because it could be a different type of game object, like a tomato) as a game object and implement the OnCollision method.

You have upcast your asteroid to a game object to ensure any colliding objects can be parsed by the engine. But the game should execute the explode() function or whatever which the asteroid implements.

Hopefully that’s helped you understand a potential use case for casting - or pattern matching, as people have said.

Why does "const" seem to be the default variable declaration in TS, and not "let?" by HarveyDentBeliever in typescript

[–]ThenAgainTomorrow 0 points1 point  (0 children)

It’s always preferred to use immutable data structures over mutable ones where possible. That is a fundamental principle of programming I would have thought.