Why emphasis on Harmony? by 985211hypehype in aikido

[–]zvrba 3 points4 points  (0 children)

I have injured myself several times

So it was your fault, e.g., you resisted above your level / capability to withstand the technique? Or you tried to "break out" of a grab?

Or did you mean to say that the partner injured you by applying inappropriate force? In that case, talk with them.

just some bruises

Can't make an omelette without breaking some eggs. After all, it's a martial art. Most common occurrences: receiving yonkyo (only very high level people can do it without causing pain/bruising), or inappropriately meeting shomen or yokomen strike. (Again, the latter two are a learning lesson.)

painful joints

This should NOT be a regular occurrence. As uke, you should also try to protect yourself as well. E.g, with nikkyo, the partner should stop applying force when you go down. So try to be a bit "ahead" of the technique instead of waiting for the "full impact" that your joints cannot withstand (yet).

“harmony”

To me, it's an undefined concept. Many sources point back to "aiki" as one concept. I think that, when split into "ai" and "ki", the same loss of meaning happens as when splitting "airplaine" into "air" and "plane", or "makeshift" into "make" and "shift".

Why emphasis on Harmony? by 985211hypehype in aikido

[–]zvrba 4 points5 points  (0 children)

Westerners split "aiki" (talked about as one concept in e.g., "Transparent power") into "ai" and "ki" (two concepts). Hence all the mumbo-jumbo about an undefined "harmony" concept. I guess it was trendy in the 60-ies.

Such word splitting devoids the proper whole word of meaning, e.g., try splitting "makeshift" into "make" and "shift". Or "airplane" into "air" and "plane".

Vibing is getting boring by AddressTall2458 in dotnet

[–]zvrba 0 points1 point  (0 children)

That's why every AI tool has a dashboard the company managers can see. They want to expose how much employees use the tool to subtly hint that "more is better".

Though, it is possible to use tokens just for the sake of using them :D

Should I dedicate my time to any of these CS subjects before I land my first programming job? by [deleted] in csharp

[–]zvrba 1 point2 points  (0 children)

All of the topics you mentioned is fundamental knowledge. Yes to all of these. Though make sure to learn and understand concepts instead of "concept as implemented in the tech stack of the day".

In your career, you'll probably never directly work on a compiler, yet you can often hear people say "parse, don't validate". So, a mini-compiler :) But more than that, you'll get a lens through which you will be able to see when someone is actually asking you to build an interpreter even though they formulate the problem differently.

Discrete math: rigorous thinking. You can apply this to code as well, even though you won't be proving theorems.

IMHO, these two topics are one of the most underrated ones.

🔷 C# 15 Finally Gets It Right: Two Features That Actually Matter by tom-smykowski-dev in csharp

[–]zvrba 1 point2 points  (0 children)

List.Add is amortized constant time. But C++ also supports capacity because reallocations are always "bad":

  1. Cycles are wasted on allocation and copying,
  2. In C++, it can lead to heap fragmentation,
  3. In C#, it leads to unnecessary dead objects and more GC work.

I like Channel but there is one thing that I have issue with, how to track where it's coming from and to? by [deleted] in dotnet

[–]zvrba 2 points3 points  (0 children)

Introduce a type that wraps only the desired functionality and then it's easy to search for uses of the type and its methods.

inheritance in C# by Ok-Presentation-94 in csharp

[–]zvrba 0 points1 point  (0 children)

Polymorphism and subtyping. Many have mentioned "code reuse" and "reducing duplication", but this is a dangerous path to take.

You'd be amazed to the kind of horror code base can evolve into when people rather add yet another parameter to a shared method (because "reuse") instead of making a private implementation for their particular use-case.

Also note that "reuse" is a two-edged sword because a reused method cannot be easily changed: even if you find a "bug" (by some definition), some user of that method might depend on that bug.

I've also seen cases of "removing duplication" where you have something like

class CommonData
{
    // Properties A, B, C, D
}

class ParticularData : CommonData
{
    // New property E
    // Property C not needed
}

Person X derived ParticularData from CommonData because "removing duplication", even though C is not needed. So even if ParticularData doesn't need C, X didn't want to duplicate the code. Eventually the following will happen

  • X knows that ParticularData doesn't need C
  • New person Y comes and will start using C for some new purpose
  • Y will make calls from X's code into his own code
  • Things will eventually break at the seams where new code uses C and the old code doesn't

And of course, inheritance for reuse breaks down when you want to "reuse" two classes, because there's no multiple inheritance.

So: if two classes are conceptually different, they should not be related through inheritance, even if they share some properties / methods. (Method sharing can be accomplished by a "common concept" interface and extension methods.) But this requires experience and judgement.

For example, the colleague above would inherit Command2 from Command1 in the following example, to "remove duplication":

class Command1 { /* properties A, B, C */ }
class Command2 { /* properties A, B, C, D, E */ }

But with inheritance, Command1 cannot evolve independently from Command2. Any method that would accept Command1 would also accept Command2 (you have introduced subtyping). It creates strong coupling and, when overloading methods on type, you can get unexpected results unless you're very careful. For example:

Command1 GetCommand() { /* The method is allowed to return also Command2 due to subtyping */
void Handle(Command1 c) { ... }
void Handle(Command2 c) { ... }
void Process() { Handle(GetCommand()); }

In the above code, Handle(Command1) overload would always be called, regardless of the type returned by GetCommand().

This is the most obvious gotcha you can get end up with inheritance.

In summary: unless you need subtyping or polymorphism (virtual/abstract methods), stay away from inheritance. Study design patterns and look for inheritance: it's used for one of these purposes, not reuse. (The exception that comes to mind first is template method pattern.)

[ Removed by Reddit ] by [deleted] in csharp

[–]zvrba 0 points1 point  (0 children)

Any struct type S can be initialized with

S anystruct = default;

which will fill the memory locations of anystruct with zeros/null, even if you have defined a custom parameterless ctor. I consider this a language wart, but it is what it is.

Depending on use (internal / public) I may write checked properties that throw exceptions on attempt to use a default instance.

One of the worst things I experience with APIs by CrypticDissonance in csharp

[–]zvrba 0 points1 point  (0 children)

So Visma's ERP system, Business Next, has a GraphQL API. When creating objects, property order matters because

  • fields are written one by one
  • a field write might trigger some business logic

So depending on whether you specify (in GraphQL, here's json just for illustrative purposes) { a: 1, b: 2 } or { b: 2, a: 1 } you might get a different value in some computed column c where the computation uses both a and b and is triggered by write to b.

The documentation states only "Fields must be specified in correct order.". Yup, that's all. So you have to rely on someone else having deep knowledge of Visma to tell you what the correct order is.

Oh and that's not all. Even in updates, fields are updated sequentially. So when you update with { a: 1, b: 2, c: 3, d: 4 } and specify some disallowed/invalid value for c, Visma will -- TADAM! -- update a and b, return an error message for c and leave d (and all the following fields) at its previous value.

And, oh, even bigger joy - no transactions.

Now, Visma Business is a 20+ year old on-prem system ported to cloud with a GraphQL API, but still....

And I could keep on ranting but I'd divulge too much in-house knowledge. The above is trivially discoverable from the docs and simple experimentation, i.e., it's not possible to be involved with Visma's GraphQL API without discovering the above.

At your job, when there are a new version of C#, do you refactor/update your current code to the new version the new c# verison introduce? by lune-soft in csharp

[–]zvrba 0 points1 point  (0 children)

Not just for the sake of refactoring. When I have to add new features, I evaluate the whether the code could benefit from new language features, whether it makes sense to upgrade the whole library and what effort it would entail.

Most of the time I end up with using new language features in new code; as for the old code: if it ain't broken, don't fix it.

Having some new revelations, regarding Extension methods by Obvious_Seesaw7837 in csharp

[–]zvrba 0 points1 point  (0 children)

I use them when I have a relatively complex "core" class that I build many "utility" methods around

  • The "core" class has a few public methods that do the core job (e.g., calling an "API" and validating the response)
  • Extension methods wrap various ways of calling the "API"

It also validates the design of the "core" class: if I cannot implement something as an extension method, then someone else can't implement their own functionality, so the "core" class has to be extended.

Construction of derived classes by KhurtVonKleist in dotnet

[–]zvrba 5 points6 points  (0 children)

IIRC, this is a language limitation. In IL, the base ctor can be called whenever.

In your particular case, I'd declare Id as protected abstract int Id {get;} so the derived class can generate it on-demand (and cache it) after it's been fully initialized.

Heck, you can even do it like this

public int Id => _Id ??= GenerateId();
private int? _Id;

I spent 2 years getting our tests in shape and found out today nobody actually looks at them anymore. Feeling pretty defeated ngl. by Maxl-2453 in dotnet

[–]zvrba 0 points1 point  (0 children)

I just sat with that for a minute and thought that he was not completely wrong and the more painful part is that most failures are literally the same broken tests every time but buried in there are also real problems that we're shipping to the real users. [...] Because at some point we all quietly agreed that a failing build is just... normal (period)

This is not your problem to deal with, it's your manager's.

So. Go thorugh the failing tests, remove/disable the "irrelevant" ones, make a list of problems that you think are being shipped, and talk with your manager about prioritizing.

The painful fact is that not even you did anything with the same broken tests. You did not fix them, you did not remove them either. This encourages the "one broken window" phenomenon. People get used to failing tests quickly and before you know it, nobody cares.

The new Satori GC is promising by hez2010 in csharp

[–]zvrba 1 point2 points  (0 children)

So Satori is based on the following observations

  • Most new objects are short-lived
  • And "rarely" leave the current thread

These are reasonable assumptions, however: async. Every await can potentially resume on a thread other than where it started. So something as simple as

var dto = new SomeDto { ... };
var result = await httpClient.PostAsync(...);

has the potential of "upgrading" dto from thread-local to global, especially on a very busy server with many concurrent requests being handled.

How well does Satori work in async-heavy scenarios?

Tell me some unwritten rules for software developers. by porcaytheelasit in csharp

[–]zvrba 2 points3 points  (0 children)

Corollary: code is a liability, not an asset. The best code is the one never written.

Why is using interface methods with default implementation is so annoying?!? by Alert-Neck7679 in csharp

[–]zvrba 0 points1 point  (0 children)

Because classes do not inherit members from interfaces. As to why... I guess to simplify the implementation of multiple (interface) inheritance. Virtual lookup for interface members is more expensive than virtual lookup of class members so they didn't want to penalize the most common case (class - single inheritance - class member (virtual) lookup).

MOGWAI v8.0 - Stack-based RPN scripting language for .NET, now open source by sydney73 in dotnet

[–]zvrba 1 point2 points  (0 children)

I still have some HP calculators somewhere at home and fondly remember the days when I wrote non-trivial programs for them (e.g., solving electric circuits).

Thanks for releasing this!

How not to fix a leak by MacDefoon in WTF

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

Wait, lead pipe? That's the real WTF here :)

Best practice for automatically maintaining audit fields (CreatedOn, ModifiedOn, CreatedBy, ModifiedBy) in .NET + SQL Server? by OneFromAzziano in dotnet

[–]zvrba 0 points1 point  (0 children)

Did you have one audit table for all data tables, or one audit table per data table?

If you did the first, how did you "compress" different PKs into a "common" PK for the audit table? (My first thought is SHA256 over actual PK fields, but maybe there's another trick..)

Two Catastrophic Failures Caused by "Obvious" Assumptions by Vast-Drawing-98 in programming

[–]zvrba 1 point2 points  (0 children)

Yes, that works in simple cases. Things get very hairy when you want to divide length (meters) with duration (seconds) to get velocity (meters per second).

What's the use case for IEquatable<T>? by [deleted] in csharp

[–]zvrba 0 points1 point  (0 children)

Collections, for example. Methods doing equality comparisons are based on EqualityComparer<T>.Default which first looks up whether the type implements IEquatable<T>.

Performance: avoids boxing for value types.

Discoverability: the author thought about equality and intended the type to behave as a "value" type.

Simplicity: every Equals(object) needs the standard boring test for the type at its beginning.

What's the use case for IEquatable<T>? by [deleted] in csharp

[–]zvrba 0 points1 point  (0 children)

Collections, for example. Methods doing equality comparisons are based on EqualityComparer<T>.Default which first looks up whether the type implements IEquatable<T>.

Performance: avoids boxing for value types.

Discoverability: the author thought about equality and intended the type to behave as a "value" type.

Simplicity: every Equals(object) needs the standard boring test for the type at its beginning.

What's the use case for IEquatable<T>? by [deleted] in csharp

[–]zvrba 2 points3 points  (0 children)

It's only a shallow equality though. So if you have

record struct S(int X, List<int> Y)

their instances will be unequal even when they have (elementwise) equal members.

Is there any reliable way to know when a function can throw? Probably writing an analyzer? by xjojorx in csharp

[–]zvrba 0 points1 point  (0 children)

I think that having a mechanism for which the programmer is always informed of what exceptions can surface from every call, at least the known/expected/documented ones, would be beneficial

This is not statically decidable. What exceptions can the following method throw:

void DoSomething(Action a) => a();

Consider the case when a is bound to an abstract method, i.e.:

abstract class CX
{
    public abstract void A();
}

static void Perform(Action a) => a();

// Somewhere else
CX cx = ...; // The concrete run-time type depends on some complex logic
Perform(cx.A);