Sunday, October 02, 2005

MVP Summit is over...

Ahhhh... I'm still recovering from the MVP Summit "social activities". ;-) It was a great summit. I learned a lot and saw a ton of amazing stuff coming from the Microsoft camp. I'm really excited about the future.

In my search for the answer to the question "What is an Architect?" I realized that even the other architects I spoke with had the same question. It was interesting to hear different views on what an architect is and what the architect MVPs actually did. I don't think there really is a clear definition of what an architect is or does exactly, however, I did learn that all architects have a couple things in common.

Architects are open minded people that can accept other people's solutions to particular problems. As long as the solution meets the problem's performance and scalability needs and the solution is easily maintainable then an architect will buy into your design. Architects balance the needs of the business and the needs of the system. They are sensitive to construction costs and maintenance costs based on the people designing and maintaining the system. They understand (or are at least aware of) the proven patterns of not only software solutions but also business processes.

Regardless of whether you are an enterprise connected systems architect or a software product architect or an infrastructure architect, you are sensitive to the construction and maintenance costs of your solution with your particular group of people and your particular business.

Tuesday, September 27, 2005

MVP Summit here I come!

I'm working from a downtown Seattle hotel with a beautiful view today -- tomorrow the MVP Summit starts. Someone forgot to tell Seattle that summer is over, it's absolutely gorgeous here!

I'm really looking forward to meeting my fellow architect MVPs. I'm interested to see exactly what other "architects" actually do. Connected systems, business applications, products, infrastructure, databases, all of the above? How much code do they actually write? How many developers do they direct? How much influence do they have on the business? Are they typically consultants or employees? What is an architect anyway? Microsoft's vision for architecture sounds a little fluffy to me. I'm hoping to walk away from the summit with a much clearer picture.

Of course, I'm also excited about seeing the new XBox 360 ;-)

Tuesday, September 20, 2005

Tragedy Hits the Fox Community

On Friday Drew Speedie and his son, Brent, fell a few hundred feet to their deaths from a bridge in Yellowstone Park while vacationing there. My heart goes out to Irene his wife. Drew was a Visual FoxPro MVP and regular conference speaker and writer.

I remember the first time I ever met Drew was at the Visual FoxPro 6.0 DevCon in May 1998 in Orlando. I remember how funny and engaging he was showing off the VFP Grid. Drew was great at showing you the ins and outs and tips and tricks of a particular feature -- things you never thought of.

The first time I ever met Brent was at an Essential Fox conference (I think 3 years ago) in Kansas City. The first thing that came to mind when talking with him was "Wow, this kid is smart. And just like his father." He was very engaging and had the same wit as Drew during our conversation about Arizona. The last time I spoke with Drew he told me about some beautiful places to visit in Arizona -- I think I'll have to go see them now.

For more information please visit the FoxWiki.

Thursday, September 15, 2005

The exciting future of Visual Basic

Make sure you check out the Future Versions section of the VB site for information on LINQ. You can even download a preview of this technology which works with the release candidate of Visual Studio! And if you haven't read this yet, this MSDN paper is a great overview of Visual Basic 9.0. Man! VS 2005 isn't even released yet and I'm drooling over the features of the next version after that! Sigh.

Wednesday, September 14, 2005

A fundamental shift in programming for most, a sigh of relief and a breath of excitement for us!

Paul Vick formally announced Project LINQ yesterday at PDC. LINQ stands for "Language Integrated Query". LINQ brings standard query operations into the .NET platform. Wow, an object oriented language with rich query syntax... hmmmm... sounds vaguely familiar ;-). This is what I've personally been waiting for ever since I moved into .NET programming from Visual FoxPro work. Paul is right; this does represent a fundamental shift in programming for most developers. When you have a language that supports this style of programming, the architecture of your applications change. You start to think about dynamic data (and metadata) as the engine of your application. It's not to say you can't create dynamic data-driven applications right now in .NET, it's just a lot harder. When you can write elegant queries directly into the editor you tend to favor that expressive style when working with data instead of a rigid strongly-typed object approach. For instance you could write a function that performs some complex operations on changing data but apply it inside of a select query for only the matching pieces of data; and you can do it in 5-10 lines of code instead of 100 lines of for each's and if statements.

Now for the people of the Fox this is the only logical way to work with data inside of an application so I think that's one of the major reasons people stay working with Visual FoxPro. However, VFP is not a strongly-typed language, it's execution is slower and it's based on COM. But because VFP is loosely-typed you can get away with a lot of slick dynamic, scripting-style programming.

What the architects of LINQ are doing is amazing. They are bringing query comprehension to a strongly-typed environment. However, I'm personally excited about the future of VB.NET. VB.NET is strongly-typed AND loosely-typed at the same time. In my opinion that will make VB.NET the preferred data-oriented programming language and the language of the future -- especially for information systems.

I hope that Visual FoxPro programmers will take a hard look at VB.NET if they haven't already. There is a lot of opportunity for you here because we already know how data-based applications should be written using query in the language and we can provide invaluable feedback to the architects of LINQ and VB.

Tuesday, September 06, 2005

I'm speaking at the Bay.NET UG on Thursday

I'm speaking on Thursday for the Bay.NET user group down in Pleasanton. So if you rather see me than the Raiders vs. Patriots game (I know it's a tough decision) then come on out!

Wednesday, August 24, 2005

The Fox is out of the bag

In the Visual FoxPro August Newsletter in a paragraph regarding the SouthwestFox conference Ken mentions: "Calvin's presentation will be on great demos of new language features being added to a future version of Visual Basic for data-centric .NET programming significantly based on Visual FoxPro technology."

On a related note, Paul Vick punches up the abstract on his PDC topic Visual Basic: Future Directions in Language Innovation

Hip hip, HOORAY!!!! And the crowd goes wild......

Wednesday, August 17, 2005

Back from vacation

Ahhhh. I love summer. This year we drove up the west coast from San Francisco to Seattle. The first day we made our way through the redwoods up to Humboldt County. We stopped in Eureka and stayed at the Carter House Inn. It was beautiful and lots of fun. It was foggy in the morning but it cleared up and was sunny and mild in the afternoon- typical Northern California costal weather for August.

We then headed up the coast into Oregon, stopping at every tourist trap along the way -- Confusion Hill, Trees of Mystery, and the Enchanted Forest (complete with concrete dinosaurs). We made our way up to a camground near Dune City, OR - 8 miles south of Florence - and camped there for two nights. We hiked to the beach in the morning -- pretty easy walk, actually -- and collected shells and played on the beach with the seal lions. It was just me, Alan and the lions -- no one else for miles. A man did come out of nowhere and strolled up to us. But he gave me some cool agate stones and a whole sand dollar he found on the beach. He was cool.

After our relaxing two days we headed up to Seattle via I-5 through Portland. We needed to meet a friend who was flying in that night for Alan's birthday. Of course the flight was delayed 2 hours (because she flew Alaska Airlines) and she missed the dinner party. I should have figured. Alaska is ALWAYS delayed no matter what time of year. You're better off flying SouthWest (if you don't mind being hearded like cattle).

The rest of the week we spent visiting friends in Seattle and going up to Victoria, Canada (yes we went to Butchart Gardens ;-)). It was cold and overcast in Seattle (naturally!) but Victoria was nice and sunny.

It's nice to be back home. Visiting other places really makes me appreciate where I live. Summer is still in full swing here in the East Bay and I'm looking forward to spending the rest of it at home. Well, maybe I'll go camping on Mount Diablo one weekend with my sister, but that's only a 20 minute drive ;-)

Monday, July 11, 2005

VB.NET as a dynamic, data language

Personally, I am very excited about what Paul says in his post here. This is one of the biggest reasons why I love VB.NET (and VFP), and it looks like there will be some very exciting things to look forward to after VS2005. Make sure to check out this paper (which Paul links to from his post) by Erik Meijer and Peter Drayton.

Monday, June 27, 2005

Back Home from DevTeach

Well I'm back home from DevTeach which was held in beautiful Montreal. If anyone was looking for the rest of the presentation demos and slides they are all up on the DevTeach site now. I met lots of new friends this trip that I hope to keep for a long time to come. Thanks to everyone at DevTeach for a wonderful conference!

Wednesday, June 08, 2005

VS/SQL-Server 2005 Release Date Announced

The release dates for the next versions of Visual Studio, BizTalk and SQL-Server were announced at Tech Ed to be the week of Nov. 7th. A few places to read about it are here, here and here.

Wednesday, June 01, 2005

Bonus Session at DevTeach

If you're coming to DevTeach, you should definately check out the architecture bonus session. I'll be sitting on a panel with a bunch of really cool architecture dudes. Plus Nick Landry is going to be the animator so it should be a lot of fun! Hope to see you there.

Tuesday, May 17, 2005

Make your .NET demos better with a TraceListener

Last night I was writing a sample application for one of my DevTeach sessions and I thought I'd share this little trick. If you've ever tried to fiqure out a speaker's sample code after the conference when you got home you'd appreciate this as well. Usually I just write copious amounts of comments in my code to help people but last night it dawned on me how I could add a very simple TraceListener to my application to easily display the application's sequence of events in a list box. This way the developer could see exactly what was going on at runtime without having to debug the code.

If you're unfamiliar with TraceListeners have a read here.

Trace listeners monitor the output of the Debug and Trace messages in an application. You can create custom listeners and then add them to the Debug or Trace Listeners collection on application startup quite easily:
Imports System.Diagnostics

Public Class Main
 ''' --------------------------------------------------------------
 ''' <summary>
 ''' Main enrty point for the application.
 ''' </summary>
 ''' <remarks>
 ''' </remarks>
 ''' <history>
 '''  [Beth] 5/16/2005 Created
 ''' </history>
 ''' --------------------------------------------------------------
 Shared Sub Main()
  '-- Registers a trace listener 
  Debug.Listeners.Add(New DemoAppTraceListener)

  Application.Run(New MainForm)
 End Sub
End Class
The idea for the DemoAppTraceListener class is very simple. I just want to globally broadcast the trace messages so that they could be displayed by the application anywhere. We can do this by declaring a Shared (static) event:
Imports System.Diagnostics

''' -----------------------------------------------------------------------------
''' Project  : DataCachingStrategies
''' Class  : DemoAppTraceListener
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' Globally broadcasts the trace messages in this demo which are displayed in the UI.
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
'''  [Beth] 5/16/2005 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class DemoAppTraceListener
 Inherits TraceListener

 Public Shared Event MessageReceived(ByVal e As MessageEventArgs)

 Public Overloads Overrides Sub Write(ByVal message As String)
  RaiseEvent MessageReceived(New MessageEventArgs(message))
 End Sub

 Public Overloads Overrides Sub WriteLine(ByVal message As String)
  RaiseEvent MessageReceived(New MessageEventArgs(message))
 End Sub

End Class

''' -----------------------------------------------------------------------------
''' Project  : DataCachingStrategies
''' Class  : MessageEventArgs
''' 
''' -----------------------------------------------------------------------------
''' <summary>
''' This EventArg is used to broadcast messages from the DemoAppTraceListener.
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
'''  [Beth] 5/16/2005 Created
''' </history>
''' -----------------------------------------------------------------------------
Public Class MessageEventArgs
 Inherits EventArgs

 Private m_msg As String = String.Empty
 Public ReadOnly Property Message() As String
  Get
   Return m_msg
  End Get
 End Property

 Public Sub New(ByVal msg As String)
  m_msg = msg
 End Sub
End Class
Now all you have to do is handle the event and display the messages. Oh, yea you also have to actually put Trace messages in your code now too!
Public Sub Foo
        Trace.Write("Entering Foo method")
.
.
.
End Sub
To display the messages in my demo I created an MDI parent and put a simple list box on the bottom. Then I just added a handler to the DemoAppTraceListener.MessageReceived event. I added the handler in the constructor because this code is hidden in the form designer region and people won't be distracted away from the demo code.
#Region " Windows Form Designer generated code "

Public Sub New()
 MyBase.New()

 'This call is required by the Windows Form Designer.
 InitializeComponent()

 'Add any initialization after the InitializeComponent() call
 AddHandler DemoAppTraceListener.MessageReceived, AddressOf Me.DisplayMessage
End Sub
.
.
.
Finally I added the few lines of code to display the message in the list box and select the last message:
Private Sub DisplayMessage(ByVal e As MessageEventArgs)
 Me.lstMsgs.Items.Add(Me.lstMsgs.Items.Count.ToString + ". " + e.Message)
 Me.lstMsgs.SelectedIndex = Me.lstMsgs.Items.Count - 1
End Sub
Another cool thing about using a TraceListener is that the developer can still copy/paste the code in the demo into their own applications without having to remove the Trace messages if they don't want to.

Now if you come to my data caching session at DevTeach you'll get to see the TraceListener in action! ;-)

Saturday, May 14, 2005

A component walks into a bar....

The component asks the bartender via .NET remoting:
"Gimme a beer"
Bartender:
"What kind of beer?"
Component:
"Just give me all of them one by one and I'll drink the one I like."

The component asks the bartender via Web Services:
"Gimme a beer"
Bartender:
"What kind of beer?"
The component thinks a minute.
"I didn't know you'd have more than one. I just want a beer."
Bartender:
"What kind of beer?"
Component:
"A plain one."
Bartender:
"What's plain beer? How about a bud?"
Component:
"Umm.. ok."
The component tries to take the beer but it slips onto the floor and the glass breaks.
Bartender:
"What's wrong with you?"
Component:
"I got a slippery SoapException."

Thursday, May 05, 2005

Refactor, refactor, REFACTOR!

So much for hiding the word "refactor" from VB.NET developers... (oh how I love the fact that it's spelled with a big fat exclamation point!!!!)

Have you taken a look at this new VB 2005 refactoring? I think this refactoring interface blows doors off the C# one. Everything is context sensitive right at your fingertips and all inline with the code editor -- no modal dialogs! And it's just a whole heck of a lot smarter about what you would want to do with the selected code. Any developer will be able to pick this up in two minutes. Thank you Microsoft for making such an awesome deal with Developer Express to provide us all with this free tool. (I think there's a C# one you can buy for $99.)

Thursday, April 21, 2005

Custom Exceptions and Remoting

I just thought I'd put up a reminder post about enabling the throwing of custom exceptions from your remote objects since this was a change from 1.0 to 1.1. It recently bit me in the butt when I was setting up a new system. If you need to throw your own exceptions from your remote objects that are hosted in IIS, you need to make sure that customErrors="Off" in your Web.config file. By default it's set to "RemoteOnly" which means it will work on your development machine, but not when clents requests are coming from remote machines.

Wednesday, April 13, 2005

Combobox Databinding Woes

UPDATE: This post is for Visual Studio 2003. For Visual Studio 2005 content please see this post.

I've been noticing a lot of questions on the newsgroups related to Winforms databinding and the combobox and I thought I'd post something up here to help people out. There are a couple very common scenarios in which people use the combobox:

1. To display information from a lookup table and send the selected value into another table's field.

2. To display a list of parent table's records and use that as a filter to display related child records. For instance, as the user selects a record in the combobox, you want to display all the related child records in a grid.

As usual, the trick is setting up the data binding properly and using the currency managers. In the first case it's not necessary to set up a data relation in your dataset between the lookup table and the table you're editing, but it doesn't hurt. In the second case it is necessary to create a relation between your parent and child tables. Let's take an example from our beloved Northwind:

Private Const SQL_CONNECTION_STRING As String = _
 "Data Source=localhost;" & _
 "Initial Catalog=Northwind;" & _
 "Integrated Security=SSPI"

Try
 Dim ds As New DataSet
 Dim cnn As New SqlConnection(SQL_CONNECTION_STRING)

 Dim da As New SqlDataAdapter("SELECT * FROM Region", cnn)
 da.Fill(ds, "Region")

 da = New SqlDataAdapter("SELECT * FROM Territories", cnn)
 da.Fill(ds, "Territories")

 ds.Relations.Add("Region_Territories", _
  ds.Tables("Region").Columns("RegionID"), _
  ds.Tables("Territories").Columns("RegionID"))

 ds.DataSetName = "RegionTerritories"

Catch Exp As Exception
 MessageBox.Show(Exp.Message)
End Try
In the first scenario we want to select a Region from the combobox and have that value populated into the Territorries record. In this case you'll need to set up the following properties on your Combobox:
Me.ComboBox1.DataSource = ds.Tables("Region")
Me.ComboBox1.DisplayMember = "RegionDescription"
Me.ComboBox1.ValueMember = "RegionID"
These properties control what items are displayed in the combobox and what value is used when the user makes a selection. Now to get that value into the Territories table, you'll need to set up a data binding:
Me.ComboBox1.DataBindings.Add("SelectedValue", ds, "Territories.RegionID")
Okay we're all set, right? Well... not exactly. You'll also need to call EndCurrentEdit on the territories currency manager at some point in order to write the value back to the dataset. Depending on the style of your form you could do this from an "Update" button (similarly you could call CancelCurrentEdit from a Cancel button). However, when working with datasets I find it much easier to use the dataset methods for Accepting/Rejecting row changes. So 99.99% of the time I just call EndCurrentEdit from the SelectedIndexChanged event handler of the combobox itself:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
 '-- This forces the comboxbox's value to be written to the dataset.
 Dim cm As CurrencyManager = DirectCast(Me.BindingContext(ds, "Territories"), CurrencyManager)
 cm.EndCurrentEdit()
End Sub
The cool thing (or anoying thing depending on how you look at it) about EndCurrentEdit/CancelCurrentEdit on the currency managers is that they cancel or commit only the fields in which they have bindings for where as the dataset rows' AcceptChanges/RejectChanges works on the whole row regardless of the data bindings. (It would be *really* nice if the currency manager had a property for this like "AlwaysCommitChanges" so we wouldn't have to call EndCurrentEdit all over the place.)

Now let's take our second scenario where we want to use the combobox as a row filter. In this case we have to have a relation set up between our parent and our child; in the example this is Region_Territories. The combobox properties can be set up just like the first example:
Me.ComboBox1.DataSource = ds.Tables("Region")
Me.ComboBox1.DisplayMember = "RegionDescription"
Me.ComboBox1.ValueMember = "RegionID"
Technically we don't need to specify the ValueMember property this time because we're not writing it anywhere, but it doesn't hurt to specify it. Next you'll need to set up the Datasource and DataMember properties of the DataGrid using the relation path. It is very important to get the path right otherwise the datagrid will not filter automatically as we move the position in the parent:
Me.DataGrid1.DataSource = ds
Me.DataGrid1.DataMember = "Region.Region_Territories"
Okay we're all set, right? Well... not exactly (I knew you were going to say that <g>). Unfortunately a combo box won't move the CurrencyManager's position for you like list controls do (Grids, Listboxes). So the trick is to get a hold of the parent currency manager and move the position manually by handling the combobox's SelectedIndexChanged event:
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, _
  ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
 Dim cmParent As CurrencyManager = DirectCast(Me.BindingContext(ds, "Region"), CurrencyManager)
 cmParent.Position = Me.ComboBox1.SelectedIndex
End Sub
Because you set up the datagrid to display the related territories by specifying the relation path Region.Region_Territories as the DataMember, the grid will automatically filter it's rows based on the selected parent row in the combobox.

The currency managers are your friends. You can obtain currency managers for any table/path in your dataset even if there are no control bindings set. You can also use the currency managers to disable controls when the position moves to -1 (no records) Here's an example. The currency managers maintain dataviews so you can easily access the current DataView as well as the current DataRowView:
Dim dv As DataView = DirectCast(cmParent.List, DataView)
Dim dvr As DataRowView = DirectCast(cmParent.Current, DataRowView)
Complex winforms databinding can take some practice, but once you get the hang of it you can create some very cool forms. Have fun!

Stop the mailing list insanity!

Looks like I'm not the only one frustrated with unwanted email that won't unsubscribe! (Make sure you scroll to the diagram on page 3. WARNING: This may offend you.)

Friday, April 08, 2005

Sunday, April 03, 2005

I'd like to thank the academy...

This was totally unexpected and I just want to extend a personal thank you to Microsoft, GiftRAP, and especially the community!