The Liebfrauenkirche in Worms looks like AI-generated code

I recently looked at the Liebfrauenkirche in Worms and had a rather unexpected thought: This looks like AI-generated code.

Not because it looks particularly bad. It is an impressive building, has a recognizable structure and serves its purpose perfectly well. But when you look at the details, something feels a little inconsistent.

Different parts seem to follow different design philosophies. Some elements fit together nicely, others feel like they belong to a slightly different building. There is an overall structure, but the individual pieces don’t always seem to share the same idea of what that structure should look like.

And that is pretty much how I experience software created with multiple AI agents.

Everybody has their own idea of good code

When you ask an LLM to implement a feature, it usually does a reasonable job. It understands the requirements, produces code that compiles and often even comes up with a sensible design.

Then you ask another agent to implement the next feature.

It also does a reasonable job. It follows the requirements, produces working code and makes some architectural decisions along the way.

The problem starts when you put both results together.

One agent prefers small functions and explicit data structures. Another likes abstractions and introduces a generic framework for something that could have been three lines of code. One uses dependency injection, another simply imports the implementation. One writes defensive code everywhere, another assumes that everything is valid because the types say so.

Individually, none of these decisions necessarily looks wrong.

Together, they create a codebase that lacks a consistent style.

This is not even necessarily a problem with the agents themselves. They are doing what they are supposed to do: solving the problem in front of them.

But they don’t necessarily share the same understanding of the larger system.

A building constructed over generations

The Liebfrauenkirche has a somewhat similar history.

Construction started around 1276 and the church was completed in 1465. That’s almost 200 years. During this time, architectural preferences, craftsmen, financial circumstances and construction decisions changed.

Later, the building suffered considerable damage during the War of the Palatine Succession in 1689. Reconstruction and subsequent restoration added further layers to its history.

The result is a building that has a coherent overall purpose and recognizable architectural identity, but also carries the marks of many different periods and decisions.

A software project that is continuously extended by different AI agents also accumulates decisions from different generations of tools and models.

The first agent establishes a structure. The next one extends it. A third one changes an abstraction because it doesn’t quite fit its understanding of the problem. Then a newer model comes along and introduces a different preference.

Everything works. At least for now.

Agents keep changing

There is another aspect that makes this particularly difficult: LLMs change.

Even if I use the same agent configuration, the underlying model might change. A new model version can have different preferences, different strengths and different ideas about what constitutes good software design.

The next generation might be better at reasoning but prefer a different implementation style. It might introduce abstractions where the previous model preferred straightforward code. It might consider a pattern outdated that the previous model used consistently.

And suddenly, the same instructions produce a different result.

This is a rather unusual situation for software development.

We are accustomed to tools becoming more predictable as we gain experience with them. A compiler version changes, but we generally don’t expect it to develop a new personal preference for object-oriented programming.

With LLMs, the tool itself is part of the creative process. Its output is not simply a deterministic transformation of requirements into source code.

It is more like working with a developer whose personality, experience and coding preferences change every few months.

And we are employing several of them simultaneously.

Conclusion

A codebase is more than the sum of its individually working components. It also contains an implicit language: naming conventions, architectural boundaries, error handling strategies, abstractions and countless small decisions that make the whole thing understandable.

Humans learn this language by working with a codebase over time. They recognize existing patterns and, ideally, extend them instead of inventing new ones.

An AI agent often has a much narrower perspective. It sees the task, explores the relevant files and makes decisions based on the context it has available.

We need something that provides continuity across agents and model generations. Architectural decisions must be explicitly documented and maintained.

Someone needs to understand the original structure, make decisions about what should be preserved and ensure that new work fits into the existing whole.

Tell different stories within the same universe

You might know this from fantasy book series: the author creates a unique world, a whole universe of their own and sets a story or series of books within it. Then, a few years later, a new series is released. It is set in the same universe, but at a different time, with different characters, and tells a completely new story. Still, it builds on the foundation of that original world. The author does not reinvent everything from scratch. They use the same map, the same creatures, the same customs and rules established in the earlier books.

Examples of this are the Harry Potter series and Fantastic Beasts, or The Lord of the Rings and The Hobbit.

But what does this have to do with software development?
In one of my projects, I faced a very similar use case. I had to implement several services, each covering a different use case, but all sharing the same set of peripherals, adapters, and domain types.

So I needed an architecture that did not just allow for interchangeable periphery, as is usually the focus, but also supported interchangeable use cases. In other words, I needed a setup that allowed for multiple “books” to be written within the same “universe.”

Architecture

Let’s start with a simple example: user management.
I originally implemented it following Clean Architecture principles, where the structure resembles an onion, dependencies flow inward, from the outer layers to the core domain logic. This makes the outer layers (the “peel”) easily replaceable or extendable.

Our initial use case is a service that creates a user. The use case defines an interface that the user controller implements, meaning the dependency flows from the outer layer (the controller) toward the core. So far, so good.

However, I wanted to evolve the architecture to support multiple use cases. For that, the direct dependency from the UserController to the CreateUser use case had to be removed.

My solution was to introduce a new domain module, a shared foundation that contains all interfaces, data types, and common logic used by both use cases and adapters. I called this module the UseCaseService.

The result is a new architecture diagram:

There is no longer a direct connection between a specific use case and an adapter. Instead, both depend on the shared UseCaseService module. With this setup, I can easily create new use cases that reuse the existing ecosystem without duplicating code or logic.

For example, I could implement another service that retrieves all users whose birthday is today and sends them birthday greetings. (Whether this is GDPR-compliant is another discussion!) But thanks to this architecture, I now have the freedom to implement that use case cleanly and efficiently.

Conclusion

Architecture is a highly individual matter. There is no one-size-fits-all solution that solves every problem or suits every project. Models like Clean Architecture can be helpful guides, but ultimately, you need to define your own architectural requirements and find a solution that meets them. This was a short story of how one such solution came to life based on my own needs.

It is also a small reminder to keep the freedom to think outside the box. Do not be afraid to design an architecture that truly fits you and your project, even if it deviates from the standard models.

Recap of the Schneide Dev Brunch 2017-10-08

If you couldn’t attend the Schneide Dev Brunch at 08th of October 2017, here is a summary of the main topics.

brunch64-borderedLast sunday, we held another Schneide Dev Brunch, a regular brunch on the second sunday of every other (even) month, only that all attendees want to talk about software development and various other topics. This brunch was smaller, which enabled us to use the meeting table with some comfort. Sometimes, with many attendees and bad weather, this table can get a little bit crowded. As usual, the main theme was that if you bring a software-related topic along with your food, everyone has something to share. Because we were a small group, we discussed without an agenda. As usual, a lot of topics and chatter were exchanged. This recapitulation tries to highlight the main topics of the brunch, but cannot reiterate everything that was spoken. If you were there, you probably find this list inconclusive:

Area of training

We shared some stories about top-notch video game players and how they keep up with the demand to stay competitive. Similar stories can be told about every topic imagineable: What did the “king of the hill” do to rise to such levels? The answer is always: training. Excessive, brutal training. They are first in the gym and lock the door late at night because they are the last, too. The use every waking second for practice and repetition. They are obsessed with being “the best”. If you want to follow such a story in movie format, you might enjoy “Whiplash”, a movie about an aspiring expert drummer that also highlights the delicate trainer/trainee dynamics. If you are more interested in the strategies of obtaining mastery, the book “Mastery” by Robert Greene will give you a lot of insights.

With this background, we asked around what our area of training (not expertise, not mastery – just training) is. The answers varied wildly, from the obvious “programming” to “whisky” (as in whisky tasting and collecting whisky). It’s an interesting question: what goal are you actively pursuing at the moment?

Hacking challenges

Evolving from the first topic, we talked about coding challenges and “capture the flag” hacking contests. If you aren’t the grandmaster in the area of the contest, you’ll get the most out of it by following the participating teams and trying to understand their approaches.  The local security capture the flag team of the KIT is especially open with their approach, their failures and successes. You might want to check out their website.

One challenge included trying to break a whitebox encryption, which is an interesting topic in itself. Maybe somebody can read up on this topic and give a little presentation in the future. Another challenge seemed to lead to an elaborate buffer overflow attack, when in reality, it could be solved with a “simple” use-after-free attack.

An useful starting point for aspiring security hackers might be the CTF (capture the flag) field guide. There are also some online challenges for basic training purposes, like the cryptopals or the bandit wargame. Thanks Tobias for the links!

If you are more interested in playful challenges and don’t want to show up on somebody’s radar, programming/hacking games like TIS-100 are perfect for you. Our game night with TIS-100 is still in vivid memory.

Software Architecture training

There are a lot of programming contests and hacking challenges out there. But what about dry-run training for software architects? On a related scale, there are hundreds of training simulators for the foot soldier (called ego-shooters), but little games for the aspiring officer/general. The website armchair general lists a few and even has some contests, but they lack the depth of real experience. Similarly, the training for software architects will probably be clean-room exercises, when in reality, the customer needs, the team mood, the latest fad in technology and even the weather will influence the architecture just as well as textbook knowledge.

We couldn’t discuss this topic to its full potential, so it will re-appear on the agenda of the next Dev Brunch. And its open for discussion in the comments: What are good books and trainings for software architects?

Thomas pointed us to the Architectural Katas by Ted Neward. Perhaps we should schedule a Schneide Event to try them out?

Epilogue

As usual, the Dev Brunch contained a lot more chatter and talk than listed here. The number of attendees makes for an unique experience every time. We are looking forward to the next Dev Brunch at the Softwareschneiderei in December. We even have some topics still on the agenda (like a report about first-hand experiences with the programming language Rust). And as always, we are open for guests and future regulars. Just drop us a notice and we’ll invite you over next time.