Monthly Archives: May 2011

My first PlayBook “application” :)

I have to be honest with you. I’m ill, desperately ill developer. :) First day I was just playing with PlayBook and exploring as much details as I was able to. First half of day two I was doing the same, but slowly. The other half was “lost” – I started to think about developing something. :D

Right now you can choose between Adobe Air and BlackBerry WebWorks. I jumped into WebWorks. I’ll not describe the details, because I know, I gained close-to-zero knowledge so far. But even this small was enough to create simple application. It’s even using OData. :)

Following screens will walk you through the application – it’s a simple eBay search application. You put some search keywords and it will show you matching listings with price and small image. That’s all. Nothing more. No fancy UI (actually no UI at all), no icon, no settings, no error handling, no …


Home screen – before starting the application


Application is starting


Ready to do the search


Search in progress (take notice of super cool throbber 8))


Results…


Application while switching to another application

Cannot say I like the development process, but who knows where it ends (I end).

PlayBook’s browser identification

Similarly to my post about Kindle’s browser I looked how the browser in PlayBook is identifying self.

With the latest OS 1.0.3.1868 the User-Agent string is:

Mozilla/5.0 (PlayBook; U; RIM Tablet OS 1.0.0; en-US) AppleWebKit/534.11+ (KHTML, like Gecko) Version/0.0.1 Safari/534.11+

It contains “PlayBook”, so it’s easily grep-able.

BlackBerry PlayBook – first sight review

I had PlayBook in my hands for almost two days. So I think it’s time to share some first impressions.

First the size and weight. It’s smaller than well known iPad, you can get that from specifications. It’s roughly the size of Kindle 3rd generation. The weight is officially 425g, but I care more about how it feels. And being used to Kindle (very light) and having two or three times iPad in my hands (first time I almost dropped it, how heavy it was) it’s what I expected. Thanks to the size, you can hold it in one hand and do stuff. And also hold it in almost every position you want (including lying for a decent amount of time) without being quickly tired. It fits my usage perfectly.

With physical size the screen size relates. For web browsing is, I think, just enough. Sure, bigger screen would mean more content. In last two days or so I just watched some videos and read articles. I had no problem with reading, slowly scrolling through text and reading paragraphs was fine, no hassle. Video is fine as well. If you’re watching is from standard reading distance, something around from 25cm to 40cm, no problem at all. The hi-res videos are looking great on in. Nice colors, but not over-juiced.

The borders are active, couple of gestures to control the tablet. But you’ve probably seen enough of it on demo videos. There are no special buttons on the edges. Only play/pause, volume up, volume down and power button on top. Talking about power button. It’s really small and almost equally with the edge itself. For a first day I had hard times to press it. Now I found “the move” to do it. But it was frustrating. :)

Connectors are 3,5mm jack for audio, micro-USB for charging and connecting to computer, micro-HDMI and one dedicated charge connector (used i.e. by dock or rapid charger).

The system is great. I love the speed of it and full multitasking. Everything is smooth. The behavior is close to normal operating systems we know from computers, but still efficient on tablet, so I got very quickly to get used to it.

So far I did only one and a half lap with charge-discharge, so it’s not a representative sample of data. But it looks like, PlayBook lasts 7 hours on average usage, about 4 hours on close to full-time usage. Not bad. I think you could “survive” a day out of the office on one charge.

The browser is WebKit based and works fine. No advanced options, just a few. Tabs are working. Rendering is fast, I feel I’m not waiting for something, though I didn’t tested it with stopwatch or something like that. The feel is enough for me. I also checked the browser’s User-Agent identification. The browser displayed all pages I visited so far without any problem, some included heavy JavaScript usage (i.e. HootSuite).

And there’s one nice feature I’d like to talk about. You can turn on WiFi sharing, which allows you to see your PlayBook as a network share. You can then upload (or download) files directly to it and access it by applications on tablet. Pretty damn nice.

I don’t know what to say more. I’m so far, pleased with it. Fulfilled my expectations. If you want to ask something, do it in comments, I’ll try my best to provide you with an answer. Later, I’ll, for sure, write some deeper observations as I gain some.

Improved command logging in ADO.NET provider for Firebird

I recently improved the command logging in ADO.NET provider for Firebird. Let me start with little bit of history and then you’ll see the motivation and current improvements.

Before I added simple Debug.WriteLine to the FbCommand class. This was mainly driven with need to easily see commands I was generating for Entity Framework. Then the Visual Studio 2010 came with the IntelliTrace (only Ultimate version) and while working with MS SQL Server I was happy to see commands without any additional effort. I wanted the same for Firebird too. Sadly the IntelliTrace right now isn’t publicly pluggable. I was still using the debugging code, but often when doing development on customer’s applications using released version of provider I lost this ability. No debug outputs, no IntelliTrace.

Because I believe it’s important to have easy way to see (and not only for Entity Framework’s generated) the command, to spot performance problems early, I added simple logging facility. This logging is enabled for all builds (not only debug) and uses Trace class from .NET Framework. Everytime you Prepare (the Prepare method is called also automatically before execute if not called manually) command you’ll see the command text and current parameter names and values (if any). If you’re inside Visual Studio you see by default the output in Output window. You can also configure it to log i.e. to file, probably usable in staging and/or production.

Hope you find this useful as I do.

Is Entity Framework Code First really third distinct option?

In a lot of articles the Entity Framework’s 4.1 Code First is described as third option to the already available so called Database First and Model First paths. But I’m not sure, it’s really a third distinct path. At least it’s not so clear.

Let’s describe what Database First means. You simply create a model by reverse engineering your current database. Then you can tweak the conceptual part and do the development. You’re not limited to work with generated classes, POCOs work too. Your model is described as XML file(s) (often in one file with EDMX extension).

The Model First goes the other way. You start with blank designer surface and at some time generate the SQL script to create database based on what’s on the surface. Of course you can use POCOs here as well. The model is stored in XML file, same as in Database First scenario.

But what the Code First does? Focusing only on important differences, it only allows you to save model as code (in any language being able to produce MSIL). Really. The only difference is the model representation, to be precise the mapping and kind of SSDL.

There’s no explicit conceptual part. You already have it. It is the objects you created – either generated or manually written both POCOs or derived from EntityObject class. The mapping and also the store model is described with your code. EntityTypeConfiguration, ComplexTypeConfiguration etc. classes directly or indirectly written. Also part of mapping could be inferred if you’re using conventions. And ultimately you can point this to an existing database or let the Entity Framework create it for you (or the SQL script). That’s when the database initializers (and providers) come to play.

Julia Lerman created a nice decision chart if you’re not sure what way to go. But in my eyes the only decision to make is whether you want to have everything in .NET code or in XML (and in fact, in runtime both approaches will create same in-memory representation).

Existing database & code ⇒ Code First
Existing database & XML ⇒ Database First
New database & code ⇒ Code First
New database & XML ⇒ Model First

See. So I think it’s more 2×2 options (and Code First being able to do two tasks) and we might call it: Code Database First, Code Model First, EDMX Database First and EDMX Model First or Database First with Code, Model First with Code, Database First with EDMX and Model First with EDMX. :)

Easy indentation control for Debug/Trace/…

I was setting up simple command logging, but keeping in my mind where I increased the indentation to later decrease it back was causing me headache. Also formatting the string I’d like to put out wasn’t smooth.

So I created simple wrapper class implementing IDisposable, where the disposing will actually decrease the indentation automatically. Only thing you (I) have to use is simple using block. The precooked WriteLine helper method is there just to save me some typing.

class IndentHolder : IDisposable
{
	public void Dispose()
	{
		Trace.Unindent();
	}
}

public static void WriteLine(string format, string category, params object[] args)
{
#if (TRACE)
	Trace.WriteLine(string.Format(format, args), category);
#endif
}

public static IDisposable Indent()
{
#if (TRACE)
	Trace.Indent();
	return new IndentHolder();
#endif
}