Unreadability Is a Smell, Not a Pathology (MG)

This topic contains 18 replies, has 3 voices, and was last updated by  Max Guernsey 2 years, 12 months ago.

Viewing 15 posts - 1 through 15 (of 19 total)
  • Author
    Posts
  • #28725

    Max Guernsey
    Keymaster

    This is where I was hoping we would discuss Unreadability Is a Smell, Not a Pathology.

    https://svn.projectlocker.com/NO/SVN_NO_OurPublications/svn/IP%20Source/Blog%20Entries/MG/02.Ready%20for%20Review/Unreadability%20Is%20a%20Smell_v2mg.docx

    #28733

    Max Guernsey
    Keymaster

    “No effort was put into making it “elegant” – for instance, I declared all my variables with an explicit type”
    I don’t think explicit types are not elegant.

    “You can do certain things that will make code less readable to almost any developer. You can do things that will make code more readable to almost every developer.
    …but you can also do things that will make code more readable to some developers and less readable to others.”

    So why don’t you always do the 2nd option?

    #28735

    Max Guernsey
    Keymaster

    In Java, explicit variable types are your only option.

    In C#, var is objectively more elegant than an explicit type. It costs nothing but eliminates a point of coupling. As we’ve covered in previous conversations, it’s not the same thing as dynamic, which is an untyped reference like you would see in JavaScript.

    This is actually kind of making my point. var objectively reduces coupling without any cost. dynamic objectively reduces compiler feedback with little benefit. As such, one sold be used always and the other should be used extremely rarely.

    Whether code us readable, on the other hand, is subjective. Mostly it’s subject to what people know, somewhat to their experience, and a little bit to their preference.

    For instance, the people who hate var the most usually think it creates an untyped reference and the people who think it makes code less readable trend to know what it does but not have used it long enough to realize it has, literally, no down sides. There are always a few hold outs with a stubborn preference that supercedes quality.

    As far as why you don’t do the second one…I don’t know why people funny do those. Does something in this article make it seem like I’m arguing against them?

    What do you think the thesis if this entry is?

    #28742

    Max Guernsey
    Keymaster

    There are a few stubborn people who always want to make the argument that var adds quality to the code 🙂

    It seems like you’re not making your point that it should be #2. Is that the point you’re trying to make?

    #28745

    Max Guernsey
    Keymaster

    No. That is not my point at all. I want people to stop treating readability like it’s a quality and start treating it like a smell.

    “That’s unreadable” is sometimes a valid indictment of code that has a serious problem but most of the time it’s a stockade in which the incompetent can hide from new ideas.

    In the case where code is unreadable because of a real problem – a lack of cohesion, nonsensical names, et cetera – I want people to focus on the real problem, rather than the symptom of said problem.

    Imagine we had an high incidence of a naturally-occurring auto-brewery syndrome in our population. The way we treat the phrase “that’s unreadable,” right now, is tantamount to taking all those people with auto-brewery syndrome and putting them through AA just because they smell like alcohol.

    #28746

    Max Guernsey
    Keymaster

    I’d leave out the three options and concentrate more on that point.

    I’m not necessarily in favor of eliminating readability as a code quality. But I understand your point on suggesting it can be a smell. There are interactions between other qualities. E.G. Testability – is it a quality or a smell?

    #28748

    Max Guernsey
    Keymaster

    That’s interesting. I have to find a way to reconcile the fact that I added those claims because they made the point more clear in Scott’s view and that their presence makes it less clear in your view.

    I’ll have to noodle on how to do that for awhile.

    Vis a vis you being in favor: I didn’t think any of you would agree. I was surprised – shocked even – by the degree to which Scott agreed with even the first cut of this entry, which was substantially less accessible than this one.

    I’m fine with this being something that generates a little controversy. It’s okay for people to hear the occasional scuffle on Olympus every now and then. I think it will help people understand that this stuff is not settled and probably won’t be in any of our projected lifetimes. 🙂

    As far as testability goes, if the criteria for a quality are as follows…

    • There or absent in an objective way
    • A property of the code, itself

    …and I propose that they are, then testability would be a quality. It’s a compound quality – one that is built mostly out of other qualities. Then again, all the code qualities feed into each other. There’s nothing qualitatively different about it.

    Readability does not meet either of the two aforementioned criteria so I don’t call it a quality and I don’t think anyone should. I’m not going to go to war with someone if they disagree but I’m also not going to start calling it a quality.

    I think of it like the difference between cycle time and efficiency. Cycle time is not efficiency but it’s pretty much impossible to be inefficient with a low cycle time. Likewise, it’s hard to be readable and low quality but a group’s inability to read something does not mean that it is low in quality.

    #28754

    Max Guernsey
    Keymaster

    var ABSOLUTELY adds quality to code – it removes redundancy..

    #28755

    Max Guernsey
    Keymaster
    #28756

    Max Guernsey
    Keymaster

    Yeah, Amir. I agree.

    Code qualities aren’t subjective beyond the veil of subjectiveness inherent in the uncertainty of the universe. Like you can’t know where a code quality is and how fast it’s moving with less error than Planck’s constant and there’s no way to know that there is even a universe and not just a “show” being fed into a consciousness.

    Beyond those conceits, code qualities are matters of fact. The degree to which they are present are absolute.

    var is an example of that. It compiles exactly the same. It refactors exactly the same. It tests exactly the same. In every way, it performs in exactly the same way as an explicitly-typed variable because it is a statically-typed variable. It just happens to be the compiler that is specifying the type of var pi = 3.1415926547m; rather than a human.

    If someone believes there is a downside, they should say what it actually is. Matters of preference carry exactly zero weight against a real thing like eliminating a point of redundancy.

    Maybe we should have a separate thread for var.

    #28760

    Max Guernsey
    Keymaster

    There is nothing absolute in life 🙂

    #28762

    Max Guernsey
    Keymaster

    There are things that are so close.

    There’s a chance that I could get to Philadelphia by jumping off my deck and flapping my arms really hard rather than taking a plane. I’m not going to try it, though.

    var is in the same category.

    #28764

    Max Guernsey
    Keymaster

    Nope.

    Why didn’t you use var everywhere in your code example in your new blog?

    #28765

    Max Guernsey
    Keymaster

    Because I didn’t want to have to deal with people who don’t understand that it is all upside.

    Can you name a single downside?

    #28771

    Max Guernsey
    Keymaster

    I can:

    I have to learn what var is; I’m too lazy.

Viewing 15 posts - 1 through 15 (of 19 total)

You must be logged in to reply to this topic.