I Read My Code From 1 Year Ago. I'm Both Impressed and Horrified.

I Read My Code From 1 Year Ago. I'm Both Impressed and Horrified.

Source: Dev.to

The Setup ## What I Found ## The Good (Surprisingly) ## The Bad (Oh No) ## The Ugly (I'm Sorry) ## What I Learned About My Growth ## 1. I Understand Async Now ## 2. I Know When NOT to Comment ## 3. I Understand Error Handling ## 4. I Value Readability Over Cleverness ## The Cringe Moments ## What Stayed Good ## The Humbling Realization ## What I'm Doing About It ## Option 1: Rewrite Everything ## Option 2: Leave It Alone ## Option 3: Strategic Improvements (What I'm Actually Doing) ## The Lesson ## My Advice ## Go Read Your Old Code ## Don't Delete It ## Learn From Past You ## One Year From Now ## Your Turn Found my first "real" project while cleaning up GitHub. Decided to read through it. One year ago, I built a full-stack blog app. My biggest project at the time. I was so proud. Felt like a senior developer. Showed it to everyone. Fast forward to today. I opened the codebase. I actually finished something. Not a half-done tutorial project. Not abandoned after day 3. A complete, working application. 17-year-old me deserves credit for that. The architecture wasn't terrible. Separated routes, controllers, models. Not perfect, but organized. I could actually follow my own logic. Checked the live site. Still running. No major bugs. Users still posting blogs. For a beginner project? That's impressive. Then I looked at the actual code. Six levels of if statements. Just to check if posts exist. Current me would write: One line. Optional chaining. Done. Variable names from hell: What was I thinking? Was I allergic to meaningful names? No. It fetches posts. The comment is wrong. The function name is right. Why did I write that comment? Spoiler: I never fixed it. It's still there. Still "temporary." Password in the code: Yes. Hardcoded. In the repo. Public repo. I'm lucky I wasn't hacked. Callback hell. I didn't understand promises. Clean. Readable. Async/await saved my life. Then: Comments everywhere explaining obvious things Now: Comments only when code isn't self-explanatory Catch everything. Log nothing useful. Pray it works. Specific errors. Useful context. Actual error handling. Then: Tried to be clever One line! So smart! Impossible to debug. Now: Readable over clever More lines. Way clearer. Future me will understand this. Plain text passwords. In 2024. I'm embarrassed. That's not validation. That's hope. Every. Single. Error. Same message. Debugging was a nightmare. Not everything was terrible: ✅ File structure made sense - Even now, I can navigate it easily ✅ Function names were descriptive - getUserPosts() does what it says ✅ Separated concerns - Routes, controllers, models in different files ✅ It works - Despite the mess, users can still use it One year ago, I thought this was amazing code. Today, I see all the flaws. The inefficiencies. The bad practices. One year from now, I'll probably look at my current code and cringe too. That's not depressing. That's growth. If you're not embarrassed by your old code, you're not learning. "Let me fix all these issues!" Reality: I'd spend weeks rewriting working code. Not worth it. "It works, don't touch it" Reality: But it's public. It's on my portfolio. It represents me. ✅ Fixed the security issues (hashed passwords, env variables) ✅ Added proper error handling ✅ Improved the most painful parts ✅ Added a README explaining it's an old project ✅ Left the rest alone It's a time capsule of my learning journey. That's okay. Your old code will always look bad. That means you're growing. Signs you're improving: If your year-old code still looks perfect, you haven't learned anything. Pick a project from 6-12 months ago. Read it honestly. I almost deleted this project out of embarrassment. Glad I didn't. Recruiters appreciate the growth story more than perfect code. Every cringe moment is a lesson: Your past mistakes are your future study guide. I'll probably read THIS post and cringe at something I said. I'll look at my current projects and see obvious flaws. And that will be a good sign. It means I'm still learning. Still growing. Still improving. When's the last time you looked at your old code? Go find a project from 6+ months ago. Read through it. Come back and tell me: Drop it in the comments. Let's celebrate our growth (and our cringe) together. My commitment: Not deleting old projects. They're proof of progress, not embarrassment. Hit ❤️ if you've ever cringed at your own code. Templates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well For further actions, you may consider blocking this person and/or reporting abuse COMMAND_BLOCK: // My actual code from 1 year ago const data = await fetch(url).then(res => res.json()).then(data => data).catch(err => console.log(err)) if (data != null && data != undefined && data != '') { if (data.user != null) { if (data.user.posts != null) { if (data.user.posts.length > 0) { // actual logic finally starts here } } } } Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: // My actual code from 1 year ago const data = await fetch(url).then(res => res.json()).then(data => data).catch(err => console.log(err)) if (data != null && data != undefined && data != '') { if (data.user != null) { if (data.user.posts != null) { if (data.user.posts.length > 0) { // actual logic finally starts here } } } } COMMAND_BLOCK: // My actual code from 1 year ago const data = await fetch(url).then(res => res.json()).then(data => data).catch(err => console.log(err)) if (data != null && data != undefined && data != '') { if (data.user != null) { if (data.user.posts != null) { if (data.user.posts.length > 0) { // actual logic finally starts here } } } } COMMAND_BLOCK: const data = await fetch(url).then(res => res.json()); if (data?.user?.posts?.length > 0) { // logic here } Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: const data = await fetch(url).then(res => res.json()); if (data?.user?.posts?.length > 0) { // logic here } COMMAND_BLOCK: const data = await fetch(url).then(res => res.json()); if (data?.user?.posts?.length > 0) { // logic here } CODE_BLOCK: const x = userData; const xx = userData.posts; const xxx = userData.posts[0]; const data1 = xxx; const data2 = data1.comments; const finalData = data2; Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: const x = userData; const xx = userData.posts; const xxx = userData.posts[0]; const data1 = xxx; const data2 = data1.comments; const finalData = data2; CODE_BLOCK: const x = userData; const xx = userData.posts; const xxx = userData.posts[0]; const data1 = xxx; const data2 = data1.comments; const finalData = data2; CODE_BLOCK: // fetches all users const posts = await getAllPosts(); Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: // fetches all users const posts = await getAllPosts(); CODE_BLOCK: // fetches all users const posts = await getAllPosts(); CODE_BLOCK: // TODO: fix this later // FIXME: this is temporary // NOTE: refactor this entire file Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: // TODO: fix this later // FIXME: this is temporary // NOTE: refactor this entire file CODE_BLOCK: // TODO: fix this later // FIXME: this is temporary // NOTE: refactor this entire file CODE_BLOCK: const DB_PASSWORD = "mypassword123"; Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: const DB_PASSWORD = "mypassword123"; CODE_BLOCK: const DB_PASSWORD = "mypassword123"; COMMAND_BLOCK: fetch(url) .then(res => res.json()) .then(data => { processData(data) .then(result => { saveResult(result) .then(() => { console.log('done'); }) }) }) Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: fetch(url) .then(res => res.json()) .then(data => { processData(data) .then(result => { saveResult(result) .then(() => { console.log('done'); }) }) }) COMMAND_BLOCK: fetch(url) .then(res => res.json()) .then(data => { processData(data) .then(result => { saveResult(result) .then(() => { console.log('done'); }) }) }) CODE_BLOCK: const res = await fetch(url); const data = await res.json(); const result = await processData(data); await saveResult(result); Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: const res = await fetch(url); const data = await res.json(); const result = await processData(data); await saveResult(result); CODE_BLOCK: const res = await fetch(url); const data = await res.json(); const result = await processData(data); await saveResult(result); CODE_BLOCK: // increment i by 1 i++; // check if user exists if (user) { Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: // increment i by 1 i++; // check if user exists if (user) { CODE_BLOCK: // increment i by 1 i++; // check if user exists if (user) { CODE_BLOCK: // Retry with exponential backoff for rate limiting await retryWithBackoff(apiCall); Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: // Retry with exponential backoff for rate limiting await retryWithBackoff(apiCall); CODE_BLOCK: // Retry with exponential backoff for rate limiting await retryWithBackoff(apiCall); CODE_BLOCK: try { // 50 lines of code } catch (err) { console.log(err); } Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: try { // 50 lines of code } catch (err) { console.log(err); } CODE_BLOCK: try { // 50 lines of code } catch (err) { console.log(err); } CODE_BLOCK: try { await riskyOperation(); } catch (err) { logger.error('Failed to process user data', { userId, error: err.message, stack: err.stack }); throw new AppError('Failed to process data', 500); } Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: try { await riskyOperation(); } catch (err) { logger.error('Failed to process user data', { userId, error: err.message, stack: err.stack }); throw new AppError('Failed to process data', 500); } CODE_BLOCK: try { await riskyOperation(); } catch (err) { logger.error('Failed to process user data', { userId, error: err.message, stack: err.stack }); throw new AppError('Failed to process data', 500); } COMMAND_BLOCK: const result = users.filter(u => u.age > 18).map(u => ({...u, adult: true})).reduce((acc, u) => ({...acc, [u.id]: u}), {}); Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: const result = users.filter(u => u.age > 18).map(u => ({...u, adult: true})).reduce((acc, u) => ({...acc, [u.id]: u}), {}); COMMAND_BLOCK: const result = users.filter(u => u.age > 18).map(u => ({...u, adult: true})).reduce((acc, u) => ({...acc, [u.id]: u}), {}); COMMAND_BLOCK: const adults = users.filter(user => user.age > 18); const adultsWithFlag = adults.map(user => ({ ...user, adult: true })); const userMap = Object.fromEntries( adultsWithFlag.map(user => [user.id, user]) ); Enter fullscreen mode Exit fullscreen mode COMMAND_BLOCK: const adults = users.filter(user => user.age > 18); const adultsWithFlag = adults.map(user => ({ ...user, adult: true })); const userMap = Object.fromEntries( adultsWithFlag.map(user => [user.id, user]) ); COMMAND_BLOCK: const adults = users.filter(user => user.age > 18); const adultsWithFlag = adults.map(user => ({ ...user, adult: true })); const userMap = Object.fromEntries( adultsWithFlag.map(user => [user.id, user]) ); CODE_BLOCK: if (password === user.password) { // login success } Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: if (password === user.password) { // login success } CODE_BLOCK: if (password === user.password) { // login success } CODE_BLOCK: if (email.includes('@')) { // valid email } Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: if (email.includes('@')) { // valid email } CODE_BLOCK: if (email.includes('@')) { // valid email } CODE_BLOCK: res.status(500).json({ error: 'Something went wrong' }); Enter fullscreen mode Exit fullscreen mode CODE_BLOCK: res.status(500).json({ error: 'Something went wrong' }); CODE_BLOCK: res.status(500).json({ error: 'Something went wrong' }); - Authentication system - CRUD operations - Comment section - File uploads - Deployed to production - You cringe at code from 6 months ago - You spot bugs immediately in old projects - You can't believe you didn't use X pattern - You want to refactor everything (but don't) - Proud (you built something!) - Embarrassed (what was I thinking?) - Motivated (look how much I've grown) - Where I started - How far I've come - That I actually finish things - My learning progression - Nested ifs everywhere? → Learn optional chaining - Callback hell? → Master async/await - Bad variable names? → Practice clean code - No error handling? → Learn proper patterns - What made you proud? - What made you cringe? - What did you learn?