Skip to content

Piero Bosio Social Web Site Personale Logo Fediverso

Social Forum federato con il resto del mondo. Non contano le istanze, contano le persone

Which software design principles do you rely on most?

Uncategorized
3 1 12
  • I’m curious which software design principles you find most valuable in real projects.

    Two concise summaries I’ve found:

  • I’m curious which software design principles you find most valuable in real projects.

    Two concise summaries I’ve found:

    Summary of Clean Code by Robert C. Martin
    Source: gist.github.com/wojteklu

    Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility, and maintainability.


    General rules

    1. Follow standard conventions.
    2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
    3. Boy scout rule. Leave the campground cleaner than you found it.
    4. Always find root cause. Always look for the root cause of a problem.

    Design rules

    1. Keep configurable data at high levels.
    2. Prefer polymorphism to if/else or switch/case.
    3. Separate multi-threading code.
    4. Prevent over-configurability.
    5. Use dependency injection.
    6. Follow Law of Demeter. A class should know only its direct dependencies.

    Understandability tips

    1. Be consistent. If you do something a certain way, do all similar things in the same way.
    2. Use explanatory variables.
    3. Encapsulate boundary conditions. Boundary conditions are hard to keep track of. Put the processing for them in one place.
    4. Prefer dedicated value objects to primitive type.
    5. Avoid logical dependency. Don't write methods which work correctly depending on something else in the same class.
    6. Avoid negative conditionals.

    Names rules

    1. Choose descriptive and unambiguous names.
    2. Make meaningful distinction.
    3. Use pronounceable names.
    4. Use searchable names.
    5. Replace magic numbers with named constants.
    6. Avoid encodings. Don't append prefixes or type information.

    Functions rules

    1. Small.
    2. Do one thing.
    3. Use descriptive names.
    4. Prefer fewer arguments.
    5. Have no side effects.
    6. Don't use flag arguments. Split method into several independent methods that can be called from the client without the flag.

    Comments rules

    1. Always try to explain yourself in code.
    2. Don't be redundant.
    3. Don't add obvious noise.
    4. Don't use closing brace comments.
    5. Don't comment out code. Just remove.
    6. Use as explanation of intent.
    7. Use as clarification of code.
    8. Use as warning of consequences.

    Source code structure

    1. Separate concepts vertically.
    2. Related code should appear vertically dense.
    3. Declare variables close to their usage.
    4. Dependent functions should be close.
    5. Similar functions should be close.
    6. Place functions in the downward direction.
    7. Keep lines short.
    8. Don't use horizontal alignment.
    9. Use white space to associate related things and disassociate weakly related.
    10. Don't break indentation.

    Objects and data structures

    1. Hide internal structure.
    2. Prefer data structures.
    3. Avoid hybrids structures (half object and half data).
    4. Should be small.
    5. Do one thing.
    6. Small number of instance variables.
    7. Base class should know nothing about their derivatives.
    8. Better to have many functions than to pass some code into a function to select a behavior.
    9. Prefer non-static methods to static methods.

    Tests

    1. One assert per test.
    2. Readable.
    3. Fast.
    4. Independent.
    5. Repeatable.

    Code smells

    1. Rigidity. The software is difficult to change. A small change causes a cascade of subsequent changes.
    2. Fragility. The software breaks in many places due to a single change.
    3. Immobility. You cannot reuse parts of the code in other projects because of involved risks and high effort.
    4. Needless Complexity.
    5. Needless Repetition.
    6. Opacity. The code is hard to understand.
  • I’m curious which software design principles you find most valuable in real projects.

    Two concise summaries I’ve found:

    Summary of A Philosophy of Software Design by John Ousterhout
    Source: danlebrero.com

    These are notes by Daniel Lebrero Berna on John Ousterhout’s A Philosophy of Software Design.

    Some advice in the book goes against the current software dogma. The current dogma is the result of previous pains, but has now been taken to the extreme, causing new pains.

    What the author solves with “Comment-First Development,” others solve with Test-Driven Development. The excuses for not writing comments mirror those for not writing tests.


    Key Insights

    • It’s easier to see design problems in someone else’s code than your own.
    • Total complexity = Σ(complexity of part × time spent on that part).
    • Goal of good design: make the system obvious.
    • Complexity accumulates incrementally, making it hard to remove. Adopt a “zero tolerance” philosophy.
    • Better modules: interface much simpler than implementation (Deep modules).
    • Design modules around required knowledge, not task order.
    • Adjacent layers with similar abstractions are a red flag.
    • Prioritize simple interfaces over simple implementations.
    • Each method should do one thing and do it completely.
    • Long methods are fine if the signature is simple and the code easy to read.
    • Difficulty naming a method may indicate unclear design.
    • Comments should add precision or intuition.
    • If you aren’t improving the design when changing code, you’re probably making it worse.
    • Comments belong in the code, not commit logs.
    • Poor designers spend most of their time chasing bugs in brittle code.

    Preface

    • The most fundamental problem in computer science is problem decomposition.
    • The book is an opinion piece.
    • The goal: reduce complexity.

    1. Introduction (It’s All About Complexity)

    • Fight complexity by simplifying and encapsulating it in modules.
    • Software design is never finished.
    • Design flaws are easier to see in others’ code.

    2. The Nature of Complexity

    • Complexity = what makes code hard to understand or modify.
    • Total complexity depends on time spent in each part.
    • Complexity is more obvious to readers than writers.
    • Symptoms: change amplification, cognitive load, unknown unknowns.
    • Causes: dependencies, obscurity.
    • Complexity accumulates incrementally; remove it aggressively.

    3. Working Code Isn’t Enough

    • Distinguish tactical (short-term) from strategic (long-term) programming.
    • The “tactical tornado” writes lots of code fast but increases complexity.

    4. Modules Should Be Deep

    • A module = interface + implementation.
    • Deep modules have simple interfaces, complex implementations.
    • Interface = what clients must know (formal + informal).
    • Avoid “classitis”: too many small classes increase system complexity.
    • Interfaces should make the common case simple.

    5. Information Hiding (and Leakage)

    • Information hiding is key to deep modules.
    • Avoid temporal decomposition (ordering-based design).
    • Larger classes can improve information hiding.

    6. General-Purpose Modules Are Deeper

    • Make modules somewhat general-purpose.

    • Implementation fits current needs; interface supports future reuse.

    • Questions to balance generality:

      • What is the simplest interface covering current needs?
      • How many times will it be used?
      • Is the API simple for current use? If not, it’s too general.

    7. Different Layer, Different Abstraction

    • Adjacent layers with similar abstractions are a red flag.
    • Pass-through methods and variables add no value.
    • Fix pass-throughs by grouping related data or using shared/context objects.

    8. Pull Complexity Downwards

    • Prefer simple interfaces over simple implementations.
    • Push complexity into lower layers.
    • Avoid configuration parameters; compute reasonable defaults automatically.

    9. Better Together or Better Apart?

    • Combine elements when they:

      • Share information.
      • Are used together.
      • Overlap conceptually.
      • Simplify interfaces or eliminate duplication.
    • Developers often split methods too much.

    • Methods can be long if they are cohesive and clear.

    • Red flag: one component requires understanding another’s implementation.

    10. Define Errors Out of Existence

    • Exception handling increases complexity.

    • Reduce exception points by:

      • Designing APIs that eliminate exceptional cases.
      • Handling exceptions at low levels.
      • Aggregating exceptions into a common type.
      • Crashing when appropriate.

    11. Design It Twice

    • Explore at least two radically different designs before choosing.

    12. Why Write Comments? The Four Excuses

    • Writing comments improves design and can be enjoyable.

    • Excuses:

      • “Good code is self-documenting.” False.
      • “No time to write comments.” It’s an investment.
      • “Comments get outdated.” Update them.
      • “Comments are worthless.” Learn to write better ones.

    13. Comments Should Describe Things That Aren’t Obvious

    • Comments should add precision and intuition.
    • Document both interface and implementation.

    14. Choosing Names

    • Names should be precise and consistent.
    • If naming is hard, the design likely isn’t clean.

    15. Write the Comment First

    • Like TDD, comment-first helps design, pacing, and clarity.

    16. Modifying Existing Code

    • Always improve design when changing code.
    • Comments belong in code, not commit logs.

    17. Consistency

    • Don’t “improve” existing conventions without strong reason.

    19. Software Trends

    • Agile and TDD often promote tactical programming.

    20. Designing for Performance

    • Simpler code tends to be faster.
    • Design around the critical path.

    21. Conclusion

    • Poor designers spend their time debugging brittle systems.

Gli ultimi otto messaggi ricevuti dalla Federazione
  • @evan @dansup just say you are building a pipeline, and you'll get millions from the Feds...

    read more

  • @leogaggl Hey, Leo. Demilitarization of Palestine has been one of the demands of Israeli negotiators since Oslo.

    https://en.wikipedia.org/wiki/Israeli%E2%80%93Palestinian_peace_process

    The US Senate is currently considering a bill to recognize a "demilitarized Palestine":

    https://www.congress.gov/bill/119th-congress/senate-resolution/410/text

    The Trump Gaza plan also specifies that Gaza will be demilitarized:

    https://en.wikipedia.org/wiki/Gaza_peace_plan

    I don't think it's naive to ask if people think Palestine should be demilitarized.

    read more

  • @evan I do enjoy your polls normally. But this one is incredibly naive. To put it mildly.

    If you would have said 'Should the Middle East be demilitarised?' - that would have been reasonable.

    read more

  • @stags ah, ok, helpful!

    read more

  • @evan The gist is: the Hebrew-speaking community on X is very 'social' and focused on the language and culture more than on particular topics or hashtags.

    This means that one would need to individually track down and follow each Hebrew speaker in that community to maintain the connection.

    So when X became really bad, most Hebrew-speaking migrants moved to the only Hebrew-speaking server at the time. Which functionally killed it. - It had to scale up to expensive IT to handle the new load.

    read more

  • @alttexthalloffame @ChasMusic I’m not certain but this may have been a result of the new CSS theme tokens work, rather than a standalone change. I can ask the team tomorrow.

    read more

  • Retrotechtacular: The $550K Video Conferencing System Used to Make Bee Movie

    The modern office environment has shifted in recent years. Employees are routinely asked to collaborate with co-workers half way around the globe and be camera ready, or whatever passes for webcam ready, in order to telecommute when they are out of office. Every office laptop, tablet, or cell phone these days comes equipped with some sort of camera sensor capable of recording at HD resolution. Twenty years ago, that was not the case. Though tech conglomerates like HP had a different idea of teleconferencing to sell back in 2005 dubbed the Halo Collaboration Studio.

    The Halo Studio was a collaboration between HP and Dreamworks that was used during the production of Bee Movie. Studio heads at Dreamworks thought it necessary to install the HP teleconferencing solution inside the New York office of Jerry Seinfeld, the writer of the film, as to allow him to avoid long trips to Dreamworks production offices in Los Angeles. According to the HP Halo Collaboration Studio brochure, “Halo actually pays for itself, not only by reducing travel costs, but also by encouraging higher productivity and stronger employee loyalty.” Certainly Dreamworks believed in that sales pitch for Bee Movie, because the upfront asking price left a bit of a sting.

    Less of a singular machine, more of an entire dedicated room, the Halo Studio had a $550,000 asking price. It utilized three 1280×960 resolution plasma screens each fitted with a 720p broadcast camera and even included an “executive” table for six. The room lighting solution was also part of the package as the intent was to have all participants appear true to life size on the monitors. The system ran on a dedicated T3 fiber optic connection rated at 45 Mbps that connected to the proprietary Halo Video Exchange Network that gave customers access to 24×7 tech support for the small sum of $30,000 a month.

    For more Retrotechtacular stories, check out Dan’s post on the Surveyor 1 documentary. It’s out of this world.

    youtube.com/embed/0E9iKKTiMSA?…

    hackaday.com/2025/11/30/retrot…

    read more

  • @lcruggeri non trovo più lo screenshot, una volta Linux me l'ha mostrato senza ritegno 🤣

    read more
Post suggeriti
  • 0 Votes
    1 Posts
    2 Views
    Did a guest spot in a business class on Monday and happened to talk gpts with them too.While my programming students may be trying LLM's, they easily see the mistakes and risks to their own understanding.The business students, all 100% on board with the autocomplete, didn't even have thoughts that it wasn't always right or leading them on paths that didn't make sense.I went back to the programming students and reminded them that is how a lot of the users think of tech, the search result is always trustworthy, the feed is safely curated. Now they understand the world better.#programming #college #diploma #business
  • 0 Votes
    1 Posts
    8 Views
    cross-posted from: https://lemmy.dbzer0.com/post/55628224 I’ve been thinking about discovering underappreciated Lemmy instances. GitHub’s awesome-lemmy-instances used to serve a similar purpose, but it hasn’t been updated in a long time, and I haven’t found anything else like it. I got the idea from this post about finding decentralized communities in the Fediverse. I’m thinking of a Lemmy bot that tracks Lemmy instances, calculates the average number of active users and standard deviation, and identifies instances with activity below the average plus two standard deviations. It would then rank these underutilized instances by performance metrics like uptime and response time, and periodically update a curated list on Lemmy to guide users toward instances that could use more participation. I'd love feedback on how you would go about doing something like this. And specifically how to rank by performance.
  • 0 Votes
    3 Posts
    14 Views
    @stefano @nixCraft @imil Here on Debian {in MX Linux} I had to add the following tools since the machine is not configured for programmingbmake`apt install bmake`bsdtar`apt install libarchive-tools`then success>> log# $ ./startnb.sh -f etc/sshd.conf* using console: vioconusing QEMU version 7.2.19 (Debian 1:7.2+dfsg-7+deb12u16)[ 1.0000000] NetBSD 11.99.3 (MICROVM) Notice: this software is protected by copyright[ 1.0000000] Detecting hardware... (QBOOT 000000000000)[ 1.0257426] done.[ 1.0345973] kernel boot time: 51msCreated tmpfs /dev (1835008 byte, 3552 inodes)add net default: gateway 10.0.2.2Starting sshd.Server listening on :: port 22.Server listening on 0.0.0.0 port 22.>> End of log^ZI pressed ^C to enter the server to add the needed passwords for the user and rootlogin was a success then#netBSD #BSD #UNIX #OpenSource #programming #quemu #bash #sh
  • 0 Votes
    2 Posts
    7 Views
    «Se vi capita di osservare qualcuno che "programma", potreste vederlo passare molto più tempo a fissare il vuoto che a digitare sulla tastiera. No, (probabilmente) non sta perdendo tempo. Lo sviluppo software è fondamentalmente una pratica di problem-solving e quindi, come quando si risolve un cruciverba complicato, la maggior parte del lavoro si svolge nella propria testa...»#coding #ai #programming https://chrisloy.dev/post/2025/09/28/the-ai-coding-trap