Lädt...

🔧 From English Major to Developer: Why Clean Code Is About Telling a Clear Story


Nachrichtenbereich: 🔧 Programmierung
🔗 Quelle: dev.to

Before I was a developer, I was an English major. I cared about how sentences flowed, how meaning was layered and could sometimes be buried and lost.
Turns out, writing clean code taps right into those same instincts.

🧼 What Clean Code Means to Me

My brain can easily be thrown into a state of chaos, and poorly written code can be very chaotic. For me, clean means:

  • Semantic at very least
  • Modularized if possible - chunks of code broken in into reusable pieces
  • Coherent - const items means very little but const blogPosts has clear meaning.

🍜 Eating Div Soup: Semantic HTML

Have you ever opened a page file only to find hundreds and hundreds of lines of divs — a styled banner, a row of buttons, some images, a form —
<div> after <div> after div-estating <div>?

Worse still, there are no comments, so it's just an abyss of HTML with no real visual landmarks. My brain looks for structure to latch onto.

When I was learning to code at Turing, they called this Div Soup — IYKYK — and they were right.

<template>
  <div>
    <div>
      <div>
        <h1
          :style="{
            fontSize: '32px',
            fontWeight: 'bold'
          }"
        >
          Welcome
        </h1>
      </div>
    </div>
    <div>
      <div>
        <div>
          <button
            :style="{
              backgroundColor: 'blue',
              color: 'white',
              padding: '10px'
            }"
          >
            Click Me
          </button>
          <button
            :style="{
              backgroundColor: 'green',
              color: 'white',
              padding: '10px'
            }"
          >
            Or Me
          </button>
        </div>
      </div>
    </div>
    <div>
      <div>
        <div>
          <form>
            <div>
              <input
                type="text"
                placeholder="Your Name"
                :style="{
                  border: '1px solid gray',
                  padding: '8px'
                }"
              />
            </div>
            <div>
              <input
                type="email"
                placeholder="Your Email"
                :style="{
                  border: '1px solid gray',
                  padding: '8px'
                }"
              />
            </div>
            <div>
              <button
                type="submit"
                :style="{
                  backgroundColor: 'purple',
                  color: 'white'
                }"
              >
                Submit
              </button>
            </div>
          </form>
        </div>
      </div>
    </div>
    <div>
      <div>
        <div>
          <div>
            <div>
              <img
                src="banner1.jpg"
                alt="Banner Image 1"
                :style="{
                  width: '100%',
                  height: 'auto'
                }"
              />
              <img
                src="banner2.jpg"
                alt="Banner Image 2"
                :style="{
                  width: '100%',
                  height: 'auto'
                }"
              />
              <img
                src="banner3.jpg"
                alt="Banner Image 3"
                :style="{
                  width: '100%',
                  height: 'auto'
                }"
              />
            </div>
          </div>
        </div>
      </div>
    </div>
    <!-- Repeat 300 more lines... -->
  </div>
</template>

🌟 Clean, Neat, Semantic Version:

Let's strip out some of that <div> soup and replace it with some semantic HTML elements!

<template>
  <section class="page-container">
    <header class="page-header">
      <h1>Welcome</h1>
    </header>

    <section class="button-group">
      <button class="primary-button">Click Me</button>
      <button class="secondary-button">Or Me</button>
    </section>

    <section class="form-section">
      <form>
        <div class="form-group">
          <label for="name">Name</label>
          <input id="name" type="text" placeholder="Your Name" />
        </div>

        <div class="form-group">
          <label for="email">Email</label>
          <input id="email" type="email" placeholder="Your Email" />
        </div>

        <button type="submit" class="submit-button">Submit</button>
      </form>
    </section>

    <section class="banner-gallery">
      <img src="banner1.jpg" alt="Banner Image 1" />
      <img src="banner2.jpg" alt="Banner Image 2" />
      <img src="banner3.jpg" alt="Banner Image 3" />
    </section>
  </section>
</template>

Ahh, that's nice isn't it? It's much easier to tell what elements are making up this page. It utilizes <section> elements showing how the page is organized. The <input> elements now have a <label>.

We can go further though.

🧹 Modularized, Neatly Organized Version

What if we put the page header code into it's own component file? We could use it on any page!

📄 PageHeader.vue

<template>
  <header class="page-header">
    <h1>Welcome</h1>
  </header>
</template>

Oh, and the buttons, well, heck let's just refactor each piece into a component.

📄 ButtonGroup.vue

<template>
  <section class="button-group">
    <button class="primary-button">Click Me</button>
    <button class="secondary-button">Or Me</button>
  </section>
</template>

📄 FormSection.vue

<template>
  <section class="form-section">
    <form>
      <div class="form-group">
        <label for="name">Name</label>
        <input id="name" type="text" placeholder="Your Name" />
      </div>

      <div class="form-group">
        <label for="email">Email</label>
        <input id="email" type="email" placeholder="Your Email" />
      </div>

      <button type="submit" class="submit-button">Submit</button>
    </form>
  </section>
</template>

📄 BannerGallery.vue

<template>
  <section class="banner-gallery">
    <img src="banner1.jpg" alt="Banner Image 1" />
    <img src="banner2.jpg" alt="Banner Image 2" />
    <img src="banner3.jpg" alt="Banner Image 3" />
  </section>
</template>

Now, let's see how the page template would look.

<script setup>
// Import your modular components
import PageHeader from "@/components/PageHeader.vue";
import ButtonGroup from "@/components/ButtonGroup.vue";
import FormSection from "@/components/FormSection.vue";
import BannerGallery from "@/components/BannerGallery.vue";
</script>

<template>
  <section class="page-container">
    <PageHeader />
    <ButtonGroup />
    <FormSection />
    <BannerGallery />
  </section>
</template>

Is it easier or more difficult to tell what the page is made of? Pretty darn clear, right? We look at the template and tell a quick tale of what makes up the page, at a glance:

  • First there's a page header
  • Next there's a button group
  • Then comes the big bad form section
  • And then the banner gallery rallied at the end
  • And the page lived happily ever after...

🏗️ Where Most Pages Land

Of course, it doesn't always make sense to create a new component file for every tiny section, especially if it's only used once on a single page.
In reality, most page templates land somewhere between Example 2 (neatly organized semantic HTML) and Example 3 (full modularization).

And that's okay.

🛠️ In the Real World

As a developer, you’re guaranteed to encounter a little (or a lot of) Div Soup chaos at some point.
And most of the time, you won’t be asked to refactor a mess into a clean, modular masterpiece — you’ll be tasked with patching, fixing, and building on top of what's already there.

But — whenever you have the chance to make things a little clearer, a little more structured, or a little more readable for the next person (even if that person is future-you) — it’s worth doing.

Clean code isn't about being perfect.
It's about being thoughtful.

And thoughtful code tells a clearer story — one that's easier to read, easier to build on, and a whole lot nicer to live inside. 🧹📚✨

...

🔧 From English Major to Developer: Why Clean Code Is About Telling a Clear Story


📈 79.82 Punkte
🔧 Programmierung

📰 Story Telling with Visualization — Which Area Has the Highest Socio-Economic Score, and Why


📈 30.36 Punkte
🔧 AI Nachrichten

🎥 Tell me you’re a developer without telling me you're a developer


📈 28.93 Punkte
🎥 Videos

🎥 Tell me your a developer without telling me your a developer


📈 28.93 Punkte
🎥 Video | Youtube

🔧 Squid Game: The Clean Code Trials — A Java Developer's Survival Story


📈 26.94 Punkte
🔧 Programmierung

🔧 The Clean Code book and the clean code paradigms


📈 26.11 Punkte
🔧 Programmierung

🔧 Story Telling AI


📈 25.98 Punkte
🔧 Programmierung

🔧 Numbers and Narratives: The Power of Tracking Your Open Source Journey and Telling Your Story


📈 25.98 Punkte
🔧 Programmierung

🔧 SAS: Telling a Story With Data


📈 25.98 Punkte
🔧 Programmierung

🪟 Mojang Studios says Minecraft Legends is about telling a story that may not be true


📈 25.98 Punkte
🪟 Windows Tipps

🪟 Mojang Studios says Minecraft Legends is about telling a story that may not be true


📈 25.98 Punkte
🪟 Windows Tipps

📰 How Does Interactive Story Telling On Netflix Work


📈 25.98 Punkte
🤖 Android Tipps

📰 How Does Interactive Story Telling On Netflix Work


📈 25.98 Punkte
🖥️ Betriebssysteme

📰 Android Developer Story: Culture Alley reaches millions of English learners on Google Play


📈 25.25 Punkte
🤖 Android Tipps

📰 Android Developer Story: Culture Alley reaches millions of English learners on Google Play


📈 25.25 Punkte
🤖 Android Tipps

🔧 The Art of Writing Clean Code: Craft Clear and Maintainable Software


📈 24.52 Punkte
🔧 Programmierung

🔧 Clean code , Clear Mind


📈 24.52 Punkte
🔧 Programmierung

🔧 Clean Code: Writing clear conditional logic in JavaScript


📈 24.52 Punkte
🔧 Programmierung

🔧 The Power of Clear Function Names: A Clean Code Essential


📈 24.52 Punkte
🔧 Programmierung

🔧 Craft Clear and Maintainable Code: Getting started with Clean Coding


📈 24.52 Punkte
🔧 Programmierung

🔧 Clear Conversations, Clear Results


📈 22.92 Punkte
🔧 Programmierung

🔧 Clear Conversations, Clear Results


📈 22.92 Punkte
🔧 Programmierung

📰 Not a clear about secure boot / validation in Clear Linux*


📈 22.92 Punkte
📰 IT Security Nachrichten

🕵️ BigTree CMS up to 4.2.18 clear.php clear cross site request forgery


📈 22.92 Punkte
🕵️ Sicherheitslücken

📰 Facebook delivers ‘clear history’ tool that doesn’t ‘clear’ anything


📈 22.92 Punkte
📰 IT Security Nachrichten

📰 Apple’s iPhone XR Clear Case Costs 39 Times More than a Typical Clear Case


📈 22.92 Punkte
📰 IT Security Nachrichten

📰 Clear Linux Project Announces the Next Generation of Intel's Clear Containers


📈 22.92 Punkte
📰 IT Security Nachrichten

📰 Clear Linux Announces Intel Clear Containers 2.1.6 with Docker 17.04.0 Support


📈 22.92 Punkte
📰 IT Security Nachrichten

🔧 The Art of Writing Clean Functions: Clean Code Practices


📈 22.83 Punkte
🔧 Programmierung

🔧 The difference between clean code and clean architecture?


📈 22.83 Punkte
🔧 Programmierung