# Tuesday, October 20, 2009
Sorry for the inaccessibility of the site for a few days. In is totally unacceptable, but this is the price for running server at home. The cause of the site outage was good old home router WBR-3406TX. It was really old and it served well till ... the end.



First thing in the yesterday morning I did was to order a new router. I did a little research during the weekend which one to buy. I was totality about Linksys WRT160NL. It has really some nice features (USB port, detachable antennas) on top of a powerful hardware (400Mhz CPU, for instance). I would flash it with DD-WRT firmware.

But in the end pragmatism won. I really need only basic routing functionality. So I smartly picked up a most popular router in one of the popular Slovene computer hardware store. It is TP-Link TL-WR642G.



Probably you do not know even the manufacture. Do not now worry, I did not either. But anyway, the idea worked perfectly. I got inexpensive reliable router which do exactly what I need and nothing more. And that is what we should always do. Do nothing more and nothing less what is necessary.

posted on Tuesday, October 20, 2009 7:52:23 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, October 06, 2009
Do you like to have a neat and transparent code base? One of the foundations of this in .NET are regions (#region ...). A smart usage of regions significantly increase readability of the code base, but it can also diminished it if it is misused (typically example would be heavy region usage in methods).

I have find out the following class region structure really neat:

But there is the problem. Maintenance of this structure. But there exists a great tool to this instead of you - Regionerate.

Regionerate is an automatic layout enforcement tool for the C# programming language as it also stated on the tool's homepage. This tool is Add-in to Visual studio. It is really simple to use, just hit a keyboard shortcut "Ctrl+R" and the tool will do the rest or right click on the code edit panel:


Code became instantly Regionerated. But question arise. In what way code became regionerated? What are the names of the regions which members go into which region? Well there this utility really shines. You can totally customize it. I will blog about this in another post.

Regions in the upper picture were created with Regionerate tool. Did you notice the number of members in the end of the name of each region? Nice.

Out of the box region structure really did no fit me, so I customize it. You can find the customization file at the end of this blog post.

You can import customization file easily into the tool, just click "Regionerate this" and then "Settings" and just select the proper XML customization file. Tool have some problems with updating or changing customization file, sometimes change is not instantaneous.

It would be nice if you post your favorite region structure in comments.
 
CustomCodeLayout.xml (2.11 KB)
posted on Tuesday, October 06, 2009 12:55:30 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Friday, September 18, 2009
When you are setting up a technology stack for new business application, well any kind of application really, one of most basic decision is what presentation tier technology you will use.

You have to ask two basic questions.

  • What is demanded richness of user experience?
Must be very responsive? Do you need fancy data manipulation? Will application handle large amount of data? Are those very dynamic? Will application be used just to present data?
  • How accessible application must be?
How portable your application really must be? What will be typically users of this application? What client software and hardware platforms are targeted? How often the application will change/update?



This picture nicely summarize those questions, what technology you should use based on your answers to those questions.

To answer to the question in the title. As far as I know typically business application and if I answer to the user experience and accessibility questions I would definitely say, Silverlight technology delivers the best trade off between user experience richfullness and accessibility that typically business application nowadays requires.

Related (picture source):
posted on Friday, September 18, 2009 10:49:09 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Sunday, September 13, 2009
On meta.stackoverflow.com Joel announced a need for countdown application for the coming DevDays, as I am planing to attend one, I have decided to make one. Maybe I will watch my counter at the conference. ;)

It looks like:



Source code: PeterStegnarDevDaysCountdown.zip (198.51 KB)

I have used WPF, .NET 3.5. The speciality of this solution is custom Stackoverflow digits. :)

Short manual:
-you can find exe in "PeterStegnarDevDaysCountdown\WPF_StackoverflowCountDown\bin\Debug"
-start the app with the following parameters, for example: 0900 "DevDays begins in %s"
-just hit an "Esc" key to exit

Core functionalitiy is, of course, countdown:

            if (second != 0)
            {
                second--;
            }
            else
            {
                second = 59;
                if (minute != 0)
                {
                    minute--;
                }
                else
                {
                    minute = 59;
                    if (hour != 0)
                    {
                        hour--;
                    }
                    else
                    {
                        throw new ArgumentNullException("No valid time entry!");
                    }
                }
            }


What do you think?

posted on Sunday, September 13, 2009 12:00:59 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, September 02, 2009
Today I have compiled a nice podcast MP3 CD with Stack Overflow podcasts from episode 38 to 57. Yeah I know is strange selection, but you have to start somewhere. :)

NerdCD is meant to be regular geek podcasts compilation. Which will contain mainly the following podcast sources:
Why NerdCD, anyway?

Well it is primary meant to be record to the CD (size of NerdCD is just under 700 MB) and to be listened in the car. Of course you can upload it on your favourite music player (iPod, mobile phone, you name it).

Where can I get I?

It will be distributable in a torrent form.

NerdCD1 torrent: NerdCD1.txt (12.97 KB) (Caution! Rename txt to torrent file extension - torrent extension is blocked on my server, sorry)

Needless to say, seed it! :)
posted on Wednesday, September 02, 2009 9:16:33 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, September 01, 2009
I would like to point out the difference between (local) and localhost. Those special "addresses" are often used in connection strings.

There are common misconception that, those address are the same. This is not the case.

"... it depends on the provider you're using to connect. If you're using the SQL Server Native Client or the .NET Data Provider for .NET 2.0 the behavior is the same regardless of which name you use (localhost/(local)/or "."). These providers will first try to connect using Shared Memory, then try to connect using TCP/IP and then finally Named Pipes."

It is not advisable to use (local) for other providers, because of the ambiguity (you have 3 different ways to access the SQL server). It is better to explicitly define the connection type (typically TCP/IP), with localhost.

More info:
http://msdn.microsoft.com/en-us/library/ms187662.aspx
http://msdn.microsoft.com/en-us/library/ms191260.aspx
http://msdn.microsoft.com/en-us/library/ms189307.aspx

posted on Tuesday, September 01, 2009 5:54:42 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Monday, August 31, 2009
Sometimes you need a control over browser window behaviour, i.e. open a new one and close it, eventually.

This is really simple. All you need to write is one liner code.

To open an window:
window.open ("http://www.google.com","window"); 
Then you can close it by:
window.close();
In ASP.NET you have variety of ways to achieve browser window close. One example:
closeButton.Attributes.Add("onclick", "window.close();")
By this, close functionality is dynamic added to the control event.

Important: you can close a browser window with code which was open by the code.

However, this open/close window java script technique is more or less obsolete. If you need to display a special "window" to the user, you should use modal windows. ASP.NET AJAX have a nice control, called "ModalPopup".

posted on Monday, August 31, 2009 7:24:45 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Wednesday, August 26, 2009
How to get the file extension from string file name?

Well brute force approach would be something like that:

string fileExtension = args.FileName.Split('.').GetValue(args.FileName.Split('.').Length - 1).ToString();

Pretty ugly, in spite of one liner code.

Well it turns out that the framework has support for this functionality:

string fileExtension = System.IO.Path.GetExtension(fileName);

Much better, right?

It is good to remember that .NET Framework contain a lot of functionality that you would not think about at first place. That's why is good to check every time is something smells that it could be in .NET Framework. You may find it.

posted on Wednesday, August 26, 2009 4:43:41 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, August 25, 2009

Roy Osherove is giving an hands-on TDD Masterclass in the UK, September 21-25. Roy is author of "The Art of Unit Testing" (http://www.artofunittesting.com/), a leading tdd & unit testing book; he maintains a blog at http://iserializable.com (which amoung other things has critiqued tests written by Microsoft for asp.net MVC - check out the testreviews category) and has recently been on the Scott Hanselman podcast (http://bit.ly/psgYO) where he educated Scott on best practices in Unit Testing techniques. For a further insight into Roy's style, be sure to also check out Roy's talk at the recent Norwegian Developer's Conference (http://bit.ly/NuJVa). 

Full Details here: http://bbits.co.uk/tddmasterclass

bbits are holding a raffle for a free ticket for the event. To be eligible to win the ticket (worth £2395!) you MUST paste this text, including all links, into your blog and email Ian@bbits.co.uk with the url to the blog entry.  The draw will be made on September 1st and the winner informed by email and on bbits.co.uk/blog

posted on Tuesday, August 25, 2009 8:34:12 PM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback
# Tuesday, August 11, 2009
A jQuery library quickly emerging really popular - and for a reason. I think it is one of the best JavaScript frameworks. You can do fancy stuff really fast and clean.

You can start a Getting Started with jQuery. On the jQuery homepage you can find a lot of nice tutorials. If you have not try jQuery, please do. You will be amazed.

Bassically what jQuery brings to web delopement is that it separates HTML and behaviour. Similarly what CSS brought: separation of presentation and HTML.

There are a great tool named Firebug, which really helps with web development. This tool surely demand a separate post. You can inspect a web page, play with CSS on the fly, debug, use a console ... Here it comes a jQuery. You can write a jQuery instruction right into the console, and it will be applied on the fly. Amazing. All you have to do is to "jQuerify" a web page.

Another great thing to know when you work with jQuery is what the selector will actually select. You can try a SelectorGadget tool which shows the most appropriate selector for the selected element(s). This tool is so great also because all you have to do to run it, just click a "link" when you are on the desired page to be check. Great!

More on Firebug and jQuery in the great video:

posted on Tuesday, August 11, 2009 7:20:20 AM (Central European Daylight Time, UTC+02:00)  #    Comments [0] Trackback