Hofstadter’s Law

October 12, 2009

Hofstadter’s Law: It always takes longer than you expect, even when you take into account Hofstadter’s Law.

0

John Carmack (on software patents)

October 10, 2009

“The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.”

-John Carmack

0

Excel has detected that ‘somefile.csv’ is a SYLK file, but cannot load it.

September 9, 2009

I am writing some software that generates CSV files to be opened by the default CSV application on the system. I just spent about 30 minutes troubleshooting this MS Excel 2007 error when opening one of my CSV files:

“Excel has detected that ‘somefile.csv’ is a SYLK file, but cannot load it. Either the file has errors or it is not a SYLK file format. Click OK to try to open the file in a different format.”

As it turns out, this error occurs when the first 2 characters of the first column name in a CSV file are “ID” (All upper-case).

The solution: Change “ID” to anything else. One or both characters can even be lower-case and that will solve this error.

I hope this saves some time for someone else out there.

4

VSS 2005 vs Subversion

February 27, 2009


I recently was asked to form an argument for switching my company’s source control from VSS 2005 to Subversion. This is what I came up with…

 

Subversion is obviously not the only alternative to Visual Source Safe, but it is a very solid one, one which I have personally used over the past several years with ease. Other source control options for us would be to use Perforce or MS TFS, both of which are pricey, especially TFS. However, Subversion is free and largely recommended by a vast number of people, especially when compared to VSS. Subversion is also supported by a large volunteer online community.

 

I have chosen Subversion over VSS mainly for the following reasons:

 

True Atomic Commits

A commit containing multiple files is treated as a single transaction, and a new revision all in one. Much like a database transaction, if one file fails to commit, they all fail – which is desirable to assure that project-wide changes being made which depend on each other are all done at once.

 

Copy-Modify-Merge

VSS’s lock-modify-unlock model makes it difficult to collaborate on rapidly changing files/projects. Subversion uses the copy-modify-merge model (aka optimistic merge), which better allows for multiple developers to work on the same project. More often than not, optimistic merge is a time saver over the lock-modify-unlock model. It is possible to lock a file from being committed by others in Subversion as well.

 

Easy Branching/Merging

Subversion allows for easy branching and merging of projects. This allows for easier development of new features or new versions of the product.

 

True Client-Server Model

VSS uses a network share for the repository database that relies on the developers having, basically, full control of the files therein. Subversion uses a true client-server model via http(s) or the proprietary svn protocol. I recommend the https protocol for compatibility and encryption.

 

Data Corruption with VSS

With VSS, it’s not a question of if the repository database will become corrupt and lose data, it is WHEN this will happen. Your source repository is supposed to be a rock – if a developer’s workstation crashes, you should only have lost HIS changes. You shouldn’t lose random files and data from the repository.

 

If you have developers spread across multiple time zones, the very act of both of them checking in can corrupt the database if they check in too close together, in the wrong order.

 

API

There is no good, usable, easily available published API for VSS and 3rd-party tools are weak for the most part. Subversion is open-source and inherently widely supported via API and many third-party plug-ins and additions.

 

Other notes:

Microsoft recommends that VSS is not suited well for large projects, but rather small projects with small teams. Microsoft themselves haven’t used VSS (in any widespread capacity) in over 10 years. If MS doesn’t believe in their own software, why should we?

0

Find Lost MS Office Product Keys

January 26, 2009

After searching a few minutes for a Microsoft Office product key viewer, I found a free program that does what I was looking for. But not until after several crippled demo programs found their way onto my screen, which require payment to work. I just wanted to help promote the free one that I found.

ProduKey is a small utility that displays the ProductID and the CD-Key of MS-Office, Windows, Exchange Server, and SQL Server installed on your computer. You can view this information for your current running operating system, or for another operating system/computer – by using command-line options. This utility can be useful if you lost the product key of your Windows/Office, and you want to reinstall it on your computer.

0

Build a Really Useful ASP.NET Exception Engine

July 8, 2007

http://www.eggheadcafe.com/articles/20030816.asp

Excerpt:

“The GetLastError() method of the Server object returns a reference to a generic HttpException wrapping the original exception that was passed from your ASP.NET page to the Application_Error event. Gain access to the original exception by calling its GetBaseException() method. This will provide the original exception instance, regardless of how many layers have been added to the exception stack. Once Application_Error has completed, it automatically performs a redirect to your custom error page that you can set up in web.config. See the MSDN documentation on how to set this up if you want it.”

0

A Few .Net (2.0) Notes

June 24, 2007

I am currently brushing up on my .Net skills so I will be taking notes on topics that are worth taking the extra time to remember.

Classes and structs

A class is allocated on the managed heap rather than on the stack and assignment between two variables results in both variables pointing to the same instance.

While the functionality is similar, structures are usually more efficient than classes. A struct takes up the amount of space (on the stack) that the value types defined in the struct take up together. You should define a structure, rather than a class, if the type will perform better as a value type than a reference type. Specifically, structure types should meet all of these criteria: Logically represents a single value; Has an instance size less than 16 bytes; Will not be changed after creation; Will not be cast to a reference type.


The runtime optimizes the performance of 32-bit integer types (Int32 and UInt32), so use those types for counters and other frequently accessed integral variables. For floating-point operations, Double is the most efficient type because those operations are optimized by hardware.


Immutable types in .Net, such as Strings: Any change to this type causes the runtime to create a new object and abandon the old one. That happens invisibly, and many programmers might be surprised to learn that the following code allocates four new strings in memory:

// C#
string s;
s = "wombat";          // "wombat"
s += " kangaroo";      // "wombat kangaroo"
s += " wallaby";       // "wombat kangaroo wallaby"
s += " koala";         // "wombat kangaroo wallaby koala"
Console.WriteLine(s);

Only the last string has a reference; the other three will be disposed of during garbage collection. Avoiding these types of temporary Strings helps avoid unnecessary garbage collection, which improves performance. One solution is to use the StringBuilder class to continuously build a String. StringBuilder is a mutable type that allows you to build a String object once you are done appending to the StringBuilder.


These notes have been “borrowed” and modified from the book: MCTS Self-Paced Training Kit (Exam 70-536): Microsoft .NET Framework 2.0 Application Development Foundation

0