| 1 | --- |
| 2 | title: "Prefer If Statements To Polymorphism..." |
| 3 | description: "In this collection of tweets, Carson Gross explores unconventional programming principles, including favoring if statements over polymorphism, minimizing abstractions, and prioritizing practical, implementation-driven development. He challenges traditional software 01-frontend norms, advocating for simplicity, locality, and utility over complexity and abstraction." |
| 4 | created: 2024-12-07 |
| 5 | modified: 2024-12-07 |
| 6 | authors: [ "Carson Gross" ] |
| 7 | tags: ["simplicity"] |
| 8 | --- |
| 9 | |
| 10 | ## Or, Watching Myself Lose My Mind In Real Time... |
| 11 | |
| 12 | > "Invert, always invert." --Carl Jacobi, by way of Charlie Munger |
| 13 | |
| 14 | * *[If Statements](https://x.com/htmx_org/status/1843804410377535533)* |
| 15 | > prefer if statements to polymorphism |
| 16 | > |
| 17 | > whenever you are tempted to create a class, ask yourself: "could this be an if statement instead?" |
| 18 | * *[The Closed/Closed Principle](https://x.com/htmx_org/status/1843805753007845474)* |
| 19 | > In grug-oriented programming, the closed–closed principle (CCP) states "software entities (classes, modules, |
| 20 | functions, etc.) should be closed for extension, but also closed for modification" |
| 21 | > |
| 22 | > they should just do something useful man |
| 23 | * *[The Minimize Abstractions Principle](https://x.com/htmx_org/status/1843806270559793475)* |
| 24 | > The Minimize Abstractions Principle (MAP) is a computer programming principle that states that "a module should |
| 25 | > minimize the number of abstractions it contains, both in API and in implementation. Stop navel gazing nerd." |
| 26 | * *[The Try It Out Substitution Principle](https://x.com/htmx_org/status/1843807054970139139)* |
| 27 | > The "Try It Out" Substitution Principle states that you should try something out and, if that doesn't work, think |
| 28 | about why, and substitute something else for it instead. |
| 29 | > |
| 30 | > It is common to need to substitute multiple things to hit on the right thing eventually. |
| 31 | * *[The Useful Stuff Principle](https://x.com/htmx_org/status/1843807769557909528)* |
| 32 | > The Useful Stuff Principle states that entities must depend on useful stuff, not overly abstract nonsense. It states |
| 33 | that a high-level module can depend on a low-level module, because that's how software works. |
| 34 | * *[Dependencies](https://x.com/htmx_org/status/1843808113230860419)* |
| 35 | > The The Existence of Dependencies Is Not An Excuse For Destroying The Codebase Principle states that the existence |
| 36 | of dependencies is not an excuse for destroying the codebase |
| 37 | * *[Abstraction Budget](https://x.com/htmx_org/status/1843821830207099007)* |
| 38 | > consider giving your developers an abstraction budget |
| 39 | > |
| 40 | > when they exhaust that budget & ask for more, tell them they can have another abstraction when they remove an |
| 41 | existing one |
| 42 | > |
| 43 | > when they complain, look for classes with the term "Factory", "Lookup" or "Visitor" in their names |
| 44 | * *[Fewer Functions](https://x.com/htmx_org/status/1843822378352291914)* |
| 45 | > if your function is only called in one place, consider inlining it & reducing the total number of method signatures |
| 46 | in your module, to help people better understand it |
| 47 | > |
| 48 | > studies show longer methods have fewer bugs per line of code, so favor longer methods over many smaller methods |
| 49 | * *["God" Object](https://x.com/htmx_org/status/1843823231771521367)* |
| 50 | > consider creating "God" objects that wrap a lot of functionality up in a single package |
| 51 | > |
| 52 | > consumers of your API don't want to learn 50 different classes to get something done, so give them a few that |
| 53 | provide the core functionality of your module with minimal fuss |
| 54 | * *[Copy & Paste Driven Development](https://x.com/htmx_org/status/1843827082687852706)* |
| 55 | > copy&paste driven development is a development methodology where, when you need to reuse some code but in a slightly |
| 56 | different manner, you copy & paste the code & then modify it to satisfy the new requirements |
| 57 | > |
| 58 | > this contrasts with designing an elaborate object model, for example |
| 59 | * *[Implementation Driven Development](https://x.com/htmx_org/status/1843828023747063866)* |
| 60 | > implementation driven development is a development methodology where you first explore various implementations of |
| 61 | your idea to determine the best one, then add tests for it |
| 62 | > |
| 63 | > no test code may be written without first having some implementation code to drive that test |
| 64 | * *[Mixing Concerns](https://x.com/htmx_org/status/1843830823113634132)* |
| 65 | > Mixing of Concerns is a design methodology whereby "concerns" of various kinds are mixed into a single code unit. |
| 66 | This improves locality in that code unit by placing all relevant logic within it. An example of this is hypermedia, |
| 67 | which mixes control & presentation information. |
| 68 | * *[Macroservices Architecture](https://x.com/htmx_org/status/1843831529300267103)* |
| 69 | > a macroservice architecture revolves around "macroservices": network-deployed modules of code that provide a |
| 70 | significant amount of functionality to the overall system |
| 71 | > |
| 72 | > by adopting a macroservice-based architecture you minimize deployment complexity & maximize resource utilization |
| 73 | * *[Sorry](https://x.com/htmx_org/status/1844005320223539524)* |
| 74 | > kinda had a manic break last night my bad |