Navigating Between Generated Code, Written Code, and the Crucial Details

Süleyman Ali Akpınar
3 min readJun 23, 2023

--

Recently, many code generating tools have entered our lives. The accessibility of these tools, which are APIs extensions and web applications, continues to increase day by day. Uncle Bob (Robert C. Martin) tells us about this situation in his book “Clean Code” in 2008 in the section “There will be a code”.

Indeed some have suggested that we are close to the end of code. That soon all code will be generated instead of written. That programmers simply won’t be needed because business people will generate programs from specifications.

Clean Code: A Handbook of Agile Software Craftsmanship
Robert C. Martin

And uncle bob has a thesis called “Details of the Requirements”.

We will never be rid of code, because code represents the details of the requirements. At some level those details cannot be ignored or abstracted; they have to be specified. And specifying requirements in such detail that a machine can execute them is programming. Such a specification is code.

Clean Code: A Handbook of Agile Software Craftsmanship
Robert C. Martin

Generated or written code, according to Uncle Bob, is a level of abstraction and level of detail the real punchline applied here?

While writing code, a programmer provides specific commands that are tailored to the abstraction level of the code. Within these details, they take into account potential scenarios, business requirements, and possible errors.

On the other hand, how do code generators, who strive to fulfill the requirements provided as prompts, adjust this level of abstraction? How much of the requirements given in the details do they meet? What significance do overlooked details hold for them?

When it comes to code generation, it’s important to strike a balance between abstraction and detail. Code generators often rely on input specifications provided by developers or business users, which specify the desired behavior of the software. While some rule generators can handle high-level requirements well, they can struggle with finer details that require specific implementation decisions. For example, a code generator can handle basic CRUD (Create, Read, Update, Delete) operations perfectly for a database-backed application but cannot incorporate advanced caching techniques or complex data validation rules

Prompt: Create a REST API for a blog application that allows users to create, read, update, and delete blog posts.

from fastapi import FastAPI

app = FastAPI()

@app.post("/posts")
def create_post(post_data: dict):
# Code to create a new blog post
...

@app.get("/posts/{post_id}")
def read_post(post_id: int):
# Code to retrieve a specific blog post
...

@app.put("/posts/{post_id}")
def update_post(post_id: int, post_data: dict):
# Code to update an existing blog post
...

@app.delete("/posts/{post_id}")
def delete_post(post_id: int):
# Code to delete a blog post
...

Taking the example of creating a REST API for a blog application that enables users to perform CRUD operations on blog posts, the provided code demonstrates the usage of a code generator. The generated code effectively handles the high-level requirements of creating, reading, updating, and deleting blog posts. However, it may not account for additional features such as authentication, authorization, or advanced validation rules, which demand more detailed implementation.

Therefore, for more advanced web services, it is essential to provide details such as authentication, authorization, validation, and database integration. While artificial intelligence can assist in generating functions like division, we still need to specify the mechanism that handles errors arising from division by zero.

As Robert C. Martin stated, code will continue to exist in the future, created either by manual writing or through generation. Ultimately, our goal is to have code that fulfills the intended purpose. In this process, our focus on details begins within our minds. Previously, we wrote code by specifying all the necessary details in the right combination. Now, we are attempting to transfer these details to artificial intelligence, ensuring correct grammar and code generation. In essence, what we call “writing code” can be seen as the act of determining specific details and translating them into the digital realm.

Ultimately, whether code is generated or written, the goal remains the same — to create code that effectively fulfills its intended purpose. While the process of writing code may evolve with the involvement of artificial intelligence, the importance of understanding and specifying the necessary details remains paramount. As software developers, we embark on a journey where our expertise in combining the right details with the correct level of abstraction becomes crucial in shaping the digital landscape of the future.

--

--