IASAConnections/ArchitectConnections

Next month I’m speaking at ArchitectConnections in San Francisco. This is going to be the most amazing event – a combination of the best of IASA with the best of us way geeky, in the trenches architects. IASA is the International Association of Software Architects (pronounced eye-sa). I’m part of the Denver chapter, and combining IASAConnections and ArchitectConnections means there will be the most amazing collection of people (your conference fee covers it all). It looks like a near historic collision of perspectives across a tremendous range of focus – with Paul Preiss and IASA there to help sort it all out. Imagine throwing Scott Ambler, David Chappelle, David Platt, Allan Holub, Juval Lowy, Rocky Lhotka, Michelle LaRoux-Bustamante and Neil Roodyn into the same place. Stir gently and bake – who knows what’s going to come out. You can check this out on the speaker’s roster at www.iasaconnections.com.

The speaker’s roster is the reason you should consider this conference come. I’m absolutely in awe about speaking on the same stage as some of these folks.

But wait, wait, there’s more.

This conference is in San Francisco – fun and easy to get to. It’s also the first run so the attendance is likely to be reasonable – with up close and personal experiences with these great speakers. And, I just heard a rumor from the speaker coordinator that the food will be great.

But wait, wait, there’s more.

As a speaker, I’ve gotten info on a significant discount. Rather than just whispering this to a few friends, I’m putting it out here. You can get $400 off the regular conference registration fee! Do that by clicking this link. When you register on line scroll to the bottom and enter the discount code “SPEAKER”. The discount should appear on the next confirmation page so you can ensure you’ve got your discount before you commit.

And there’s even more…

Until they run out, I’ll give you a collapsible VB Frisbee if you find me (I’m not going to be hard to find) and say you came because of this blog post!

Firing up VB.NET for the First Time

Over the last couple of weeks I’ve had the delightful experience of conversing with one of my heroes – Bruce McKinney who wrote Hardcore Visual Basic. Bruce has been off doing other things – not programming. So from my narrow perspective, it’s a bit like talking to he’s been in a time capsule. I asked him to let me share this unique and very different perspective on VB.NET:

——————————–

I hadn’t even thought about VB or any other computer language for years when a woman named Kathleen Dollard sent me an email out of the blue asking if I was the same Bruce McKinney who wrote a certain book. Well, yes, I did write a certain book about a certain language back in a different lifetime. I started a conversation with Ms. Dollard (who turned out to be some sort of VB.NET guru) and during that conversation I idly asked how VB.NET had turned out. I had written a short analysis of VB.NET in its beta stage (see http://vb.mvps.org/hardweb/vbnet.htm), but I never saw the finished product, much less the current version of what should by now be a mature language.

Well, one thing led to another (as it had in the past and as I had promised it never would again). I discovered what I assumed was a crippled toy version of VB.NET called Visual Basic Express Edition. Why not download it and at least look through the language syntax to figure out what happened? Well, anybody reading this probably knows that VB Express is one of the largest toys in history. It didn’t take long to realize that I had probably made a mistake.

The first thing I discovered is how bad the help and the help engine are. It’s a mess of incompleteness and broken links—even worse than the execrable help in VB6. During setup I made the mistake of saying I wanted help first on my disk rather than online. The result was total confusion with all sorts of languages mixed up with incomplete topics. Everything seems related to VB6, and some of it is completely wrong about VB6, and its differences from VB 2008. You’d think after ten years most VB.NET programmers would be new people who wouldn’t know or care about VB6, but the internal help seems oriented to people who skipped all those earlier versions and are just now converting from VB6.

Finally I got online to an MSDN site that summarized all the language features. It wasn’t great, but way beyond what came with the program. I worked for five or six years in Microsoft language documentation before I went into development and then to Microsoft Press. We had less training and education than documenters have today, but we did a much better job. Are there no good technical writers left? Is MSDN paying three times as much as the VB team to get the few semi-competent ones? It was depressing.

Once I finally found documentation, I had some surprises. First I checked everything I criticized in the beta and sure enough the mistakes were all still there. They really did cripple arrays. They really did put AddressOf in the Delegate syntax even though it’s a lie. They really did change While/Wend to While/End While instead of killing it. They really did change the Property syntax for no reason other than to break code. They really did remove Imp and Eqv without adding Shl and Shr. Fortunately, they restored Static, which some idiots had removed from the beta.

Now I know these are really small things in the big picture, but languages are about symbolism and metaphor. If you don’t understand the importance of metaphor you shouldn’t be designing languages. And if you’re going to clean house and change everything, why not kill Dim? If they had just added Local, they could have left Dim in place for compatibility, but no thoughtful coder would ever use it in new code. But no on the VB team seems to understand the purpose of compatibility or deprecated features.

The thing that bugs me the most is the crippled arrays. In VB6 (as in all real high-level languages) you can declare any array bounds you want. For example, assume I wanted an array of temperatures within a reasonable range so that I could record how many times each temperature was reached.

Const iMinTemp As Integer = -50, iMaxTemp As Integer = 125

Dim aTemp(iMinTemp To iMaxTemp) As Integer

aTemp(iTodayTemp) += 1

That’s how I’d do it in VB6 (or Pascal or any other civilized high level language), but that’s not possible in VB.NET (or C# or Java or any of the other pretenders). Instead I’d do something like:

Dim iOffsetTemp = 0 – iMinTemp

Dim aTemp(0 To iMaxTemp – iMinTemp) As Integer

aTemp(iTodayTemp + iOffsetTemp) += 1

I have to do all the stupid bookkeeping (with all the risk of an off-by-one error) every time I use the array even though that’s the sort of thoughtless bookkeeping high level languages are supposed to take care of. Every time I used one of these brain-dead arrays it would make me angry that someone had deliberately crippled our language.

Well, enough about old complaints. I also found some surprising new stuff such as += and -=. I didn’t expect that. It’s hardly in the Basic tradition, but I always appreciated those operators in C. They also added signed integers. Kemeny and Kurtz didn’t just forget about signed integers. They left them out on purpose and bragged about their absence as a feature. I’m sure signed integers are there for interoperability, which shouldn’t be a Basic goal and wasn’t needed, not even to call signed arguments in the library.

How about operator overloading? That was a surprise. Does overloading work nice and easy in VB? Or is it loaded with gotchas as in C++? Generics look simple enough, and it would be nice to have them built into the language without the weird side effect of the C++ preprocessor. I had a great time building generic C++ classes for VB safearrays (now gone). I hope generics in VB are as much fun as in C++, but less confusing.

But enough philosophizing. Let’s write some code. I start out by trying File New Project. Interesting choices. I have not the slightest idea what a WPF Application might be (and when I check help I see I don’t want to know), but I can guess what a Windows Form Application might be. So I try it. There’s my form. Once again VB guesses that I want to call my form variable Form1 and that the caption on it should be “Form1″. Just as wrong and evil as in VB1. You’d think by now they’d have learned not to encourage bad habits. OK, I want to put a button on this form, but there are no buttons. I play around for three minutes before I figure out how the toolbox slides over. Cool.

I put a button on the form. It comes out as Button1 rather than Command1. A step forward. It takes me a minute to figure out how to change the variable name to something sensible–btn. I add a label named lbl. When I remove the text from this label it disappears. Something funny is going on in the properties, so I examine the list. There are some properties I’ve never seen. I put the cursor on an unfamiliar one and press F1. It tells me what a property list is, but nothing about any particular property. Hmmm. Finally I figure out how to turn off AutoSize and make the label 3-D.

I click on the button and insert lbl.text = “Hello, world” in the btn event procedure. I run it and it works. But when I click it again nothing appears to happen because it’s overwriting the same message. I need the text to change. I go back to the event procedure and type Static c As Integer = 1. Ahhhh! What a luxury! What I would have given to do that back in VB5. I started begging for this in VB4. I go to the bottom of the procedure and type c += 1. I’m still not sure I like this, but I do it anyway. Then I think what if VB has… Naw, it couldn’t be. I try c++, and what a relief. It doesn’t work.

Then I go back up and change the label assignment to lbl.text = “Hello, world ” + c. I get an InvalidCastException. So, VB is not so loose anymore with type conversions. “Evil Type Coercion” must be gone. This is a good thing. How about “Hello, world ” + CStr(c). This works. But then I think: This is an object oriented language. An integer variable ought to have conversion methods. So I remove the CStr and type a dot after c. All the methods appear including ToString. Wow! lbl.Text = “Hello, world ” + c.ToString. Yes! When I run it, the text counts every time I click.

Not quite like old times, but it has its moments.

Then I remember something interesting from the File New Dialog. Could I really write a console application in Visual Basic? I try it and there’s the Sub Main() followed by End Sub with a cursor sitting in the middle. It looks more like my first C program than my first BASICA program, but it’s obvious what to put in between. I type Print “Hello, World”. VB encloses my string in parentheses. Is the syntax difference between a Sub and a Function really gone? When I press Run, it starts a console, but then fails and tells me an InvalidCastException was handled. A syntax diagram tells me that print takes a file number followed by a ParamArray Output(). OK, we’re not in Kansas anymore.

This isn’t enough information, so I move the cursor to Print and press F1. Information Not Found. No help on Print? I look in the help index. No Print statement. There is an entry for Print # statement, but that takes me to a table of changes from VB6. I find Print # in this table and click on a topic called Print and PrintLine. Information Not Found.

After messing around for a while and seeing more Information Not Founds, I figure out that I may be on the completely wrong track. It appears that maybe writing text is done through the FileSystem. Instead of Print, I try My.Computer.FileSystem.WriteAllText(“Hello, World”). This fails because it needs three arguments, the first a file name. Maybe there is a standard string for the console such as “CON” or “SCRN”. I think this worked in some version of C file I/O. After some experimenting, I try arguments WriteAllText(“scrn”, “Hello, world”, True). This is valid and runs, but doesn’t print in a console. Probably somewhere on my disk is a file called “scrn” containing the words “Hello, world”. I search and sure enough, there it is in a semi-random directory.

I put my cursor on WriteAllText and press F1. Information Not Found. I mess around for a while longer and find a link to a help topic on console applications. Information Not Found. Do I really want to be a VB programmer? Information Not Found.

Now it happens that at the moment my home internet connection is broken so I have to go to work to get online, but I’m doing this at home. I could probably figure this out if I could get to MSDN. But there’s no excuse for installing a broken help system on something called VB Express Edition that takes more than an hour to install. Sure enough, when I get back to the internet, the solution is simple, although I never did find it in VB help or MSDN. I googled “VB.NET console sample” and found the information on a non-Microsoft web site. I just need Console.WriteLine(“Hello, world).

There are some good things here, but overall I think I better get this damn thing off my computer before I get really mad. Or hooked.

In Praise of Nested Classes

I love nested classes. You can do elegant thing wit them that otherwise require a ton of code – even if its generated. But the rest of the world seems confused by the syntax. Assuming a class named Budget, we could have Budget.List refer to a class (not an instance).

 

Public Class Budget
  ‘ Other Stuff

   Public Class List
      ‘ Stuff
   End Class

End Class

 

Unfortunately, the rest of the world is either confused by them, hasn’t been introduced, or is following the Microsoft party line that they are uncool as expressed via FxCop. So to a large extent this post is a requiem. I have decided not to do what I’m describing here in my current architecture. At least today.

Since I think it is such a huge loss, I want to show you what nested classes can accomplish. Imagine an architecture tat contains these classes (with other meaningful stuff deleted):

 

Public MustInherit Class BizEntityBase(Of TEntity As EntityBase(Of TEntity))
End Class

Public Class Budget
   Inherits BizEntityBase(Of Budget)

End Class

Public Class BudgetList
   Inherits BizListBase(Of Budget)

   Protected Sub New(ByVal list As IEnumerable(Of Budget))
      MyBase.New(list)
   End Sub

   Public Function GetItem(ByVal id As Guid) As Budget
      Dim q = From entity In Me Where entity.BudgetGuid = id
      Return q.SingleOrDefault
   End Function

   Public Shared Function GetList() As BudgetList
      Return GetListInternal(Of BudgetList)()
   End Function

End Class

In this scenario, you have a copy for BudgetList for every single entity – probably hundreds adding many thousands of lines of code. Sure you can generate it, but it’s better to reuse code than generate it. Now, use a nested class:

Public MustInherit Class BizEntityBase(Of TEntity As BizEntityBase(Of TEntity))

Public Class List
   Inherits BizListBase(Of TEntity)

   Protected Sub New(ByVal list As IEnumerable(Of TEntity))
      MyBase.New(list)
   End Sub

   Public Function GetItem(ByVal id As Guid) As TEntity
      Dim q = From entity In Me Where entity.PrimaryKeyValue = id
      Return q.SingleOrDefault
   End Function

   Public Shared Function GetList() As EntityBase(Of TEntity).List
      Return GetListInternal(Of EntityBase(Of TEntity).List)()
   End Function
End Class

End Class

Public Class Budget
   Inherits BizEntityBase(Of Budget)

End Class

As a result of this change, there is ONE location for the List functionality reused by all classes. There is no BudgetList class to be generated or handcrafted.It’s not needed.

But external code must use Budget.List to access the class. I asked a smart structural architect know about this. He didn’t even grok the question until I explained it. So for now, I’m skipping this approach at the same time I’m throwing it out there for other people to gnaw on.

Although I’m not completely skipping it. The entity list classes I’m writing derive and leverage base class code so are less lines than I’m showing above. But it’s still hundreds of extra classes I see as existing only because as an industry we’ve yet to wrap our heads around this concept.

How is VB.NET Doing?

I recently touched base with someone from the good old VB6 days. They were good old days, but I’m not going to talk about them. He asked where VB.NET went, and it set off this weird thinking about how to explain VB.NET to someone that had dropped out and was only peripherally interested. I thought I’d share this, but many of you will want to skip.

“How is VB.NET doing? … never saw the final product, much less what it has grown into now.”

I suppose grown is the operative word here. It’s huge. No, bigger. And I don’t mean the size of the market or its respect. I just mean the libraries. And it’s not really about libraries anymore because Microsoft’s releases all things in relation to .NET – even the Xbox. Not via API’s or some other approach, but more libraries. So the size reflects the complexity of nearly every platform initiative Microsoft has come up with.

The rate of growth is still increasing. We have around 15 “modern” data access strategies and 18 (user) interface strategies. I don’t have my slide handy, but four or five of the data access strategy and a few of the interface strategies released in the last year. You could be spend all your time trying keeping up and you wouldn’t.

As a result the interactions with .NET are quite different. There were a large handful of people that knew just about everything there was to know about VB6 and before. Not everything, because it’s asymptotic, but close enough to touch. Now a handful of people are experts in a single area – anyone, like me, who covers more than one topic stays acutely aware of what we don’t know. No one is competent anymore in the sense we would have used that term ten years ago. This makes the personal experience profoundly different – instead of sailing, it feels like running Class IV whitewater, and Class VI if you’re actually doing stuff with a company on the line. Uptake is slow; even of generics three years old with a clear payback.

And the people. That’s a sad side. There used to be programmers who were hobbyist. I’ve been slammed for using that word – but this is a person who’s not a full time coder but passionate about coding. It’s not a job, it’s a joy. The grip from LA, the pet store owner from Arcata, the Canadian speechwriter, the dozens and dozens of people that knew about a niche ad weren’t afraid to dive in and do it. I loved those people; they made the tapestry so rich around us. They’re gone. Just gone. I propped up my brother as one of the last standing hobbyist coder until the last few weeks when he had a chance to give up and merge with an existing group. I feel his relief that he’ll play music and see his wife.

Folks would like to tap that old VB market, a lot of people recognize how many strong midsize companies exist today because of what someone started in their basement with VB or Access or FoxPro. But this will be a new tool, not VB. It might run VB as a language, but just like VB lassoed the complexity of C++ as a language, we now need something to lasso the complexity of platforms. It’s a new level we need. I think we have everything we need to build it, we just can’t quite (almost) tell what it should look like.

But as the hobbyist side of the rich tapestry withered, another surprising one wove itself. Microsoft itself changed entirely at the level that mattered. Remember when people were afraid to talk to you and even knowing you were on an NDA was a secret? Well that’s gone. People blog and they are excited and I’ve even had managers say “my job is to be sure my people are excited every day when they come to work.” Softies caring if softies in general are happy. I can feel a bit old hanging around there because they are so young – but I can also feel the energy and brilliance and the teamwork –even if there are still a few thousand teams. A bunch of softies are my friends now – heck I got my last piercing with a softie on tour.

There are more women than ten years ago, but it’s hardly balanced. There’s the Brian joke. A few years ago at PDC or TechEd there were more men named Brian speaking than women. But there are a large handful of us and I think we get respect for our accomplishments. I think we need to start way down the pipeline helping women know how fabulous, fun and exciting it is to be a software developer.

You would not recognize the MVP program. Gates, Balmer, Ozzie, all the superstars come and speak to us in a vast convention center. Yeah, I know you think I’m kidding. It’s something to put on your business card and Microsoft works to tell people who we are. I share my MVP lead with only a few hundred other MVPs and my last lead turned into a good friend. To those of us that were MVPs when no one knew who we were, it’s weird. I almost cried the first time I saw a “Welcome MVPs” banner on a campus building. It makes it harder to convince younger MVPs what Karl first told me “If you ever do anything to stay in the program, you don’t understand the program.” But we still have a feisty bunch giving the team hell in order to make VB.NET better as fast as we can. Yep, we’ve got daily communications with the team and yep, the listen. Or, well, sometimes anyway.

We’re currently coping with legacy .NET apps. When you start with a clean slate, you skip them for a while, but they are back now and we need strategies for piecewise improvements. Between that, the competence across technologies issue, and the sheer size of what we accomplish is driving me to the concept of human scale architecture or block based architecture as a current passion. .NET apps are rarely as small as 100 KLOC. At least not ones I see or hear about. They are generally gigantic, so the monolithic thing is a disaster. But so is the 3-tier/n-tier stuff. It’s just not enough, so we’ve been through this web-services arabesque. Good ideas, and really important to some scenarios, but just shifting around the deck chairs in others. It makes me think of Spirograph. The picture keeps looking different, but we seem to keep coming back around.

So, this is a lot of words not to answer a simple question. I’ve hardly mentioned VB and I guess that’s the biggest change. VB hardly matters. I mean a lot of us like it and it’s a really cool language, but most of what I can do in VB I can do in C# in nearly the same way. There is more difference within either language in any two adjacent versions than there are between the two languages. Languages are evolving pretty quickly. VB.NET has a nice OOP model, generics, lambda expressions, SQL-ish statements checked by the compiler, embedded (compiler checked) XML, the ability to automatically create help files for our libraries, an absolute ton of awesome toys.

Microsoft publishes numbers that there are more people in VB.NET than C#, but the rest of us can’t figure out what planet their using for the statistics. C# is common in my clients and the majority of my audiences. So I learned C# and am comfortably bilingual. VB.NET is hanging in there. It’s not what it was – but the world is most definitely not what it was either.