Trials and Tribulations of DataGridView, Column Selections, and Sorting

I had to implement some custom sorting in a DataGridView recently.  Essentially, the stakeholders wanted full column selection (like Excel) while still having the ability to sort the data based on a particular column. This particular DataGridView is data-bound.  DataGridView offers the Sort(DataGridViewColumn, ListSortDirection) method to perform this.  Nice and easy I thought: I’ll set the SelectionMode to DataGridViewSelectionMode.ColumnHeaderSelect and simply call Sort with the selected column. Well, much to my chagrin this had the side effect of making that column look selected all the time.  No matter where else I clicked, that recently sorted column looked selected (SelectedColumns had … Continue reading Trials and Tribulations of DataGridView, Column Selections, and Sorting

Drag and drop of control selections onto forms designer toolbox

A while back I blogged about the ability we have in Visual Studio to select text in a text editor and drag it onto the toolbox.  Once on the toolbox you could drag those items back into the text editor to effectively “paste” frequently needed snippets of code into other text files. Imagine my surprise when we didn’t have this ability in the forms designer.  When writing code, it’s a bit specious to want to have multiple copies of hard-coded snippets of code (DRY should come to mind).  But, for forms, the only alternative is to create user controls to … Continue reading Drag and drop of control selections onto forms designer toolbox

Location of unit tests.

I had a short  conversation at Alt.Net Canada about the location of unit tests.  I personally tend towards a distinct unit test project.  But, I deal with mostly commercial, off-the-shelf (COTS) projects where I simply can’t ship code like that.  I also don’t want to wire-off the unit test via #if because I would then be shipping something different than that which was tested. From an enterprise application point of view, this is different.  I would have no problem including the unit tests within their respective project as production code

The winds of change are blowing

The essence of ALT.NET, or at least the essence that people made use of, was that it was a venue for improving one’s skills.  There has always been an undercurrent of other agendas there; but they never really took root. The problem with the ALT.NET moniker was it isolates it from most of the industry–it was an island of .NET practitioners.  This basically flicked its thumb at the other communities–other communities that propagated some of the guidance that ALT.NET was trying to proliferate. In the very spirit of continuous improvement it seems that ALT.NET is attempting to evolve and the … Continue reading The winds of change are blowing

Extra Features: One of the Lean 7 Wastes of Software

Derik Whittaker recently blogged about how writing unused code is one of the Lean 7 Wastes of Software.  Mary Poppendieck calls this “Extra Features” and has a one-to-one association to overproduction in manufacturing.  In Manufacturing it has different caveats: if you overproduce something you have to have somewhere to store it until its sold.  What do you do when you don’t have the space to store it?  If you have the space, it’s not too much of an issue; you just tuck it away; but you still need people to move it, manage the space, manage the responsibilities around moving/storage, … Continue reading Extra Features: One of the Lean 7 Wastes of Software

IS prolific use of inheritance a sign of a poorly design program?

A principle that is used to validate inheritance is Liskov Substitution principle (LSP).  Basically, it implies that a subtype must be interchangeable with its super-type without adverse side effect. With this principle in mind it’s easy to discount many particular sub/super-type inheritances.  The quintessential Uncle Bob example of a Liskov Substitution violation are Rectangle and Square.  In geometry a Square is a type of Rectangle (and Rectangle is a type of polygon, etc…); but that maxim doesn’t hold true in most OO implementations in light of LSP. Let’s say we implement a Rectangle class like this:     public class Rectangle … Continue reading IS prolific use of inheritance a sign of a poorly design program?

Law of Reversibility of Attributes

I’ve come up with a simple law called Law of Reversability of Attributes.  It’s based on the physics law of a similar name.  Basically what the law means is that the inverse of a transformation should result in a return to the original state. The Law of Reversibility of Attributes is defined as: For a given state of an object; when a attribute’s value is changed, the inverse of that value, when applied to that attribute, will result in the object returning to its original state. I say “attribute” rather than “property” to encompass methods that imply setting of attributes.  So, … Continue reading Law of Reversibility of Attributes

DataGridViewColumn.Frozen

DataGridViewColumn.Frozen is documented as “When a column is frozen, all the columns to its left (or to its right in right-to-left languages) are frozen as well.” Which is nice until you think of the consequences.  The consequences being that freezing a column and all columns to the left is performed with a single assignment of true to the Frozen property of that column; but to unfreeze is not the opposite (a assignment of false to the Frozen property of that column).  No, you must unfreeze each of those columns to the left.  This can be done by manually unfreezing each … Continue reading DataGridViewColumn.Frozen

Transparency in Software Products

Lack of transparency leads to an "us and them" attitude.  It breeds contempt for your customer.  Customers are forced to provide feedback at a point when changes are very high friction and hard to manage.  It forces the development team to follow through with undesired functionality simply because "its too late in the development cycle". No one disputes that iterative development is a bad methodology; but some organizations simply don’t follow it.  They promote iterative development and say they’re iteratively developing; but they aren’t.  They periodically provide their releases and sometimes publicly available betas; but that’s not iterative.  Iterative development … Continue reading Transparency in Software Products

Getting the most out of Reflector

Reflector has been out for years now.  It’s ubiquitous and a staple for many .NET developers.  But, I think it’s taken for granted because of it’s ubiquity.  I’ll outline how I use Reflector and show how I wouldn’t be able to develop .NET software as well without it. Understanding Language Constructs In the days of .NET 1.x, what the .NET languages produced mapped, more-or-less, one-to-one with the language constructs of Intermediate Language (IL or MSIL).  That is, it was easy to reverse from IL back to C#.  View Code From the Point Of View of a Previous Language Version Viewing … Continue reading Getting the most out of Reflector