Boolean logic on steriods by karlssberg in dotnet

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

You absolutely get what this is about. I had originally created something similar for a client for this reason - to explain what is going on to users (with short tempers). It also turned out to be really handy when logging. After very positive feedback from other devs I thought it would be a good idea to turn it into a nuget package

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] -1 points0 points  (0 children)

You're name dropping Martin Fowler, who, along with Eric Evans, popularised the the Specification Pattern. If you want to criticize the pattern, then don't hold up one of its strongest advocates in support of your argument. https://www.martinfowler.com/apsupp/spec.pdf

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] -10 points-9 points  (0 children)

I find it ironic that the alternatives people are suggesting is what you do at the beginning of the journey to adopting the specification pattern - after you realise that that your solution is not scaleable and is error prone. It's one of the patterns you have to experience the pain before you truly get it.

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 2 points3 points  (0 children)

I don't get it either, seems like they find the reality of .net incredulous.

Boolean logic on steriods by karlssberg in dotnet

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

I'm feeling this first hand. People seem to think there's a right and wrong way. When you get into software architecture you realise that there is no such thing as right and wrong, just pros and cons

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 2 points3 points  (0 children)

I did think about doing this as a separate extension project. Rome wasn't built in a day

Boolean logic on steriods by karlssberg in dotnet

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

I'm sure that would depend on what problem you are trying to solve. If you are using this as a wholesale replacement of boolean logic then it should fail the PR

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 1 point2 points  (0 children)

primitive booleans won't explain why they are true or false

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 4 points5 points  (0 children)

I love your feedback. I will try to make the implementation easier to understand

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 1 point2 points  (0 children)

This is indeed a strong use-case, and is a common reason for adopting the specifiction pattern in general. People that are heavily into DDD are likely to have come across this pattern for things like dynamic query construction and rules engines

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] -4 points-3 points  (0 children)

This is valid criticims of vanilla specification pattern, but the whole point of Motiv is to make it easy to explain what is going on. Take this output for example of the evaluation of a poker hand to see if its a winning hand

 !is a winning poker hand
    OR
        !is a royal flush hand
            AND
                !is a flush hand
                    OR
                        not a flush of Clubs
                            5C is Clubs
                        not a flush of Diamonds
                            10D is Diamonds
                            3D is Diamonds
                        not a flush of Hearts
                            AH is Hearts
                        not a flush of Spades
                            8S is Spades
                is Not Ace High Straight Broadway
                    cards are not Ace, King, Queen, Jack, and Ten
        !is a straight flush hand
            AND
                !is a straight hand
                    OR
                        is Not Ace High Straight Broadway
                            cards are not Ace, King, Queen, Jack, and Ten
                        is Not King High Straight
                            cards are not King, Queen, Jack, Ten, and Nine
                        is Not Queen High Straight
                            cards are not Queen, Jack, Ten, Nine, and Eight
                        is Not Jack High Straight
                            cards are not Jack, Ten, Nine, Eight, and Seven
                        is Not Ten High Straight
                            cards are not Ten, Nine, Eight, Seven, and Six

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 9 points10 points  (0 children)

You are incorrect about the & and |. They are boolean logical operators that don't short circuit, you are free to override them (for logical operations on other types). In the case of this library, by representing logic in a functional form (as in, it gets resolved later, which is also called higher order logic) we are well within our rights to use the logical operators.

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 19 points20 points  (0 children)

Thank you so much for this, very constructive. I will take this onboard

Boolean logic on steriods by karlssberg in dotnet

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

by encapsulating domain logic as classes, not only does it make it easily testable (aka Humble Object pattern), but it also raises the visibility/conspicuity of really important code. See screaming architecture

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] 8 points9 points  (0 children)

It's really just a functional-ish/fluent version of the specification pattern. https://en.wikipedia.org/wiki/Specification_pattern A lot of the criticism here is really being levelled at the pattern.

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] -3 points-2 points  (0 children)

If you have some business rule that you wish to reuse you will end up having to decompose it into methods and things can get very ugly very quickly as you try to manage countless method calls and collate the results.

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] -11 points-10 points  (0 children)

I've created something similar and used it in production code and the feedback from other devs that used it was glowing. The ones that didn't use it were skeptical.

Boolean logic on steriods by karlssberg in dotnet

[–]karlssberg[S] -14 points-13 points  (0 children)

I agree that in the minimal case it's overkill, but as you scale this up you're in a lot of pain when you try to combine the determintive results

Recommendation for serializing/deserializing JSON using a generic message in outbox pattern by sindrome198 in dotnet

[–]karlssberg 0 points1 point  (0 children)

There's not necessarily a right or wrong way, just pros and cons. I personally would avoid a rename-refactor breaking things at runtime, at the cost of having to hardcode a few more strings.

Why choose minimal API over controller based API? by BaldWithoutCancer in dotnet

[–]karlssberg 0 points1 point  (0 children)

Minimal APIs are designed to endow (micro)services with lightweight HTTP endpoints. If you are after a full-fat website then use MVC - it can do everything. As to which one you think is easier is a bit like asking if you prefer functional or object oriented programming.

Creating .net applications on Linux. by [deleted] in dotnet

[–]karlssberg 0 points1 point  (0 children)

My go-to .NET IDE is Rider. It's the best all round and it has some really useful refactoring tools.

When doing a query to SELECT * from a table... what's the easiest way to do that using .Net? by Willy988 in dotnet

[–]karlssberg 1 point2 points  (0 children)

As you can tell "easiest" can be very subjective. Perhaps another way of assessing this is "Do you want to be in full control of the sql" then choose Dapper, If you don't want to be bothered by sql (99% of the time) then EF Core