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.

These damn spammers!!!

Once again one of my blog posts got infected by "spam" comments. But this time not the usual pharmaceutical spam messages which you immediately recognize.

I recently came accross your blog and have been reading along. I thought I would leave my first comment. I dont know what to say except that I have enjoyed reading. Nice blog. I will keep visiting this blog very often.

[LINK DROPPED]
So if you see such messages drop them immediately, because the only goal of these spammers is to "eat from page-rank-cake" by placing their own links at the end of their comments. It's really awkward because I don't want to restrict people from commenting on my blog, neither by enforcing them to own a Google Account, nor by implying "comment moderation". But I fear that if it continues this way I'll have to react somehow (sorry for that).
What I wonder is how these spammers are able to leave their comments because when commenting you have to enter these word verifications. Poor guys if they do it manually. They should better produce good content rather than trying to get a high page-rank this way.

This was the guy that left the spam comments: g$o$o$g$l$e$t$e$l$e$c$o$m$m$u$t$e$DOT$blogspot$DOT$com
(I made the URL a bit unreadable to not make advertisement and give him what he wanted....so..keep him on your black list ;) )

Extended view reloaded

With the transition to the complete new blog design I initially had to leave away some features which I had on my old blog layout. One which I personally found most important was the ability to extend the blog post content area s.t. the full width of the blog can be used for reading the post.
I experimented a bit with jQuery which made it extremely easy to add the kind of effects I needed. What I had to do is to just include the jQuery script which can be downloaded from the official jQuery site. The remaining could be solved with these lines of jQuery enhanced JavaScript.

<script type="text/javascript">
   var isHidden = false;
   $("#resizeBar").click(function(){
       if(isHidden){
          $("#sidebar-column").fadeIn("slow");
          isHidden = false;
       }else{
          $("#sidebar-column").fadeOut("slow");
          isHidden = true;
       }
   });
</script>




Click on the small gray bar that separates the (white) post content area from the navigation area to see the result :)

I tested the feature on Safari, Chrome, Firefox and Internet Explorer and it works on all of them. However I found a strange behavior in IE7 (not related to this new feature here). I opened the blog on IE7 and strangely the small bar which separates the two areas was not shown, the navigation area was pressed on the left corner and the main content area where the posts are written filled more than the available space on the web-page s.t. a horizontal scrollbar appeared on the page (really ugly). Initially I though of a CSS incompatibility but then I notice an interesting thing. When you load this blog in IE7 till it's fully rendered, then you open another tab, browse a bit around and then you switch back to the tab with my blog loaded...and suprise...the blog is rendered perfectly as it should be. It's really strange, it seems as IE7 takes a bit till it renders the entire CSS completely?? Does anyone have a suggestion?

Best practices: Deploying webapps (contd.)

Some time ago I've written a post about best practices in deploying web applications by mentioning the different environments

  • Development environment
  • Testing environment
  • Production environment

Since the three different environments must be completely separated (no references between them to the DB or whatever), you have to have different connections strings in your web.config file (for each connection to the according development-/test- and production-DB).
In my last post I addressed this problem by suggesting as a possible solution to not let the web.config file being copied automatically when the web application is published.
So a possible solution is to do not automatically deploy your web.config file. When your application is first published to some environment you copy your web.config file manually and immediately update the connection string s.t. it points to the right environment. On all subsequent deployments, your web.config file won't be touched which avoids to run into troubles. The disadvantage: of course if you modify other parts on your web.config file beside the connection string, you have to manually copy it on the other web.config files on the different environments. But that shouldn't be a big deal.
To avoid that you web.config file is automatically copied when you click on "Publish...", you have to open the properties of the web.config file and set the properties "Build Action" to "None" and "Copy to Output Directory" to "Do not copy" (see figure).
Well this is not really the most elegant solution because it may still happen that you have to change or add some new entries to the web.config file during the development. In this case you have to remember to copy those changes manually to the web.config file when you again deploy your application. This may be error prone because you have to remember those changes.

So a better solution is to externalize the critical part of the web.config file. In this specific case we have to externalize the connection strings from the web.config but potentially there could be also other settings where it would make sense. The following piece shows this section, where [DATASOURCE_HERE] etc.. has to be replaced with the right values of course.

Original web.config file
<?xml version="1.0"?>
...
<connectionStrings>
  <add name="MasterOracle" connectionString="Data Source=[DATASOURCE_HERE];User ID=[USER_ID_HERE];Password=[PASSWORD_HERE]" providerName="System.Data.OracleClient" />
</connectionStrings>
...
What can be done now is to create a new file in the same folder as the original web.config file and give it a meaningful name, i.e. "DBConnectionStrings.config" or "ConnectionStrings.config" etc. What's important is to use the ".config" file extension since this prevents that the file can be browsed over the web. Then the part of the connection strings in the original web.config file can be extracted and placed into the newly created file:

DBConnectionStrings.config
<?xml version="1.0"?>
<connectionStrings>
  <add name="MasterOracle" connectionString="Data Source=[DATASOURCE_HERE];User ID=[USER_ID_HERE];Password=[PASSWORD_HERE]" providerName="System.Data.OracleClient" />
</connectionStrings>

The orginal web.config file has to be modified to point to the new external configuration file:

Modified web.config file
...
<connectionStrings configSource="DBConnectionStrings.config"/>
...
Now I think my strategy should be evident. You can now let your web.config file be copied on each publish as usual but you prevent the copying of the external DBConnectionString.config by setting the properties "Build Action" to "None" and "Copy to Output Directory" to "Do not copy" . So the first time you setup your different environments you copy your DBConnectionString.config to each of the different locations and apply the necessary corrections such that the connection string points to the correct DB.

This is much a cleaner and more elegant solution as you do the setup once and then you don't have to remember on each publish to eventually also copy the new changes of the web.config file manually to each of the deploy environment.

UML Use Case "extend" and "include" relationships

From now and then I have to create UML diagrams to model certain parts of software projects, especially for the University. Initially, creating UML models, may seem annoying but in fact they can be very useful if they are applied correctly. So for instance an UML Use Case diagram can help a lot in explaining the main functionalities of a program, either to some other technical person or to the user itself (or even to create the diagram with the user itself). On the other side, modelling a whole system with a class diagram may be completely nonsense. Creating class diagrams makes sense for the critical / most important parts of the system, s.t. all the developers can take it as a point of reference. Modelling the whole system will lead to a lot of work that nobody will ever look at and which will soon again be out of date.

So I'm currently creating an UML Use case diagram to describe the basic features of my application I'm planning to develop and it always happens again to me that I come to the point where I have to search the web about the details regarding the "extend" and "include" relationships. Just out of the head it seems to be clear: "extend" is some kind of specialization, a use case that extends the functionalities of its base case etc...while "include" is a use-case which will be called as a consequence of invoking another one. But still there are these doubts...should this new use case be one for itself or should it extend this other one here...the boundaries are not always very clear.
Well here I've found a documention from IBM Rational Architect that explains the difference quite good (I think):

The [...] figure illustrates an e-commerce application that provides customers with the option of checking the status of their orders. This behavior is modeled with a base use case called CheckOrderStatus that has an inclusion use case called LogIn. The LogIn use case is a separate inclusion use case because it contains behaviors that several other use cases in the system use. An include relationship points from the CheckOrderStatus use case to the LogIn use case to indicate that the CheckOrderStatus use case always includes the behaviors in the LogIn use case.
The "extend" relationship is explained as follows:
You are developing an e-commerce system in which you have a base use case called Place Online Order that has an extending use case called Specify Shipping Instructions. An extend relationship points from the Specify Shipping Instructions use case to the Place Online Order use case to indicate that the behaviors in the Specify Shipping Instructions use case are optional and only occur in certain circumstances.
So the key point in the extends relationship is "optional"! It adds further functionality to the base use case which may be restricted by constraints. The following diagram shows this:
Consider the "Order Wine" and "Serve Wine" use cases. The "Order Wine" extends the "Order Food", meaning that wine may be ordered by the customer, but not necessarily (optional). Therefore the use case "Server Wine" has a condition on its extend relationship: "if wine was ordered".

Another relationship is the "Specialization/Generalization" relationship. The notation is a arrow with a white triangle at the end, basically the same that is used for defining the inheritance (extends) relationship in the UML class diagrams. The figure below (taken from Wikipedia) shows an example:
Another source of interest may be AgileModeling.com.

Floating figures and tables with Latex

Latex provides you with a lot of advantages when writing scientific papers. It allows you to fully focus on the content without having to worry to much about the formatting. Of course this works out well if you know the Latex syntax and thats also why I was a bit skeptic initially. I know MS Office really well and I'm therefore fast and productive. Nevertheless I tried Latex for writing a technical report for the Data Mining and Data Warehousing course at the university. And I was positively surprised. Once you know the basic stuff you become productive very soon. Learning the syntax wasn't a big deal..for a computer scientist :)
Anyway, I'm writing this post because I think that if you're a newbie (like me) you'll quite soon get into some trouble, especially when you have to deal with tables and figures. When I wanted to lay them out on the page, they just were not placed where I defined them on the source code. So I searched on the web and found the "[h]" attribute. So I wrote the following:

\begin{figure}[h]
  ...
\end{figure}
This however didn't place the figure exactly at the position defined in the Latex source but where Latex "thinks" it best fits on the page. When in your document you're writing however something like "...as shown in he figure below:" you want your figure to be displayed immediately afterwards in the next line and not two paragraphs further down. So, to overcome this problem, there are basically two possibilities. One is to not use the figure (or table) environment but just use the graphix include (or tabular for the tables). In this way however you cannot make use of tags like "caption" and "label" which may be useful.
The other possibility is to use the float package. For doing so you probably have to download the float package. Here's the URL where I downloaded it:
http://www.ctan.org/tex-archive/macros/latex/contrib/float/
Extract the "float.ins" file and run it through Latex (in your shell type "latex float.ins"). This will produce a file called "float.sty" which you can use in your project.

Now you can write
\begin{figure}[H]
  ...
\end{figure}
and your figure will be positioned exactly where you defined it in your Latex source. And that's basically what we wanted to achieve. The same works also with tables.

Here's another quite useful link on floating images and tables:
http://en.wikibooks.org/wiki/LaTeX/Floats,_Figures_and_Captions

Problems with character encoding on cookies

For preserving the search criteria on some page of our web application we're saving the different settings of the search filters into a cookie. So, when the user comes back next time we can restore the search filter settings that have been used previously.
Now however one of my working colleagues had the problem that some strings where not correctly retrieved from the cookie. Actually it was a character encoding problem. Characters like "ü,ö,.." were not displayed correctly after retrieving them from the cookie. I'm not sure whether you can set the character encoding of cookies. I don't think so, I've however not done any deep search on the web. Our solution was to do an url-encoding/decoding on the "critical" values of the cookie. So you can do something like

public void SaveValuesToCookie(){
   ...
   Response.Cookies["key1"]["valuekey"] = Server.UrlEncode(criticalValue);
   ...
}

public void LoadValuesFromCookie(){
   ...
   retrievedValue = Server.UrlDecode(Request.Cookies["key1"]["valuekey"]);
   ...
}

Microsoft Surface...the future of human-computer interaction?

Here are some videos about Microsoft Surface. I wonder how long it will take to see one of these live :)




(bad audio quality)

Del.icio.us links and three new projects online

My blog readers can now bookmark posts I've written with delicious, by just clicking on the "add to del.icio.us" link on the bottom of each post. The implementation was inspired by this blog entry which I found quite neat.

Moreover I finally managed to upload three new projects on my project page, namely

Connect4 is actually an "old" project I did during my Bachelor but did never upload yet. The other two are new ones.
Take a look at them if you're interested.

"Everything you always wanted to know about Google..."

This is a presentation done by a french consulting firm. The slideshow doesn't address technology but goes more into the analysis of the business part, of key business strategies that Google applies on the market. There are some interesting things, for instance, have you ever heared about "crowdsourcing"?? It's more a business term and it's basically the process of externalizing tasks onto the users (slide 19 in presentation). How can this be done?? The slide describes for instance how Google uses its voice local search for collecting millions of different human voices in a database. These voices will then be used to improve their speech recognition services ("speech to text" technologies) which again will then be used to index Youtube audio tracks s.t. you will be able to search "inside" Youtube videos (which to some degree is already possible) as if you were searching for some text on a webpage. So you see, although the launch of a new service may often seem as "just another service in the huge amount of available ones", but in fact, most often there is of course a very well defined business strategy behind.

All about Google
View SlideShare presentation or Upload your own. (tags: google seo)

Guidelines for promoting your blog

Some guidelines on how to promote and so to increase the traffic on your blog. These "rules" have been taken from the Blogger Help and I thought some of you may be interested.

  1. Set your blog to Send Pings. When this setting is activated, your blog will be included in various "recently updated" lists on the web as well as other blog-related services.

  2. Activate Your Navbar. Do this and you might start to see the effects right away! One of the features on the Blogger Navbar is a button called NextBlog - click it to visit the next Navbar-enabled blog.

  3. Install Email This Post. If you use Email This Post on your blog, people will be able to forward your posts to friends. This may not have an immediate impact on your site stats but it enables others to publicize your blog for you.

  4. Turn on Post Pages. By publishing every post as its very own web page with Post Pages, you ensure that your entries are way more link-able and more attractive to search engines.

  5. Turn on your site feed. When people subscribe to your site feed in their newsreaders, they're very likely going to read your post.

  6. Add your blog to Blogger's listings. When you add your blog to our listings it shows up in Nextblog, Recently Updated, and other places. It's like opting-in to traffic.

  7. Write quality content and do it well. If your "style" is bad writing, worse grammar, no punctuation, and an ugly design, that might be okay for a niche crowd. But the idea here is to achieve mass appeal, so fix yourself up a bit.

  8. Publish regular updates. Simple: the more you blog, the more traffic you'll get.

  9. Think of your audience. A good way to build an audience is to speak to one in particular. When you keep your audience in mind, your writing gains focus. Focus goes a long way toward repeat visitors.

  10. Keep search engines in mind. There are a few things you can do to make your blog more search engine friendly. Use post titles and post page archiving. This will automatically give each of your post pages an intelligent name based on the title of your post. Also, try to be descriptive when you blog. A well crafted post about something very specific can end up very near the top results of a search.

  11. Keep your posts and paragraphs short. Strive for succinct posts that pump pertinent new information into the blogosphere and move on. Keep it short and sweet so visitors can pop in, read up, and click on.

  12. Put your blog URL in your email signature. Think of how many forwarded emails you've seen in your day, and just imagine the possibilities.

  13. Submit your address to blog search sites and directories. People look for blog content at Technorati every day, are you on their list? You should be. Submit your blog's url to Technorati, Daypop, Blogdex, Popdex, and any other site of that ilk you come across.

  14. Link to other blogs. Links are the currency of the blogosphere and it takes money to make money so start linking.

  15. Install a blogroll. It's a very simple yet effective social networking scheme and it has the same result as a simple link if not stronger: traffic! So if you don't have one yet, sign up for a blogroll and get that link-list going.

  16. Be an active commenter. This is in the same vein as linking. Most comment systems also provide a way for you to leave a link back to your blog which begs a visit at the very least. So if you feel inspired, leave a comment or two in your blog travels. It behooves you.

  17. Enable Following on your blog. Following a is a great way to keep your friends updated on the latest activity on your blog. New blogs will have this blog feature enabled by default, but for older blogs you will have to enable it from the Layout | Page Elements tab.