Code through the pain Ladislav Mrnka's professional blog about software development


Microsoft today announced arrival of Surface Pro tablet in January 2013. Great! What about announcing when will be Surface RT available world wide?

When I first saw announcement of Surface tablets I immediately wanted one and my choice was ARM version with Windows RT. I was very suspicious to initial expectations of  "low price" but on the other hand Google showed that you can do high quality tablets with very interesting price. My determination to buy Surface RT was for a while weakened by the final announced price - $499 for bare version was little bit more than I expected for two simple reasons:

  • Surface tablet without touch or type cover is just a half of the product and the price of those covers is extraordinary high. The real price of Surface RT tablet is $599 if you want just black touch cover. I want type cover so the price is  $628 (+ 20% VAT for Czech Republic and probably some import tax).
  • Office 2013 RT was a great value until Microsoft added Home & Student edition suffix. This suffix made it for many people just a bloatware because to use the tablet in business environment (for example as BYOD), you also need additional full license of Office 2013. The real licensing policy to use the tablet in business environment is very unclear. Does it mean that to use the tablet in business environment we also need Office 2013 Home & Business edition (additional $219) or Office 365 Small Business Premium (additional $149 per year)? Why should I pay licensing fees for version with Outlook when I cannot use it on Surface RT?

I hoped for price around $500 but with touch cover and Office 2013 RT without limited license - those two features should have been market differentiators. Even after initial price disappointment I still want the device and I want it now. I desperately try to buy one (preferably with EU continental power supply) since its official release but with no luck. I live in a country where Microsoft Store (the online version) is not available. When I tried to order the tablet from UK, they don't post it abroad. When I traveled to London for vacation, I wasn't able to find any single shop where they would offer Surface RT for sale. I guess there is none official because Microsoft simply chose strategy to release the product only through the online store and through Microsoft Retail Stores but no retail store exists in Europe!

Surface is just another product showing that global market or at least EU market doesn't exist. I can watch localized advertising in local TV broadcast showing how great Windows 8 is on tablet but there are almost no tablets available on local market and probably no RT tablets at all (Asus Vivo Tab RT will probably hit the local market soon). I'm not looking for anybody to mediate the purchase for me - we have family friends in UK so I can use their help (unfortunately that means UK power supply) in the same way I did it before when I wanted Nexus 7 prior to availability on Czech market (Nexus 7 is offered by Asus directly, not by Google) but why do I need to use such complicated way to buy a simple product?

Microsoft, Google and Amazon are great in showing how uninterested they are in small markets. One would expect that $628 has the same value regardless of the customer's address.

Posted on November 29, 2012 by Ladislav Mrnka
Filed under: Microsoft

I just had a very hard month at my job. I was behind the schedule due to my fault during estimating some of my tasks. When I realized that my estimate for the essential task was completely wrong, I was too close to the deadline and too far from my commitment to meet the deadline. I decided to make my best to finish the assignment on time. I worked very hard and did more than 10 man days of overtime during just 17 days. This effort successfully ended week ago and I again work in normal mode - still two weeks to go and I will take some vacation. I didn't fully recovered yet and I still feel very tired. That is also the reason why I reduced my participation everywhere this month (including Stack Overflow).

Even with so much work to do I watched or read about all big October's events and announcements including Apple's keynote, Windows 8 launch, Windows Phone 8 launch, Google's announcement of new Nexus devices and finally also some Build sessions. I have also already upgraded my PC to final version of Windows 8 Pro. I was especially happy to see announcement of Windows Phone SDK 8.0 and the new version of .NET for Windows Phone 8 because not releasing the preview of the SDK to community was a very strange decision. It will be definitely something I will try once I recovery from the exhaustion.  I'm full of enthusiasm with all new things happening in Apple's, Goolge's and Microsoft's platforms but only Microsoft platform interests me at the moment also as a developer and not just a customer.

I'm not going to buy Windows Phone 8 mobile phone but I'm very interested in development for this platform and its relation to WinRT. I will perhaps buy Microsoft Surface RT. It could be a nice companion to my iPad 3rd generation and Nexus 7. Just the price seems too high and availability in Europe isn't good. Availability in Czech republic is equal to zero and it will most probably not be available this year at all. I just have to hope that it will get to Czech republic faster than for example XBox 360 - it took one year to launch XBox 360 in Czech republic and next 3-4 years to launch XBox Live which is at the end something like bad demo to the service available in main markets (US, UK, etc.).

Posted on October 31, 2012 by Ladislav Mrnka
Filed under: Microsoft
1 Comment

Data access code follows simple implementations patterns. One of very common patterns consist of fetching data from a database, modifying those data and persisting those data back to the database in the same transaction. Using this pattern in any concurrent environment where multiple threads (or processes) can work with the same record concurrently results in new challenges. How should our application handle scenario when another thread updated the record after the first thread fetched the record from database but before it was able to persist its changes back to the database? This area of database access implementation is in general referred as concurrency. We differ between two common solutions: Optimistic concurrency handling and Pessimistic concurrency handling.

Optimistic concurrency uses a special column in the table to track if the record was changed. The main requirement is that the column must change its value every time when the record is updated. Each relational database offers a special data type for this purpose which is automatically updated every time its record is updated. Microsoft SQL Server offers deprecated TIMESTAMP and newer recommended ROWVERSION data types for this purpose.

If we use Optimistic concurrency to solve the initial scenario with two threads the first thread will load the record together with an actual value of the time stamp and when it tries persisting the change it uses time stamp's value in WHERE condition of UPDATE command together with the record identification (for example key). If another thread updates the record in the mean time the update from the first thread doesn't find any record matching its WHERE condition. This will result in 0 updated records (in Microsoft SQL Server this information is received by executing SELECT @@ROWCOUNT query after the update command) and the thread should somehow react to this situation. The reaction follows common pattern of reloading the record to get current values, applying changes to reloaded data and persisting them again. The real implementation of this pattern may involve for example user interaction where a user must resolve the conflict. Entity framework has direct support for Optimistic concurrency in both ObjectContext API (also shows required mapping in EDMX) and in DbContext API. Code first supports mapping in both data annotations and fluent API.

Pessimistic concurrency doesn't use any special column but it instead uses transactional and locking mechanisms offered by relational database. The whole idea of pessimistic concurrency can be compared to critical section. The fetching of the record, its update and followed persistence must be considered as atomic operation which can be executed by only single thread (per record or record set). When the first thread enters this critical section no other thread can modify the record or enter critical section for the same record. Using this mechanism requires understanding of transaction isolation levels and locking mechanism in used database. The bad news is that Entity framework doesn't have any built-in support for Pessimistic concurrency.

This article was inspired by question asked by Ari on Stack Overflow. The rest of the article will show why base Entity framework update patterns do not provide pessimistic concurrency and why approach described in the mentioned question from Stack Overflow doesn't work. The article will also provide a real solution for pessimistic concurrency which requires usage of native SQL.

Posted on September 29, 2012 by Ladislav Mrnka
Filed under: Entity framework
Continue reading

I have already wrote the article about Microsoft strategy to annoy as many of their current Windows Phone customers as possible by announcing that their phones will not receive upgrade to Windows Phone 8 and that they will only receive Windows Phone 7.8 with a new fancy home screen - that is still the only officially announced feature for the upgrade. But somebody in Microsoft believes that annoying customers is not enough so they decided to annoy developers as well. The rest of this article is about features in Windows Phone 7.8 and about situation around Windows Phone SDK 8.0.

Posted on September 23, 2012 by Ladislav Mrnka
Filed under: Microsoft
Continue reading

This article is about "improvement" in Visual Studio 2012 unit testing. I think it doesn't happen very often to have an upgrade which makes the functionality worse than the previous version. In the case of the new Test Explorer window we can even talk about removing previously available functionality because the new window is mostly useless for any bigger solution. Until Microsoft improves the window we are not away from the testing experience known before Visual Studio 2008 when we didn't have any built in support for unit testing and we had to use third party plugins or external test runners.

I wanted to write this article immediately after I tried the new Test Explorer in Visual Studio 2012 Ultimate RC but I still believed that Microsoft will improve it before launching Visual Studio 2012 especially when complains to the new Test Explorer appeared long time before RC. Unfortunately Visual Studio 2012 RTW was released with the same Test Explorer window and there is also no update available yet. Test Explorer window should be hopefully improved this fall. There is also related request on Visual Studio User Voice with few other suggestions for improvements in comments.

The rest of the article describes what is wrong with the new window and compares the functionality with Visual Studio 2010 and Resharper 7.

Posted on September 16, 2012 by Ladislav Mrnka
Filed under: Visual Studio
Continue reading

Apple's iPhone 5 keynote ended more than hour ago. It didn't bring any big surprise and even didn't convince me to change my iPhone 4 for the new iPhone 5 because I don't need a new phone and a larger screen or LTE which is not available in my country do not change it. I'm using tablet when I need mobile device with a larger screen and more computing power. The disappointment is missing NFC support because in my opinion, it means either that Apple doesn't believe in that technology yet or that the technology didn't succeed on the main markets.

Anyway I didn't start this short post to discuss the new iPhone. I wanted to watch the live stream of the keynote. One could think that it should be enough to turn on Apple TV and simply select a keynote and stream it to my TV or run iTunes on iPad/MacBook/PC select keynote and stream it but no luck. I didn't find the live stream and I believe the reason was quite simple - Apple didn't provide any. I know, I will be able to watch it as a podcast but that is not the same as streaming it live. There are rumors that Apple wants to bring streamed TV content to Apple TV. How Apple wants to do that when they are not able to stream their own keynote? This was a huge disappointment - bigger than anything in the keynote itself.

Btw. the new iPod Nano looks more like Lumia Nano ...

Posted on September 12, 2012 by Ladislav Mrnka
Filed under: Apple

I'm currently Pluralsight's subscriber for few months. My first experience with Pluralsight's training courses came after receiving one month free subscription during promotion on Stackoverflow last year - what a great marketing skill. I found their library the best training source available on the Internet especially if you need either get quickly basic-to-intermediate general understanding of some unfamiliar technology or if you need to dive deep into some specific features of selected Microsoft technology. There are also few courses targeting development tools, practices and processes. I have previously also used the library to prepare for multiple Microsoft certification exams.

The basic subscription without exercise files, assessments and offline viewing has in my opinion so good value / monthly cost ratio that I'm paying it myself (I don't have subscription payed by my employer). Pluralsight offers short trial so you can try it yourselves if you don't believe me.  The current library contains overview and in-depth courses about Microsoft technologies and overview courses for other technologies. I hope the library will get in-depth courses for other technologies (especially from Java and Apple world) as Pluralsight will grow.

I searched for a while for the best way to watch those courses with minimum distraction. I started by watching courses on a desktop PC with headphones but with two monitors I always started browsing internet on the second screen after a while. Pluralsight online course player requires Silverlight and there is no application for Mac so I cannot watch courses on my MacBook Pro (I'm not going to install any additional web content player on Mac after previous bad experience with Flash player) but Pluralsight have application for iPhone and iPad (and other mobile platforms)! I left the desktop and started watching courses on iPad with headphones and it really worked much better for me but after that I got an idea to use AirPlay on Apple TV and watch training courses on 40" HDTV. This way really rocks. When sitting on a sofa and watching the large screen I feel very comfortable and it gets closest to the feeling of being on a real lecture.

P.S. This is not a commercial advertisement. I'm just referring the service I found very valuable.

Posted on August 19, 2012 by Ladislav Mrnka
Filed under: General

I have recently become quite interested in Windows 8 and new "Metro" style applications development. I even think about buying Microsoft Surface (ARM version) once it is released but the final decision will depend on the final price of the device. As I thought about this I found that changing platform or using two or even three (I would like to try Google Nexus 7 as well) platforms concurrently can have additional hidden costs and complexities related to loosing applications, content and services used on another platform.

I'm currently Apple's customer. This article is about my move from loyal Microsoft's customer to loyal Apple's customer and about bad product strategy which can make a huge damage to company's reputation and customers loyalty. Current Windows Phone 7.x customers and Nokia Lumia owners can find part of my story quite familiar.

Posted on August 18, 2012 by Ladislav Mrnka
Filed under: Apple
Continue reading

Entity framework team today announced a new level of cooperation with community by releasing Entity Framework on CodePlex under an Open Source license (Apache 2.0). This license provides opportunity to get the code, modify the code and use it in our own hobby, open source or commercial projects (for further license details check the license page). We can also contribute back to the repository - Arthur Vickers wrote very nice series for contributors. This move may raise some questions about support of Entity Framework. There will still be the main branch maintained by Microsoft which will be used for official releases with full support. Entity framework follows move already made for example by ASP.NET MVC team. We can only hope that other teams will follow this decision. I would like to see WCF under an Open source license as well (it is the top request in WCF UserVoice). Open sourcing code can make .NET APIs only better.

Posted on July 19, 2012 by Ladislav Mrnka
Filed under: Entity framework
No Comments

Two weeks ago Microsoft announced Windows Phone 8 (related article) for a new generation of smartphones. Windows Phone 8 will have a shared core with Windows 8 to unify whole Windows ecosystem. As I understand it, developers will be able to write Metro application once and target it on all Windows 8 and Windows Phone 8 devices including desktops, notebooks, servers, smartphones, tablets and probably also a new generation of Microsoft XBox. The targeting will most probably be only about different UI for some devices. I will not deny that this sounds promising. The Windows Phone 8 and all its features looks really great. Microsoft did a great job when creating this new version of operating system for mobile devices and as a developer I really like the new platform.

Some new Windows Phone 8 features are dependent on a new hardware available only in new devices created directly for Windows Phone 8. These devices will be available on official Windows Phone 8 launch. There is also a lot of amazing software features which are completely independent on a new hardware. Current Windows Phone 7.5 customers highly expected these features and they were so happy to hear about them. Until Microsoft did it ... The history is repeating and Microsoft again showed how they care about their current smartphone customers. There will be no official upgrade path from Windows Phone 7.5 to Windows Phone 8. The current known situation and a lot of assumptions around Windows Phone 8 and relation to Windows Phone 7.5 is explained in the rest of this article.

Posted on June 30, 2012 by Ladislav Mrnka
Filed under: Microsoft
Continue reading