Posts

  • What is REST (really)?

    Michael Stowe’s book, Undisturbed REST: A Guide to Designing the Perfect API, begins with an understanding of what REST is. REST, or Representational State Transfer, is an architectural pattern for APIs, and it was defined by Dr. Roy Fielding in his 2000 Doctorate Dissertation.

    [Read more]

  • Why Algorithms Matter

    The second chapter of A Common-Sense Guide to Data Structures and Algorithms shows us why we should consider which algorithms are best for our programs.

    [Read more]

  • Why Data Structures Matter

    The first chapter of Jay Wengrow’s A Common-Sense Guide to Data Structures and Algorithms explains how to think about the time complexity of data structures.

    [Read more]

  • The Unix Time Command

    Today I learned about the time command available on Unix and Unix-like systems, which tells you how long a given command takes to run.

    [Read more]

  • Docker Volumes

    By default, all files created inside a Docker container are stored in a writable container layer. This layer is like the container’s “scratch space”, so any changes won’t be seen by other containers, even if they’re using the same image. Also, if you stop and restart the container, any file changes you previously made will disappear.

    [Read more]

  • Semantic HTML

    Today I learned about semantic HTML, which provides meaning through the HTML elements as opposed to pure presentation.

    [Read more]

  • Date.today vs Date.current in Rails

    The other day I learned a valuable lesson when some of my tests in a Ruby on Rails application suddenly started failing, despite them passing earlier in the day and despite no changes to the code. The issue boiled down to my assumption that the following would always be true:

    [Read more]

  • File Permissions

    I recently set up the ability to deploy to my remote server via the git push command, but it failed on my first attempt with the error, remote unpack failed: unable to create temporary object directory. As the error message suggests, git push was attempting to create a directory on my remote server, but my user did not have permission to do this. After researching file permissions and how to modify them, I was able to solve the problem.

    [Read more]

  • Creating Deploy Users in Linux

    This week I set up a server on DigitalOcean to host a new project. The server uses Ubuntu (a Linux distribution) and I can SSH into it from my local machine like this:

    [Read more]

  • Polymorphism in Elixir

    While we tend to associate polymorphism with object-oriented design, the functional language, Elixir, allows us to create duck types through a mechanism called protocols.

    [Read more]

  • The Builder Pattern

    If you’re familiar with the concept of default arguments provided in some languages, you know how useful they can be. Default arguments allow us to instantiate new objects without having to explicitly pass in every requirement. Java does not provide default arguments, but there are a number of ways to simulate this feature ourselves. One such way is with the builder pattern.

    [Read more]

  • The Four Rules of Simple Design

    Kent Beck developed the four rules of simple design in the late 1990’s. The rules, in order of highest priority to lowest, are the following:

    [Read more]

  • SOLID: Dependency Inversion Principle

    We can place an application’s modules along a spectrum of higher-level to lower-level behaviours—the higher-level ones are the business models of the program that contain important policy decisions, while the more detailed, lower-level ones contain implementation details. It’s a difference between knowing what should be done versus how it should be done.

    [Read more]

  • SOLID: Interface Segregation Principle

    “Fat” interfaces have methods that are used by some, but not all of their clients. Discussions around the Interface Segregation Principle (ISP) tend to use the concept of “interfaces” that we see in Java and C++ (the abstract types used to specify a behaviour that classes must implement). While we may not have these same interfaces in Ruby, we’ve seen how important the concept of interfaces is in object-oriented design, and therefore the ISP is an important concept to understand in Ruby programming.

    [Read more]

  • SOLID: Liskov Substitution Principle

    We saw in the previous post on the Open-Closed Principle that polymorphism is one of the most powerful tools in our object-oriented design tool belt. Having classes inherit from each other is one way to achieve polymorphism, and the The Liskov Substitution Principle (LSP) provides important guidelines for building inheritance hierarchies without making our code brittle.

    [Read more]

  • SOLID: Open-Closed Principle

    The authors of Agile Software Development: Principles, Patterns, and Practices (PPP) claim that the Open-Closed Principle (OCP) is at the heart of object-oriented design. It is this principle that gives our code the most flexibility, maintainability, and reusability, and it prioritizes adding new code over changing old code that already works.

    [Read more]

  • SOLID: Single-Responsibility Principle

    Without even knowing it’s definition, the Single-Responsibility Principle (SRP) sounds like it would be a good thing for your code; after all, anything that has one responsibility is likely to be smaller, less complex, and more maintainable than something that has multiple responsibilities. But the SRP gives us even more than that.

    [Read more]

  • Design Techniques: Classical Inheritance

    My previous post about duck typing showed duck-typed objects responding to the same message. But what if objects share not only the same message, but also the same behaviour? In order to keep our code DRY, we should extract this common behaviour to a single place in our code. One way to do this is with inheritance.

    [Read more]

  • Design Techniques: Duck Typing 🦆

    You may already be familiar with the idea of public and private interfaces—they are the methods that are implemented within a class, and only the public ones are made available to other objects. But interfaces are not limited to single classes—some interfaces cut across multiple classes, and an object can have many interfaces.

    [Read more]

  • Moving Data Between Remote Databases with Your Local File System

    I needed to migrate data from one of our production Postgres databases to another. My initial thought was to do all of this from the Rails console of each application by storing and accessing query results on Amazon S3. Instead, I decided to transfer the data through my local file system.

    [Read more]

subscribe via RSS