Live data from Hacker News

The C4 model for visualising software architecture (2017)

c4model.com

61–70 of 107 posts

Re: The C4 model for visualising software architecture (2017)

#61
Even as a non civil engineer I can understand floor plans and alikes and find then immediately useful. Even as a professional SWE these example diagrams don't seem useful or informative enough to justify bothering with them.

Code is too multidimensional to be approximated with 2d drawings. It just doesn't work.

What could work are more conventional architectural code patterns. Things like structured concurrency, but also for higher level. Maybe.

Re: The C4 model for visualising software architecture (2017)

#62
I've tried creating diagrams of this nature (not realizing this is a thing) but I chose them for documenting the system to others that weren't already familiar with the project so it felt necessary to layer it all together. Those diagrams shown looked more like team meetings hashing out the details. Seemed kind of an unfair comparison.

That being said, the biggest issue I ran into is in the diagram tooling. At the time we had Gliphy. One could not make it interactable, such that double-clicking on a node would explode the container and let someone drill-down. At best they had layers which were awfully crude to work with. And at the end of the day didn't export in SVG so were useless for embedding. Overall, a waste of time. :(

Re: The C4 model for visualising software architecture (2017)

#63
post #7

Earlier quoted context omitted.

Diagrams are similar to textual documentation: You generally can’t auto-generate useful ones from code, unless the code has extra markup that specifies what to generate. Diagrams often present a specific perspective that emphasizes certain features while omitting others. You might have several diagrams for the same entity, each illustrating a different aspect or scenario. The upshot is that diagrams have to be mainta…

Agreed. I experimented with autogenerating C4 diagrams from source a while back, but quickly abandoned the project when I realized that the output was inevitably the flowchart equivalent of bool mystery_func(int i) { // define a new function int x = (int)(i / 2); // x is i divided by 2 and truncated int y = x * 2; // y is twice x return y == i; // return true if y == i } // end of function

Indeed, the documentation (diagrams/text with particular layout and formatting) should abstract a lot of what the code does. Otherwise, what's the point since the code is there for you to read.

In my experience, auto-generated documentation in general does a poor job.

That said, such automation is improving by virtue of better AI, that understands and cross translates people's languages and computer languages.

Re: The C4 model for visualising software architecture (2017)

#64
post #7

> Ideally this diagram would be automatically generated using tooling... The biggest problem I've seen with architecture diagrams is they fall out of sync with the code base. In my opinion, automatic generation of these diagrams is necessary. Otherwise, teams have no way to know whether the picture in front of them accurately represents the latest state of the system.

Diagrams are similar to textual documentation: You generally can’t auto-generate useful ones from code, unless the code has extra markup that specifies what to generate. Diagrams often present a specific perspective that emphasizes certain features while omitting others. You might have several diagrams for the same entity, each illustrating a different aspect or scenario. The upshot is that diagrams have to be mainta…

> You generally can’t auto-generate useful [architecture diagrams] from code,

The question is: why is this the case?

IMNSHO, the reason is that we don't have a way to express architecture in or as code. Instead, we have to compile the actual architecture of the system into one that is expressible using the call/return architectural style that our programming languages support.

That's a lossy process.

When we can program with actual architectural connectors, auto-generating useful architectural diagrams becomes trivial.

https://objective.st

Re: The C4 model for visualising software architecture (2017)

#65
post #21

Earlier quoted context omitted.

This is not a trivial problem to solve. Some would say that one of the entire points of software engineering is to assure that the code meets the design spec. A more rigorous approach would be to encode your design as a bunch of linting rules that you could run against your codebase (IaC and all). I'm pretty sure that auto generating a diagram from some code and then trying to work out if it's semantically equivalent…

Yeah it's hard. For http API design I like to start with an openapi spec then generate as much of the server and client library implementation from this as possible. The spec gives a language/implementation agnostic way to describe what you're intending to build that's nicely diff-able over time, and you can generate a lot of the boilerplate that's easy to screw up in a way that's both compile time (static types) and…

Sure, but there’s a whole dimension missing here.

Architecture is more than simply “what", it’s also "why". It binds the context to the requirements and the desired componentsA diagram is not "the architecture", it’s simply a view on it, or a "projection of the model" as the c4 folk like to express it as.

I just find the idea that we should automate diagram production because diagrams are hard to keep up to date a little quaint, because you hardly ever need to update just a diagram when changing the architecture. So your actual problem is that your design documentation is hard to keep up to date, and that’s a process problem. Generating diagrams from code won’t save you there.

Re: The C4 model for visualising software architecture (2017)

#66
post #55

Earlier quoted context omitted.

Try testing if people can comprehend the diagrams by asking a question after showing them a somewhat complicated one. You'll likely be disappointed. We don't seem to be using them because they work.

As it happens, most people understand easier a standard notation that can refer to, and get a book at the library, than NIH boxes and lines. Now people straigth out of bootcamps calling themselves engineers, without having a Software Engineer degree, yeah maybe not. Then again, they can get that book I just mentioned, and in the process maybe discover other goodies at the local library, or just ask ChatGPT.

> As it happens, most people understand easier a standard notation that can refer to, and get a book at the library, than NIH boxes and lines.

I do not believe this for a second. You're possible arguing against a straw man.

The alternative to UML isn't a "NIH UML" which uses a different array of arrows. It's labelled boxes and lines. You don't need to go to a library to understand the diagram because the diagram is self-explanatory.

Here's a really good example:

https://buck2.build/docs/concepts/concept_map/

Every arrow is labelled. No tedious textbook needed.

Re: The C4 model for visualising software architecture (2017)

#67

Earlier quoted context omitted.

But you don't need and official standard that everyone learns. Just use words. If your box is a class, write "class Foo". If your arrow means "contains 1 or more" just write that next to the arrow.

Yes, that’s exactly the convention that C4 specifies: add legends on every diagram and make sure things are labeled in a way that people can understand.

Well they don't follow their own rules then because the "Level 4" diagram on that page is just standard awful UML with no legend or labels.

Re: The C4 model for visualising software architecture (2017)

#68
post #55

Earlier quoted context omitted.

As it happens, most people understand easier a standard notation that can refer to, and get a book at the library, than NIH boxes and lines. Now people straigth out of bootcamps calling themselves engineers, without having a Software Engineer degree, yeah maybe not. Then again, they can get that book I just mentioned, and in the process maybe discover other goodies at the local library, or just ask ChatGPT.

> As it happens, most people understand easier a standard notation that can refer to, and get a book at the library, than NIH boxes and lines. I do not believe this for a second. You're possible arguing against a straw man. The alternative to UML isn't a "NIH UML" which uses a different array of arrows. It's labelled boxes and lines. You don't need to go to a library to understand the diagram because the diagram is s…

You are free to believe in whatever makes you happy, I am not UML missionary.

Re: The C4 model for visualising software architecture (2017)

#69
post #7

Earlier quoted context omitted.

Diagrams are similar to textual documentation: You generally can’t auto-generate useful ones from code, unless the code has extra markup that specifies what to generate. Diagrams often present a specific perspective that emphasizes certain features while omitting others. You might have several diagrams for the same entity, each illustrating a different aspect or scenario. The upshot is that diagrams have to be mainta…

> You generally can’t auto-generate useful [architecture diagrams] from code, The question is: why is this the case? IMNSHO, the reason is that we don't have a way to express architecture in or as code. Instead, we have to compile the actual architecture of the system into one that is expressible using the call/return architectural style that our programming languages support. That's a lossy process. When we can prog…

I don’t think that’s the problem. There are so many different ways to look at a system. An architectural diagram shows you how components connect. A procedural diagram shows you what steps a program takes. An entity diagram shows you the major high level entities you’ve selected into your system. I just don’t see how a single language can express all the detail. Maybe a new one can be invented but I don’t see how S expressions solve this (the link you posted don’t have any indication that any diagram generation is part of the language). Also, diagrams can be useful even if they have birotted because discrepancies are a good teaching tool - “why does this diagram say x but the code seems to do y” is a tracing opportunity, an opportunity to update the diagram, and highlights which engineers are paying attention.

Maybe if LLMs get sufficiently advanced they can generate this stuff more automatically with some minor prompting with the code as context, but I doubt it. Not until AI can actually start understanding sentiment from code.

Re: The C4 model for visualising software architecture (2017)

#70

You can see a crappy house that’s falling apart pretty easily. Conversely management cannot see a crappy codebase that’s rife with technical debt. Maybe they would make more intelligent decisions if they could visualize the problem.

Code quality does not seem to have any correlation with business success. Why should business care?

Well this is just wrong, so I don't really know how to respond. You're probably thinking about monopolies such as Facebook, Google, or the like, where not only does code quality not matter, but not much matters at all. Most businesses do not have this luxury.
Post reply on HN