Live data from Hacker News

Clean Coder: The Dark Path (2017)

blog.cleancoder.com

51–60 of 71 posts

Re: Clean Coder: The Dark Path (2017)

#51
I could not agree less. The line of reasoning here is: relying on the type system to prevent error lets people writer fewer tests. Tests are the only way to assure quality. Therefore fewer tests is bad, and powerful type systems are bad too, because they cause you to act against software quality.

Furthermore, Uncle Bob sets up this weird opposition between the programmer and the type system, as if the latter is somehow fighting the former, rather than being a tool in their hand.

I think that sadly this is just the narrative of a man whose life’s work consists of convincing people that there is a silver bullet, and it is TDD.

Re: Clean Coder: The Dark Path (2017)

#52

I understand what the author says, but in my experience, "Nullable Types" and "Open/Sealed Classes" are two different subjects and... 1) For "Nullable Types", I see that it is VERY good to think about if some type can be null or not, or use a type system that does not allow nulls, so you need some "unit" type, and appropriately handle these scenarios. I think it is ok the language enforces this, it really, really hel…

sealed classes are just retrofitting sum types onto the JVM. If Kotlin could have used "enum" for it then they probably would have, like Swift and Rust did.

The main point of sealed classes is exhaustive `when` expressions:

    return when (val result = something()) {
      Result.Success -> // ...
      Result.Failure -> // ...
    }
If another subclass appeared at runtime, then the code would fall off the end of that when expression.

Re: Clean Coder: The Dark Path (2017)

#53
post #14

Earlier quoted context omitted.

I can understand, I’ve had some awful bicycle accidents while not wearing a helmet and the helmet would have made no difference. My knees, hands and elbows have been through a lot but I have never hit my head. Even while skateboarding the one time I hit my head a helmet would not have helped. In hindsight I should have worn knee pads a lot more often but then I wouldn’t be able to tell if it’s gonna rain or not from…

And there are countries where everyone rides a bike, and they are not usually the ones with mandatory helmets. When you hit someone with a bike you are less likely to kill them than when you hit them with a car, so more bike riding means less deaths, without even considering the effects of air pollution. Helmets are fine for sport riding, but inconvenient if you want to ride 5 minutes to the shops on a whim. And that…

Those countries also have a higher number of brain injury cases vs countries where people wear helmets.

If you are hit by a car a helmet will do approximately nothing. However there are a lot of accidents that happen where you are not hit by a car where a helmet will help. (and even more when knee and elbow pads are what you need)

Re: Clean Coder: The Dark Path (2017)

#54
post #7

Your elevator should not have automatic doors, doors are restrictive. They stop you from quickly jumping out of the elevator if you decide that you actually want to stay at the first floor. Sure, we’ve seen some pretty gnarly accidents, and there is no reasonable situation where risking death is a sane choice. But ask yourself: is it the elevator's job to prevent an accident? If you think so, I suggest you never leav…

> “never wear a helmet you coward”. Unironically the biggest flame-wars I ever saw on forums back in the day was on whether or not mandatory bike helmets made cycling safer or more dangerous.

Can't resist taking this bait, but I feel like the consensus is pretty much that as an individual, choosing to wear a helmet will make you safer, and as a society, mandating bike helmets (and other measures that will cause people to use transportation methods that are more dangerous to others) will make everyone less safe.

Of course, it's hard to prove. But I think you'll generally find that, if you compare the number of injuries/deaths while cycling in countries with mandatory helmets per km will be higher than it is in the Netherlands, where they are not mandatory.

Re: Clean Coder: The Dark Path (2017)

#55

Your elevator should not have automatic doors, doors are restrictive. They stop you from quickly jumping out of the elevator if you decide that you actually want to stay at the first floor. Sure, we’ve seen some pretty gnarly accidents, and there is no reasonable situation where risking death is a sane choice. But ask yourself: is it the elevator's job to prevent an accident? If you think so, I suggest you never leav…

Did you even read the second half of the post? The author's answer to your concerns is testing. He suggests relying on tests rather than on strict type system that forces you to design everything upfront. Personally, I can see arguments for both approaches - stricter types or more tests.

I've written python and C++. For small simply problems python is nice, and writing tests for everything is easy enough. However as the program gets larger python becomes painful to work with. Writing code is the easy part, the hard part is when you want to refactor existing code to add a new feature - if you don't have the right tests (integration tests, not unit tests - though these terms are poorly defined) you will miss some code path that then won't work when it finally is run - unless you have a good type system which catches most of the errors that can happen when refactoring.

C++ is a notoriously difficult language to write in. However when the problem demands tens of millions of lines of code I'll take it over python because of the type system. There are other languages with good type systems that are reportedly better.

Re: Clean Coder: The Dark Path (2017)

#56
post #25

Earlier quoted context omitted.

Explain how

Not OP, and not sure about OCaml and Haskell, but one example where Java's type system is unhelpful/incorrect is mutable subtyping. E.g. Java assumes Cat[] is a subtype of Animal[]. But this only holds when reading from the array. The correct behavior would be: - `readonly Cat[]` is a subtype of `Animal[]` - `writeonly Cat[]` is a supertype of `Animal[]` - `readwrite Cat[]` has no relationship with `Animal[]` But Jav…

All type checkers either permit incorrect programs, reject correct programs, or are turing complete.

Re: Clean Coder: The Dark Path (2017)

#57
Surely needing to change some class declarations is better than bugs that take all day to track down? And sure as a programmer i can consider every npe case along with all the others but if the language can take car3 of that for me, I’ll let it

Re: Clean Coder: The Dark Path (2017)

#58

Your elevator should not have automatic doors, doors are restrictive. They stop you from quickly jumping out of the elevator if you decide that you actually want to stay at the first floor. Sure, we’ve seen some pretty gnarly accidents, and there is no reasonable situation where risking death is a sane choice. But ask yourself: is it the elevator's job to prevent an accident? If you think so, I suggest you never leav…

C programmers non-ironically believe this And of course they only believe this because they don't lose a finger when they write outside of bounds or they don't fall down the shaft once a pointer was accidentally null

C programmers want program like they drive race cars or fighter jets, anything for greater speed

Re: Clean Coder: The Dark Path (2017)

#60
post #54
post #7

Earlier quoted context omitted.

> “never wear a helmet you coward”. Unironically the biggest flame-wars I ever saw on forums back in the day was on whether or not mandatory bike helmets made cycling safer or more dangerous.

Can't resist taking this bait, but I feel like the consensus is pretty much that as an individual, choosing to wear a helmet will make you safer, and as a society, mandating bike helmets (and other measures that will cause people to use transportation methods that are more dangerous to others) will make everyone less safe. Of course, it's hard to prove. But I think you'll generally find that, if you compare the numbe…

Comparing the Netherlands with some of the best, if not the best bike infrastructure to other countries without said infrastructure seems very reductionist. To get anywhere near an interesting number you would have to compare the number of injuries to the total number of accidents including cyclists in countries with comparable bike infrastructure and differing helmet policies.
Post reply on HN