Implicit and magic looks nice at first but sometimes it can be annoying. I remember the first time I tried Ruby On Rails and I was looking for a piece of config.
Yes, "convention over configuration". Namely, ungreppsble and magic.
This kind of stuff must be used with a lot of care.
I usually favor explicit and, for config, plain data (usually toml).
This can be extended to hidden or non-obvious allocations and other stuff (when I work with C++).
It is better to know what is going on when you need to and burying it in a couole of layers can make things unnecessarily difficult.
(Of course you are also free to write C# without any of the built in frameworks and write purely explicit handling and routing)
On the other hand, we write CRUD every day so anything that saves repetition with CRUD is a gain.
Yes, they make CRUD stuff very easy and convenient.
await client.Write(
new ClientWriteRequest(
[
// Alice is an admin of form 123
new()
{
Object = "form:124",
Relation = "editor",
User = "user:avery",
},
]
)
);
var checkResponse = await client.Check(
new ClientCheckRequest
{
Object = "form:124",
Relation = "editor",
User = "user:avery",
}
);
var checkResponse2 = await client.Check(
new ClientCheckRequest
{
Object = "form:125",
Relation = "editor",
User = "user:avery",
}
);
This is an abstraction we wrote on top of it: await Permissions
.WithClient(client)
.ToMutate()
.Add<User, Form>("alice", "editor", "226")
.Add<User, Team>("alice", "member", "motion")
.SaveChangesAsync();
var allAllowed = await Permissions
.WithClient(client)
.ToValidate()
.Can<User, Form>("alice", "edit", "226")
.Has<User, Team>("alice", "member", "motion")
.ValidateAllAsync();
You would make the case that the former is better than the latter?Better than no magic abstractions imo. In our large monorepo, LSP feedback can often be so slow that I can’t even rely on it to be productive. I just intuit and pattern match, and these magical abstractions do help. If I get stuck, then I’ll wade into the docs and code myself, and then ask the owning team if I need more help.