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.

No unit tests?? Forget it!

I know a lot of people that look somehow skeptic to unit tests and unit testing in general. They see it as an additional work that has to be done and often think it's just a waste of time. So why to write them? Well, because they give you some kind of peace during the development that you're on the right path. My preferred approach is to have some kind of Test-Driven-Development. I applied this development style when working on my thesis project where I wrote unit test cases for the mobile as well as for the server-side (using mock objects), at the end having about a hundred of them. Developing in a TDD style is however not that easy, especially if many people are in a team. You need a lot of training and you have to be open-minded and available for changes regarding the development. And still you will catch yourself again and again during development, writing the code before the test :)
What I want to say is: write unit tests, even when you're under pressure with project deadlines etc. If you have only a small project you may not feel the need, but what if you have hundreds of business rules to validate where your input may come directly from the UI or over other sources such as XML files. I can guarantee you that in such a case you'll thank god for having a unit test in place which shows you the green bar :D (I'm talking from experience) A prerequisite is of course to have a well structured application in terms of the architecture. All the logic has to be inside a business layer. Otherwise you will have a hard time to write your tests or you'll cover only small parts of your logic.

Better Web Application Framework

Introduction to this post
In the future you'll see more posts of this kind (at least I want to). Since the computer science area is evolving rapidly, you have to stay up-to-date. Videos are a great way for that. The various platforms such as Youtube and Google video offer a lot of interesting materials from screencasts, conferences to technical talks. My first idea was to have somewhere a collection of interesting videos in order to be able to maybe check them out again later. So I basically started to have a list on GDocs, then I wanted to implement something with GMashups and finally my idea ended up on writing this special kind of posts (also for sharing with others), assigning all of them the reference label "tech vids" such that all videos can be filtered out (of my blog) easily.

Comment
Sean Kelly makes a nice and funny comparison of different web development toolkits (J2EE, Django, Ruby on Rails,...). It's a video to which you can just watch, relaxing without having to be concentrated to be able to follow everything. J2EE is criticized extremely!! Ruby on rails, Django and so on perform great on the shown examples, I'm not sure however how the comparison would look like on real-life enterprise applications. It would also have been interesting to involve ASP.NET in the comparison.

Duration
36 min 18 sec


External Link

Label cloud on my blog

Yesterday I found some minutes to go ahead with my blog revision. Already for a longer time I planned to integrate a label cloud, since a lot of sites and blogs which manage tags or labels have one. Instead of writing one myself, I wanted to consider the implementation of phydeaux3. Till now the problem was mainly a lack of time, but also the problem that the default implementation of phydreaux3's label cloud didn't work on my blog. There were some problems with the CSS which I couldn't yet identify. Refactoring the source of my blog is also a point on my blog renewal "todo", mainly the CSS layering has to be refactored. Anyway, in the mean time I had to tweak the label cloud JavaScript a little such that it worked also for me. Now I have my own label cloud :) I have still to do some refinements but for now it works.

Best practices: VCS usage flowchart

So now there's the graphical representation of my yesterday's post. Computer scientists usually understand these graphs better ;) Comments, critics or improvements are very welcome.

Best practices: version control system usage

I come to the office in the morning, start Visual Studio and fetch the latest versions of the source code....recompile the solution: COMPILATION ERROR. The build is broken! That's for sure something you don't want to see in the morning!
Working in a team is actually not that straightforward. Normally (actually there should be!!), there is a version control system (CVS, SVN, TFS) in place which allows more people to work together on a project. But that's not enough. People need to be aware that they're not working alone on the project and have therefore to use the version control system appropriately. "Of course" you would think, but it sometimes doesn't seem that clear to people.
The number 1 rule: NEVER EVER upload a broken build to the common repository!!
Why that?? Well, because the next time your team members are fetching the latest versions, they'll have a broken build on their local development environment, which will not allow them to continue to work on the code.
Don't get me wrong, it's not that it never happened to me that I accidentally uploaded some broken build. Anyway, I started to think about some guidelines for working with version control systems, lets call them best practices:

  • ONLY check-in working code
    Checking-in or committing only working code is essential. If you don't do so, you'll break the build.
  • Check-in often
    Don't check out in the morning and check-in in the evening!!
    Checking-in in short time frames has several advantages. For the first you have always only checked out the code you're currently working on, which helps you keeping the overview and secondly checking-in is somehow a backup of your work. Lets assume the case that you've implemented something wrong or you made a mistake which broke your whole build. If you checked-in constantly, you can just revert to a previous version.
    So the advice is: implement a use-case (if it isn't to large) and after successful implementation commit it to the repository.
  • Fetch the latest versions regularly
    It doesn't cost you anything! Retrieve the latest source code versions regularly to stay up-to-date. Assume you're working on a piece of code which makes use of functionalities provided by other source-code modules which you're not currently working on. Those functionalities may change while you're working on your code. Method signatures may change which may break your running-code. By fetching the latest version you can immediately react to those changes.
  • Write comments on the files you check-in to the repository
    Sometimes this may be annoying, but it may help you, especially when there comes the situation when you have to revert to a previous version. Then comments may help you find the right one.
So how could an ideal work cycle look like(from my perspective)?
  1. Open your programming environment and fetch the latest versions from the repository
  2. Compile and build the system to see whether there are no problems.
  3. Check out the files where you have to work on and implement your use-case.
  4. Once finished, make sure that everything compiles without errors.
  5. Again, retrieve the latest versions from the repository.
  6. Run a project build to see whether still everything compiles and works fine.
  7. If it does so, check-in your changes and add a comment to what you've done.
  8. (Continue with step 3)
I'm actually not an expert, but if you follow these rules, everything should work fine. The steps mentioned above are somehow adapted to the work with Microsofts TFS (Team Foundation Server) where the option of multiple checkout is disabled. This easies the handling because code merges should theoretically not be necessary. If you're working however on SVN systems where theoretically two team members could work on the same piece of code at the same time, things become more complicate and need still more discipline. In that case before you commit, you're usually doing a synchronize with the repository. You'll get a list of conflicts which you have first to solve by manually merging the files and fixing your local build. Once that is done you can commit your code.
So happy coding ;)

Busy week, my birthday and a really nice present

I actually didn't find the time till now, but on this week's thursday was my birthday :) I became 23! I'm currently really busy at work since we have to meet an important project deadline...anyway, lets return to my birthday. Immagine what I got as present from my girlfriend (beside a nice cake)... A book from Martin Fowler on "Patterns of Enterprise Application Architecture"!! Well..ok..I gave her a "small" hint ;)
The book (as far as I've already read till now) is really great. Software architectures is a topic which interests me a lot as well as design patterns. Actually both of them are related somehow. I think having a good knowledge about them really improves your programming and productivity skills. At work I'm also developing on enterprise applications and I'm very lucky to work in a team which attaches great importance on having a clean and well structured architecture. So I cannot wait to read over the book and maybe I'll also post some pieces which I find especially useful here on the blog.

Btw, I don't know whether you've notice the change in the design of my blog. I've changed the CSS of my gadgets and sidebar. It's actually the design I've had on one of my previous pages (which will go offline in the next time). I think it looks now much cleaner. There are still some changes I'm going to take on my blog. But if you take a look at the pie-chart in the upper right you'll see that there are still more issues open than closed: time is a problem :( unfortunately.

Extended User Management under XP

This will become just a very short post since I'm too tired to write a lot today. I just set up my little "server" the term is maybe not really appropriate, anyway. What I'm doing is to use my old notebook as some kind of server, where I can store common files, and on which I'm performing bigger downloads. I just wanted to configure the machine s.t. it always logs on automatically with the same account. This is quite comfortable when you control it remotely and you have to perform a restart or something. The system installed on my old notebook is a Windows XP Home Edition - not really great, but it works. Well...to come back, I wanted to set up this user-account configuration, but the Windows Home standard of managing and configuring user accounts is quite limiting, especially if you're accustomed to the one used on Win2k.
To come to an end, if you want to have also that same extended user management on your Windows XP machine, just start the following script, which puts a key in the registry:
Download Windows registry script

The content is the following:


Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2Ce1298969D}]
@="XP extended user management"
"InfoTip"="Extended user managing for XP"

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2Ce1298969D}\DefaultIcon]
@="%SystemRoot%\\\\system32\\\\Shell32.dll,111"

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2Ce1298969D}\Shell]

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2Ce1298969D}\Shell\Open]

[HKEY_CLASSES_ROOT\CLSID\{98641F47-8C25-4936-BEE4-C2Ce1298969D}\Shell\Open\command]
@="Control Userpasswords2"

[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Explorer\ControlPanel\NameSpace\{98641F47-8C25-4936-BEE4-C2Ce1298969D}]
@="Userpasswords2 in Systemsteuerung aktivieren"

After you double-click on the script, it will be executed. As a consequence you'll find an entry in your control panel which looks as follows:

I hope I was able to help some of you :)

Happy Birthday Manfred!!

Happy birthday


Got a Dropbox account

I don't know whether you remember my post some time ago, about new services appearing on the web which offer you webspace for uploading files and sharing them with others. Some days ago, I actually received a Dropbox account. For the moment the service - which is currently in beta - is just open through invitations. I already installed the Windows client and started to upload some files and to create some shared folders with some of my friends. The product is great because it is so simple to use. You basically just have to install a client application on your machine which creates a folder called "My Dropbox". Everything you then put inside that folder, will be automatically synched up by the client to your Dropbox online storage. On another workstation you then have the possibility to either just access your files through the web interface or to again install the Dropbox client there and to link it to your account. In this way it is easier than ever to take your files across multiple computers. You don't have to use services like GSpace or even send your files to your own email account.
Other great features are
  • Public folder - All files in there get a unique URL for publishing on the web
  • Shared folders - You can share folders with your friends. Of yours they have to have a dropbox account
  • Versioning - All files are automatically versioned. It's like a simple version control system which may be great if you collaborate with your friends on documents, but also if you just want to restore an older version because you broke something in the newer one. If you collaborate on word-processing documents I recommend however to try GDocs which has an real-time collaboration feature and is now even accessible offline.
And the service is just in beta...I'm expecting a lot of new interesting features to appear. Just go to http://www.getdropbox.com to get more information about it. There you'll also find a forum where the planned features are listed.

Update:
As I said...online file sharing and sychronization becomes more and more popular. Here's the Microsoft solution:
http://dev.live.com/blogs/devlive/archive/2008/04/22/279.aspx
Here's also a video, unfortunately only in German:
http://techfiles.de/dparys/videos/LiveMesh/LiveMeshInAction.wmv

Retrieving list of installed applications

From now and then it happens that you have to reset your workstation, meaning to reformat your hard disk and install everything fresh. In this way you get rid of all the garbage on your PC. In such a case it may be useful afterwards to have a list of all of the previously installed applications in order to have your loved, every-day used programs :) installed and configured. Opening the "Add or remove programs" entry of the control panel for copying (by hand) all of the entries is for sure not the best approach for that. Usually as software developer you are too lazy to do such things manually and you try to automate things as much as possible (also if sometimes at the end it costs you more time ;) ).
Actually there is an automated solution for this problem here (otherwise of course I wouldn't probably write this post here). I have two different versions. The first, which is the simpler one, queries the Windows registry, while the second queries directly the WMI service. You can simply start the script and wait till the "Done" message box appears. The softwareSimple.vbs and the softwareExtended.vbs create a software_simple.csv and a software_ext.tsv correspondingly. The best way to view them is to open them with MS Excel or another spreadsheet application.

SoftwareSimple.vbs

strHost = "."
Const HKLM = &H80000002
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("software_simple.csv", True)
objTextFile.WriteLine "Program Name" & ";" & "Installation date"
Set objReg = GetObject("winmgmts://" & strHost & "/root/default:StdRegProv")
Const strBaseKey = "Software\Microsoft\Windows\CurrentVersion\Uninstall\"
objReg.EnumKey HKLM, strBaseKey, arrSubKeys
For Each strSubKey In arrSubKeys
intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, "DisplayName", strValue)
If intRet <> 0 Then
intRet = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, "QuietDisplayName", strValue)
End If
intRet1 = objReg.GetStringValue(HKLM, strBaseKey & strSubKey, "InstallDate", strValue2)
If (strValue <> "") and (intRet = 0) Then
objTextFile.WriteLine strValue & ";" & strValue2
End If
Next
WScript.Echo "Done"
objTextFile.Close


SoftwareExtended.vbs
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.CreateTextFile("software_ext.tsv", True)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSoftware = objWMIService.ExecQuery ("SELECT * FROM Win32_Product")
objTextFile.WriteLine "Caption" & vbtab & _
"Description" & vbtab & "Identifying Number" & vbtab & _
"Install Date" & vbtab & "Install Location" & vbtab & _
"Install State" & vbtab & "Name" & vbtab & _
"Package Cache" & vbtab & "SKU Number" & vbtab & "Vendor" & vbtab _
& "Version"
For Each objSoftware in colSoftware
objTextFile.WriteLine objSoftware.Caption & vbtab & _
objSoftware.Description & vbtab & _
objSoftware.IdentifyingNumber & vbtab & _
objSoftware.InstallDate & vbtab & _
objSoftware.InstallLocation & vbtab & _
objSoftware.InstallState & vbtab & _
objSoftware.Name & vbtab & _
objSoftware.PackageCache & vbtab & _
objSoftware.SKUNumber & vbtab & _
objSoftware.Vendor & vbtab & _
objSoftware.Version
Next
WScript.Echo "Done"
objTextFile.Close


You can also download them from here:
softwarevbscripts.zip

Extended-view improved

I've recently written about the "extended view" feature I've implemented on my blog here. Today I improved it. Now it automatically saves your last view mode such that the next time you can immediately start reading from you preferred one. For instance if you leave the page in extended view, this view mode will be automatically restored the next time you visit my blog.
Technically speaking I realized this by saving down a cookie with JavaScript which is read the next time you come back..so nothing exciting actually :) Clearly your browser must accept cookies, otherwise it won't work.