4 ms·
I'm very disappointed that he starts out with a diagram and "This is what ugly code looks like.", but doesn't follow it up with "This is what beautiful code loo
by Mithaldu 12y ago
I'm very disappointed that he starts out with a diagram and "This is what ugly code looks like.", but doesn't follow it up with "This is what beautiful code looks like."
Then again, maybe that part's just in the book this excerpt is trying to sell.
- wellpast 12y agoBeautiful code looks like a directed, acyclic graph -- a tree with small nodes (high cohesion) and minimal dependencies (low coupling). Narrow interfaces are the last piece, but I'm not sure how you visualize that -- perhaps with the width of the edges; the narrower, the more beautiful. Of course, "beauty" is a hard sell. What you really get with maintaining code with these "beautiful" qualities is massive productivity and choice.
- jowiar 12y agoDrawn as a graph, it ends up minimizing: - Node size (think small functions and objects, not big ones) - Degree (minimize dependencies. Also, an O(m+n) many-to-few-to-many is probably easier to reason about than an O(mn) many-to-many), - Overall number of nodes (DRY, also, less code is generally better than more code). Of course, the prioritization between these three is up in the air.
- holri 12y agoBeautiful code looks like muesli. Small different distinct pieces swimming independent in a interconnecting milk in a big pot.
- mhomde 12y agothe smaller the bowl* the more beautiful the code * up to a point
- stinos 12y agoCame here to post the exact same thing. Was expecting to see a diagram of beautiful code after every scroll, but no avail. Also: what does HN recommend for creating such a diagram for my code (say C# and C++ codebases)? Not that I'm sure it is really an ok measure: I'm a heavy adept of DIY and have a ton of small utility functions which are used all over the place (mainly missing pieces in the STL). This should lead to a whole lot of extra lines in a diagram which might look like spaghetti as well.