February 2008 Entries
Today I had to tear apart and refactor one of core pieces of tool I'm working on. Oh, and I had to do it fast. At first, I was like: "Hey, you can't change that, it was supposed to stay the way it is now!". Next I started to refactor, changing one by one, all the pieces I needed to change in order to achieve desired effect. I was refactoring, compiling, testing... and again refactoring, compiling, testing.... And ultimately when all tests were once again green - I knew I was done. I felt confident. Thanks to TDD and...
Those of you who visited my blog yesterday might have noticed that it was down. I fixed problem with Subtext's export to BlogML I blogged about recently, and I decided to take a plunge, leave Subtext behind and move to BlogEngine.net. As you may notice if you read it on the website, not as RSS, I ended up rolling back to Subtext. BlogEngine by default does not use SQL database, but stores everything in XML. If I wanted to keep on using my database, I needed to do the following: Add connection string to web.config Change default provider from...
I've missed it, but two days ago Smarties v1.0 has been released. This is a new productivity plug-in for Visual Studio, with lots of useful refactorings, and strong emphasis on managing #regions. There are quite a few screencasts on the website, so better go and check them out for yourself. The tool is not free, but very reasonably priced, and there's a trial version. Highly recommended. Technorati Tags: Smarties, Reafactoring tools, Productivity tools
I've been using Subtext for this blog since its very beginning 10 months ago. Back then I installed what was the latest version (1.9.5 with later security-fix). I was pretty happy with it. I don't have high needs: it is supported by Windows Live writer, is stable and just works. However I've been receiving emails from people complaining that they cant post comments to my blog. I checked the issue, and I was able to reproduce it, with error message presented on the screenshot. I googled for it, but I didn't find out anything useful. I decided to upgrade my...
Let's look at an example: This is somewhat simplified diagram of classes that are part of object model I created for a certain XML format (it doesn't reflect physical structure of XML file, rather it's a conceptual, higher level model). Document can contain few types of elements. To achieve this, it has a method Add, that takes a ValueElement (which is an abstract class). The problem here, is that it is not obvious what is a ValueElement. You have to know what you can put into Add method, which means, you have to know what ValueElement's children are. Their...
I found pretty slick new feature in C# 3.0 that I haven't seen anyone mentioning before. In C# 2.0 to initialize List<T> inline you had to use arrays, like List<string> keys = new List<string>(new string[]{"key1"});
As you probably already know, in C# 3.0 you can initialize collections in in similar way like you did with arrays in C# 2.0:
List<string> keys = new List<string>(){"key1"};
This has been said many times in many places. What I missed however, was that syntax for initializing arrays changed as well. Now you can simply write:
string[] keys = new[]{"key1"};
Did you know that?
Technorati Tags: C# 3.0, array initialization
Camel humps intellisense. Start using it, and you'll be wondering how you could ever have lived without it. Technorati Tags: ReSharper, ReSharper 4.0, EAP, Intellisense
I found nice trick. Instead of writing: private string SetNewName() { string newName = GetName(); _name = newName; return newName; }
you can write
private string SetNewName() { ...
One of the hottest news in last week was end of HD formats war. HD-DVD got dropped, Blu-Ray people are more than happy, but days of their format are counted as well. Arguably Blu-Ray won't even last as long as DVD (12 years and counting). Here's why: Optical disks gained popularity in times, where CPM (cost per megabyte) of using them was way lower than HDD. Hard disks had capacities like 2GB, and buying three CDs 650MB each was way cheaper. It was economically reasonable to buy CDs, and keep your files there. I don't recall the numbers but I'm...
Go get it here, and while you're downloading, read release notes. UPDATE: And suddenly I'm much less happy... :( UPDATE2: Well, maybe not that much less happy ;) Ilya Ryzhenkov said... We will renew evaluation period regulary, so all you need is use latest nightly build all the time ;) Technorati Tags: ReSharper, ReSharper 4
I'm currently writing tests for a piece of code that has lot of events flying here and back. Something like: 1: public class Caller 2: { 3: public event EventHandler<CancelEventArgs> MyEvent; 4: 5: public void Call() 6: { 7: if (MyEvent != null) 8: ...
Tool for managing windows services in Windows XP allows you many things, but you can't unregister (delete, remove) a service with it. There is however a command line tool that allows that. Remember that unregistering important services may break your system. If you aren't sure what you're doing - don't. You have been warned. First you need to check real name of the service (not it's display name). To do this go to Control Panel-->Administrative Tools-->Services, and find the service you want to uninstall. Right click it, and choose "Properties". Then, on the "General" tab, find "Service Name"....
Since probably Windows 95 or even earlier (I'm not that old) Desktop did not change. There was Windows 98 and it's active content, Linux with its 4 desktops and more recently Compiz, but they all were just variations around basic idea: 2D space where you put some icons, some background and that would be the end of it. Until... I saw this: And then I installed this. It seems to be some variation of the same idea (much limited compared to what is presented on this YouTube video) but it has one simple advantage: it's available right now....
Joe Developer once had to read options from configuration file, where each line looked basically like this: option: first;second;third;;fifth; Each line consisted of option name, followed by few spaces, and its parameters delimited by semicolons. Now the question is: how would Joe get to those parameters? The most elegant way would be using Regular Expressions, but Joe has strong allergy to them. For this simple example String.Split method will do. Joe rolled up his sleeves and crafted that beautiful masterpiece of code: 1: ...
Regular Expressions are very powerful and useful, but one thing that stops them from being widely used, is their complexity. They're commonly referred to as write-only language. Even my colleague, who is very proficient at crafting complex regular expressions often deletes the whole thing and starts from the scratch. For easy tasks however, like matching a literal piece of text, you can use two static methods of Regex class: Escape and Unescape. Escape escapes all characters that have special meaning in regex language, and Unescape, does the opposite thing. ...
January came and went, and much anticipated ReSharper 4.0 Early Access Program is still not available. It seems, that we'll have to wait another two weeks, before I stop turning off ReSharper every time I want to write something using new C# 3.0 features. What bothers me however is that, although I do understand the vastness of the tool, I'm more and leaning towards agreeing with Alan's comment on a recent post. C# is getting bigger, .NET is getting bigger, and it looks like JetBrains starts having troubles to keep up. I hope I'm wrong. Technorati Tags: ReSharper, EAP, C#...