Samuel Goodwin

95 posts Samuel Goodwin
  1. How to Write IRC: Part 4

    This is a continuation of the article published yesterday: How To Write IRC: Part 3 Async Integration Testing Some of you might be reading along and think to yourself, "This guy hasn't tested anything! He doesn't assert anything. What kind of lies is he trying to sell?". To that I say, "Give me a minute, it gets better". One of the nice things about code is that nothing you write really needs to be permanent. Especially when you're starting a thing, it's fine if you have to change it a bunch. You don't need to know exactly what you're going to do right when you start. That would be boring. The very next thing I wrote was an actual test with actual assertions. func testServerDelegateGetsServerMessages() { let user = IRCUser(username: "sgoodwin", realName: "Samuel Goodwin", nick: "mukman") let server = IRCServer.connect("

    Samuel Goodwin
  2. How To Write IRC: Part 3

    This is a continuation of the article published yesterday: How To Write IRC: Part 2 Defining the API Before you run off and make a framework, it can be helpful to do a bit of brainstorming and plotting or scheming first. For this part I pulled out a sweet notebook and my fancy pencil. After some doodling and discussion with a friend of mine, I came up with this: I wanted the idea of a channel to be a first-class object rather than an interface where you send along the channel name as a string and say "hey send this message to this channel". Directly having a channel object to send messages to sounded nicer to me. With this vague idea in mind, I started writing tests. This way I could work out exactly what the API would look like by attempting to actually use the API. After

    Samuel Goodwin
  3. How To Write IRC: Part 2

    This is a continuation of the article published yesterday: How To Write IRC: Part 1 Spike! When I write a framework, I don't start by making a framework. First I mess around and build what you might call a "spike" to get an vague idea how things work. I was fairly familiar with the IRC protocol when I started, but not this new API from Apple. Writing something right off the bat with tests is quite difficult if you're not even very sure what you need to make your code do. After some time to play around, I had a better sense of direction and could be confident writing tests. Walking Skeleton Last thing I needed before I could write any tests was the skeleton of an app. You can see what I wrote in this initial commit on Github. Mostly it is Xcode's new-project template for a

    Samuel Goodwin
  4. How To Write IRC: Part 1

    IRC is a fairly old protocol for chatting with people on the internet. It's not super popular these days because even more technical people have migrated to things like Slack or Hipchat which may or may not be more friendly to use. Still, I decided to try to write a library for interacting with IRC for a few reasons: I think a big reason for Slack/Hipchat popularity over IRC is the clients. Every IRC client I've ever tried seems fairly technical and does not try to simplify the experience very much. The library and my writing explaining it can serve as nice example of how to make a framework and how to write Swift in general using tests. Even if it never gets used in an exciting IRC client. The library can also serve as an example for implementing support for an internet protocol that isn't already supported for

    Samuel Goodwin Featured
  5. Making SwiftKilo Part 2: Raw mode

    In the next chapter of the tutorial, I went through the steps to enable raw mode. In a typical command line app, you print some things on the screen and maybe wait for input for the user on the next line. The terminal is setup by default to send your program this input one line at a time which means waiting until the user hits return/enter. For a text editor where we want to handle things like keyboard shortcuts and special characters, this isn't good enough. Fortunately, the terminal can be told to change its behavior and send each individual keypress to your program one at a time. Unfortunately, it takes several steps to do this. Also, since you're changing the behavior of your terminal for your program, you need to make sure you turn the settings back to normal when your program is done. Many of the functions

    Samuel Goodwin