My name is Juri Strumpflohner and this is my technical blog. I'm a software architect, .Net, Android, Web and Java dev, TDD and best practices promoter and martial arts practitioner.

Recent Posts Subscribe

Dear reader of Juri's TechBlog,
I moved my blog to a new domain and a new hosting solution as well. I'm now blogging on juristr.com.

Why Extract {Class | Interface | Method} Refactoring improves Testability and Readability

I still see many developers coding huge methods and large classes. The code looks very much procedural, having lots of conditional statements and loops one following the other and eventually even nested. Asking for the reason of such structuring, surprisingly the readability is often mentioned.

Well, when reading or debugging the code, I don't have to jump between classes/methods, but I immediately see what's going on within that method.

Android: HowTo Detect Installed SQLite DB Version

As you might already know, Android comes with a preinstalled SQLite database. This is quite handy because you can rely on it without the need to care about installing a DB along with your application (although you can, standalone, small DB's of course like HSQLDB). On the Android Developer documentation SQLite version 3.4.0 is indicated as the reference version to develop against. Usually you should be fine with that and if you don't have any valid reason you should stay with. But still in the very rare cases you may have the need to detect the installed version on the handset your application is running on (maybe simplifying/optimizing a complex query with operators introduced in some 3.4+ version).

ASP.net: Organize Your Resources the Correct Way!

ASP.net provides well-known mechanisms for localizing web applications, namely by extracting hard-coded strings into resources files. Localization for Pages and UserControls is fully automated and available from within Visual Studio. While most of these issues may seem quite obvious to you, I think it is still worth mentioning some organizational facts related on how to distribute local vs. global resources. I always again encounter devs using the same resource messages repeated over and over again distributed onto many local, page-related resource files. This makes it an extremely annoying process if you happen to encounter the need for changing them.

"App_LocalResources" vs. "App_GlobalResources" folder
Mainly there are two different types of resources, those available locally to the target element that has been localized (i.e. for the ASP.net Page or UserControl) and those that are globally available to the whole application.

Local resources are being generated by opening the design view of a Page or UserControl and by then clicking on the Visual Studio menu "Tools > Generate Local Resource". This automatically generates appropriate resource files in the "App_LocalResources" folder.

Moreover it adds "meta:resourcekey" tags to the localized server controls on the ASPX code:
  
All of the generated resources within the App_LocalResources file are just locally available to each Page/UserControl they belong to.

On the other side, App_GlobalResources are - as the name already suggests - globally available to the whole application. They are normally not generated automatically, but created on demand. If the App_GlobalResources folder doesn't yet exist, it can be created by right-clicking on the project in the Visual Studio Solution Explorer and by then choosing the appropriate menu entry (as shown in the following figure)

Which resources are good candidates to become global?
Resources that are good candidates to become global and should therefore be placed in the App_GlobalResources folder are all those which may appear to be replicated throughout the application and are not specific to a certain Page or UserControl.

Examples are:
  • Common action names such as "Save", "Delete", "Back",...
  • Common, generic messages such as "Successfully saved", ...
Which resources are good candidates to go into the App_LocalResources folder?
Simply all of the resources that only belong to the Page or UserControl itself and are not shared among different entities.

How to access resources in the ASPX code?
Local Resources
Local resources can be accessed in the ASPX code either by specifying a meta:resourcekey tag (which is also automatically done by generating them through VS) or as follows:
<%= GetLocalResourceObject("resourcekey") %>

Global Resources
Global resources can be accessed by using the following syntax
<%$ Resources:GlobalResourceFilename, MY_KEY_IN_THE_RESOURCE_FILE %>  

How to access resources in the C# code?
Local Resources
GetLocalResourceObject("resourcekey")  

Global Resources
GetGlobalResourceObject("GlobalResourceFilename", "resourceKey");  

Gist: A Suitable Tool For Collaborative Online Code Reviews?

Doing code reviews is an extremely useful practice where you can learn a ton of things. Prerequisite: being open-minded and ready to share your code, accept and learn from criticism ;).

Today I was searching for some suitable tool for doing code reviews online. Of course, doing reviews live with your mate beside you would be much more valuable. Voice is still the most efficient communication medium. Here some tools that came to my mind: