March 22nd, 2009
Personally I write xml comments on all my methods even though I am a fan of method names enough describing that comments really are unnecessary. By descriptive method names I mean that others also understand them.
In a project I stumbled upon this method:
private void ShowHideControl( bool truefalse ){…
Since I had the source code it didn’t take much effort to find out what it did.
But a question remains – how do I present the problem for the original programmer without being rude?
March 22nd, 2009
>
I heard a thing the other day I haven’t heard for a long time. “That is not my code”
I believe no code and all code in your current project is Yours. There is nothing like finding a bug and leaving it be. If you can’t correct it, flag it. Either in a bug tracking system, to the person currently working with that part or to wherever your project stores possible riscs.
This my code-your code mentality mentioned above lead to the bug being forgotten.
That is not considered good.
March 22nd, 2009
Linq is sooo good.
The next time you loop a list or array to find a value or two; consider spending 15 minutes to learn some Linq; it is well invested. The syntax is somewhat like SQL but more straight forward. For instance the keywords are written “the normal” way. First what you have (from), then the filtering (where) and finally what you want (select).
var query =
from c in myCustomerList
where c.Age < 42
select c;
If you are looping two lists and compare them to get a new list, you should really look into Linq. It will save you lots of time.
March 20th, 2009
>
A small rule I have while estimating time or looking into a system is to run CRUDSLM against all business objects and possibly all database tables.
I make sure that every business object has one tick in each C, R, U and D. This is the normal case and by doing this I guard myself against forgetting something. There are times when things aren’t updated and even not deleted but then I know this and can argue for it.
It is a fast exercise and I usually run it only once against every business object and once against every database table.
For time estimation I extend the CRUD with SLM where the letters are Search, List and Manipulate respectively. Many times, especially with the main business objects, they are Listed and Searched. Then for reports, imports and exports they have to be Manipulated too.
I have many times found out that Delete is missing.
March 20th, 2009
There is something called xml comments in the dotnet world.
It looks something like
/// <summary>
///
/// </summary>
/// <param name=”name”></param>
/// <returns></returns>
public User FindUser( string name )
{…
The trick here is to write the comments on the very first line. Like:
/// <summary>This method finds and returns a User by its name.
/// </summary>
/// <param name=”name”></param>
/// <returns></returns>
public User FindUser( string name )
{…
When the code is folded it then looks like
/// <summary>This method finds and returns a User by its name. …
public User FindUser( string name )…
Visual Studio “suggests” writing the comments on line two, like
/// <summary>
/// This method finds and returns a User by its name.
/// </summary>
/// <param name=”name”></param>
/// <returns></returns>
public User FindUser( string name )
{…
but then after folding it looks like
/// <summary> …
public User FindUser( string name )…
(this is not a problem in vbnet)
More commenting comments are found here and here.
March 1st, 2009
>
Short story:
Totally wierd. One day VSNet of my colleague refused to open a form.
The solution was to run “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe” /ResetSkipPkgs
Long story:
VSNet 2008 suddenly refused to open a form in a VBNet project with the message
—————————
Microsoft Visual Studio
—————————
There is no editor available for ‘C:\Documents and Settings\myusername\Local Settings\Application Data\Temporary Projects\WindowsApplication1\Form1.vb’.
Make sure the application for the file type (.vb) is installed.
—————————
OK
—————————
(How to copy error message dialogues.)
Googling didn’t give much.
Repair did nothing. It stopped after a “…has encountered a problem…” with Ok as only choice.
Uninstallation din’t work; the same error as above.
Uninstalled through a tool found here. Reinstalled VSNet2008 and Service Pack 1. The “total uninstallation” was a fraud, the old projects still populated the MRU list :-( And the problem remained.
My colleague created a new winform project in C# where the problem was the same but the error message different.
—————————
Microsoft Visual Studio
—————————
Project ‘WindowsFormsApplication1’ could not be opened because the Microsoft Visual C# 2008 compiler could not be created. QueryService for ‘{74946829-37A0-11D2-A273-00C04F8EF4FF}’ failed.
—————————
OK
—————————
This gave us more Google fodder to find more switches here.
After running “C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe” /ResetSkipPkgs the sky was sunny again.
This took the better part of a day.
Why didn’t uninstall all remove everything. Who do Microsoft think they are? Adobe?
(the dialogue dumps above were easily copied with ctrl-c. read more here)
February 28th, 2009
In the west we are raised in a strong belief that everything can be owned; written text, images and even land(!) With this belief as our Pen and money as our Sword we push this way of thinking on the rest of the world so as to keep our wealth.
Not everyone has this same belief and are happy to invent and reinvent former inventions and constructions instead of protecting the old. One word for this is plagiarism, another is Shanzhai. I am afraid a new word will be “economic terrorism”.
If I claim that others follow my rules then I should be prepared to follow theirs; I am not automatically right because I have a bigger gun.
http://www.bunniestudios.com/blog/?p=284
http://online.wsj.com/article/SB123257138952903561.html
February 20th, 2009
At the time of wrintig there are like 78 open source licenses to choose from. The original creator of the open source license idea has an argument that 3 or 4 should do.
So if you ever think of choosing a license for you work the linke below might a good place to start.
http://itmanagement.earthweb.com/osrc/article.php/3803101/Bruce-Perens-How-Many-Open-Source-Licenses-Do-You-Need.htm
Update: A similar article is here.
February 9th, 2009
Datagridviews in dotnet work well with datasets. They work less good with “normal” objects; for instance sorting is much more of a hassle to implement.
The sorting problem is solved nicely in this http://groups.google.co.uk/group/microsoft.public.dotnet.languages.csharp/msg/2b7528c689f9ef84 piece of code. It is more or less just to copy the code and violà, a sortable object list.
February 4th, 2009
>
There is a somewhat hidden feature in Visual Studio TFS edition (or whatever it is called) for checking who changed a row. It is called Annotate and can be reached through the context menu. After some number crunching it gives you a semi graphic view of which row was edited by who.
Further Annotate can be done on other rows but not the same row again; I don’t know why.