msysgit installer is broken on vista

OK, it isn’t exactly broken, it just doesn’t know about vista’s virtual path features. This means you can run the exe as a non-admin user and it does not get installed properly.

The work around is to not run the installer as a regular use and wait for UAC to invoke itself. It never will. Instead, save the .exe file and right click on it and choose "Run as administrator…"

Now the program will actually get installed to C:\Program Files or C:\Program Files (x86) instead of the virtual are c:\Programs\data\user\blah\wahterver\it\is\vista\has\some\crazy\features.

Why am I using GIT? Well, unfortunately because I have to. Cloning was easy enough but just typing git help or git help clone and I immediately miss the polish of bazaar. The "I have to" is in reference to the no longer ignorable myriad of projects now hosted at github. IMNSHO all of these should have opted to be hosted a launchpad. But as we have seen in the past in technology, the best solutions don’t always win. Sometimes the solution with the loudest voice wins. (VHS>Beta?) (DAT>DCC?) (Blueray>HDDVD?)

Lack of Value of Code Metrics

I was just reading blogs and stumbled across this gem:

http://codebetter.com/blogs/patricksmacchia/archive/2008/08/26/nhibernate-2-0-changes-overview.aspx

Patrick ran NDepends (an awesome static analysis tool) on the 2.0 release of NHibernate.

Patrick went on to suggest that the NHibernate code base was spaghetti because its internal namespaces are cross dependant. Having looked at the NHibernate code base, I disagree. In fact as a base for learning more about programming by reading others source code, I have found NHibernate to be an excellent source of learning.

I tried to post this as a comment, but I couldn’t (maybe my Opera browser, or lack of JS?).

“IMHO, the NHibernate team should fix this problem asap”

I can fix it easily, just flatten out the namespaces. Put EVERYTHING into the NHibernate namespace and this wouldn’t be a problem.

Is this the right thing to do?  NO!  But it does fix your metric.  So I assert that your metric is wrong.

Who care if namespaces are cross dependent?  I don’t. Namespaces are for logical groupings of behaviors. If your behaviors are cross dependent, so will your namespaces.

This metric may be useful in a typical 3 tiered layered business application. NHibernate is not that. It is one ORM library. ONE. I do not find your metric useful.

 

Given any metric that you are using (P/E ratio for stocks anyone?) please be aware of what that metric actually means and consider its value in that specific case. Yes, you must reconsider each metric on a case by case basis.

C# Features As Requested By Others: Please No Duck Type By Default in C#

I replied to a blog post by Tosos over here:

The reply was long enough that I thought it warranted posting here too. I expand on why “var” is not dangerous and can go away. I also describe why it isn’t duck or dynamic or anything but strong and static. If you know F# this is nothing new to you.

Here it is:

I love these.

@Mike Borozdin:
Consider F#’s definition of methods(functions). It is just as strongly typed as C#, yet the compiler is left to infer the return type.

In the example above the return type is not weak, it is not vague or dynamic or relying on duck typing. The return type is the anonymous type defined by the select clause of the linq statement. All of the static type checking and strength of warnings and errors of the compiler will still occur.

I’d like to see similar syntax, but drop the var, it is needless noise.

e.g.

public GetFirstPageOfFiles(string dir)
{
  return Directory.GetFiles(dir).Take(10);
}

The signature of the method GetFiles takes a string and returns a string so we (and the compiler) KNOWS that GetFirstPageOfFiles returns a string.

But have we simplified the language as much as we can? F# wouldn’t make me specify the type of the argument to the method. It would infer it.

public GetFirstPageOfFiles(dir)
{
  return Directory.GetFiles(dir).Take(10);
}

Again, the argument to GetFiles is string so the compiler knows how to turn the method signature of

public GetFirstPageOfFiles(dir)

into

public string GetFirstPageOfFiles(string dir)

Where the compiler can’t infer, it should give an error and require the explicit use of the type.

This exactly the behavior of var now.

As for #3, I would NOT want this to be the default behavior. The default behavior should be strong-static types. As strong and as static as possible. That said, some compiler support for the equivalent of duct typing via reflection would be rather nice. AFAIK what you are asking for is already available through a 3rd party library from David Meyer at http://www.deftflux.net/blog/page/Duck-Typing-Project.aspx

With respect to default behavior being duck, Phil Haack is wrong, everyone is wrong. If you want that, use Iron Ruby or Iron Python.

I wrote about my uncertainty about the GetEnumerator duck here: http://jrwren.wrenfam.com/blog/2007/07/21/c-has-duck-typing/  It may have been necessary. If it wasn’t necessary, I’d call it a mistake. Maybe it was an accident. I don’t know.

Could I be more against duck typing? Yes, I could be against it entirely. I could completely misunderstand it. Unfortunately I’ve written in duck languages. I’ve probably written more code in PHP, Python and Perl than I have in C#. (I wrote A LOT of Perl and PHP.)

My simply request is to require the manual selection of behavior of duck, like Boo. Yes, I say “like boo” a lot, but much could be learned from boo. Boo had extension methods before C#. Boo has duck in a strong, static typed language. Of course, boo is not a special case. It is best to learn as much as possible from neighbors so that you can make your own decisions about things. My request is probably going to be granted. Charlie Calvert wrote about the dynamic keyword and dynamic blocks as a possible solution to this.

Business Logic is a Bad Word

I do not write business applications. Oh sure, I write applications for a business. This business makes money. The applications which I write helps them make more money. However, these applications are in the domain of product engineering. They are not in the domain of running the business. They do not deal with cash flow, inventory, accounts receivable or payable. There is no letter opener of death involved with any of my application users.

My applications have no Business Logic. The business processes could change at this company and my applications don’t know anything about it. We solve engineering problems. That said, separation of UI and Business Logic is still a strong concern. It isn’t Business Logic. It is Application Logic.

Why mention this? I feel like there are programmers out there who say to themselves, “I do not write business applications, therefore this silly separation of business logic does not apply to me.” These programmers are wrong. Separation of application logic from UI code is valid not matter what the application. Separation of Concerns extends to every type of software. I cannot imagine a type of software from which separation of concerns does not benefit. I’ll go so far as to say that if you think you have a case: that you are wrong. If you think you can justify it to me, I will simply redesign to a case which does fit.

Do you write math apps?  Separate your Math Logic from your UI.

Do you write engineering apps? Separate your Engineering Logic from you UI.

Do you write medical apps? Separate your Medical Logic from your UI.

Do you write biology apps? Separate your Biology Logic from your UI.

Do you write Anthropology apps? Separate your Anthropology Logic from your UI.

Do you write Sociology apps? Separate your Sociology Logic from your UI.

Do you write Psychology apps? Separate your Psychology Logic from your UI.

Do you write Legal apps? Separate your Legal Logic from your UI.

Do you see a pattern here? Separate your seeing of patterns from your UI.  Good.

C# vNext feature request 2

I previously had a list of things I wanted. Yes, I am like a 2-year old. I want. I want. I want.

mdavey posted a link to a channel 9 video which made me rethink my request. Oh I still want all of the original list and… I want more. I want more. I want more.

  • List Literals – it is silly that I even have to request this
  • Dictionary Literals – see list literals for comments
  • Extensible Literals – the .NET BCL already has this really great type conversion system. You ask for a type converter for a specific type and whether or not it can be converted between two types. One of these types is often a string. You can write your own converters and register them with this system of type converters. It is very elegant and beautiful. The compiler should use this to let me express my own literals. Type initializers are nice, but this would be nicer.
  • Variable Generic Type Parameter ArityChris Marinos had a use case for this and had to implement a solution in a much less elegant way because he was missing this feature. Its a request in Java too. Cliff Biffle says that Mongoose has them, but I can’t find whatever became of the smalltalk inspired language.
  • Restricted Types – The same post on Variable Generic Type Parameter Arity, Cliff reminded me of my favorite Modula-3 feature. He points out that Dylan has it. I like Modula-3’s approach to this using Subtypes. This paper by Cardelli, Donahue, Jordan, Kalsow and Nelson does a great job of explaining Modula-3’s simple but powerful type system. Not all of the subtypes in M3 make sense in a .NET world. We already have a well defined type system and some of the constructs would not mix. One concept that I think would mix well is range subtypes. Imagine that you know a value is always going to be between zero and 100. You can define a subtype of int and use that type throughout your program. The compiler actually checks that variables of this type are never out of this predefined  range. Type Conversion is automatic from int subtype to int type, but not the other way. It is awesome if for nothing other than eliminating IndexOutOfRangeException on array indexers.

 

Yes, I do want my cake and to eat it too.

Enterprise Library 4.0 released and unusable

EntLib4 was released recently. My bug is not closed. I can’t use it. πŸ™

It is just a library. I don’t want your guidance. Just give me the source. Let me change it, build it and use as I see fit. Last time I checked, that is what developers do.

You may be asking, why would I even want to look at EntLib?

EntLib is better than nothing. If you happen to work at one of those horrible organizations that can’t use anything that isn’t from Redmond, then EntLib is what you should be using. That is, EntLib is what you should be using after you try to find a better organization in which to work πŸ™‚ As a contractor, I want to be aware of it and know what things I can expect to run into when working with a client’s code.

My preferred library is castle for IoC and data access and even logging with Castle.Core.Logging being a thin wrapper to either log4net or NLog. Some area’s where EntLib does do things which I might find useful is Exception Handling and Instrumentation.

Meme: How I Got Started In Programming

Josh Holmes tagged me.

I must admit I enjoyed reading many of these by people I have met and they have all definitely been in the spirit of what I read at Michael Eaton’s blog when he said “…while I know my tweeps (twitter friends), I don’t really ‘know’ them.”

How old where you when you started programming?

Six years old?

How did you get started in programming?

My dad has a really cool pocket computer. Yes pocket computer. When I was causing trouble in church or out in public or some place where I needed to not cause trouble he would point to the Sharp PC-1500 and I would write him a little program. Later I would find out that it was mostly TRS80 compatible BASIC. The programs were pretty stupid, but the ability to control the little machine kept me entertained for a while. They usually involved questions like “What is your name?” and “How old are you?” with responses like “Wow <name>, you are old”. Sometimes I would put if statements if the name was “Jay” it would say “You are cool” or if the age was under 10 (10 is old when you are 5) it would say “you are not old”. GOOD TIMES!

I really wanted my own computer. My Uncle had a ton of Commodores. When I say “ton” I mean MANY. He automated an entire candy factory by making his own robotics and automating the robotics using Commodore computers. Some were VIC20s some were various editions of the C64, the C64 plus 4, the C64 plus, etc. Anyway, he had an extra VIC20 at some point, I think it was fall of ’85 or ’86. He lent the family a VIC20 and so I got to learn all the differences between TRS80 BASIC and Commodore BASIC. Immediately I had opinions about coolness and suckage between the two languages. Another critic was born!

Sometime after that, it must have been Christmas of ’85 or ’86, the family got an Atari 800XL. It had a TAPE DRIVE. It had a slot for a cartridge, but I never, ever used the cartridge. Games were way too expensive said that parents and so I never got any. Now I’m told there was a huge piracy ring for trading games on floppy disk back then, but notice I didn’t say I got a floppy drive. I didn’t. So I didn’t pirate software. I didn’t play hardly any games except for a few which someone did pirate to me on cassette. Lacking games, I learned to program.

It was an awesome experience as a seven or eight year old to learn to program the 800XL. Later I learned that the LINE, DRAW, CIRCLE and FILL commands which I learned to love on that ATARI BASIC were not on C64. Actually I learned that months later when I was visiting my Uncle or someone else who had a C64 and I tried these drawing primitives and they didn’t work. It was later that I learned that C64 just didn’t have these and I realized how blessed I was to have gotten the ATARI. I remember learning Cartesian Coordinate systems in grade school and thinking they were backwards(graphics occur unsigned with numbering like the 4th quadrant of a Cartesian system), but quickly adapting and thus being ahead of my grade school peers.

In summer of ’87 the family got an Amiga 1000 with the 512K expansion unit and a second external double density 3.5″ disk drive used from a coworker of my pops. A WHOLE NEW WORLD WAS REVEALED TO ME as I learned BASIC WITHOUT LINENUMBERS! It turns out that Microsoft wrote the versions of basic that shipped with the Amiga Workbench versions 1.2 and 1.3 and while I had versions 1.1, I didn’t like the funny screen that popped up with the 1.1 BASIC which was not from Microsoft. So I learned non-line numbered procedural programming around age 10. 1987 was a fun year. The drawing primitives on the Amiga Basic were very similar to that on an Atari so I was able to draw fun pictures and play with geometry.

The Amiga also came with a FORTH interpreter and so I followed the manuals to do some simple FORTH program.

The Amiga also came with a C compiler called North C. I tried and tried and tried to get Hello World to run, but I don’t think I ever succeeded. At 12-14 years old, I had no idea what compiling and linking were all about. I was used to interpreted BASIC.

After IBM Clones (that is what we called PCs back then) looked like they were the winner, I begged and begged and begged for one and after a few years off from learning much about computers, I got one. In 1991 it was a 486 33Mhz DX with 4MB of RAM and a 100MB disk. Yes I typed 100G the first time I typed that. We ordered it with a 80GM but they had some inventory issues so gave us a 100MB. It was sweet. I learned DOS and played with Windows 3.0. I programmed QBASIC.

I saved up all my allowance, because that is what 12year olds do, and I got a modem, 2400 baud baby! It was a $30 BestData brand modem. I got to set jumpers and insert it into a free ISA slot in the 486. BBSing was awesome. Later a 14.4kbps modem came too.

Then came my drivers license, the job in food service and high school girls. Programming took a back seat.

After high school I got a job operating a Unisys mini-computer (yes, as opposed to a mainframe or microcomputer) at the world headquarters of a small local paper and plastics manufacturer. This horrible job is where I decided for sure that I was going to go to college. One of my jobs at this place was searching for certain text in the green and white mainframe print outs. Later I would assume that no one on the IT staff there knew what grep was. I was human grep.

Then came College, a brief stint with a Computer Engineering program before I switched to Computer Science where I belonged.

What was your first language?

BASIC, DUH!

What was the first real program you write?

I’m still waiting to write it.

What languages have you used since you started programming?

I lost count somewhere in the late 90s, but for the sake of keeping up with others who followed this Meme, I will try. In order as I recall:

BASIC, FORTH, PASCAL, C, C++, VB, SQL, Bash, JAVA, HTML, JavaScript, PHP, Python, Pike, IDL, ML, Modula-3, VHDL, Perl, C#, Ruby, Boo, F#

What was your first professional programming gig?

Three years ago when I started working at ADP writing custom software to aide in managing their Hosting Center. All jobs prior to this were System Administrator jobs which I may have scripted or programmed, but programming (or delivering software) was not my primary responsibility in those roles.

If you knew what you know now, would you have started programming?

Yes, although I may have kept it a hobby rather than doing it professionally. Sometimes, I wish I was a lawyer.

If there is one thing you learned along the way that you would tell new developers, what would it be?

That guy over there that you think is so smart is just a man just like you, trying to be the best programmer he can be (hopefully) just like you.

What’s the most fun you’ve ever had… programming?

Fun? What is so fun about it? Its hard damned work!  J/K

I can’t place just one thing. Most thoughts are of the little graphics programs I wrote as a child. The first time I ever pair programmed was in college and that definitely stands out.

Update: I showed my Mom this article and she reminded me that she used the Atari 800XL to practice her typing for her secretarial work. She told me a great story about how I asked her “When you press the R on the keyboard, how does the R show up on the screen?” And like most computer users, she didn’t know, but I was a 7 or 8 year old who could read and so she handed me the manuals and I started reading them. Most of the manuals we had were on BASIC and getting started and so I guess the curiosity of getting the R on the screen is what triggered the curiosity of how these PRINT, INPUT and LINE commands make things appear on the screen. Thanks for the good memory Mom.

Visual Studio Task Tokens Help Me Find Smells

VS TaskTokens_2008-06-10_12-29-43

I work with some great people whose initials are BWW, DWH, etc. They already comment up a code base which I inherited with their initials. Visual Studio’s Task List feature lets me get a list of all of these comments just bad adding their initials as tokens.

I’ve also added a token named “SMELL” for when I see something I think is code smell, but I cannot fix it immediately.

Now, my proposal is for teams to exploit this feature. A small team could easily get all of the initials of its team mates and add them as tokens and then export only the Task List settings from VS and post that to their web site, repository, wiki, whatever for all of the team to download and import into settings.

This might be a cool team feature for teams who don’t have blame setup in their source control management system.

C# is already whitespace significant

error CS1040: Preprocessor directives must appear as the first non-whitespace character on a line

 

Of course you would put an #if or #pragma on its own line, but what if you didn’t?

#pragma warning disable/restore makes sense to be on the same line as the warning generating code. But in this case the C# language is white space significant. Why not extend this to other areas of the language?