I wrote before about cool uses of anonymous methods (sometimes called anonymous delegates). Finding uses for generics is also a no-brainer – as a minimum, you’ll use generics with the generic collections.
But the iterators, supported through the new yield keyword, are slightly more tricky. It is easy to write a trivial example on how to create them yet it’s another thing to make a compelling case.
However, I found a case where it’s almost always applicable. Assume you have a class B somewhere in your code and that this class contains a collection of items of class C. Something like this:
class B
{
private List<C> _coll;
internal IEnumerable<C> GetAllCsThatSatisfySomeCondition()
{
foreach(C c in _coll)
{
if(/* complicated criteria */)
yield return c;
else if (/* extra exit criteria */)
break;
}
yield break;
}
}
Now you can use this from some class A like this:
foreach(C c in _b.GetAllCsThatSatisfySomeCondition())
{ /* do something with the C's... */ }
The elegance in this is that you are not exposing the way C’s are stored in B, nor the complicated criteria by which they are taken out. Think about the alternative – you’d have to expose elements of _coll somehow (maybe through a custom indexer) and to reason about iteration directly in the last foreach loop. Not nice, especially if this code is supposed to be called from many places, which would either lead to duplication or the awkward placement of the wrapper method (where would you put it?).
I am so glad I can base my product on the CLR 2.0 and not 1.1.
P.S. I am shocked to find that Java got the foreach equivalent only in the latest (1.5) revision. WTF?
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
This is unbelievable. I know that there are developers out there not using Source Code Control (SCC) systems, but I treat them as either hobbyists or amateurs. Developing without SCC is a disaster waiting to happen, if you ask me.
Naturally, I was once developing without SCC too. But as soon as I was given a chance to use one (even if it was a crappy Visual SourceSafe at the time) there was no turning back. That was in 1997 and I’ve never developed anything without SCC since then. All of that work was for someone else – I was either an employee or a contractor. But when the time came to work for myself, I took extra care to use a good SCC for my own business, even if I am only a single developer.
If you followed the above link you will notice that there are several entrepreneurs – µISVs with a single developer usually – who have been (successfully?) living off of their software for years not using SCC.
I just don’t get it. Is changing the habits that hard? Aren't the advantages of using SCC far better than disadvantages? There are at least three free SCC systems out there – Visual SourceSafe1, Subversion and Vault2. Some integrate into development tools well, some have separate GUIs, some do both and some are best used from the command line – there’s something for everyone.
I am amazed at the people’s ability to survive for years without a SCC. Apparently, this is good news for the commercial SCC systems out there – there are developers who are aware of the existence of SCC systems but have not tried them yet.
1Visual Source Safe is not free, but most of the µISVs on the Microsoft Windows platform are Empower program members and get it with the rest of the development tools.
2Vault is free for a singe user which is exactly the scenario for most of µISVs.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
These days I read around one digital for each three to five physical books. The digital format has many advantages (mainly searching and hyper-linking to and from chapters) but is still not easy on eyes enough.
Even though I only read one page at a time, I realized that I feel a lot better having two facing pages open at all times. Either way, modern computer screens are a lot wider than are tall so if one page can be read comfortably two will most likely fit as well. My laptop screen is great for book reading – LCD with ClearType rocks – but its 1920x1200 resolution on a 15.4” diagonal is a bit too much. I guess if I had a 17” screen things would look better, but I’ll have to wait and see.
It’s not just the small fonts. it’s the book layout and typeface chosen. Ironically, physical books seem to have a lot better look and feel in spite (or is it because) of the fact that nothing can be changed once the text is printed.
Up until very recently, my favorite publisher was Microsoft Press; note that I am talking about look of the books and if they are easy on eyes, not about content. Microsoft books always had great rounded and quite large font, margins that are large enough and a cool font for code listings.
My new favorite is everything from the Pragmatical Programmer’s series – similar font, great book size and paper thickness and the most excellent font for code listings. The even better thing with this publisher is that they often sell the physical book and the digital (PDF) version together and that the digital version looks almost identical to the printed one.
Everyone should look at how these guys are doing it and copy it.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Last night one of the two drives in my server machine died after a short (but violent) power outage (or surge). Since the drive was part of the RAID0 strip (two 40GB drives imitating one 80GB drive) all of my data was gone. I know, I know, I should have had an UPS or something similar.
More precisely, everything that I did not back up was gone. In the end, we lost a few e-mails of my wife and a single document (it was a final revision of a small manual, I still have a recent copy). I used the chance and when restoring important data (mostly source code history) I ditched the SQL Server 2005 Express + MSDE combo (long story) and went with SQL Server 2005 SP1 only.
That did turn into a world of pain, because Management Studio Express (MSE) did not allow me to change a few things because a text box was not filled in. It was not filled in because it was disabled by the MSE, so I struggled with it for a while until I found a workaround.
When you restore a database backed up from MSDE, users and their rights seem to be imported correctly. Unfortunately, the logins for the users do not exist and you can’t create them because you want the logins to map to the users restored from the backup, which you can’t do. The solution is to delete the users and create new logins and map them to newly created users with proper rights. That you can’t do because restored users got a fake schema to own, so you first have to delete the schema, delete the users, then create logins and associate with the new users (these will be automatically created for you). If it sounds confusing, that’s because it is 
Besides from this, the rest was a breeze. A big thank you goes to NVidia for showing the other companies how the driver installation should look like – unified for all (recent) versions of the product. Just a few years ago I wasn’t even able to download a full driver version for my Audigy card (some genius decided that only driver updates should be available online, go figure) but today I was very pleased to find a unified driver for Windows XP that covers all variants of Audigy.
In the end, this was one of the easiest reinstalls ever, but it still took almost 5 hours.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
You have probably heard of Ruby in Steel, a nice new add-in for the Visual Studio 2005 that enables Ruby editing and debugging. Since version 0.7 they also support Rails in the shape of .rhtml color coding and verification. Nice! Just to be clear – this is not Ruby running on the .NET platform, it runs on the original VM. If you’d like to see a great preview of what it will be like to run Ruby on the .NET see the Ruby.NET website.
Small problem – I am guessing this is due to the prerequisite to the installation required by Visual Studio SDK – all the color coloring for your C# projects will vanish! Not that the color setting will be reset to the default, the settings themselves will disappear. Since one of the important reasons for me to use Reshaper is great coloring support (I’m a sucker for color coded source) I could not stand the new situation.
Fortunately, it is easy to fix the problem – just start Resharper installation again and choose the option to Repair the installation. The settings will show up again (all colors will unfortunately be reset to the defaults) while Ruby color coding settings will not disappear. Finally you get both of them. I only fear that the next installation of Steel might disrupt color coding again…
By the way, if you are not a Visual Studio person but like Eclipse better, there is a Ruby editing add-in for Eclipse and even RadRails aimed at Rails development. There definitely is no reason to complain about not having Ruby development tool-set any more (except when trying to make the existing ones better, of course
).
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
As I mentioned in one of my recent posts, one of the two most frequently asked questions about the .NET development is how to protect your intellectual property – in other words, how to prevent people from decompiling the code (IL) into the source (Lutz Roeder’s Reflector is a great tool that shows how easy the process is with the right tool, it can even decompile into several different languages).
Naturally, a sub-market emerged populated with the tools – obfuscators – that will make decompiled code extremely hard to read. It is still a young segment even though there are several solid players in it with products that vary a lot in the price and the capabilities.
I have tried a few of these tools and I have generally been unimpressed. The whole process is too hard and requires a lot of fine tuning. Thus when my friend Vladimir decided to build an obfuscator that will require very little fuss, be deeply integrated into the Visual Studio 2005 and work reliably well with all the modern language features like generics, I jumped at the opportunity to beta test it.
So far, it worked really, really well. It has a clear, step by step wizard-like interface, uses sensible defaults and generates a great preview of what the resulting code will look like. In a few places where the code did crash because of the obfuscation, it was really easy to see why (data binding in the .NET 2.0 uses reflection with the names of properties as strings, so you need to exclude these properties from obfuscation). If you’d like to give it a try, a public beta is available since yesterday on the Outer Self blog (Assemblur’s web site is still under construction).
Highly recommended.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
Well, the title says it all. Just now I have started the Visual Studio 2005 and for the first time I saw the dialog pictured on the screenshot to the right. Apparently, when I exited Visual Studio 2005 something went bad (I did not notice) and when started again Visual Studio 2005 noticed that some of the backup files have not been deleted and offered to restore them.
I checked the file in question and it’s the same byte-for-byte between the version I have and the one that got restored. Still, this might come handy one day. I always liked auto-save features, especially when I did not have a UPS (read: laptop with batteries) 
Oh, the name of the product – NTorrent – is just a code name (my P2P application is based on the BitTorrent and is built on the .NET, thus NTorrent).
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
For those of us who will ship their first product on the WinFX platform, the story on the deployment is a very important one. In fact, for all those shipping applications that use the .NET platform this has been a problem in this way or another for quite some time.
The deployment of the .NET based applications is probably the second most frequently asked question on the Internet, right after the one about protecting your IP by preventing code decompilation. It is still a mystery why hasn’t Microsoft made the .NET 1.1 and later the .NET 2.0 required system component update for Windows XP, just like Service Pack 2 was made mandatory.
It was even more confusing to predict what will happen in the Vista time-frame. There was a lot of confusion regarding the version of the .NET that will come pre-installed with the Vista. Even worse, there was rumor and speculation that there will not be a pre-installed version.
Well, now we at least now one thing for sure - the .NET platform will be pre-installed with the Vista. This is to be expected but still good new for the ISVs that will start shipping their products with the Vista wave. On the other hand, the way that naming turned out is both good and bad.
The good thing is that at least for the consumer, this is a good thing. Want to explain to the user what the dependency of your software is? It’s the .NET 3.0 (notice that there are 408(!) comments to the announcement of WinFX to .NET 3.0 name change at the time this post was written). How do you install this? Microsoft provides the installer that is smart enough to install only what’s necessary.
Turns out that the 3.0 version “envelopes” the 2.0 version in a… weird way, looking from the perspective of the previous .NET versions. You see, all the previous versions were a “single package” versions – you got 1.1 version of the compilers, runtime and all the libraries, even though the compilers and runtime might not have changed much between 1.0 and 1.1.
What is happening now is that Microsoft has decided to independently evolve the compilers, runtime and the libraries. So, the .NET version 3.0 keeps the .NET 2.0 compilers and runtime, but adds libraries like WPF, WCF and WF. The next version of the .NET (tentatively version 3.5), that’s the one that will improve on the C# (version 3.0 to confuse the matters) and VB.NET (version 9.0), will improve on the compilers (languages changed!), keep the 2.0 runtime and add libraries like LINQ. Sounds confusing? Only until you think about it a little. Compare the situation with Java 1.5 a.k.a. 5.0 – the Java compiler was upgraded to support generics, but the virtual machine (the runtime) was not changed. In the same way the new features like LINQ will require newer compilers and new libraries, but will not require a new runtime. Still confused? A detailed blog post from Jason Zander might help.
In the end, it is important to note that some confusion exists only in the realm of the .NET developers. Users will have a clean upgrade path – version 2.0, 3.0, 3.5… If I had to choose between a lot of work for me and a simple story for the customer or the other way around, I pick the former every time. As long as I can explain my dependencies to the user with a single simple sentence and have a single installer that will do all the work, I am happy.
On the other hand, I pity the developers of the Fusion sub-system in the .NET (the one responsible for finding the right version of the assembly and loading it) now that consecutive versions of the .NET get installed into several directories reusing pieces of the previous (and even the one before that!) version 
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
As an aspiring µISV I am very interested in all the ways to promote my future product. When I saw the announcement for the Project Glidepath early access program (EAP from now on) I had to check it out.
On a first look, what’s not to like – assuming you’ll be using .NET 3.0 (I will) and plan to ship about the same time Vista ships (I do) all you need to do is to apply and (if you are accepted) Microsoft will help publicize your app. Sounds great?
Well, yes and no, because as always the devil is in the details. The intent is definitely good and the work put in the Project Glidepath is non-trivial, but I think that the whole thing is somewhat misguided. Here’s why…
Let’s assume that I am a perfect fit for the EAP as described above. I can easily commit to all four points:
- to ship 90 days within Vista availability
- to use C# and
Project Glidepath1
- to build the app using .NET 3.0
- to allow2 Microsoft to promote my app
What do I get in return?
- early access to updated builds of Vista and related technologies
- copy of Visual Studio 2005
- regular conference calls and private forum
- direct technical support (limit 25 hours) over the course of the EAP
Here’s the thing: if I am an aspiring µISV, I already have access to Vista and related technologies. Why? Because I am most likely either paying (not cheap) for my MSDN subscription or I am subscribed to the most excellent empower program (very cheap).3 For the same reason I already have a copy of Visual Studio 2005. If I needed both the access to Vista and Visual Studio 2005 then I really am either naive or a beginner – Vista will ship in about six months and I plan to ship a product but don’t have basic tools and the platform? Not likely.
The third point (conference calls, private forum) looks to me as “hype and filler”, said one of the contributors to the great Business of Software (BOS) forum over at Joel. Especially the private forum thing – if we are all testing the platform, why not share the findings with the other developers who are also developing for Vista in one of the MSDN forums?
The only thing that’s left that can be useful is direct technical support for those rare occasions when something looks really, really weird. My experience however has been less than positive about direct technical support in general – if you encounter a problem that you’ve thoroughly studied, went to all the relevant forums and searched the Internet and did not find the answer, the chance is high that support will not be able to help you.
The whole things looks and smells quite similar to something that I did participate in: Channel 9 ‘s PDC 05 contest. Turns out that the same team/person that provided Shareware Starter Kit (SSK from now on) is doing the Project Glidepath (coincidence? I don’t think so). After using the SSK I can attest that its quality has been… less than satisfactory, mildly put. In fact, as soon as the competition was over I could not wait to remove the code from my codebase.
The whole SSK (and looks like Project Glidepath is the same) was just too much hand-holding and step-by-step process. If you need all that then you are probably not a µISV material. It takes a lot more than a “silver bullet” solution like Project Glidepath to launch a successful µISV. For more info just go visit BOS forum and see for yourself what real people who already have products on the market are facing every day.
On the other hand, I understand that for Microsoft it is beneficial to look cool (Project Glidepath’s updates are delivered over RSS straight into Visual Studio) and support the µISVs. After all, these are the people that are building for the next Windows platform and in a way, their products will (if only by little) help sell more Windows licenses. I just think that empower program plus an ISV buddy program are more than good enough for practically everyone. For those that will still take the EAP opportunity, I say: good luck and all the best. Maybe something cool comes out of it.
1After a direct question I posted to the Michael Lehman's blog this does not seem to be necessary. Or did I misunderstand the answer? I know I don’t need Project Glidepath in general, but do I need it for the EAP?
2Why wouldn’t I allow Microsoft to promote my product? After all, the main problem most µISVs face is spreading the word about their product, not developing it.
3I’d really love to provide the link, but Microsoft partner site requires you to login with a Windows Live ID (a.k.a. Microsoft Passport). That’s not a problem for me, but it’s a bit useless for (many) people who hate don’t have Windows Live ID.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5
The success of AJAX and Ruby on Rails points out at another small “revolution” going on for the Web applications – the change in the underlying markup language used to shuffle data back and forth. Classic examples are YAML and JSON. A little bit of history on both and an inspiration for this blog post is here: JSON on the Web, or: The Revenge of SML.
I generally agree with the points presented in the article but I have a thing or two to add. Both YAML and JSON are pretty much specialized object serialization formats – the former for Ruby and the latter for JavaScript. In theory, they could be used for other languages too, but in practice these are the two places where they are used.
It all makes perfect sense. If what you are trying to do is to serialize and deserialize an object graph, round-tripping through the XML might not be the best thing to do. It’s not too hard to design a specialized format that will cover your needs better than an equivalent XML, where better is usually defined as faster to parse, easier to read (by a human) and more compact, as long as you narrow the scope enough.
But the point is that this does not make XML any worse than it is. I see XML as an interchange format between different operating systems, machines and different programming languages. XML is often used as a format for a DSL (domain specific language). It may not fit hundreds of tasks very well, but it will fit thousands good enough.
The XML is never (and I postulate it never was) a be-all solution to various kinds of problems. Here’s an example – since Ant, we have seen several build systems (libraries that help you build your code) based on XML, one of the latest being Microsoft’s (quite well thought out) MsBuild. All these build systems are easy to author, easy to read and work really well. One would think that all has been said an done regarding build systems (using current generation tools and languages). But then rake came out and changed everything. Instead of “interpreting” or deserializing the build DSL (expressed as XML) the DSL is embedded in the host language (Ruby). The integration works even better than Ant and MsBuild IMHO. For a really thorough and well-written discussion check out this article by Martin Fowler: Using the Rake Build Language.
The way I see it, JSON, YAML and XML will continue to co-exist; we may even see the proliferation of other specialized languages. That does not make any of them better or worse than the other – they are not here to compete, but each to be used well in its problem domain.
Be the first to rate this post
- Currently 0/5 Stars.
- 1
- 2
- 3
- 4
- 5