1. 16

  2. 8

    Learn the rules and the reason behind them, and you know when to break them.

    Not all software requires high modularity, and not all modularity is good. However, that doesn’t stop modularity from being a good default to start from.

    1. 3

      I had trouble making sense of this post. Too many loosely related ideas are brought together incompletely. A short note like this should be more narrowly defined, or the complex interconnections more fully defined.

      1. 3

        My main complaint about in-lined code is that is makes the logic tree more difficult to parse due to spreading out the opening & closing of each branch. At my previous job I fixed lots of code with broken logic trees by factoring out the chunks within if-else block into functions(which also allows a simple level of documentation with the function name ala addToTableView() or selectNewViewController()) which then made the tree much easier to parse allowing bugs to show their face.

        The following example is a result of factoring out the inlined action for each branch of a logic tree.

           if allowReplay && autoplay {
                // This is a common case.
            } else if allowReplay && !autoplay {
                // This is a common case.
            } else if !allowReplay && autoplay {
                // This is a less common case. The item is NOT added to the list.
                // The use case for this has historically been for introduction videos.
            } else if !allowReplay && !autoplay {
                // This is the least common case, and the most non-intuitive.

        You’ll first look at this and say, who came up with these 2 boolean values that have this strange interaction with each other. Let me just clarify that is wasn’t me, and I had no authority to change this design decision only to handle it as best I could. That being said, I think this highlights the simplicity of this tree, the complexity of each action is now bundled into a specific place and can be looked at in isolation with the intended action as the function name.

        My boss would argue that you could accomplish the same with folding the intention blocks. And while this is true, you lose a free/forced level of documentation of the method/function name.