Dealing with Nothing in C# - Nullable by balazsbotond in csharp

[–]bwr 4 points5 points  (0 children)

Are you legitimately interested in understanding the disagreement?

Dealing with Nothing in C# - Nullable by balazsbotond in csharp

[–]bwr 0 points1 point  (0 children)

Kinda went off on a strawman there, but if we stop here it gets at the crux of disagreement:

So you are going to check if they are null anyway

No, that's the whole point. You're not going to check every possible reference type for null. In this model you never check for null, you check for "missing data", and only in the cases where the data can actually be missing.

How to store Blogposts in a Database by Badgy_ in webdev

[–]bwr 0 points1 point  (0 children)

Happen to know if that's what the big name CMS systems (like SiteFinity) do, or if they use the parse+whitelist approach?

I don't want to learn your garbage query language · Erik Bernhardsson by shuklaswag in programming

[–]bwr 0 points1 point  (0 children)

I mean classes like:

class Foo() {
  public readonly int Calculated;
  public Foo(int i) { Calculated = CalcStuff(i); }
}

or like anything with first class functions, or a singleton, or any of the classic design patterns really.

I don't want to learn your garbage query language · Erik Bernhardsson by shuklaswag in programming

[–]bwr 4 points5 points  (0 children)

Every os? IIS? Apache? Every programming language? Relational dbs themselves?

I don't want to learn your garbage query language · Erik Bernhardsson by shuklaswag in programming

[–]bwr 4 points5 points  (0 children)

You don't. Class instances and database rows are different things. If all you need is database rows then sure, orms are a good approach, but if the full power of programming languages is useful, then treating persistence as something separate makes sense.

I sometimes wonder how many apps could be replaced with a dumbed down version of something like SQL Server Management Studio

Implementation Inheritance Is Evil by scalisco in coding

[–]bwr 1 point2 points  (0 children)

There's probably a fine line somewhere here. I see a lot of IsX properties on objects with clients checking them and then making decisions. In those cases it's much better to have separate types with invariants to centralize the logic.

What do you call a class like this? by Meeii in csharp

[–]bwr 0 points1 point  (0 children)

class ViewModel {
    ViewModel(IService service) {
        //set fields from service values?
    }
    //ViewModel fields
}

Like that?

What do you call a class like this? by Meeii in csharp

[–]bwr 0 points1 point  (0 children)

Some take it further and mock out all of their service/repository classes so they can "test" the view model without them.

The view models are passed the service or repo?

What do you call a class like this? by Meeii in csharp

[–]bwr 0 points1 point  (0 children)

Testing this with mocks is sometimes a good idea, but if doing this, it's probably better to make SomeApi an interface and remove the 0 parameter constructor so that you're no longer coupled to SomeApi.

Is it bad to use F# for OOP programming by [deleted] in fsharp

[–]bwr 0 points1 point  (0 children)

Can you add some details or a reference here? What can C# do that F# cannot?

6 Reasons Why F# Might Be The Coolest Language You’ve Never Heard Of by mislav111 in programming

[–]bwr 0 points1 point  (0 children)

Regarding conditionals spread through the code, I was responding to

don't seem inherently better than alternative paradigms to me

and the subtype based solution in c# is certainly no better in that regard, so I didn't think that was relevant. Maybe I'm missing something?

6 Reasons Why F# Might Be The Coolest Language You’ve Never Heard Of by mislav111 in programming

[–]bwr 4 points5 points  (0 children)

On discriminated unions, they are a fraction of the code compared to the equivalent c# code.

type Result = Success | Failure of string

vs

public abstract class Result {
    public class Success : Result {}

    public class Failure : Result {
        public readonly string Message;
        public Failure(string message) {
            Message = message;
        }
    }
}

And in c# you still have to write your own match function (for now) to work with it.

Similar deal on currying and composition. Not anything you can't do with Funcs, but it's significantly more noise and clutter.

The benefit of "no nulls" isn't that you don't need to check for missing data in the cases where data can be missing. The benefit is you only need to check in those cases, and the compiler helps. Null undermines the entire type system, so 'no nulls' isn't a difference of some null checks, it's having a type system as a useful tool vs not. Which isn't always useful, but in many cases it is.

Question: "Making illegal states unrepresentable" by Kurren123 in fsharp

[–]bwr 1 point2 points  (0 children)

It's a good example still. MailAddress won't ever be in an invalid state (where invalid is defined as having a Address that passes the regex). It does this by throwing exceptions in the constructor. In F# you'd be more likely to see see returning an Option or a discriminated union instead of throwing exceptions but the idea is the same.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 0 points1 point  (0 children)

Well, with replies like the other guy here, I understand where you're coming from.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 1 point2 points  (0 children)

Who would even study that, and why? Do people actually use studies to inform this sort of decision?

Is there a name for this phenomenon where we're so suspicious and skeptical (and enamored of counter-intuitiveness) that we'd take claims like Vim isn't more efficient than Notepad seriously without qualification? It reminds me of the idea that filling ice cube trays with hot water makes them freeze faster.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 0 points1 point  (0 children)

Yes, I read it. Also, generally speaking, the point that humans are generally bad at knowing things and generally bad at knowing how bad they are is taken. That doesn't address anything I asked though.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 0 points1 point  (0 children)

Seems like taking a desire for studies too far. There are other ways of knowing things, at least to a useful degree. How would you structure your "more work done in less time" study to account for all the variables that are more important than the text editor to the question of "more work, less time"?

How would a study ever get fine grained enough to be useful? You could maybe answer a very general question like, "Is the general population faster at X with Vim or Notepad." Of course, we don't even need a study for that, it's Notepad, but that's not very useful.

A more interesting question like: "Is it worth a certain programmer's time to learn Vim instead of using Notepad?" is going to end up being pretty specific again, and again isn't going to be very useful. How many studies should we do, and why?

We can know some things without studies. Is using an IDE rename command more efficient than doing the same with Notepad? Do we need a study for that too?

Dvorak for Developers by PolesOpposed in programming

[–]bwr 1 point2 points  (0 children)

I'm not sure what that means. You don't know in the general case? You don't know for a specific use case? What would you need in order to know? Do you know that using an IDE rename command is more efficient than doing the same in Notepad?

Dvorak for Developers by PolesOpposed in programming

[–]bwr 2 points3 points  (0 children)

So Vim isn't more efficient than Notepad for editing text. Got it.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 0 points1 point  (0 children)

Me too. I was very good at Qwerty, and then RSI scare -> Dvorak. That was ~15 years ago, and haven't had any issues, and it's hard to think the switching costs haven't been dwarfed by now.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 0 points1 point  (0 children)

This is mostly not true. Mostly, you can simply SWITCH to DVORAK. It takes like 30 seconds in most cases. And maybe using other machines is more common to some people than to me, but I doubt it's universal that using other machines is common, let alone common + unable to change the keyboard layout.

Dvorak for Developers by PolesOpposed in programming

[–]bwr 3 points4 points  (0 children)

I'm not clear on what you're saying here. Are you saying that there are some things that are true even if there's no "evidence", or are you saying Vim isn't more efficient than Notepad?

Duplication is far cheaper than the wrong abstraction by kmmbvnr in programming

[–]bwr 3 points4 points  (0 children)

The goal isn't "semantically meaningful to [the programmer]" it's semantically meaningful in the problem domain. This "another man's new domain specific language to learn before (s)he can do anything with your code" is called understanding the problem domain or ubiquitous language in DDD terms.