Archive for the ‘Uncategorized’ Category

Apple Product Predictions

October 18, 2011

I’v been thinking about this, so why not throw it up here? On the one hand it’s an oppotunity to say “I told you so” but ofcours on the other hand I might end up eating my words 🙂

Anyways here goes:

iPad 3:
Screen will be 4 x resolution
Camera will have “flash” and be 4 or 8 megapixel

Macbook Pro:
Will adopt Air body design and add black bezel
Will loose optical drive (and maybe a few ports? :))

Maybe a bit obvious.. 🙂

My Little BlackBerry Playbook App

April 24, 2011

So my app for the BlackBerry Playbook was approved a couple of days ago and wend live on AppWorld on the 19. of april. So far it’s averaging 80 downloads per day (it’s free) – 400 in total so far. It’s even got a five star rating – based on one review :-). Still it’s nice to know that somebody likes it.

Heres the AppWorld link:

Oh – the app is a clone of my iPhone / iPad app “My Little Book Of African Animals”.

Windows Phone 7 development: FINALLY!

January 28, 2011

I finally got a chance to try out the entire Windows Phone 7 experience, from creating Silverlight and XNA applications to deploying on actual hardware. But thats not the finally this post is about. The reason I am writing this post is becaus now i FINALY have what I have been missing from Windows Mobile for the last several years: a mature smartphone platform that i can develop for using my favourite toolchain and language.

With arround a days experience total, this isn’t exactly an indepth impression but I have to say I’m very excited. Developing in XNA compared to the work I’ve done in Cocos2d on iPhone is a really smooth experience. And Silverlight – well slap on a listbox, style it which ever way you please, databind it and it just works. A dream of mine just came true.

This is not to say that there isn’t a lot of kinks Microsoft needs to work on – a great platform is more then great developer support. Like the brower – don’t even get me started. And I’m not just talking about the rendering, I’m talking about the whole entering and editing a URL and what not. Also while deploying to WP7 is super fast, I can’t help but think that Microsoft could have done something so that i don’t have to manually unlock the phone each time i wan’t to deploy.

I’m not even going to mention the missing enterprise story here..

All in all I’m starting to think Microsoft have a winner on theire hands if they can keep the updates rolling out quickly. Noe i’m just gonna sit here and wait patiently for a chance to work on the platform professionally.

CQRS: Really simple real life benefit

January 18, 2011

I got this real life question once again just recently:

“Could you show the name of the person who created each order in the list as well?” (domain changed to protect the innocent)

This question is a very basic, but very real, example of why I like the Command Query Responsibility Segregation (or CQRS) pattern.

With a datamodel that looks like the one above, the technical answer is usualy someting like: “Ok, how are we going to do this? Let’s put in a join to the User table. Then lets extend the order object with a display property (!!!) for the users name”. If the team is a little more trained you might hear something more along the lines of: “Ok so we’ll just specify in the query that the object mapper should load the user that’s associated with each order as well”. One is a little cleaner then the other, but both will most likely start to smell pretty quickly. Then somebody comes along and asks for a count of the items on each order and before you know it, your “FetchAllOrders” sql has balooned into some kind of monster join that no one but it’s mother can love (or figure out) and as an added bonus, performance goes south.

In a CQRS environment we have the priveledge of designing solutions like: “Sure, lets just store the user name in the viewmodel for the order list screen so it will be right there for clients to display. Also to make sure it’s kept up to date if it changes, let’s subscribe to the “UserRenamed” event.”.

And for the item count? Just subscribe to the “ItemAddedToOrder” and “ItemRemovedFromOrder” events and update “NumberOfItems” accordingly.

It just makes me feel all warm inside.

How to NOT inject services into entities (copycat title)

January 17, 2011

Working on my hobby poject I came across a familiar situation of having to interact with a (to my domain) external service. The service in this case is push notification. I know the “official” guidance is to not inject services (or anything else for that matter) into domain entities (I completely agree), but I was struggeling with how to follow this advice without breaking the incapsulation of my domain. The critical advice came from a blog post ( – see “Behavior methods”) by Jérémie Chassaing.

The techniques is familiar, but i’m surprised how perfectly in makes sence for these kinds of cases. My event handler ended up looking like this (domain has been substituted for a basic blog for the example):

public class PostChangeHandler : IHandle<PostAddedEvent>, IHandle<PostUpdatedEvent>
     ISessionFactory sessionFactory;
     ISubscriberNotificationService subscriberNotificationService;

     public PostChangeHandler(ISessionFactory sessionFactory, ISubscriberNotificationService subscriberNotificationService)
         this.sessionFactory = sessionFactory;
         this.subscriberNotificationService = subscriberNotificationService;

     void IHandle<CommentAddedEvent>.Handle(CommentAddedEvent domainEvent)

     void IHandle<CommentUpdatedEvent>.Handle(CommentUpdatedEvent domainEvent)

     private void NotifySubscribers(Guid postId)
         using (var s = sessionFactory.OpenSession())
         using (var tx = s.BeginTransaction())
             var post = s.Get<Post>(postId);


Command handlers are a great candidate for DI in my opinion. Leaving it up to the command/event handler to supply the service to use in the concrete case makes a lot of sense too. I find that the above leaves me with a domain that describes exactly what i want it to: “Who should be notified?” – all while abstracting away the concrete “How”.

Unit testing JSON services part 2.

January 8, 2011

Continuing with unit testing the ASP.Net MVC JSON service I am playing arround with, I got arround to the login action. For whatever reason, an instance of WebClient does not preserve cookies across multiple requests. What that meant was that all thought I was logging in fine, subsequent calls were failing due to authentication.

Fortunately it’s quite easy to make WebClient preserve the cookies. Heres how:

I rolled that into a class called JsonWebClient, along with the other options I was setting on the standard WebClient in each test.

public class JsonWebClient : WebClient
    public JsonWebClient()
        this.Encoding = UTF8Encoding.UTF8;
        this.Headers.Add(HttpRequestHeader.ContentType, "application/json");

    private CookieContainer container = new CookieContainer(); 
    protected override WebRequest GetWebRequest(Uri address) 
        WebRequest request = base.GetWebRequest(address); 
        if (request is HttpWebRequest) 
            (request as HttpWebRequest).CookieContainer = container; 

        this.Headers.Add(HttpRequestHeader.ContentType, "application/json");

        return request; 

Now I can do tests like this:

public void LogOnTest()
    var webClient = new JsonWebClient();

    var logOnModel = new LogOnModel()
        Email = "",
        Password = "12345",
        RememberMe = true

    webClient.UploadString("http://localhost/WebSite/Membership/LogOn", DynamicJson.Serialize(logOnModel));

    var result = DynamicJson.Parse(webClient.DownloadString("http://localhost/WebSite/Product/BE33A625-63F3-4014-85E7-D306F00A5A7E"), UTF8Encoding.Unicode);

    Assert.AreEqual(result.Status, "ok");

Distributed Systems Podcast

December 22, 2010

I’m right now listening to the first episode of “Distributed Systems Podcast” – a brand new postcast by Andreas Öhlund, Jonathan Matheus, Jonathan Oliver and Rinat Abdullin.

If your following the CQRS/DDD google group (also very recommendable) you allready saw this, but in case you diden, it shows lots of promise. So there’s your “head’s up” 🙂

Go check it out:

Life beyond Distributed Transactions: an Apostate’s Opinion by Path Helland

December 20, 2010

I just read the 10 pages that make up “Life beyond Distributed Transactions: an Apostate’s Opinion” by Path Helland (Amazon, Microsoft). If your at all interested in scalability, messaging ect., i highly recommend it:

BlackBerry Playbook Simulator and SDK hands-on

October 27, 2010

So i just got the BlackBerry PlayBook SDK and simulator up and running. While there is nothing in the form of apps in the simulator, it diden take much work to get the HelloWorld project running. All in all the initial impression is quite positive. I can see the split screen combination of WebOS style multitasking “cards” and “All programs” menu working well in practice. Since there are no hardware keys on the simulator (it’s just a VMWare image), swiping up minimizes the active application to a card. While there’s obviously some ways to go, everything seems quite smooth and well thougt through, with dedicated icons at the top of the screen for accessing notifications and the integrated media player (no media comes loaded unfortunately).

For whatever reason you have to provide your own 90x90px icon for the example app – I just picked one up from and resized it. I’m resonably comfortable with photoshop, but some people might not be.. blackberry-tablet-icon.png

Below is a couple of screenshots of the hello world example app running and what it looks like minimized to a card:

Settings on Windows Phone 7

June 18, 2010

Storing and retreiving settings from isolated storage on Windows Phone 7 is easy:

IsolatedStorageSettings.ApplicationSettings["UserName"] = "Olav";
string username = IsolatedStorageSettings.ApplicationSettings["UserName"].ToString();