Rufen Sie mich an unter +49 151 20 43 62 02|info@berndrabe.de

Blog

Test-Driven iOS Development

I recently came to Graham Lee’s book Test-Driven iOS Development when looking when searching for an in-depth look on unit testing.

Graham’s Book doesn’t make use of mock objects but using what is coming with every Xcode installation – OCUnit.

The unit testing environment lacks mock object, so as soon as you start to dive into test driven development you have to choose your tools.

I’ve decided to start with John Reid’s OCHamcrest/OCMockito and though I found it sometimes difficult to achieve what I needed, I finally was able to work through the books example without greater problems.

I even found a rather bad coding style on my side. So thinking about testing in the first place makes you more thinking about your design and coding style in the first place too.

If you haven’t done unit testing before I strongly recommend the excellent screen casts John made on http://www.qualitycoding.org.

 

In short – especially using OCHamcrest/OCMockito made the test code shorter and therefor easier to read.

You will see that the project uses storyboarding and more often property declarations and the automatic synthesize behavior. So I even deleted some of the tests where only setter behavior was tested (e.g. testAnswerHasSomeText in AnswerTest.m).

Here are the other things I changed

 

When you work through the book you see that Graham developed a dataSource and delegate class and then merged the delegate methods into the dataSource class. The class is called ..DataSource.h/.m which I find isn’t ideal.

So the classes, as we need several provider, are all named following that naming convention (TopicTableDataSource -> TopicTableProvider).

 

Instead of Graham’s BrowseOverflowObjectConfiguration class I moved the code into the AppDelegate and created a protocol to have access to the StackOverflowManager, the AvatarStore and the initial topics array.

 

I reduced the number […]

von |Wednesday, May 22nd, 2013|Books|0 Kommentare
  • The Agile Samurai by Jonathan Rasmusson
    Permalink Gallery

    The Agile Samurai – All about your start in agile development

The Agile Samurai – All about your start in agile development

The Agile Samurai by Jonathan Rasmusson lets you dive in what it takes to start being agile.
From introducing agile principles as “done means done” via the Inception desk, the first and one of the crucial steps you take in agile. Followed by Project Planning and Project Execution it goes
to Creating Agile Software using Refactoring, Test Driven Development and Continuous Integration.
Jonathan Book is not bound to software tool but more a general approach and one of the messages I’ve taken from the book. There is not one tool, one process you have to follow.
Working agile is keeping in mind that the main goal is delivering great software to our customers.
And whatever it takes to make that happen is welcome. He lists the problems he faced and gives guidance how to avoid or overcome them.
For me it was worth reading and a source how to move on.

On one of the last pages Jonathan states about a question he often hears from teams “Are we there yet? Are we being agile?

It’s not a checklist. It’s a journey, not a destination. You never really get there.
And don’t forget. It’s not about being “agile”. It’s about building great products and delivering world
class services to our customers.

You can buy the book on Amazon but I came to the book via another great site – The Pragmatic Bookshelf where you can get the book as ebook as well.

von |Tuesday, May 14th, 2013|Books|0 Kommentare

HorizontalPicker update

My previous post about a HorizontalPicker showed the visual results

but no code. I must confess that my first approach was not in the shape to be made public. So I reworked the code and just moved it to Github:HorizontalPicker.
You can use it under the MIT License.

The workspace contains the HorizontalPicker project which produces a static library as well as a framework and its also available as CocoaPod, which makes it easy to integrate into your projects.

By the way – CocoaPod is, if you haven’t heard about it, worse reading on CocoaPods Homepage. In short its a dependency manager for your Xcode projects and available as a ruby gem.

von |Saturday, April 20th, 2013|UIPicker|0 Kommentare

Provide localized content for languages not supported by iOS

During app development I was asked to provide localized strings in urdu, a language spoken in some region in India and Pakistan. Urdu is not available on the iPhone as language but as region setting only. That means that you would have localized number formatting (date/time/phone number etc.) but strings would never been seen in a localized fashion.
Here is what I did to overcome that situation.

1. in Xcode add the localizations to your project (here ur, ur-IN, ur-PK). This step is necessary as localizedStringFromNumber relies on the existence of project folders with the corresponding identifier (ur-IN.lproj) even if there is nothing in it. In my case I worked with a storyboard in english only and provided localized UI strings from a bundle with localized strings.
2. create a bundle file
I use bundles a lot to keep things together on one place especially with image resources or when there is chance that I need provide a “drop-in” functionality on other projects.

3. with your bundle create the same project folders you see in your main project directory.
4. within your lproj directories place UTF16 (to be on the save side when it comes to Japanese/Chinese an alike) text files (en.lproj/Localizable.strings).
NOTE: The name you use is your TableName you have to use in Globals.m

5. Add Globals.h/Globals.m to your project and you are done

Usage
CustomLocalized(@”TextToBeLocalized”)

von |Friday, November 16th, 2012|NSBundle, NSLocale, NSString|0 Kommentare

Fighting NSManagedObjectModels configurations

Whenever you add an NSManagedObjectModel into your project it comes with a Default Configuration. I’m sure you’ve noticed it but probably never dived into the burrow. I had when Apple rejected my app for violating the iCloud storage guidelines.
As quick as you add configurations (the default one can’t be edited nor deleted) and assign entities to it, you’ll notice that even Apple make you think that inserting new objects into your model, those object get assigned to the right store file it is not the case.

- (void)assignObject:(id)object toPersistentStore:(NSPersistentStore *)store
Special considerations
“It is only necessary to use this method if the receiver’s persistent store coordinator manages multiple writable stores that have object’s entity in their configuration. Maintaining configurations in the managed object model can eliminate the need for invoking this method directly in many situations. If the receiver’s persistent store coordinator manages only a single writable store, or if only one store has object’s entity in its model, object will automatically be assigned to that store.”

You might thing I’ve added my and only my configurations to the store coordinator but as soon as you insert new object into the model (I guess) core data looks in your managed object model available configurations (including the default one) and finds at least 2 configurations for your newly created object. So this might be the reason that for newly created objects returns nil.

So I wrote a category on NSEntityDescription to overcome that problem.
The method name is quite long but I wanted to make sure that you understand that this method skips the default configuration whenn looking for you entities store file.
NOTE: Core data allows you to have the same entity in different configurations. So might be […]

von |Monday, July 2nd, 2012|Core Data|0 Kommentare