# Monday, March 09, 2009

SDN Event on March 30th in Hotel & Congrescentrum "De Bergse Bossen" (The Netherlands)

The combined user groups of the SDN are putting together a terrific one day event with great sessions for software developers, architects, information workers and database professionals. Don't miss it!

Here is an overview of the sessions:

image

Go to www.sdn.nl/sde to sign up!

#    Comments [0] |

developer.Equals( otherDeveloper );

It often seems that management believes developers are highly exchangeable. Is an experienced developer leaving the team?

Then just new up a new .NET developer and you're done. This Dilbert episode reminded me of that attitude.


From www.dilbert.com

#    Comments [0] |
# Monday, February 16, 2009

MSDN Roadshow is coming to Augusta

Roadshow.pngOnce again the Maine Developer Network (thanks to John, Shawn and the State of Maine Government) is happy to help out Chris, Bob and Jim with finding a location to hold the MSDN Northeast Roadshow.

On March 19th the Roadshow will hit the Central Maine Commerce Center in Augusta. Go here to sign up today!

Location
Central Main Commerce Center
Florian Auditorium
500 Civic Center Drive Augusta Maine 04330
United States

Date
Thursday, March 19, 2009 8:30 AM - Thursday, March 19, 2009 4:00 PM Eastern Time (US & Canada)
Welcome Time: 8:00 AM

#    Comments [0] |

How about those code comments?

I just read Daniel's post on 'The Value of Commenting'. Food for thought people :-)

I like to use the following rules of thumb:

a) Code should be self explanatory. This means using well named variables, properties and objects in order to make code as easy to read as possible. It should be obvious from the code what it is that it is trying to do.

b) Code should be easy to read. By easy I mean that you need to be able to scan it pretty fast. Sometimes comments can help make code easier to read by describing what is going on. I find this especially true in if/else constructions where a short comment can guide the reader of the code.

c) If more that one line of code is needed to describe a code block, consider refactoring the code to a private method and put comments on the method. A useful name for the method should help in achieving point (a).

d) Comments should describe why you're trying to do something, but this has limits. Extensive explanations on why the purchase amount of an order should never exceed $10000 should not be in the code. A list of rules should be maintained as part of the documentation and a reference to the rule should be made from the code comments.
Note: I have been known to document a list of rules as an enumerator, where the documentation of the rule is documented as the description of the enumerated value.

Actually (d) is the hardest one. When is it necessary to describe the 'why' of an operation?
The code is readable, the original programmer put it there for a reason. Are the comments there because the presence of the code needs to be justified? No! The 'why' comments are to facilitate (b).

As always, it's easy to spot useless comments, but hard describe a fixed set of rules to describe good comments. Use your brain!

#    Comments [2] |
# Tuesday, February 10, 2009

It's sleek, it's cool, it's got gadget power!

But it is not the same as having a book that sits on your shelve and collects dust.

The Amazon Kindle 2 is here:

Kindle2

 

 

 

 

 

Lighter, better display, more storage and longer battery seem to be the improvements in the second generation Kindle.

I want one, but part of buying books and novels is the feel of collecting and adding to my library... I'm not sure I want to miss that feeling. I must be getting old fashioned ;-)

More info here.

#    Comments [0] |
# Monday, February 02, 2009

.NET Framework platform availability

I had to find out which platform supports which version of the .NET Framework. The information is a little fragmented, but here is the overview I came up with.

Windows 95
The .NET Framework cannot be installed on Windows 95.

Windows 98
.NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0

Windows 98 SE
.NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0

Windows ME
.NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0

Windows NT 4.0 SP6a
.NET 1.0, .NET 1.1

Windows XP
.NET 1.0, .NET 1.1

Windows XP SP2
.NET 1.0, .NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5

Windows 2000
.NET 1.0, .NET 1.1

Windows 2000 SP4
.NET 1.0, .NET 1.1, .NET 2.0

Windows Vista
.NET 2.0, .NET 3.0, .NET 3.5

Windows 2000 Server SP2
.NET 1.0, .NET 1.1

Windows Server 2003
.NET 1.1, .NET 2.0, .NET 3.0

Windows Server 2003 SP1
.NET 1.1, .NET 2.0, .NET 3.0, .NET 3.5

Windows Server 2003 R2
.NET 2.0, .NET 3.0, .NET 3.5

Windows Server 2008
.NET 2.0, .NET 3.0, .NET 3.5

 

Just to be clear, .NET 3.5 cannot be installed on:

  • Microsoft Windows 95
  • Microsoft Windows 98
  • Microsoft Windows Millennium Edition
  • Microsoft Windows NT Server
  • Windows NT Workstation
  • Windows NT Server Enterprise Edition
  • Microsoft Windows 2000 Professional
  • Windows 2000 Server
  • Windows 2000 Advanced Server
  • Windows 2000 Datacenter Server
  • Windows Server 2003, Enterprise Edition for Itanium-based Systems
  • Windows Server 2003, Datacenter Edition for Itanium-based Systems

 

References:

[UPDATE: .NET 3.0 will not run on Windows 2000 or Windows 200o SP4]

#    Comments [4] |
# Tuesday, January 13, 2009

Microsoft starts new ad campaign

Microsoft has started a new ad campaign. Why mention it here? I like the ad, that's why.

#    Comments [0] |
# Thursday, January 01, 2009

MVP Award 2009

The year is off to a great start! I got an email this morning informing me I've been awarded the MVP Award 2009. Terrific! 

MVPLogo

 

Quote: The Microsoft MVP Award provides us the unique opportunity to celebrate and honor your significant contributions and say "Thank you for your technical leadership."

#    Comments [4] |
# Thursday, December 18, 2008

SQL Server file sizes

Today I needed a query to see what the size and growth settings were for our databases. The query below will output name, size and growth information.

SELECT  SUBSTRING([name], 0, 40) as [Name],
                (([size]*8)/1024) as SizeMB,
                CASE [growth]
                        WHEN 0 THEN 'Fixed Size'
                        ELSE
                                CASE [is_percent_growth]
                                        WHEN 0 THEN 'Absolute growth: ' + CAST([growth] as varchar)
                                        WHEN 1 THEN 'Percentage growth: ' + CAST([growth] as varchar)
                                END
                END as [GrowthInfo]
FROM    sys.database_files

Output looks like this:

Name                                     SizeMB      GrowthInfo
---------------------------------------- ----------- -------------------------------------------------
AdventureWorks                           10          Fixed Size
AdventureWorks_log                       5           Fixed Size

#    Comments [0] |

SQL Server 2005 SP3

Microsoft has release SQL Server 2005 Service Pack 3, download the service pack here.

Release notes can be found here and there is also a list of the bugs that are fixed in SQL Server 2005 Service Pack 3. Looks like around 45 bugs fixes!

#    Comments [0] |
# Thursday, December 11, 2008

EC2 in Europe

Living in the United States it is sometimes easy to forget that some companies are much more America focused than others. Microsoft will offer some of it's betas to the North American region only, but products are usually available worldwide. Windows Azure, as a beta, is offered worldwide.

Amazon EC2 (RTM) has been offered in North America only, but has made the jump across the pond to Europe. In my mailbox today:

"We are excited to announce that we have extended Amazon Elastic Compute Cloud (Amazon EC2) to Europe. Developers and businesses can now run their Amazon EC2 instances in the EU to help achieve lower latency, operate closer to other resources like Amazon S3 in the EU, and meet EU data storage requirements when applicable. The new European Region for Amazon EC2 contains two Availability Zones enabling you to easily and cost effectively run fault-tolerant applications with the same scalability, reliability and cost efficiency achieved with Amazon EC2 in the U.S."

 

Amazon EC2 is the Amazon offering for hosting virtual machines in the Amazon Cloud. Windows Azure is a slightly different, but competing solution from Microsoft.

 

Note: Interested in Amazon services? Some time ago I wrote Introduction to AWS for C# developers.

#    Comments [0] |
# Tuesday, December 09, 2008

The next thing for the web: Google Native Client = Googlelight?

Brad Chen from Google just announced a new form of browser technology: Native Client. It will allow you to write C or C++ code which runs, through Native Client, in the browser.

"At its core, our release consists of a runtime, a browser plugin, and a set of GCC-based compilation tools."

With my Microsoft minded way of thinking, I read:

  1. a runtime which needs to be installed, like the .NET CLR,
  2. a browser plugin, like Silverlight,
  3. tools to develop like Visual Studio / Expression Blend.

Sounds to me like Google is a little worried about Silverlight and Flash and wants to play too :-)

Update [9/12/2008]: PC World refers to Native Client as Google ActiveX. It'll be interesting to see how soon the focus will go from computing power to animation power.

#    Comments [0] |
# Monday, December 08, 2008

MCTS Self-Paced Training Kit (Exam 70-561): Microsoft® .NET Framework 3.5 ADO.NET Application Development

I just send the last revision of my chapters for TK 70-561 to the editor. Yeah! Hopefully the book will go to print soon. You can pre-order already on Amazon!

Cover-TK70-561

For me the last chapter to work on was LINQ to SQL, but the book includes chapters on learning ADO.NET, Typed DataSets, LINQ to SQL and Entity Framework. You'll need to know it all. :-)

Stephen Forte has an interesting post on the relevance of LINQ to SQL.

#    Comments [2] |
# Sunday, November 30, 2008

LINQ to SQL SubmitChanges()

The DataContext.SubmitChanges() method will update the database in the following order:

- Perform all inserts
- Perform all updates
- Perform all deletes

Running SQL Profiler while running the following code will first perform all inserts on product, then the updates and the deletes. Also note that SubmitChanges will perform a batch update (which is good). The SubmitChanges is a single statement, but it does not implement a transaction, so if you want a rollback to occur if an exception occurs (for instance a foreign key violation) then you'll need to use a TransactionScope.

public void UpdateOrders()
{
    using ( var db = new VideoGameStoreDBDataContext() )
    {
        var query =  from p in db.Products
                    select p;
 
        foreach(var product in query)
        {
            product.ListPrice = product.ListPrice * 1.1;
            if ( product.ListPrice > 400 )
            {
                db.Products.DeleteOnSubmit( product );
            }
        }
 
        ProductType game = (from pt in db.ProductTypes 
                         where pt.ProductTypeName == "Game"
                         select pt).Single();
 
        Product newProduct = new Product()
        {
            ProductName = "Travian",
            ListPrice = 20,
            ProductType = game,
            ProductDescription = "Online Game",
            ProductTypeID = 1,
            ListPriceCurrency = "$"
        };
 
        db.Products.InsertOnSubmit( newProduct );
        db.SubmitChanges();
    }
}
#    Comments [1] |
# Thursday, November 27, 2008

Change selected cell in DataGridView on right click

I wanted to add a context menu to a DataGridView, allowing the user to perform an action on a specific row. However, right clicking in a DataViewGrid does not change the selected row. This can be achieved by adding the following code to the CellMouseDown event (the name of my grid is dgvWorkflows):

private void dgvWorkflows_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
    if (e.ColumnIndex >= 0 && e.RowIndex >= 0)
    {
        dgvWorkflows.CurrentCell = dgvWorkflows.Rows[e.RowIndex].Cells[e.ColumnIndex];
    }
}

#    Comments [0] |
# Wednesday, November 12, 2008

Workflow Foundation, fault handlers and self recovering state machines

We had an interesting workflow issue the other day. For some inexplicable reason our state machine workflow was terminated. After digging around in the database trying to reconstruct what might have happened we finally figured it out:

We have a transaction scope activity which sends an update to the database. The update failed and the exception cause the fault handler on the activity to kick in. The fault handler changed the state of the state machine to custom state called 'TechnicalError'. We explicitly modeled this state because it allows our administrators to recover a workflow from a technical error and essentially restart the workflow. In the InitializeState of the 'TechnicalError' state we wanted to update some data in the database. This also failed, since the cause of the original error was that we had lost connectivity to our database.

Next?

Since we had no fault handler on this database action the workflow crashed. Since connectivity to our workflow persistence database was also lost we now have a situation where the workflow in memory is inconsistent with the data in our line of business application database and is also inconsistent with the last persisted state in the workflow persistence database.

Next?

The workflow runtime never crashed several minutes later the workflow persistence database came back online and the in memory state of the workflow (which was terminated) was sync-ed with the workflow persistence database. However, our line of business database was never updated. The timestamp on the updates in the workflow persistence database where minutes apart from the last updates in the line of business database, which made it hard to reconstruct what had happened.

Solution?

We now have a fault handler on the initialize state of the 'TechnicalError' state. If the workflow persistence database OR the line of business application database is unavailable then a delay is introduced. And the workflow retries to transition to the TechnicalError state. This way the workflow will never ever terminate. The only scenario left is where the machine running the workflow is turned off. If this happens then the workflow will recover from it's last save point and life should be good.

#    Comments [0] |

MSDN Roadshow is coming to Augusta

 Roadshow-September-2008_thumb

The Maine Developer Network is proud to announce that the Northeast MSDN Roadshow by Chris Bowen and Jim O'Neil will once again make it as far north as Augusta!

Don't hesitate: sign up today!

 mdn_logo

#    Comments [0] |
# Saturday, November 01, 2008

LINQ to SQL is dead

It would appear that LINQ to SQL is running on a dead end track.

At PDC the announcement was made that no more investments in LINQ to SQL are made and the Entity Framework will absorb any features that LINQ to SQL has and that are worth preserving.

The following message from Tim Mallalieu says it all:

Is LINQ to SQL Dead?

We will continue make some investments in LINQ to SQL based on customer feedback. This post was about making our intentions for future innovation clear and to call out the fact that as of .NET 4.0, LINQ to Entities will be the recommended data access solution for LINQ to relational scenarios. As mentioned, we have been working on this decision for the last few months. When we made the decision, we felt that it was important to immediately to let the community know. We knew that being open about this would result in a lot of feedback from the community, but it was important to be transparent about what we are doing as early as possible.  We want to get this information out to developers so that you know where we’re headed and can factor that in when you’re deciding how to build future applications on .NET.  We also want to get your feedback on the key experiences in LINQ to SQL that we need to add in to LINQ to Entities in order to enable the same simple scenarios that brought you to use LINQ to SQL in the first place.

#    Comments [2] |
# Friday, October 31, 2008

Live Mesh goes to world wide beta

Live Mesh has gone from Tech Preview to official beta status. This also means it has gone world wide!

"Worldwide availability. We’ve removed the limits on what countries are able to sign up to use Live Mesh. We previously had limitations in place so that we could complete our testing with various language and locale settings, and now that work is indeed complete (with the caveat of course that for now the mobile client, as mentioned above, is not actually available worldwide)."

Yesterday I watched Don Gillet's PDC session on building a Mesh Application. It looks very easy.

My main concern with all this data in the cloud is securing my data. I'm thinking I may need to implement some sort of EncryptedDataEntry class which derives from DataEntry. I'll think about it some more...

#    Comments [0] |