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.

HowTo: synchronize Google Calendar with your iPhone

I'm sure you already tried this before. Well unfortunately there is no existing, pre-installed way for synchronizing your iPhone calendar with your Google Calendar. What you can do is to sync your Outlook calendars with your iPhone, either when attaching it to your Mac, PC or whatever (having iTunes installed of course :) , Apples strategy as usual) or over the Microsoft Exchange account (if you have one).
I'm mainly using Google Calendar however. The main reason is simply that it has a simple, intuitive interface and you can access it from everywhere and every computer (due to web interface). Having it however automatically synchronized with my iPhone would be great. So in this way you can get immediately your notifications on your phone. Ok, you could also use Google Calendars SMS service, which notifies you with an SMS (for free) about upcoming events. And in addition, having everything in sync, you can add new entries on your iPhone, immediately when they come to your mind, without having to be in front of your computer.
But enough blabla, the good news is that there actually exists a "workaround" for getting all this. It is a service, called "Nueva Sync" , which makes use of the MS Exchange account for synchronizing your Google Calendar. This page...

...describes in detail how you can configure your iPhone. I did it in about 3 minutes and it really works perfectly and surprisingly fast. The only disadvantage: you can just have one MS Exchange account with active sync on your iPhone at a time. I don't know the reason for that.

//Edit:
Another great option for synchronizing Google Calendar with your iPhone is the "SaiSuke" application. It has a much nicer representation than the original build-in iPhone calendar. Unfortunately "SaiSuke Free" supports only one-way (from GCalendar down to iPhone) and just one calendar.
The "SaiSuke Pro" app costs $9.99 but I think it may be worth to buy it.

HowTo: testing jFace Action class taking a StructuredSelection object

Let's consider the following jFace Action class:

public class RateAction extends Action {
 private final int fRating;
 private IStructuredSelection fSelection;

 /**
  * @param rating
  * @param selection
  */
 public RateAction(int rating, IStructuredSelection selection) {
  //hack: have to use a button because otherwise the star images won't show up on Linux (Ubuntu)
  super("", AS_PUSH_BUTTON);
  fRating = rating;
  fSelection = selection;

  setImageDescriptor(createImageDescriptor());
 }

 ...

 /*
  * @see org.eclipse.jface.action.Action#run()
  */

 @Override
 public void run() {
  List<INews> newsList = ModelUtils.getEntities(fSelection, INews.class);
  if (newsList.isEmpty())
   return;

  /* For each News */
  for (INews newsItem : newsList) {
   newsItem.setRating(fRating);
  }

  /* Save */
  DynamicDAO.saveAll(newsList);
 }
}
Action classes are heavily used in the Eclipse plugin development environment. They are basically nothing other than the representation of the Command design pattern, which is an extremely useful pattern. For instance for factoring out/grouping common behavior. Do not always put it in a common superclass: inheritance should only be used for specialization and moreover it imposes a very strong dependency among the classes. Command objects can be easily exchanged and are much lower coupled.
But back to the main purpose of this post. Another advantage of the Command pattern is to increase testability. So the above Action class can be tested as follows. The only peculiarity in this specific case may on how to create the appropriate StructuredSelection object which is normally automatically provided by the jFace environment. But also this is quite straightforward as can be seen:
public class RateActionTest {
 private RateAction action = null;
 private INews newsItem = null;
 private IStructuredSelection selection = null;
 
 @Before
 public void setUp() throws Exception {
  //reset DB schema
  Owl.getPersistenceService().recreateSchema();
  
  //construct the necessary selection
  IFeed feed = new Feed(Long.parseLong("" + 0), new URI("http://www.dummyurl.com"));
  newsItem = new News(feed);
  selection = new StructuredSelection(newsItem);
 }

 @After
 public void tearDown() throws Exception {
  selection = null;
  newsItem = null;
  action = null;
 }
 
 /**
  * Tests the actions core parts
  */
 @Test
 public void testAction(){
  assertNotNull(newsItem);

  //Verify that the created newsItem has a rating of 0
  assertEquals("rating should be equal to 0", 0, newsItem.getRating());

  //boundary test: empty selection -> nothing should happen, no exception etc..
  action = new RateAction(3, new StructuredSelection());
  action.run();
  
  //start the Action and set some rating
  action = new RateAction(3, selection);
  action.run();
  assertEquals("rating should be equal to 3", 3, newsItem.getRating());
  
  //decrease the rating again
  action = new RateAction(1, selection);
  action.run();
  assertEquals("rating should be equal to 1", 1, newsItem.getRating());
 } 
}

It is done...

...my blog shines in new splendor :) . I finally "managed" to upgrade everything to a new design. Managed....well...ehm...in theory I should have studied for my exams the last hours when I upgraded everything. Anyway, I'll catch that up today evening :( .
I'm very satisfied with the outcome. The old blog got really messed up over the last years. There was just too much on the page. So the goal for this new redesign was to make it

  • more professionally looking, 
  • simple, 
  • clearly structured, with just the necessary information on the page,
  • focus on what's most important: the reading area, where the blog post contents are and to
  • make it run on the most commonly used browsers.
    Tested on IE, Webkit (Safari, Chrome), Firefox. (forgot Opera, I leave it to you Peter :) ).
Well, this is the outcome. There are still some minor problems and I will still add some things over time. I had to remove the star ratings temporarily for instance and of course I'll add the links to my friends and colleagues blogs.

So what do you think? Comments are welcome :)

Accessing webcontrols inside the ProgressTemplate of an UpdateProgress

Apparently it is not possible to access server-side web controls that are within the "ProgressTemplate" of an UpdateProgress control. If you have for instance the following code

<asp:UpdateProgress ID="updateProgressMain" runat="server" DisplayAfter="100">
    <ProgressTemplate>
        <div id="progressBackgroundFilter">
        </div>
        <div id="genericProgressMessage">
            <asp:Label ID="lblProgressMessage" runat="server" Text="Loading..."></asp:Label>
            <br />
            <br />
            <asp:Image runat="server" ID="imgProgress" alt="Loading" ImageUrl="~/Images/ajax-loader.gif" />
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
then accessing the Label control "lblProgressMessage" like
lblProgressMessage.Text = "Some other text";
from your codebehind code will result in a failure. If you take a look at your designer file you'll notice that there is actually no declaration of the created label and also if you create it manually, the designer will remove it or it will not be instantiated with an object at runtime. This behavior is really strange and unfortunately I don't  have any explanation for it at the moment. It seems as if all server-side controls within the ProgressTemplate are simply ignored. So you can also have a situation like
<asp:Label ID="lblProgressMessage" runat="server" Text="Loading..."></asp:Label>
<asp:UpdateProgress ID="updateProgressMain" runat="server" DisplayAfter="100">
    <ProgressTemplate>
        <div id="progressBackgroundFilter">
        </div>
        <div id="genericProgressMessage">
            <asp:Label ID="lblProgressMessage" runat="server" Text="Loading..."></asp:Label>
            <br />
            <br />
            <asp:Image runat="server" ID="imgProgress" alt="Loading" ImageUrl="~/Images/ajax-loader.gif" />
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>
which of course should just be illegal since you have two controls with the same ID, but surprisingly nothing happens. The code compiles without any problems. Generally I would suggest to not use any server-side controls inside the ProgressPanel, but if you have to (like in my case) you can use the FindControl(...) to get an instance of your webcontrol at runtime:
protected void Page_Load(object sender, EventArgs e)
        {
            Label progressMessageLabel = updateProgressMain.FindControl("lblProgressMessage") as Label;
            if (progressMessageLabel != null)
            {
                progressMessageLabel.Text = Properties.Resources.ProgressMessage;
            }
        }
If anyone has an explanation why there is this behavior...your comment is very welcome :)

Best practices: Tracking information on the source code with Visual Studio and TFS

An issue in managing a code base is not only to guide different developers through the development process, preventing that they overwrite each others modifications on the source code (which would for sure happen when just sharing the code files over the normal file system. Never do that!!). But another extremely important point is to track bug fixes which represent extremely useful information. I'm sure you already experienced situations like the following. You develop some application, after some testing phase it goes into production. Feature requests and bug reports come in which you implement/fix. Then after some month again a bug report comes in, related to some of the bug fixes/feature implementations you did previously. And then, if you're lucky you remember why these changes happened and if you're excellent, you may even remember the exact feature request/bug report given by the customer. But I'm sure, if it was just a bug you fixed in 5 minutes you will not be able to remember exactly.
And here's where you need good tools. Luckily, Visual Studio Team System (if correctly used) provides you already a lot of tools for helping you in managing these kind of information. I'll show you an example, I experienced today.

A bug report came in. So I started the application and tried to reproduce it. It was not really a bug, but more like an explanation request, why the program behaved in a certain way. So I took a look at the piece of code which cause that behavior:

When looking at the code, I immediately remembered that this code was written due to a previous bug request. But which one? Good question...
Well, if you did worked in a clean fashion previously, you can get that information in less than 20 seconds. You just right-click on the code, go to "source control" and then "Annotate":
A new editor window will open, containing the corresponding annotations on the left side:
As you can see, this change was about two month ago, so of course it is difficult to remember everything. So, you just click on the corresponding annotation link and the change set dialog will open.
Now you can immediately see the involved source files and if you wrote a meaningful comment you may even immediately recognize the reason for this change. But you can even go further. If at the time of your commit when you fixed this bug, you associated the related work item, which has been entered by your customer on the Team Foundation system (of course this is a precondition for all of this here), then you can view this item now, with the customer's description, all of the history with your comments etc..:
And that's great I think. So it is worth to take this 2 seconds more and to associate the related work items (if available of course) when you commit your code.

As already mentioned, a condition for being able to work in this way is that you have all of your bug reports and feature requests as work items in your team system. Now the best way of course is to instruct your customer appropriately s.t. he's able to create these work items over the TFS web interface. If that's not possible, you either have to do it yourself when you get a bug report (this is however inconvenient and time consuming) or there is some intermediate help-desk person which creates these items.

Discover: file management on the iPhone

As I've written already in this post I bought an iPhone and I'm really satisfied with it. The experience in browsing the web is really amazing. And still I have some critics to do (always in hope they will be resolved with the next major iPhone OS update). I'm not going to post all of them now, but just to list some of them:

  • copy&paste between the applications
    i.e. safari to email etc...(will be included most probably on the next update)
  • file system manager
    being able to download and store files on the iPhone hard disk while surfing on the web. In this feature there would also be included the ability to upload stored files to the web
  • Store partially written SMS
    If I'm currently writing an SMS to one of my collegues and I'm getting interrupted, I'd like to store the SMS in the meanwhile and continue afterwards. For some strange reason this is not possible :(
  • Exchange data with other devices over bluetooth
    Well it's not reaallly needed, but it may often be handy to send images to other mobile devices. With your computer you'll most probably anyway use the wifi connection.
  • ...
There are still many other things, often really stupid things which one may thing would be much much easier to implement than many other fancy features but still they have not been added (yet).
Anyway, one of the most wanted features (from my side) is to have a local file system manager on the iPhone. If you have about 16 GB of space available you'd like to not just use them for music, podcasts, videos and pictures, but also to store files for transporting them. I searched a while on the web for such iPhone apps and found a couple, but no one was really interesting, some of them also limiting the available space in the free version. But then I found Discover. It's completely free, although it displays some ads, which are however not disturbing at all. It is quite like a normal file system manager. The only thing which is missing, is the integration with other apps (download files to it from safari,..), which I think however is not allowed by Apple's philosophy regarding iPhone apps.
Discover is great however. It disposes of a web interface where you can add folders, upload, view and download files.
When you launch Discover on the iPhone, (after the ads ;) ) it shows you immediately the screen on how you get access to the web interface:
It then shows you the list of folders and files...
...and you can browse through the folders for seeing the different files:
With the integrated iPhone document viewer (for viewing pdf, doc,...) you can directly read your pdf files on your iPhone
There are a lot more options available (sharing with other iPhone users,etc...), I'm just not going to post them. If you're interested, just download Discover and see yourself.
I had to do some "advertising" here, because the guys developing Discover do really a good job :) The only problem I'm experiencing is on my Windows installation. On Linux the uploads through the browser work without any problems, on Windows however I'm always getting an error when uploading files :( I have to see what's causing the problem. Probably it is related to the Flash player installation...

By far the best "404 Not Found" notification I've ever seen!!

I just wanted to download a zip-file from a url provided by one of my university professors, but sadly the URL didn't exist and a "page not found" message was displayed to me. But take a look at the 404 page, it's really funny. Not just the standard plain old formal pages :)


I had to post this :)
(Now I have to search for the correct URL :( )

Blogging year 2008

First of all, happy new year 2009, I wish you all the best! :) This is a scheduled post of course :D I'm not in front of the PC over new year, and you shouldn't be neither. Go out and celebrate :)

As last year, also this year some statistics. Year 2008 was a good year :) . I changed job, and in October I switched to work part-time for starting my master studies in computer science at the University.
In March, this blog got a new domain and after a lot of more and less meaningful :) posts, I recently wrote the 100. post for this year. Visitors started to increase, from an average of 10 to 15 users per day in the beginning of 2008 to an average of 50 to 60, often there are even more than 100 users per day on this site here. And that's great, it's a feedback that people find my sites and the stuff I write. I hope it will go on in this way :)