Alex Soulim

Beanstalk: What Happened This Morning

Great example of outage description. Like it!

beanstalkapp:

This morning at about 8:15am EDT we had an outage on our primary MySQL server. It affected the entire service. No data was lost, but some deployments and repository caching was delayed or even failed. I want to give a brief overview on what happened, how we recovered and where we are now.

The…

Death is very likely the single best invention of life. It is life’s change agent. It clears out the old to make way for the new. Right now the new is you, but someday not too long from now, you will gradually become the old and be cleared away. Sorry to be so dramatic, but it is quite true.

Your time is limited, so don’t waste it living someone else’s life. Don’t be trapped by dogma — which is living with the results of other people’s thinking. Don’t let the noise of others’ opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.

Steve Jobs, 1955 - 2011 (via eploko)

digdog:

“Actually, Sheldon Has Better Design.”
If you’re an iOS developer, and love the scicom The Big Bang Theory, then you have to watch season 4 episode 12: The Bus Pants Utilization (original air date is January 6, 2011.)
In this episode, Leonard comes up with an idea for his iOS app and derails his friendship with Sheldon.
What’s the app? It’s a handwriting-recognition based equations solver, or in Sheldon’s way: “The Surprisingly Helpful Equation-Linked Differential Optimized Numerator.” The basic idea behind this is to use iPhone’s camera to take a picture of the equation, and scan it with handwriting recognition, then run it through a symbolic evaluation engine, and bam.
During the episode, they show several actual Objective-C code snippets and interesting design sketches on white boards, here are some of them:
 You can see they have a CRecognition object holds an UIImage instance variable, and sadly they are naming it _Photo (with underline as prefix), it’s not the naming convention Apple suggested.
 The next morning, Sheldon started his own design, if you look closer, it’s much more considered than Leonard’s.
 For example, since this is an utility app, Sheldon comes up with a flip view design that similar to built-in Camera app. You can see a full screen SPhotoView with a snapshot button in the middle, and on the other side, it’s SEquationView and a UITableView at the bottom with some buttons.
 In here, you can see more details. A UITableView holds the scanned equations, and supports rotation for landscape full screen detail view and portrait detail view. And on the right side, Sheldon shows a better understanding of UIViewController’s view hierarchy.
 Later, Leonard’s team is doing some reference counting. Instead of accessing instance variable directly in -initWithPhoto: and -dealloc, they decide to use retain property self.photo, with class method to return a autoreleased CRecognition object, and claim there’s no leak.
What a mess, you should always use instance variable directly in -initWithPhoto: and -dealloc when creating/releasing instance object.
 Here you see Leonard’s app class hierarchy, mostly C/C++ style naming convention for the class names, almost everything starts with letter “C” (is for “Class” I think), CAppDelegate, CMainView, CCameraView, CSymbolicView, etc. They should use prescribed prefix like “LRH,” which means Leonard, Rajesh and Howard.
 The beautiful Penny next to Sheldon, and there’s Facebook API behind him.
 In the end, Penny’s shoes app project. There’re many of them on the AppStore already, and her UI design looks kinda lame.
 And Sheldon is working on this project…
Conclusion
I love and enjoy this episode a lot, and the TBBT crew dis a great job for all these minor details, they looks very convincible to me.
But, they should all use Mac when doing the coding, I only saw Raj’s MacBook Pro, and rest of them are all using PC. That’s not right, you can’t run Xcode on PC, well, unless they all use Hackintosh…
References
The Big Bang Theory: 4x12 The Bus Pants Utilization
Apple: Introduction to Coding Guidelines for Cocoa
[digdog dig]; To nil, or not to nil, that is the question

digdog:

“Actually, Sheldon Has Better Design.”

If you’re an iOS developer, and love the scicom The Big Bang Theory, then you have to watch season 4 episode 12: The Bus Pants Utilization (original air date is January 6, 2011.)

In this episode, Leonard comes up with an idea for his iOS app and derails his friendship with Sheldon.

What’s the app? It’s a handwriting-recognition based equations solver, or in Sheldon’s way: “The Surprisingly Helpful Equation-Linked Differential Optimized Numerator.” The basic idea behind this is to use iPhone’s camera to take a picture of the equation, and scan it with handwriting recognition, then run it through a symbolic evaluation engine, and bam.

During the episode, they show several actual Objective-C code snippets and interesting design sketches on white boards, here are some of them:

You can see they have a CRecognition object holds an UIImage instance variable, and sadly they are naming it _Photo (with underline as prefix), it’s not the naming convention Apple suggested.

The next morning, Sheldon started his own design, if you look closer, it’s much more considered than Leonard’s.

For example, since this is an utility app, Sheldon comes up with a flip view design that similar to built-in Camera app. You can see a full screen SPhotoView with a snapshot button in the middle, and on the other side, it’s SEquationView and a UITableView at the bottom with some buttons.

In here, you can see more details. A UITableView holds the scanned equations, and supports rotation for landscape full screen detail view and portrait detail view. And on the right side, Sheldon shows a better understanding of UIViewController’s view hierarchy.

Later, Leonard’s team is doing some reference counting. Instead of accessing instance variable directly in -initWithPhoto: and -dealloc, they decide to use retain property self.photo, with class method to return a autoreleased CRecognition object, and claim there’s no leak.

What a mess, you should always use instance variable directly in -initWithPhoto: and -dealloc when creating/releasing instance object.

Here you see Leonard’s app class hierarchy, mostly C/C++ style naming convention for the class names, almost everything starts with letter “C” (is for “Class” I think), CAppDelegate, CMainView, CCameraView, CSymbolicView, etc. They should use prescribed prefix like “LRH,” which means Leonard, Rajesh and Howard.

The beautiful Penny next to Sheldon, and there’s Facebook API behind him.

In the end, Penny’s shoes app project. There’re many of them on the AppStore already, and her UI design looks kinda lame.

And Sheldon is working on this project…

Conclusion

I love and enjoy this episode a lot, and the TBBT crew dis a great job for all these minor details, they looks very convincible to me.

But, they should all use Mac when doing the coding, I only saw Raj’s MacBook Pro, and rest of them are all using PC. That’s not right, you can’t run Xcode on PC, well, unless they all use Hackintosh…

References

(via cocoaheads)

Chris Wanstrath @ StartupBootcamp 2010

Mocking and Stubbing can be evil

railsfreak:

Lately I’ve been seeing some things that make me worry. Mocking and stubbing can be very helpful tools when you use them right, but I am not seeing them used right!

Why stubbing is dangerous

Don’t get me wrong, stubbing is good when you need to decouple one class from another, or your app from a service. My problem is with functional testing and view testing with mocks and stubs - what’s the point? If I make a change to a model and the controller throws a 500 because of the change, don’t you want to know about it? If you setup a stub and then add expectations for model calls and fake return values, you won’t get any red flags.

Twitter Poll

Before we get into the nitty gritty with some real code examples, let’s take a minute to look at some exchanges on this very subject via twitter:

  • @joshowens - “Do you stub model calls in your controller tests? I don’t think you should, if the model breaks, so does the controller, tests should fail.”
  • @aeden - “@joshowens if your controller tests are functional tests then you should consider it, if they’re integration then you shouldn’t.”
  • @joshowens - “@aeden They are functional, but if the action breaks on the controller level and not in the view, shouldn’t the test catch that?”
  • @aeden - “@joshowens a functional test should catch broken controller logic…not broken model logic (that’s reserved for unit tests)”
  • @dougalcorn - “@joshowens @aeden with how little logic should be in your controller, I’ve quit writing functional tests and only do integration with webrat”

Some code for your enjoyment

Let’s assume we have a Saving Model and a Savings Controller. Saving has a state field and uses a state machine plugin to offer transition methods.

Now let’s look at a quick spec sample with some stubs

Alright, everything is looking good, we are green and the pages are loading in the browser. But wait, the client changes their mind, they don’t like the states “pending” and “used”, they want to use “new” and “completed”. With this change, we are going to change the transition methods to match, we will now use @saving.complete! in our update action.

I change our model specs, they go red, then I fix the code to support the new states and methods. I run the full suite and get green… Wait, green?!? Yip, because we stubbed out the calls, we never catch the broken controller.

A better shade of green

Here is how I would approach a better test that would catch our failure:

Let’s get real!

So now that I’ve given you a few examples, let me give you some real experience on why false passing tests are bad. At change:healthcare we have 19,000 LOC with a 1:2.5 code to test ratio - that doesn’t include our custom plugin across shared apps. Even with a full six months of working on the app, doing a major overhaul of the system can be problematic if you don’t have good tests. How can you be 100% confident of rolling out your new code when you haven’t seen and touched 100% of the app?

At change:healthcare we rely on a robust test suite, a hand rolled continue integration suite, and vigorous staff testing to ensure we get everything right. Even with all these efforts, we miss occasional bugs. Better tests (avoiding false passing tests) and better code coverage (81.9% right now) are the best way to catch these bugs! With a code bed so large, the test suite is used as much for regression testing as it is for anything you gain with TDD/BDD.

Personally, I am with Doug’s tweet above, forget functional testing and even view testing and head straight for the integration testing. If you are doing it yet, look at webrat and cucumber. After all, we want a rails app that works from top to bottom, right?

Whether you think you can or think you can’t, you are right.

—Henry Ford

If you’re good at something, never do it for free!