Posts

  • Detecting PHP Files That Don't Start With <?php

    Header In the past week I’ve had two weird bugs come up. After an hour or two of troubleshooting they both revolved around an extra character before the <?php tag in a PHP file. In one case I added an extra return line before the <?php and in another I added an extra “`”.

    `<?php
    class ... {
    ...
    }

    In trying to debug these problems I wrote a script to find PHP files with extra characters and I’ve added it to my pre-commit check.

    Read More
  • Link Post and Podcast Roundup: February 2019 Edition

    Link Post Logo

    February’s links.

    Read More
  • Refactoring 2nd Edition: Chapter 4: Building Tests

    Refactoring: Improving the Design of Existing Code (2nd Edition) Cover Book cover copyright Martin Fowler

    Overview

    This chapter explains the value of self-testing code and gives some examples.

    My One Takeaway

    The section “Probing the Boundaries” talks about writing code that tests for edge cases like negative numbers and invalid numbers/string. This is something I need to do more of in my own testing.

  • Refactoring 2nd Edition: Chapter 3: Bad Smells in Code

    Refactoring: Improving the Design of Existing Code (2nd Edition) Cover Book cover copyright Martin Fowler

    Overview

    This chapter covers various “bad” practices that are a good indicator that you should refactor your code.

    My One Takeaway

    It’s a good thing the back cover has a list of these and what to do because it’s hard to know what to do with this list. It almost seems like there should be some kind of tool that looks for these. I’m not going to make it but it would be a good check.

  • A Weird Email

    A Weird Email Header Image

    The other day I received an interesting spam scam email:

    Read More
  • Refactoring 2nd Edition: Chapter 2: Principals in Refactoring

    Refactoring: Improving the Design of Existing Code (2nd Edition) Cover Book cover copyright Martin Fowler

    Overview

    This chapter: 1. What refactoring is 2. Why you should refactor 3. When you should refactor 4. Problems with refactoring

    My One Takeaway

    Under the section “What Do I Tell My Manager” there’s this quote:

    Of course, many managers and customers don’t have the technical awareness to know how code base health impacts productivity. In this cases I give my most controversial advise: Don’t tell! Page 55.

    I’ve worked for places where this is absolutely the case and think “Don’t Tell!” is good advice but you might have to hide the refactoring inside a deliverable.

  • Refactoring 2nd Edition: Chapter 1: Refactoring: A First Example

    Refactoring: Improving the Design of Existing Code (2nd Edition) Cover Book cover copyright Martin Fowler

    Overview

    This chapter works through refactoring a piece of JavaScript code. It outlines both a process (working on a private branch and committing after each successful refactoring) and a series of refactoring methods.

    My One Takeaway

    This concept of working on a private branch and then making small commits that are later squashed down into a larger significant commits interests me. Firstly, it makes me wonder how hard it would be to swap so quickly between code and commit because I usually only commit once something large has been done. Secondly, it makes me wonder if this could just be as simple as git commit -a -m "Refactoring" or if more thought needs to be put into the commit messages. I wish this part had been shown as well (maybe the 3rd Edition can cover that :-)).

    Random Thought

    For those of you who are following along, when he references a refactoring method it always has the a number in parenthesis after the name. This is the page where the method is explained. Took me way longer to figure this out than I would have liked. :-)

  • Working With PHP's Output Buffering Functions

    Header PHP provides a series of functions that allow you to capture any output that should be sent to the browser so you can do something else with it (or ignore it). In this article, we’ll go over a couple use cases for how you can use PHP’s output buffering.

    Read More
  • Asynchronous Book Group: "Refactoring 2nd Edition" by Martin Fowler

    Refactoring: Improving the Design of Existing Code (2nd Edition) Cover Book cover copyright Martin Fowler

    Why an Asynchronous Book Group?

    As a team bonding and educational process I try to get the programming teams I’m part of to read a book together every quarter. As I’m currently a team of one, this process has been more difficult. I thought I would take this process to the Internet so at the very least I would have to think critically about the book and write up my thoughts and the things I found most interesting.

    Why This Book?

    I’m a follower of Martin Fowler and his work and if you’re not already a follower of his blog (https://martinfowler.com/) you should be. I’ve been slowly working my way through his books but a couple months ago he posted that the 2nd Edition of Refactoring: Improving the Design of Existing Code (Amazon Link) had been finalized and would be available soon. I immediately ordered the book and was happy to see it arrive just before Christmas. I’ve been slowly working my way through the book (the holidays and small children make it a slow process sometimes :-)) and it’s been enjoyable and full of helpful information so far.

    How is This Going to Work?

    The book contains 12 chapter so for the next twelve weeks I’m going to post a new post on Friday. I will write down the one thing I found most interesting/helpful and then anyone who wants to can add a comment with something they’ve found interesting. The plan is to complete the following chapters on the following dates.

    1. January 11th - Chapter 1: Refactoring: A First Example
    2. January 18th - Chapter 2: Principals in Refactoring
    3. January 25th - Chapter 3: Bad Smells in Code
    4. February 1st - Chapter 4: Building Tests
    5. February 8th - Chapter 5: Introducing the Catalog
    6. February 15th - Chapter 6: A First Set of Refactorings
    7. February 22nd - Chapter 7: Encapsulation
    8. March 1st - Chapter 8: Moving Features
    9. March 8th - Chapter 9: Organizing Data
    10. March 15th - Chapter 10: Simplifying Conditional Logic
    11. March 22nd - Chapter 11: Refactoring APIs
    12. March 29th - Chapter 12: Dealing with Inheritance

    I hope you’ll join me in this process.

  • Link Post and Podcast Roundup: January 2019 Edition

    Link Post Logo

    January’s links.

    Read More

subscribe via RSS