Sharpen Your Git Saw – Aliases, Selective Staging, & Interactive Rebasing

Git is a powerful tool that we love as developers. It’s also complicated. I consider the bare essentials of Git, the minimum set of features to be familiar with before we can be productive, to be all of this:

  • local interaction: status, add, remove, commit, reset, checkout
  • branch management: checkout, merge
  • remote interaction: clone, fetch, push, pull

Once we’ve learned these basics well, we move onto advanced features and tricks. Read more on Sharpen Your Git Saw – Aliases, Selective Staging, & Interactive Rebasing…

Backbone Event Best Practices

When our Backbone.js apps become complicated, we need to utilize Backbone’s EventAggregator. From the Marionette docs: “An event aggregator is an application level pub/sub mechanism that allows various pieces of an otherwise segmented and disconnected system to communicate with each other.”

// Three ways of creating an event bus in backbone
var marionetteVent = new Marionette.EventAggregator();
var backboneVent   = new Backbone.Wreqr.EventAggregator();
var vent           = _.extend({object}, Backbone.Events);

1. Make sure you need it.

It’s harder to follow the execution of an event-based program than of regular synchronous method calls, so make sure you understand why you need an event in the first place. It’s worthwhile to ask: if events weren’t available, what would I have to do to solve this problem? Read more on Backbone Event Best Practices…

Develop Smoothly with the Right MacBook CPU

If you’re a developer shopping for a new MacBook, choosing a CPU can be confusing. Apple always gives you a handful of different CPUs options, all with different specs and prices, but it’s very difficult to understand how your development experience will be affected by this choice.

You can put thought into the other options that Apple lets you customize. For hard drive capacity, it’s easy to check the amount of space you’re using on your current machine and decide on a hard drive size for your new machine. If you’re comparing two different screen sizes, you can decide if you’d rather have a cheaper and lighter machine or a larger screen.

You can’t do that with CPUs. For instance, the latest round of 15″ Pro Retinas (released in late 2013) gives you three CPU options: Read more on Develop Smoothly with the Right MacBook CPU…

The Cost of Unit Testing

How far should we take unit testing? Should every line of code be covered by a unit test? What about code that’s hard to test? Let’s look at the cost and value of unit testing in a couple of different situations.

Tests We Can All Agree On

It’s easy to see the value of unit tests when we’re writing actual functions. Let’s say we’re writing a helper function called next_valentines_day for our greeting card application. Here are some tests that we might write:

describe next_valentines_day do
  it "returns next year's valentine's day when after Feb 14" do
    expect(next_valentines_day('2014-02-15')).to eq('2015-02-14')
  end
  it "returns same year's valentine's day when on Feb 14" do
    expect(next_valentines_day('2014-02-14')).to eq('2014-02-14')
  end
end

Even from just these two tests, we we’ve significantly reduced the risk of calculating the wrong Valentine’s day in our software. And that means we’re less likely to lose valuable time fixing bugs in the code or dealing with other fallout from the code being wrong (like decreased greeting card sales). Read more on The Cost of Unit Testing…

Tackling Silence, Avoidance, & Negativity in Project Retrospectives

At retrospective meetings, we reflect on how our team has been operating, sharing both the good and the bad. We try to identify problems and take actions that solve those problems.

But just as important as fixing procedural problems is giving individual team members the chance to speak, be heard, and “air-out” anything that’s been bothering us. Ideally, we will honestly share our feedback and perspectives, and humbly acknowledge our mistakes. In reality, though, most of our retros fall short of that standard. Here are some common problems and ideas to help work through them. Read more on Tackling Silence, Avoidance, & Negativity in Project Retrospectives…

Dumb Development Mistake Checklist

As engineers, we enjoy solving technical problems and enjoy the results of our hard work. But sometimes, our development suddenly and mysteriously stops working, and we get stuck trying to figure out what happened. Then, hours later, we realize it was a really dumb mistake or oversight. Those times are really unfulfilling and frustrating.

To help you avoid this frustration, here’s list of lessons that have been painfully burnt into my heart over the years.

1. Save the file.

Yeah, we still forget to do this sometimes. We were supposed to have permanently learned this lesson during our first ever Hello, World program, but sometimes we still forget. Many IDEs have an autosave feature, but watch out when using that same IDE on another machine, since the feature might not be switched on. I’m more likely to neglect saving when I switch between buffers or tabs a lot. Read more on Dumb Development Mistake Checklist…

Animating Around the iOS Keyboard

My recent post gave an introduction to iOS animation, showing how to move elements around the screen. This time, I’ll show you how to animate view elements in response to the keyboard appearing and disappearing. We’ll pretend we’re working on a photo-sharing app that has a text field to enter the photo’s description into.

Unfortunately, our text field gets covered up by the keyboard as soon as we tap it:

Our app has controls on the bottom of the screen (left), but they are covered up by the keyboard (right) when the user taps the text field.

1. Dismissing the Keyboard

The user has no way to dismiss the keyboard once it’s been shown. It would be nice to be able to tap anywhere else on the screen and have the keyboard go away. To do this, we add a Tap Gesture recognizer to our view, along with a method that dismisses the keyboard:
Read more on Animating Around the iOS Keyboard…

Intro to iOS Animation

Simple iOS animations are straightforward to implement. For example, say you’ve got an image on your storyboard that you want to to fly into position when the view controller first loads. To make this happen, first move the image off-screen before the view is displayed. Then, when the view appears, move the image back to its original location inside of a call to animateWithDuration:

- (void)viewDidLayoutSubviews {
  // Move image off the screen to the left
  self.myImage.center = CGPointMake(self.myImage.center.x - 300,
                                    self.myImage.center.y);
}
 
- (void)viewDidAppear:(BOOL)animated {
  [UIView animateWithDuration:1 animations:^{
    // Move image back to where it started
    self.myImage.center = CGPointMake(self.myImage.center.x + 300,
                                      self.myImage.center.y);
  }];
}

Enter left. (Click to view.)

Read more on Intro to iOS Animation…

Google Circle
Join my Circle on Google+