Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Browse all series

BaseCode Reloaded

Years and years of hard-fought coding breakthroughs, distilled into sixteen essential lessons.

In this course, I'll show you how to write code for humans, not just machines. Together, we’ll review powerful techniques, like naming, structuring, removing clutter, and spotting patterns. These aren’t abstract theories from a dusty book. They’re practical and proven habits that you can apply to your codebase right now. If you’ve ever opened an old file and struggled to understand your own code, this course was made just for you.

Progress

Series Info

Episodes
16
Run Time
1h 58m
Difficulty
Intermediate
Last Updated
Sep 3, 2025
Version
Latest

Series Episodes

  1. Writing for Humans (5)
    1. Writing Code for Humans

      We explore how AI-generated code—like a basic to do app from ChatGPT—often works but may not follow the latest Laravel conventions or best practices for maintainability. Then we dive into why readability matters for humans maintaining code, setting up 10 practical tips to make your code cleaner, clearer, and easier to work with.
    2. Apply a Code Style

      We cover why consistent, automatic code formatting matters more than personal style preferences, showing how tools like Laravel Pint (built on PHP CS Fixer) help apply common presets like PSR-12 to keep your PHP code readable and uniform. By adopting a shared code style across projects, you reduce friction when switching contexts and make your code easier to scan—just like reading well-structured language.
    3. Remove Dead Code

      We dig into different types of dead code—like commented-out snippets, unreachable code after return or Laravel helpers such as abort, and abandoned logic tied to conditions or temporal features—and why they clutter your codebase. You'll learn how to spot and safely remove these dead bits using tools like PHPStorm’s unreachable code inspection or static analysis, making your code cleaner and easier to maintain.
    4. Avoid Nested Code

      We refactor nested if-else blocks by using guard clauses to return early, flattening the code and bringing the primary action to the top level for easier readability. By collapsing simple conditionals and inverting logic where needed, we make methods like add and contains cleaner and more intuitive, avoiding deep nesting and improving overall code clarity.
    5. Chapter Review (and Demo)

      We apply Laravel’s vendor/bin pint to enforce code style, remove dead code such as unnecessary break statements, and simplify nested logic by collapsing conditionals and using guard clauses. Then we experiment with refactoring a switch into a match expression and back to simple if statements, aiming for clear, symmetrical returns that make the code easier to scan and understand.
  2. Structuring Code (3)
    1. Using Objects

      We tackle primitive obsession by replacing loose arrays and long parameter lists with well-defined objects that formalize and group related data, such as a Money value object coupling amount and currency. This not only reduces code complexity and improves readability but also enables encapsulation of related logic, making the code easier to maintain—without overusing objects just for the sake of it.
    2. Break Up Big Blocks

      We break down a large block of code by first reviewing its context and reading level, then regrouping it into smaller, commented sub-blocks to clarify its intent and spot duplication. From there, we refactor by replacing code with native methods when possible and moving logic to the appropriate level—such as shifting user role mappings into a user method—streamlining the controller to a clean, readable single line.
    3. Chapter Review (and Demo)

      We break down a large Laravel controller method by identifying its sub-blocks—validation, model retrieval, user creation, and enrollment—and refactor each using more native approaches such as form request objects and implicit route model binding. Then we extract complex logic into private methods and model-level functions to simplify the controller action into just a couple of clear, readable lines that handle enrolling a user and redirecting to the course page.
  3. Refactoring for Readability (3)
    1. Naming

      We avoid abbreviations and leverage conventions like using i in loops or singular/plural naming to make code more readable, while also trusting context to guide naming without adding redundant type info. By focusing on human-readable names and building a vocabulary from the problem domain over time, we make naming less stressful and more natural, improving clarity and maintainability.
    2. Removing Comments

      We focus on removing inline comments that simply restate what the code does, improving readability by using clear variable and method names instead. Exceptions like doc blocks or comments explaining why code exists remain, but the goal is to reduce clutter and let well-written code explain itself.
    3. Chapter Review (and Demo)

      We refactor a large accumulation foreach loop by applying the proximity rule—moving related variables closer to their usage—and then replace it with PHP’s native array_filter for better readability. Next, we simplify date comparisons using the Carbon library and show how abstracting this logic into its own method keeps the code clean and easy to follow.
  4. Patterns and Principles (4)
    1. Reasonable Returns

      We explore avoiding null returns in PHP by refactoring a vowel-counting script to return empty arrays instead, cutting down on extra null checks and simplifying the codebase. Along the way, we see how reasonable return values reduce complexity and hint at how pairing this with objects leads to the powerful null object pattern.
    2. Rule of Three

      We explore the rule of three, which encourages deferring code refactoring until the same logic appears at least three times, helping avoid premature abstractions and poor design decisions. By living with some duplication early on, we gather enough data to make smarter architectural choices and apply the right design patterns as the code naturally evolves.
    3. Symmetry

      We dive into symmetry in code, where the same idea is expressed consistently across your codebase to make it cleaner and easier to read. We'll explore syntactic, semantic, and systemic symmetry with practical examples—such as aligning method calls and naming conventions—to help your code feel intuitive and cohesive from anywhere in the app.
    4. Chapter Review (and Demo)

      We practice symmetry by refactoring a needsToRun method from the O Dear uptime monitoring app, focusing on cleaning up asymmetrical conditionals, method calls, and naming for clearer, more consistent code. Along the way, we tighten method names, reorder guard clauses, and simplify logic to make the code read more human while maintaining a balanced style throughout the class.
  5. Wrapping Up (1)
    1. Goodbye

      We recap 10 fundamental practices—like formatting code, avoiding nested structures, and using reasonable returns—to make your code cleaner and more readable. These basics strip away complexity and help you craft code that’s easier for humans to understand, even if mastering them takes time.

Continue Learning