which side are you on? the great brace debate that defines your entire programming identity left side: function { on the same line. clean, compact, saves vertical space. right side: function with opening brace on the next line. readable, structured, respects hierarchy. this isn't just about code style. this is about your entire worldview as a developer. the religious war nobody asked for but everyone participates in: same-line brace arguments: - saves screen real estate for actual code - easier to scan through functions quickly - standard in javascript, java, c++ communities - keeps related syntax visually connected - every modern style guide recommends it next-line brace arguments: - makes block structure immediately visible - easier to match opening and closing braces - follows traditional c and c sharp conventions - reduces visual noise on the function declaration line - better for debugging and reading stack traces the uncomfortable truth is that both styles work perfectly fine and the only thing that matters is consistency within your codebase. but we still fight about it anyway because that's what developers do. practical advice for ending the war: - adopt whatever your team or company standard requires - use auto-formatters like prettier or black to enforce consistency - focus on logic quality over brace placement - save your energy for actual architecture debates - remember that readable code is more important than winning style arguments pick your side and defend it in the comments. #programming #codestyle #javascript #developers #coding #debates #syntax #bestpractices #cleancode #softwareengineering
The Great Brace Debate: Left or Right?
More Relevant Posts
-
🔧 Bad Code Today = Technical Debt Tomorrow Yesterday, I dedicated 3 hours to debugging an issue. Surprisingly, the solution boiled down to a simple one-line alteration. The root cause? Code resembling this snippet: let d = [] let u = data.map(x => x.map(y => y * 2)) Contrast that with the refined version: let discounts = [] let userPrices = data.map(item => item.map(price => price * 2)) Same functionality, yet operating in entirely different realms. Key takeaways: 1️⃣ The significance of variable names → d vs discounts conveys distinct narratives. 2️⃣ Simplify complexity → When dealing with nested loops, structure them for enhanced legibility. 3️⃣ Anticipate future laziness → Craft code with the developer (possibly future you 😅) in mind, six months down the line. 4️⃣ Comments are crucial → Elucidate the 'why' behind the code, not just the 'what'. Incorporating these minor practices can significantly reduce your team's debugging time. 💬 What's the most valuable lesson you've learned from encountering "unreadable code"? Share below 👇 #CleanCode #DeveloperLife #CodingTips #NodeJS #MERN #Debugging #BestPractices
To view or add a comment, sign in
-
-
🧹 Code Linting & Formatting, Because consistency beats cleverness. Every developer has their style, indentation, naming, commas, quotes…But when you’re in a team, code style disagreements can turn into silent wars. 😅 That’s where linters and formatters come in ensuring your codebase speaks one consistent language. Here’s why they matter 👇 ✅ Consistency Across Teams: Every file looks and feels the same, no matter who wrote it. ⚙️ Fewer Code Review Debates: PRs focus on logic and structure, not tabs vs spaces. 🚀 Faster Development: Automatic formatting saves time and mental load because one less decision to make. 🧠 Early Error Detection: Linters catch potential issues before your code even runs. Popular Tools: JavaScript / TypeScript → ESLint + Prettier Python → Flake8, Black Java → Checkstyle, SpotBugs Go → gofmt (built-in perfection 😉) 💡 Pro Tip: Automate linting & formatting in your pre-commit hooks (Husky, pre-commit, etc.) Because clean code should be automatic, not optional. At Veyon Lab, we treat code formatting as hygiene, not style because clarity today prevents chaos tomorrow. #CleanCode #SoftwareEngineering #CodeQuality #VeyonLab #DeveloperTools #Programming
To view or add a comment, sign in
-
-
✨ Don’t Use the ELSE Keyword — Simplifying Logic and Improving Readability 💡 One of the most interesting rules from Object Calisthenics is: “Don’t use the ELSE keyword.” At first glance, it seems radical — after all, else is a fundamental part of most programming languages. But when we stop using it, we start writing more linear, readable, and intentional code. In Java, this principle pushes us to design methods that express decisions clearly, avoiding nested logic and long conditional chains. Instead of focusing on what happens otherwise, we focus on the main flow — and that changes everything. 🤔 Why avoid else? ❌ Nested complexity: Each else adds one more level of indentation, making it harder to follow the method’s logic. ❌ Blurry intent: When if and else blocks both contain logic, it becomes harder to see the “happy path.” ❌ Difficult evolution: As rules grow, new else if statements quickly create a tangle of conditions. 🚀 What improves when you remove it? ✨ Simpler flow: By handling edge cases early (using guard clauses), the main path remains clean and focused. ✨ Better readability: The method reads like a short story — straightforward, without mental jumps. ✨ More maintainable code: Fewer nested blocks mean fewer bugs and easier refactoring. #Java #CleanCode #ObjectCalisthenics #Refactoring #CodeQuality #SoftwareDesign #SpringBoot
To view or add a comment, sign in
-
-
𝗘𝘃𝗲𝗿 𝘄𝗼𝗻𝗱𝗲𝗿𝗲𝗱 𝗵𝗼𝘄 𝗝𝗮𝘃𝗮𝗦𝗰𝗿𝗶𝗽𝘁 𝗺𝗮𝗴𝗶𝗰𝗮𝗹𝗹𝘆 𝗰𝗹𝗲𝗮𝗻𝘀 𝘂𝗽 𝗶𝘁𝘀 𝗼𝘄𝗻 𝗺𝗲𝘀𝘀? 🤔 𝗜𝘁'𝘀 𝗻𝗼𝘁 𝗺𝗮𝗴𝗶𝗰, 𝗶𝘁'𝘀 𝗚𝗮𝗿𝗯𝗮𝗴𝗲 𝗖𝗼𝗹𝗹𝗲𝗰𝘁𝗶𝗼𝗻! 🗑️ Think of it as a tiny, diligent janitor inside your code. Here's a super quick rundown of how it works: 1. 𝗜𝘁'𝘀 𝗔𝘂𝘁𝗼𝗺𝗮𝘁𝗶𝗰: JavaScript's garbage collector works silently in the background to free up memory that's no longer needed. No manual cleanup required! 2. 𝗧𝗵𝗲 "𝗨𝗻𝗿𝗲𝗮𝗰𝗵𝗮𝗯𝗹𝗲" 𝗥𝘂𝗹𝗲: It identifies and targets "unreachable" objects. If there's no way for your program to access an object, it's considered garbage. 3. 𝗠𝗮𝗿𝗸-𝗮𝗻𝗱-𝗦𝘄𝗲𝗲𝗽: The most common method is "mark-and-sweep." 𝗠𝗮𝗿𝗸: It starts from the root and "marks" all the objects it can reach. 𝗦𝘄𝗲𝗲𝗽: It then "sweeps" away everything else that wasn't marked. Simple and effective! 4. 𝗦𝗰𝗼𝗽𝗲𝘀 & 𝗖𝗹𝗼𝘀𝘂𝗿𝗲𝘀 𝗮𝗿𝗲 𝗦𝗮𝗳𝗲: Don't worry, variables in your active scopes and closures are considered "reachable" and won't be collected. 𝗪𝗵𝘆 𝘀𝗵𝗼𝘂𝗹𝗱 𝘆𝗼𝘂 𝗰𝗮𝗿𝗲? Garbage collection is crucial for preventing memory leaks and optimizing your application's performance. While it runs periodically and doesn't guarantee instant cleanup, understanding this core concept is a game-changer for writing efficient and robust code. What are your thoughts on JavaScript's memory management? Drop a comment below! 👇 #JavaScript #WebDevelopment #Programming #Coding #SoftwareDevelopment #Tech #MemoryManagement #GarbageCollection
To view or add a comment, sign in
-
-
I’ve been using Cursor and Claude Code since the early days — and honestly, after a phase of disappointment with Cursor, I had completely shifted to Claude Code. But Cursor 2.0 hits differently. This update isn’t just a patch — it’s a complete transformation of how AI-assisted coding feels. Here’s what stood out to me: → Multi-Agents: Run up to 8 agents in parallel on isolated workspaces — no conflicts, no chaos. → Composer Model: Their new agent model is 4× faster — perfect for fast-paced dev loops. → Browser (GA): Agents can now interact directly with web pages — a game-changer for UI-driven automation. → Sandboxed Terminals: Secure command execution with zero network access — safer testing, fewer risks. → Team Commands: Create and share prompts, rules, and workflows across your team — a real productivity boost. → Improved LSPs: Much smoother experience in large Python and TypeScript projects. → Plan Mode: Build and compare multiple agent plans in the background — parallel thinking at its best. → Enterprise Suite: Audit logs, admin control, and compliance-ready security — finally enterprise-grade. Final thought: Cursor 2.0 feels mature — fast, stable, and deeply team-oriented. If you left Cursor before, this version might just win you back. #Cursor #Claude #AItools #Developers #AgenticAI #Coding #DevTools #Productivity
To view or add a comment, sign in
-
-
It’s not always the complex algorithms that break systems , sometimes it’s a single misplaced string. The smallest things in code often make the biggest impact. That’s the difference between something that works and something that’s well-engineered. I wrote a short blog about one of those small but important habits avoiding “magic strings” in code. 🪄 “The Problem with Magic Strings - and How to Avoid Them” Read it here 👉 https://lnkd.in/gQUBC3TS #CleanCode #SoftwareEngineering #JavaScript #CodingBestPractices #DeveloperMindset #Maintainability
To view or add a comment, sign in
-
The hidden power of "𝑣𝑎𝑟 _ 𝑃𝑜𝑟𝑡 = (TokenAdapter)(nil)" in Go 💡(aka implements) If you’ve seen this line in Go code before and wondered 𝑤ℎ𝑎𝑡 𝑘𝑖𝑛𝑑 𝑜𝑓 𝑠𝑜𝑟𝑐𝑒𝑟𝑦 𝑖𝑡 𝑖𝑠, you’re not alone: ```go var _ Port = (*TokenAdapter)(nil) ``` It looks odd — but it’s actually one of the most elegant compile-time checks in Go. Here’s what it does: • "Port" is an 𝐢𝐧𝐭𝐞𝐫𝐟𝐚𝐜𝐞. • "TokenAdapter" is a 𝐬𝐭𝐫𝐮𝐜𝐭 meant to implement that interface. • By assigning a "nil" pointer of type "*TokenAdapter" to a variable of type "Port", Go forces the compiler to verify that "TokenAdapter" implements all the methods of "Port". If it doesn’t, the compiler immediately complains. No runtime surprises, no silent mismatches. 💡 𝐖𝐡𝐲 𝐢𝐭’𝐬 𝐩𝐨𝐰𝐞𝐫𝐟𝐮𝐥: • It acts as 𝐝𝐨𝐜𝐮𝐦𝐞𝐧𝐭𝐚𝐭𝐢𝐨𝐧: developers can instantly see which interface a struct is meant to satisfy. • It ensures 𝐜𝐨𝐦𝐩𝐢𝐥𝐞-𝐭𝐢𝐦𝐞 𝐬𝐚𝐟𝐞𝐭𝐲 without having to instantiate the type. • It’s 𝐥𝐢𝐠𝐡𝐭𝐰𝐞𝐢𝐠𝐡𝐭 𝐚𝐧𝐝 𝐢𝐝𝐢𝐨𝐦𝐚𝐭𝐢𝐜, zero runtime cost. You could also write: ```go var _ Port = &TokenAdapter{} ``` …but using "(*Type)(nil)" is cleaner since no object allocation happens, just a type check. It’s a small line of code that says a lot: "𝑌𝑒𝑠, 𝑡ℎ𝑖𝑠 𝑎𝑑𝑎𝑝𝑡𝑒𝑟 𝑓𝑢𝑙𝑓𝑖𝑙𝑙𝑠 𝑖𝑡𝑠 𝑐𝑜𝑛𝑡𝑟𝑎𝑐𝑡 — 𝑎𝑛𝑑 𝑡ℎ𝑒 𝑐𝑜𝑚𝑝𝑖𝑙𝑒𝑟 𝑎𝑔𝑟𝑒𝑒𝑠." ✅ Have you used this pattern before in your Go projects? Would you add it to your interface-based designs? #Golang #GoLangTips #SoftwareEngineering #CleanCode #GoDeveloper #Programming #BackendDevelopment #CodeQuality #TypeSafety #TechLeadership #GoInterfaces #GoPatterns #CodeDesign #LearnGo
To view or add a comment, sign in
-
-
Problem 25 : Leetcode 🚀 LeetCode Problem Solved: Find the Duplicate Number (Cyclic Sort Approach) 🧠 🔍 Problem Overview: Given an array of n+1 integers where each number is between 1 and n (inclusive), at least one duplicate number must exist. The task: Find that duplicate — with O(n) time and O(1) extra space. 💡 My Approach – Cyclic Sort Technique: I applied the Cyclic Sort algorithm to achieve both performance and space efficiency. In-Place Hashing Logic: I treated the array as a hash map where each number x should ideally be placed at index x - 1. Duplicate Detection: If arr[i] != arr[arr[i] - 1], I swapped the elements to place them correctly. If arr[i] == arr[arr[i] - 1], it indicates that arr[i] is the duplicate number — and I immediately returned it. 🏁 Results: ✅ Time Complexity: O(n) – Runtime: 6 ms, beating 50.29% of Java submissions. ✅ Space Complexity: O(1) – Solved entirely in-place. ✅ Memory Usage: 82.82 MB, outperforming 6.05% of other submissions. 🧩 Tech Insight: Cyclic Sort is an elegant in-place sorting strategy ideal for problems involving numbers within a fixed range — making it a powerful tool for efficient duplicate detection and data placement. #LeetCode #Java #DSA #ProblemSolving #CodingJourney #SpringBootDeveloper #BackendDevelopment #CyclicSort #JavaDeveloper #LearningInPublic Link : https://lnkd.in/diWSfAaM
To view or add a comment, sign in
-
-
Beyond Fowler's Refactoring: Martin Fowler's Theatrical Players kata is brilliant for teaching refactoring mechanics. But there's a gap between refactored code and production-ready code. I created an advanced version demonstrating patterns that bridge this gap. What Fowler teaches (essential foundation): - Extract Method - Split Phase - Replace Conditional with Polymorphism What's still missing: 1. Type Safety : Fowler uses strings for play types like "tragedy" and "comedy" - one typo and you have a runtime bug. The advanced version uses type-safe enums where the compiler catches typos before the code even runs. IDE autocomplete works, refactoring is safe, and invalid types are impossible to create. 2. Value Objects Fowler uses primitive integers for both money and credits. Problem: you can accidentally add money to credits and the code compiles fine - but it's completely wrong. With value objects (Money and VolumeCredits), mixing incompatible types becomes a compile-time error. The type system prevents an entire class of bugs. Plus you get currency awareness, proper formatting, and precision handling built-in. 3. Domain Boundaries Three separate layers: Event Domain (what happened - performances, invoices) Calculation Domain (business rules - pricing strategies) Presentation Domain (formatting - text, HTML, JSON) This separation means you calculate once and can format the same results as text for email, HTML for web, JSON for API, or PDF for reports. No calculation logic duplication. 4. Make Illegal States Unrepresentable through the type system: Can't create negative audience sizes Can't create empty play names Can't mix money with credits Can't create invalid play types The compiler enforces business rules. Bugs are caught at compile-time, not in production. Check it out for learning production worthy code practices. Full implementation on GitHub (link in comments) Detailed blog post with examples and comparisons (link in comments) #SoftwareArchitecture #DomainDrivenDesign #Java #Refactoring #TypeSafety #CleanCode
To view or add a comment, sign in
Explore related topics
- How to Achieve Clean Code Structure
- Writing Functions That Are Easy To Read
- Why Well-Structured Code Improves Project Scalability
- Importance of Consistent Code Editor Settings
- Importance of Clear Coding Conventions in Software Development
- Intuitive Coding Strategies for Developers
- How to Refactor Code Thoroughly
- How to Add Code Cleanup to Development Workflow
- Innovating vs. Maintaining Code Quality
- How to Resolve Code Refactoring Issues
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development