Best Programming Practices for Clean Code

Explore top LinkedIn content from expert professionals.

  • View profile for Addy Osmani

    AI Engineering & DevRel Leader, Recently: Director, Google Cloud AI. Eng Lead, Chrome Best-selling Author. Speaker. AI, DX, UX. I want to see you win.

    287,316 followers

    "Agentic Code Review" - The hard part of engineering isn't writing code anymore. Coding agents are extraordinarily good now and getting better fast. But the hard part of engineering has moved from writing code to deciding whether to trust it. Code review is the big bottleneck. My latest free deep-dive: https://lnkd.in/gSZqtKDP ✍ AI pushes raw output up by about 4x, but real productivity gains sit closer to 12%. The gap between those numbers is review work. Because we poured machine-speed output into a system built for human-speed work, the friction has moved downstream: - PRs merged with zero human review are up 31.3% - Median review duration is up 441.5% - The per-developer defect rate has jumped from 9% to 54% How you solve this depends entirely on your blast radius. A solo developer vibe-coding a side project and a team keeping a ten-year-old enterprise system alive share almost no constraints. To adapt, the rules of code review have to change: Tier by risk, not author: Spend scarce human attention only where being wrong is costly. A config change gets a linter; a payments path gets the full stack of tests, multiple AI reviewers, and human ownership. Embrace heterogeneous AI review: CodeRabbit, Greptile, Seer, and others all catch different classes of bugs. Run at least two with deliberately different characters. Keep humans on the loop: The volume ended the era of a human reading every single line. Instead, humans must own the accountability, the high-stakes gates, and the judgment of whether the change was the right thing to build in the first place. We made writing cheap, but understanding a system well enough to stand behind it remains the most durable and interesting skill in software. I mapped out exactly where the work has shifted in my latest write-up and hope you find it helpful. #ai #programming #softwareengineering

  • View profile for Allen Holub

    I help you build software better & build better software.

    34,698 followers

    Last night, I was chatting in the hotel bar with a bunch of conference speakers at Goto-CPH about how evil PR-driven code reviews are (we were all in agreement), and Martin Fowler brought up an interesting point. The best time to review your code is when you use it. That is, continuous review is better than what amounts to a waterfall review phase. For one thing, the reviewer has a vested interest in assuring that the code they're about to use is high quality. Furthermore, you are reviewing the code in a real-world context, not in isolation, so you are better able to see if the code is suitable for its intended purpose. Continuous review, of course, also leads to a culture of continuous refactoring. You review everything you look at, and when you find issues, you fix them. My experience is that PR-driven reviews rarely find real bugs. They don't improve quality in ways that matter. They DO create bottlenecks, dependencies, and context-swap overhead, however, and all that pushes out delivery time and increases the cost of development with no balancing benefit. I will grant that two or more sets of eyes on the code leads to better code, but in my experience, the best time to do that is when the code is being written, not after the fact. Work in a pair, or better yet, a mob/ensemble. One of the teams at Hunter Industries, which mob/ensemble programs 100% of the time on 100% of the code, went a year and a half with no bugs reported against their code, with zero productivity hit. (Quite the contrary—they work very fast.) Bugs are so rare across all the teams, in fact, that they don't bother to track them. When a bug comes up, they fix it. Right then and there. If you're working in a regulatory environment, the Driver signs the code, and then any Navigator can sign off on the review, all as part of the commit/push process, so that's a non-issue. There's also a myth that it's best if the reviewer is not familiar with the code. I *really* don't buy that. An isolated reviewer doesn't understand the context. They don't know why design decisions were made. They have to waste a vast amount of time coming up to speed. They are also often not in a position to know whether the code will actually work. Consequently, they usually focus on trivia like formatting. That benefits nobody.

  • No, you won't be vibe coding your way to production. Not if you prioritise quality, safety, security, and long-term maintainability at scale. Recently coined by former OpenAI co-founder Andrej Karpathy, "vibe coding" describes an AI-coding approach where developers focus on iterative prompt refinement to generate desired output, with minimal concern for the LLM-generated code implementation. At Canva, our assessment — based on extensive and ongoing evaluation of AI coding assistants — is that these tools must be carefully supervised by skilled engineers, particularly for production tasks. Engineers need to guide, assess, correct, and ultimately own the output as if they had written every line themselves. Our experimentation consistently reveals errors in tool-generated code ranging from superficial (style inconsistencies) to dangerous (incorrect, insecure, or non-performant code). Our engineering culture is built on code ownership and peer review. Rather than challenging these principles, our adoption of AI coding assistants has reinforced their importance. We've implemented a strict "human in the loop" approach that maintains rigorous peer review and meaningful code ownership of AI-generated code. Vibe coding presents significant risks for production engineering: - Short-term: Introduction of defects and security vulnerabilities - Medium to long-term: Compromised maintainability, increased technical debt, and reduced system understandability From a cultural perspective, vibe coding directly undermines peer review processes. Generating vast amounts of code from single prompts effectively DoS attacks reviewers, overwhelming their capacity for meaningful assessment. Currently we see one narrow use case where vibe coding is exciting: spikes, proofs of concept, and prototypes. These are always throwaway code. LLM-assisted generation offers enormous value in rapidly testing and validating ideas with implementations we will ultimately discard. With rapidly expanding LLM capabilities and context windows, we continuously reassess our trust in LLM output. However, we maintain that skilled engineers play a critical role in guiding, assessing, and owning tool output as an immutable principle of sound software engineering.

  • View profile for Brij Kishore Pandey

    AI Architect & AI Engineer | Building Agentic Systems & Scalable AI Solutions

    736,793 followers

    Claude Code just shipped something most developers haven't noticed yet.   Agent Teams.   Not one AI coding assistant. A full team of AI agents — working in parallel — talking to each other — on your codebase.   Here's what changes everything →   𝗪𝗵𝗮𝘁 𝗔𝗿𝗲 𝗔𝗴𝗲𝗻𝘁 𝗧𝗲𝗮𝗺𝘀?   → Multiple Claude Code instances coordinated as a team → One session acts as Team Lead — assigns tasks, synthesizes results → Teammates work independently with their own context windows → They message each other directly — no bottleneck through the lead   This is NOT the same as subagents.   Subagents report back to a parent. That's it. One-way. Agent Teams talk to each other. Share findings. Challenge assumptions. Self-coordinate.   Think: contractors on separate errands vs. a project team in the same room.   𝟰 𝗣𝗿𝗼𝗱𝘂𝗰𝘁𝗶𝗼𝗻 𝗧𝗲𝗮𝗺 𝗣𝗮𝘁𝘁𝗲𝗿𝗻𝘀 𝗧𝗵𝗮𝘁 𝗔𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝗪𝗼𝗿𝗸   𝟭. 𝗙𝘂𝗹𝗹-𝗦𝘁𝗮𝗰𝗸 𝗧𝗲𝗮𝗺 Lead/Architect → Frontend → Backend → Testing → Reviewer Each agent owns a layer. No stepping on each other's code.   𝟮. 𝗗𝗲𝗯𝘂𝗴 𝗗𝗲𝗯𝗮𝘁𝗲 𝗧𝗲𝗮𝗺 Spawn 3-5 agents with competing hypotheses. They actively try to disprove each other. The theory that survives is the actual root cause.   Why this works → sequential debugging suffers from anchoring bias. Once you explore one theory, everything after is biased toward it.   𝟯. 𝗤𝗔 𝗧𝗲𝗮𝗺 Security reviewer + Performance agent + UX quality agent. Pro tip: route models — Opus for deep debugging, Sonnet for perf, Haiku for UX.   𝟰. 𝗪𝗿𝗶𝘁𝗶𝗻𝗴 𝗧𝗲𝗮𝗺 Context Gatherer ↔ Writer ↔ Editor All run simultaneously. The writer requests context mid-task. 𝟳 𝗕𝗲𝘀𝘁 𝗣𝗿𝗮𝗰𝘁𝗶𝗰𝗲𝘀 𝗜'𝘃𝗲 𝗟𝗲𝗮𝗿𝗻𝗲𝗱   → Always plan BEFORE spawning — without a plan, agents go random and waste tokens → CLAUDE. md is your force multiplier — 3 agents reading clear docs >> 3 agents exploring blindly → Set quality bar explicitly — tell the lead, instructions trickle down → Define roles prescriptively for expensive tasks → Monitor context usage — single agent fills 80-90% on large codebases, splitting keeps each at ~40% → Use model routing to control costs → Know that idle agents auto-kill themselves   𝗧𝗵𝗲 𝗣𝗮𝗿𝘁 𝗠𝗼𝘀𝘁 𝗣𝗲𝗼𝗽𝗹𝗲 𝗠𝗶𝘀𝘀   Agent Teams' killer feature isn't parallelism.   It's collaboration.   Agents debating each other. Agents reviewing each other's code. Agents challenging assumptions that a single agent would never question.   That's a fundamentally different quality of output.   I drew out the complete architecture, patterns, and decision framework in one handwritten cheatsheet (see image).   The gap between "uses Claude Code" and "orchestrates Claude Code teams" is about to get very wide.   Which side do you want to be on?

  • View profile for Charafeddine Mouzouni

    Applied AI for enterprises. Founder @ Cohorte, Professor @ OPIT.

    27,175 followers

    Too much "human in the loop" kills "human in the loop." It does not mean "human buried under the loop." First, "Human in the loop" IS NON NEGOTIABLE to make AI work at scale. BUT... If your AI process looks like this cartoon, you don't have oversight. You have a bottleneck. Here's the thing. Nobody is reviewing 2,000 pages of AI output line by line. Nobody. That's not oversight. That's fiction. So how does human-in-the-loop actually work when it's not cosplay? First, break down your processes. Split the work. Some tasks need human judgment. Others are "agentifiable". It's easier to check intermediary steps, than to check the final 234 pages, 24 files work. Second, build quality gates BEFORE the human ever sees anything. Self-consistency checks. Automated evaluation. Confidence scoring. If the agent isn't sure, it flags it. If it is sure, it proves it. The human should receive pre-filtered, pre-verified output. Not a raw dump and a prayer. Third, design the human checkpoint around decisions, not documents. Nobody's reviewing 20 generated files and pretending they read them. The human reviews the 3 decisions that matter, the 2 flags the system raised, and the 1 thing that actually needs domain judgment. The order matters: identify what needs a human. Automate quality on everything else. Route only the real decisions to the person in the chair. Human-in-the-loop is not a person drowning in AI output and clicking "approve." When done well, it's actually human-machine COLLABORATION. Your thoughts ↓ (image credit: Tom Fishburne / marketoonist.com) P.S. If you’re learning AI or want to use it better—you will love my weekly newsletter (it’s free). Make sure to subscribe to receive your letter.

  • View profile for Aishwarya Naresh Reganti

    Founder & CEO @ LevelUp Labs | Human-First AI Transformation For Your Enterprise

    127,688 followers

    😅 The biggest AI coding question today: how do you get to production without shipping vibe coded slop? A lot of developers now understand that AI can help them move fast. You can vibe code a prototype, generate a feature quickly, and get a working draft in minutes. But the harder question is, how do you make sure the code actually stands the test of time? This is exactly what Mihail Eric covered in our internal Chai & AI community session last week. Mihail teaches the "The Modern Software Developer" course at Stanford, is Head of AI at Monaco, and was also a colleague of mine back at Alexa. In the session, he introduced his RePPIT framework for using AI to ship production quality code. RePPIT breaks down the coding process into five deliberate steps: (Re)search, (P)ropose, (P)lan, (I)mplement, and (T)est. A few ideas from the RePPIT framework, although I’d recommend reading the whole the whole article we wrote around the session (linked below): ⛳ Research the codebase: Before asking AI to implement anything, first ask it to understand the architecture, file layout, dependencies, design decisions, and existing patterns. This keeps the model grounded in the actual codebase. ⛳ Propose solutions: Instead of jumping straight into code, ask the model to generate a couple of different implementation paths with tradeoffs, validation plans, and open questions. This is where you, as the developer, make the judgment call. ⛳ Plan the chosen solution: Once you pick a direction, turn it into a proper design doc. This helps define what’s in scope, what’s out of scope, what files need to change, and how the feature should be tested. ⛳ Implement the plan: Only after the research, proposal, and planning steps should the model start writing code. At this point, it has enough context to avoid guessing its way through the implementation. ⛳ Test what got built: Don’t let the same model instance blindly approve its own work. Use a fresh context or a different model to review, test, and critique the implementation before you trust it. I think a lot of this boils down to strong context engineering. It was also super useful to walk through a concrete example, which you can see in the article. Article: https://lnkd.in/gG9uF6kC Mihail also runs an incredibly cool course at Stanford as well as on Maven. You can find links to both below!

  • View profile for Kasra Jadid Haghighi

    Senior software developer & architect | Follow me If you want to enjoy life as a software developer

    230,076 followers

    Best Practices for Writing Clean and Maintainable Code One of the worst headaches is trying to understand and work with poorly written code, especially when the logic isn’t clear. Writing clean, maintainable, and testable code—and adhering to design patterns and principles—is a must in today’s fast-paced development environment. Here are a few strategies to help you achieve this: 1. Choose Meaningful Names: Opt for descriptive names for your variables, functions, and classes to make your code more intuitive and accessible. 2. Maintain Consistent Naming Conventions: Stick to a uniform naming style (camelCase, snake_case, etc.) across your project for consistency and clarity. 3. Embrace Modularity: Break down complex tasks into smaller, reusable modules or functions. This makes both debugging and testing more manageable. 4. Comment and Document Wisely: Even if your code is clear, thoughtful comments and documentation can provide helpful context, especially for new team members. 5. Simplicity Over Complexity: Keep your code straightforward to enhance readability and reduce the likelihood of bugs. 6. Leverage Version Control: Utilize tools like Git to manage changes, collaborate seamlessly, and maintain a history of your code. 7. Refactor Regularly: Continuously review and refine your code to remove redundancies and improve structure without altering functionality. 8. Follow SOLID Principles & Design Patterns: Applying SOLID principles and well-established design patterns ensures your code is scalable, adaptable, and easy to extend over time. 9. Test Your Code: Write unit and integration tests to ensure reliability and make future maintenance easier. Incorporating these tips into your development routine will lead to code that’s easier to understand, collaborate on, and improve. #CleanCode #SoftwareEngineering #CodingBestPractices #CodeQuality #DevTips

  • View profile for Jesper Lowgren

    Agentic Enterprise Architecture Lead @ DXC Technology | AI Architecture, Design, and Governance.

    13,898 followers

    🧠⚙️ Is Agent Debt the new Technical Debt? Generative AI is changing how we build software. Tools like Copilot and ChatGPT can generate code in seconds. But after the wow-factor fades, we’re left with a tough question: Who maintains the code AI writes? 💡 Context Is Everything—and AI Doesn’t Have It AI can generate syntax, but it doesn’t understand your architecture, business logic, or roadmap. As a result, its output often lacks: ⮕ Consistency with your design principles ⮕ Scalability beyond the immediate task ⮕ Readability for future developers ⮕ Rationale for why decisions were made The result? Code that’s hard to evolve—and harder to trust. 🔧 Set It and Forget It? Think Again! AI-generated code may "work," but that’s not the same as being maintainable. Without integration, review, and documentation, it becomes a silent form of technical debt. And when no one can explain how or why it was written, that “free” code can become a costly liability. 👨🔧👩💻 Human-in-the-Loop Is Essential AI won’t replace developers—it will demand better ones. The future isn’t autonomous generation—it’s collaborative augmentation. That means: ⮕ Code reviews matter more than ever ⮕ Standards must evolve to include AI output ⮕ Generated code should come with intent metadata ⮕ Documentation isn’t optional Use AI for acceleration, but don’t skip craftsmanship. 🤔 A New Kind of Technical Debt? We need to rethink what tech debt means. It’s no longer just rushed features. It’s also about: Code generated quickly, functional now, but resistant to change. If no one can confidently update it six months from now, you're accruing AI-induced debt. 🚀 Build Smart, Not Just Fast AI gives us speed. But maintainability is what enables scale. So let’s not just build quickly—let’s build wisely. 👋 Have you embraced AI coding? How are you balancing speed and sustainability? I’d love to hear your approach 🙏. #TechnicalDebt #VibeCoding #EnterpriseArchitecture #HumanInTheLoop

  • View profile for Andy Werdin

    Team Lead BI & Data Engineering | Data Products & Analytics Platforms | AI Enablement (GenAI, Agents) | Python/SQL

    33,706 followers

    Unlock the full potential of your data projects with regular code reviews. Here’s what you need to know about them: 𝗪𝗵𝘆 𝗥𝗲𝗴𝘂𝗹𝗮𝗿 𝗖𝗼𝗱𝗲 𝗥𝗲𝘃𝗶𝗲𝘄𝘀 𝗠𝗮𝘁𝘁𝗲𝗿 • 𝗘𝗻𝗵𝗮𝗻𝗰𝗲𝗱 𝗖𝗼𝗱𝗲 𝗤𝘂𝗮𝗹𝗶𝘁𝘆: Regular reviews ensure that code is not only functional but also clean and maintainable. They help in identifying potential errors early, saving time and resources in the long run.    • 𝗞𝗻𝗼𝘄𝗹𝗲𝗱𝗴𝗲 𝗦𝗵𝗮𝗿𝗶𝗻𝗴: They create a platform for team members to share coding practices and insights, which enriches the team’s overall skill set.    • 𝗜𝗺𝗽𝗿𝗼𝘃𝗲𝗱 𝗖𝗼𝗹𝗹𝗮𝗯𝗼𝗿𝗮𝘁𝗶𝗼𝗻: By regularly engaging with your team’s code, you build a deeper understanding of the project and foster a supportive coding culture.    • 𝗣𝗿𝗼𝗳𝗲𝘀𝘀𝗶𝗼𝗻𝗮𝗹 𝗚𝗿𝗼𝘄𝘁𝗵: Receiving constructive feedback and discussing different approaches to problem-solving contribute significantly to your professional development. 𝗛𝗼𝘄 𝘁𝗼 𝗣𝗲𝗿𝗳𝗼𝗿𝗺 𝗘𝗳𝗳𝗲𝗰𝘁𝗶𝘃𝗲 𝗖𝗼𝗱𝗲 𝗥𝗲𝘃𝗶𝗲𝘄𝘀 • 𝗣𝗿𝗲𝗽𝗮𝗿𝗲 𝗶𝗻 𝗔𝗱𝘃𝗮𝗻𝗰𝗲: Take the time to review the code before the meeting, noting areas that need clarification or improvement.    • 𝗙𝗼𝗰𝘂𝘀 𝗼𝗻 𝗟𝗲𝗮𝗿𝗻𝗶𝗻𝗴: Approach reviews as learning opportunities, asking questions to understand decisions and considering alternative solutions together.    • 𝗖𝗼𝗺𝗺𝘂𝗻𝗶𝗰𝗮𝘁𝗲 𝗖𝗼𝗻𝘀𝘁𝗿𝘂𝗰𝘁𝗶𝘃𝗲𝗹𝘆: Deliver feedback that is specific, actionable, and focused on the code, not the coder.    • 𝗞𝗲𝗲𝗽 𝗶𝘁 𝗘𝗳𝗳𝗶𝗰𝗶𝗲𝗻𝘁: Aim for concise, regular reviews that respect everyone’s time and keep the project moving.    • 𝗙𝗼𝗹𝗹𝗼𝘄 𝘂𝗽: Ensure that actionable feedback from the review is implemented to continuously improve the codebase. Regular code reviews help to increase the quality of your code base and foster an open team environment that supports continuous learning. Have you participated in code reviews in your data role, and what benefits have you observed? ---------------- ♻️ Share if you find this post useful ➕ Follow for more daily insights on how to grow your career in the data field #dataanalytics #dtascience #codequality #teamwork #careergrowth

Explore categories