Back Button PHP

How to Read Code

To improve as a developer, you must focus on three things: learning, reading, and writing. Or, in other words, learn from somebody more seasoned than you; read a lot of code; and write your own code daily. This series will focus on the reading component. Together, we'll mentally parse an open source project. How was it constructed? What are the routing conventions? How are the controllers structured?

Intermediate
Difficulty
6 episodes
1:17:11 hrs
Start Series

How to Read Code

To improve as a developer, you must focus on three things: learning, reading, and writing. Or, in other words, learn from somebody more seasoned than you; read a lot of code; and write your own code daily. This series will focus on the reading component. Together, we'll mentally parse an open source project. How was it constructed? What are the routing conventions? How are the controllers structured?

  • Latest Episode: Make Your Own Documentation Website with TDD

  • Like this series? Share the love!

  • 01

    Episode 1 Run Time 5:31

    Let's use the laravel.com source code as the basis for our learning in this series. This code is freely available to review on GitHub. Specifically, we'll focus on the documentation layer. We see all these markdown files for each page of documentation. How are they loaded, parsed, and presented on the page? And how is versioning handled? We'll decode all of it. To begin this journey, however, we must first get the laravel.com source code running locally.

  • 02

    Episode 2 Run Time 10:56

    Now that we have the application running locally, let's figure out how a documentation page is loaded. We already know that each section is stored as a Markdown file. So how exactly are the files loaded and presented to the user?

  • 03

    Episode 3 Run Time 8:18

    It seems that, at some point, the companion Markdown for a requested documentation page is loaded, compiled, and cached. In this episode, let's figure out exactly how that workflow is organized and processed.

  • 04

    Episode 4 Run Time 6:47

    We've figured out how the Markdown files are loaded, and parsed. The only remaining step is to get the content on the page. In this episode, we'll learn how the content is passed to the view, while accounting the situations when an invalid documentation page is requested.

  • 05

    Episode 5 Run Time 10:33

    Now that we fully understand how the documentation is loaded, parsed, and rendered on the screen, let's move on to a different piece of the codebase. Are there additional performance considerations that we might learn from? Well, as it turns out, the answer is yes. The Laravel.com website adopts full page caching to vastly improve load times. Why boot the entire framework for each request, when you can easily render a cached HTML response instead?

  • 06

    Episode 6 Run Time 35:06

    In this episode, we'll put what we've learned to the test. Can we create a project from scratch that renders versioned documentation pages, written in Markdown? Let's use TDD to drive our workflow, while implementing the techniques we've learned from this series. Along the way, we'll review a number of key decisions, including:

    • How to use TDD to describe our desired features and functionality.
    • How to use Mockery's partial mocks to intercept method calls.
    • Why it's vital that you be thoughtful when mocking.
    • When/How/Why to use real-time facades.

    View the source code for this episode on GitHub.