Prashant Sridharan, Microsoft group product manager for Visual Studio, announced Monday, March 26, 2007, that Microsoft plans to release Visual Studio code-named ‘Orcas’ by the end of the year, and it also plans to release Visual Studio code-named ‘Rosario’ (the next version after ‘Orcas’) within an year timeframe after that. A CTP for ‘Rosario’ might be available about the same with the ‘Orcas’ release. This page describes Microsoft’s future releases of Visual Studio: http://msdn2.microsoft.com/en-us/teamsystem/bb407307.aspx, but this may not be yet updated.

As for what concerns the code-names, Brian Keller, a Technical Evangelist for Microsoft Visual Studio Team System said:

For the past several years we’ve been using north west locations as code names. The pattern is that with each release the location gets further from Seattle (not sure why we decided to do that but that’s the pattern). Everett (the code name for VS2003) is a city just North of Seattle – there’s a big Naval base there: aircraft carriers, the works, pretty cool. We really didn’t have much of a code name for VS2002 – I can’t actually remember why, we just referred to it as VS.NET. After Everett, came Whidbey (VS2005 and an island just off the coast north of seattle) and now we are working on Orcas (another island a bit further north west). [...] We created the Rosario code name to describe some work that we (VSTS) really want to get done and doesn’t fit in the Orcas release. In a sense Rosario is a place holder code name. As Orcas unfolds and the rest of the division turns their attention to what is next for them too, we may see changes in what we currently believe our Rosario plan is. For now we’ll plow ahead with what we think we are doing.

Hits for this post: 5491 .

LINQ is a valuable feature for database and XML programming, but not only. Basically, you can use LINQ with everything that returns an IEnumerable. Here is an example, when I want to list the directories of a parent directory, in alfabetical order, and grouped by the file attributes (first all that have only the flag Directory set, then those that have both ReadOnly and Directory, etc.).

First, let’s try how you would put this clasically in C# 2.0. Basically you need these:

  • obtain a list of directory names
  • create a sorted dictionary with the key representing the file attributes, and the value a list of directories
  • iterate over the list of names and create a DirectoryName object
  • add the object to the list corresponding to the key represented by the directory attributes
  • iterate over the dictionary and print its content

The code I wrote for that looks like this:

void ClassicList(string path)
{
    string [] entries = System.IO.Directory.GetDirectories(path);

    SortedDictionary> dic =
        new SortedDictionary>();

    foreach (string entry in entries)
    {
        DirectoryInfo dir = new DirectoryInfo(entry);

        try
        {
            dic[dir.Attributes].Add(dir);
        }
        catch (KeyNotFoundException)
        {
            dic.Add(dir.Attributes, new List());
            dic[dir.Attributes].Add(dir);
        }
    }

    foreach (KeyValuePair> group in dic)
    {
        Console.WriteLine("Directories with attributes: {0}", group.Key);

        foreach (DirectoryInfo dir in group.Value)
            Console.WriteLine("  {0}", dir.Name);
    }
}


With LINQ, things get much simpler, as you no longer need to create a dictionary. You can apply SQL-like queries on objects. What you have to do is:

  • obtain a list of directory names
  • create a query to select the directories and group them according to their attributes
  • iterate over the result and print the its content

This is how it looks like:

void LinqList(string path)
{
    string[] entries = System.IO.Directory.GetDirectories(path);

    var result = from dir in
                     from e in entries select new DirectoryInfo(e)
                 orderby dir.Name
                 group dir by dir.Attributes into dirGroups
                 orderby dirGroups.Key
                 select dirGroups;

    foreach (var group in result)
    {
        Console.WriteLine("Directories with attributes: {0}", group.Key);

        foreach (var dir in group)
            Console.WriteLine("  {0}", dir.Name);
    }
}


Let’s take the querry line by line and see what it does:

  • from dir in from e in entries select new DirectoryInfo(e)creates a DirectoryInfo for each element of entries and uses the resulted array as source
  • orderby dir.Nameorders the DirectoryInfo array by the name of the directories
  • group dir by dir.Attributes into dirGroupsgroups the directories by their attributes into dirGroups
  • orderby dirGroups.Keyorders the group by the key
  • select dirGroupsselects the groups

And that’s all. You don’t have to struggle with creating dictionaries, maintaining the correct sorting and so on. You can do all of that with a simple query.

The following listing shows a second query that displays the directories ascending by their creation time, and for each directory the name, creation time and attributes are listed. The code also exemplifies the use of anonymous types, and the inference of the type from the assigned value, concepts new in C# 3.0:

void LinqList2(string path)
{
    string[] entries = System.IO.Directory.GetDirectories(path);

    var result = from dir in
                     from e in entries select new DirectoryInfo(e)
                 orderby dir.CreationTime
                 select new {
                            Name = dir.Name,
                            Attr = dir.Attributes,
                            Creation = dir.CreationTime };

    foreach(var item in result)
    {
        Console.WriteLine("{0}\n\t{1}\t{2}",
                          item.Name, item.Creation, item.Attr);
    }
}


Hits for this post: 17148 .

This is a simple guideline from my own experience for installing Visual Studio 2005 with SP1 and SP update for Vista. Installation of Visual Studio 2005 is pretty straight-forward. It does not take more than one hour. For the rest you should consider these:

  1. download Microsoft Visual Studio 2005 Team Suite Service Pack 1 (it installs SP1 for standard, professional and team editions)
  2. download Visual Studio 2005 SP update for Vista
  3. get a long movie, 2 hours and a half at least (suggestions: Titanic, Rose Red, Aviator, or perhaps if you want something newer, try Apocalypto)
  4. get a big cup of coffee; you don’t want to fall asleep
  5. get pop-corn

After installing VS2005, run VS80sp1-KB926601-X86-ENU.exe to install the SP1 and start watching the movie. After one hours you might want to check the computer, you may be finally prompted to click on several Next buttons. After that the “gathering information” process starts. This will take for at least one hour and a half, perhaps two, so you’ll have enough time to watch the rest of the movie. If you’ll have a look from time to time on the PC screen, try to ignore the service pack texts displayed in Latin (yes, it’s that old language spoken in the Roman Empire, until many centuries ago).

Overall, the installation of SP1 should take at least two hours and a half. If you watch Titanic or Rose Red and it’s not yet finished, don’t worry, you still have to installed the 30MB update for Vista (run VS80sp1-KB932232-X86-ENU.exe), and this will follow the same pattern, but will only take about 45-60 minutes. At the end I’m sure you’ll thank Microsoft for allowing you to catch to bunnies from one shot: install the SPs for VS2005 under Vista, and watch a good lengthly movie.

Thank you Microsoft!

Hits for this post: 5105 .

I decided to add a counter to my web site and blog. Unfortunatelly, I was not able to start them from the actual hit count (as idicated by the hosting company’s statistics), so they had to start from 0. This should be a quicker info tool for the hits count.

Hits for this post: 4862 .

Channel 9 forums has posted in January a video interview with Anders Hejlsberg (chief architect of C#), Herb Sutter (architect of C++), Erik Meijer (architect of VB.NET and C#) and Brian Beckman (physicist and architect of VB.NET). For one hour they talked about new trends in programming, the new issues and dificulties faced, and what the future could hold. Here are some points from the discussion:

Evolution of programming languages:

  • In the past 10 years the learning curve has changed from learning the syntax to learning the framework; we have big frameworks today, and the syntax is just the cherry on top of that (Anders Hejlsberg)
  • there are two driving forces in language changes (Anders Hejlsberg): 1) make them more productive; one way is to elevate the abstractions (garbage collector, unified type system, etc.), and 2) Take advantage of the progress in hardware (concurrency, 64-bit architectures)
  • You cannot make a language simpler by adding new features (Herb Sutter)

Functional programming:

  • LINQ project tries to demystify the functional programming (Anders Hejlsberg)
  • Gradual increase of awareness of people on functional programming, specially because of languages such as Python (Brian Beckman)

How much abstraction is too much?

  • it’s important to add levels of abstraction; it’s more important the spectrum of abstraction, not the level of abstraction (Anders Hejslberg)
  • you cannot have too much abstraction, because it leaves away necessary details (Erik Meijer)

Where are we going with the languages?

  • fusing of disciplines; what are we doing with many cores? (Anders Hejlsberg)
  • programming languages should look more like mathematics (Brian Beckman)
  • computers should help us program (Erik Meijer)
  • functional programming is an important trend, and being able to address concurrency (Herb Sutter)

The interview is available here.

Hits for this post: 3249 .

This week I decided to test the March CTP of Visual Studio code-named ‘Orcas’. So I started with a google search for the the download page, I found two:

  1. Microsoft Pre-release Software Visual Studio Code Name “Orcas” – March Community Technology Preview (CTP) (Self-extracting Install): contains 7 archives totalling 4.5GB
  2. Microsoft Pre-release Software Visual Studio Code Name “Orcas” – March 2007 Community Technology Preview (CTP): has 9 archives totalling 6.2GB

Faced with two possibilities I tried understanding the differences between them, and eventually I thought the first one should be more appropriate to download, because is smaller in size and is self-extracting. So I left my laptop running over night and second day I had all the files. I uncompressed them and started the installation on my PC under Windows XP. But surprize, the installation failed, with the error signature:

EventType : visualstudio8setup
P1 : 10826
P2 : 9.0.20209.00_orcas_x86_net
P3 : pr
P4 : inst
P5 : f
P6 : microsoft web designer tools
P7 : baseret_unknown
P8 : -    
P9 : 30066
P10 : -    

Eventually, after consulting the MSDN forum for the installation of ‘Orcas’ I realized that I’m not the only one having that error, and that the other version should be the correct one. So, I left my laptop run once again over night and downloaded the 6.2GB. But surprize: after uncompressing, I realized that I need Virtual PC to install this one, and an additional download of Orcas Base Image, a file of about 1GB. That made me give up and return to the first download: I tried installing it on my laptop, under Vista Ultimate and guess what: it worked like a charm (except that the installation process seemed to be much slower than under XP).

Thus, it took me several days to get Orcas up and running. :(

Hits for this post: 4873 .

Surprize! According to the latest Internet Security Threat Report release on March 19, 2007 by Symantec, Microsoft Windows is the most secure operating system. The survey covered the second half of 2006, in which period Microsoft Windows had 29 vulnerabilities, with 12 of highly priority or severe, and the turnaround for fixing them was 13 days. Red Hat Linux was the second, with 208 vulnerabilities and 58 days on average for fixing, and on the 3rd place Mac OS X with 43 vulnerabilities and 66 days on average for fixing.

Some other interesting facts from the report:

  • of all databases, oracle had the most vulnerabilities, 168
  • worms represented 52% of malicious code, trojans 45% of the top 50 malicious code samples
  • home users were the most highly targeted sector, accounting for 93% of attacks
  • spam made up 59% of all monitored email traffic

The report is available on Symantec web page: Symantec Internet Security Threat Report Volume XI: March 2007. The Flash presentation summarizing the report is also quite interesting.

Hits for this post: 2753 .

Yesterday I posted an article about readability of code, code conventions, Hungarian notation and its inventor, Charles Simonyi. Today I found that he paied between 20-25 million dollars for a 10-days stay on the International Space Station. Moreover, Space Adventure Ldt., the company that organizes the trips said it will bring special meals for him. You can read more about it on MSNBC: http://www.msnbc.msn.com/id/17708743/.

So people, start coding, perhaps one day, you’ll follow him. Or not. ;)

Hits for this post: 3857 .

One of the most important qualities of code is, or at least should be, readability. The simple fact that it works is not enough. If it’s not readable, it definitelly ain’t maintainable. Thus, our mission, as programmers, is to right code, that above being correct, is also readable and understandable. When a new programmer joins a team it takes time to familiarize with the application domain, language or code or all. To reduce that time, companies use code convension, that in theory should make the code readable, but unfortunatelly in reality, in many cases, does the oposite. 

A long time ago, in a galaxy far, far away there were no rich IDEs and no Intellisense. Programmers had to knew by memory all the types, functions, and variable names. Moreover they had to new the type of variables, parameters or returned values. Thus, naming conventions helped in taming the beast. Probably one of the most famous (and infamous at the same time) convention, at least for C and C++, is the so called Hungarian notation, invented almost 3 decades ago by Charles Simonyi, a chief architect at Microsoft. It was named so because it made code looked like written in a foreign language, and Simonyi was of Hungarian origins. Nowadays there are a lot of variations of the Hungarian notations, but in the beginning was one called Apps Hungarian, named after the group Simonyi was working in, called Applications, that was in charged with developing Word and Excel. Later, the group that developed the Windows barrowed the convention without understanding it, and developed a second version called System Hungarian. That was evangelized by Charles Petzold in his bestseller “Programming Windows”, probably the bible of windows programmers.

Though Simonyi had some good intentions and ideas, they were misinterpreted, and that led to a bad convention style. All because he used the term “type” when he actually meant “kind”. In a paper, written in an academic style, he wrote:

“The basic idea is to name all quantities by their type.”

Though he used to quote the word type, and tries to explain that a type is defined by a set of operators that apply to a quantity, people did not correctly undestand what he was saying. He used rgX to indicate an array of X or “range X”, cX, to count the instances of X, or dX for the difference between two instances of type X. Apps Hungarian was used for Excel and Word, where rowWidth could be an integer variable specifying the width of a row, and dX also an integer variable but specifying the number of selected colums. In his Apps Notation it didn’t make any sense for instance to add dX to rowWidth, though these were both integers, which has an operator + defined. They have the same type, but they are not of same kind. The original paper of Charles Simonyi was published in 1999 in MSDN: http://msdn2.microsoft.com/en-us/library/aa260976(VS.60).aspx

The Apps Hungarian focused on the semantic of quantities (variables, functions). In Systems Hungarian, however, the focus was moved on type. With p indicating pointer, ch characters, dw double words, ar arrays, sz, null-terminated strings, or lp far pointers, you could see variables named like lpszName (long pointer to null-terminted string specifing a name), dwI (double word index), arx (array of X), but also things like lpararszID (long pointer to an array of arrays of null terminated strings). Now imagine hundred of thousand on lines of code written line that. It simply makes my head ache. Such notations cannot make the code more readable. Only the oposite.

If you look up on the web, you’ll see a lot of notation conventions for the same language. Even for the Hungarian notations, there are plenty of variants. Here are just two that I picked-up randomly with a google search:
http://web.umr.edu/~cpp/common/hungarian.html
http://www.gregleg.com/oldHome/hungarian.html

I say enough with bad style programming! The days of such notations are long gone. Today Intellisense help you writing the code. When you use an object and type . or -> it automatically shows you the list of functions, variables, properties, etc. it has. When you write a function name it shows you the prototype, with all the overloads, parameters type and name, and even comments. And many other features that replace the need to prefix your variables with a long string of letters that you can barely read. Joel Spolsky wrote a very good article called Making Wrong Code Look Wrong, where among others he explains why the Hungarian notation fell into disgrace and was replaced at Microsoft with a new one with the release of the .NET framework.

I’m not going to delve into proposing good convention styles, there are plenty available. I just want to make some points: often, what you think it’s good for you, it proves the oposite in reality. Using bad naming convension is like deeling with a lot of birocrary: too many paper work, no real benefit. Thus I will restrain myself to just a few points:

  • variables (whether local, global, parameters, etc.) should be named in such a way that the focus is on the kind (the meaning of the variable) not the type. dwCnt doesn’t tell me anything, except that its a double word value, but countOfItems indicates that this variable is used to count items, regardless it’s a single or double word. That’s much more valuable for someone reading and trying to understand your code. When you have two variables dwCnt and dwNr, perhaps in a given context you may wonder why they are not summed together, but if they were called countOfItems and numberOfBuyers, you could immediatelly understand why.
  • context should not be added aritificially. Tim Ottinger makes a very good point on this matter in his article called Ottiger’s Rules for Variables and Class Naming. The company I work for uses a very bad naming convention that adds unnecessary context to variables. They use to prefix the names of types, functions, even variables with the name of the module. For instance if a module is called “Cluster Display Framework” (a name invented by me), they prefix everything with CDF: variable names, function, parameters, types, everything starts with the module name. Such context is totally unnecessary. Prefixing all your entities in a module with the module name does not add any kind of value to the code of that module, because you simply ignore that context. When you write in languages such C++, C#, Java, etc. you have the mechanism of namespaces available. You can put functions, classes, etc. that belong together inside a namespace, instead of prefixing everything.
  • unnecessary comments should be avoided. Don’t write comments just for the sake of writing. That doesn’t help. Polluting the code with redundant comments is unnecessary. If you have a variable of type string called nameOfUser, don’t add a comment to it, saying it specifies the user name. That is already known from the name of the variable. And that leads back to the first point I made above. Comments should be used to explain algorithms, or decision makings (why something is called in a particular context). As for the rest, the code should be self-commenting. That is a very good point made by Rober Fowler in his book “Refactoring”.

With all that being said, I just want to add that perhaps the best naming convension I know is the one use in the .NET framework (you can read about it here http://www.akadia.com/services/naming_conventions.html). I tend to use it lately even in C++, though C++ is not a language targeting the framework. It’s simple and meaningful. 

To conclude, make sure that when you write code, you do it in such a way that it doesn’t take a lot of time and head aches to understand it. Keep it simple. Keep it readable.

Hits for this post: 6173 .

Recently, CodeGuru has published my article about customizing the Places Bar of the common file dialog. In this article I have explained how to twick the registry to display your own list of shortcuts in the places bar.

The folders are specified in registry under HKEY_CURRENT_USER in Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\PlacesBar in two ways: either by IDs for a predefined list of folders, or by path. The name of the values must have the form PlaceX, where X is a numerical value. The key specified above does not exist by default. The operating system tries to read it and if it is find, it loads the enumerated places; if the key is missing a default list is displayed. The key affects the entire system, except for the application in the Office suite. To have a Places Bar changed only for a specific application, a temporary modification of the registry can be done, by mapping a temporary key to HKEY_CURRENT_USER with the use of RegOverridePredefKey() API. That basically implies:

  • Creating a temporary key and mapping it for the HKEY_CURRENT_USER
  • Putting the file dialog places there under Software\Microsoft\Windows\CurrentVersion\Policies\ComDlg32\PlacesBar
  • Displaying the file dialog
  • At the end, restoring the predefined HKEY_CURRENT_USER and deleting the temporary key

In the article published on CodeGuru you can read more details about this and see the code of a demo application that I created to explain how things work. The article is available at http://www.codeguru.com/cpp/misc/misc/system/article.php/c13407/.

Hits for this post: 6367 .