🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)
🔧 AI Nachrichten Major AI platforms go down in unprecedented simultaneous outage(03.09.2026 um 17:34 Uhr)
🔧 AI Nachrichten ChatGPT, Claude, and Grok Down? Users Report Widespread Outages(03.09.2026 um 19:14 Uhr)
🔧 AI Nachrichten OpenAI Launches GPT-6 Astra, Says We May Have Entered the AGI Era(03.09.2026 um 22:08 Uhr)
🔧 AI Nachrichten Claude Comes to CarPlay as Fifth Major AI Chatbot App(05.09.2026 um 05:31 Uhr)
🔧 AI Nachrichten OpenAI’s GPT-6 Astra Is AGI, Says NVIDIA CEO Jensen Huang(07.09.2026 um 06:31 Uhr)
🔧 AI Nachrichten Blame AI companies for Mac mini and Mac Studio shortage(31.08.2026 um 10:32 Uhr)

🔧 Programmierung 🕛 kürzlich 3 Min Lesezeit
0

Write Code You Can Still Read 6 Months Later

↗ Quelle (dev.to)
🗣️ Stimme:
📑 Inhaltsübersicht

I'm AlanWu. I'm in junior high. I've written a lot of bad code. Here's what I changed to make it less bad.









1. Name things like a human






CODE
// Don't do this
int d; // days? distance? damage?
int cnt = 0; // "cnt" — you know, the classic
vector<int> v; // v of what

// Do this
int daysUntilDeadline;
int errorCount = 0;
vector<int> studentScores;






Full words, no abbreviations. idx instead of i in loops is fine. But sz for size, cnt for count, ptr for pointer — just type the word. You're not being charged by the character.









2. Functions should do one thing



If you need the word "and" to describe a function, split it.




CODE
// Bad: does two things, name lies
void loadAndValidateConfig() {
readFile();
checkSyntax();
}

// Better
Config loadConfig(string path) {
return parseConfig(readFile(path));
}

bool validateConfig(const Config& cfg) {
return cfg.width > 0 && cfg.height > 0;
}






My rule of thumb: if a function is longer than what fits on one screen, break it. If I can't describe what it does in one sentence without "and", break it.









3. Comments explain WHY, not WHAT






CODE
// Bad — tells me what the code already says
// Loop through all students
for (auto& s : students) {
s.score += 5;
}

// Good — tells me WHY, which the code can't
// Extra credit: 5 points for submitting early
for (auto& s : students) {
s.score += 5;
}






If you're writing a comment that just restates the next line of code, delete it. The only comments worth keeping are the ones that answer "why did I do it this way?"









4. Don't nest too deep






CODE
// Bad — 3 levels deep, I've already forgotten what the top level was
for (auto& student : students) {
if (student.hasSubmitted()) {
for (auto& answer : student.answers) {
if (answer.isCorrect()) {
score++;
}
}
}
}

// Better — flatten with early exits
for (auto& student : students) {
if (!student.hasSubmitted()) continue;
for (auto& answer : student.answers) {
if (!answer.isCorrect()) continue;
score++;
}
}






Also: if you have if (a) { if (b) { if (c) { ... } } } with no else, just combine them: if (a && b && c).









5. Split long files



My algorithmCombination project started as one gigantic header. 800 lines. Finding anything was pain.



Now I split by topic:




CODE
math_utils.h      // gcd, lcm, fast_pow
string_utils.h // split, trim, join
data_structures.h // heap, disjoint_set






Each file is under 150 lines. I know exactly where everything lives.









6. The 30-second test



Six months from now, can I look at a random function and understand it in 30 seconds?



If yes: it's good code, even if it's not elegant.



If no: rename things, add one comment, split one function. Repeat until it passes.



I don't write code for the compiler. I write it for the version of me who hasn't slept and needs to fix a bug at midnight.






My GitHub: https://github.com/Cn-Alanwu

Vollständiger Original-Bericht
Ausführliche Details, Code-Beispiele & Hersteller-Stellungnahme auf dev.to.
↗ Original-Artikel auf dev.to lesen
Wie bewertest du diesen Beitrag?
1 Klick Feedback
Teilen mit Netzwerk & Team:

Community-Analysen & Experten-Meinungen 0

Verfasse deine eigene Analyse, teile Workarounds oder diskutiere diesen Vorfall im Blog.
Noch keine Community-Analyse verfasst. Markiere einen Textabschnitt oder klicke oben auf Eigene Analyse verfassen“!
Community Pulse: Relevanz-Einschätzung
1 Klick Experten-Votum
🔴 Akute Relevanz 0%
🟡 In Evaluierung 0%
🟢 Keine Auswirkung 0%
Spannende Innovation 0%
Verwandte Story-Cluster & Quellen (Vektor-KI)
Port 8095 Engine
3 Quellen
GPT-6 Astra Release Today? OpenAI’s Next Major AI Model Is Almost Here
1 Quelle
Apple accuses OpenAI of destroying evidence as trade-secrets fight intensifies
1 Quelle
Major AI platforms go down in unprecedented simultaneous outage
Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten Write Code You Can Still Read 6 Months Later

Thematisch verwandte Begriffe: Write, Code, Still, Read · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...