Thursday 31 March 2005 — This is over 19 years old. Be careful.
As I’ve mentioned, I’ve taken over responsibility for a body of C# code. The layout code is filled with stuff like this:
this.Size = new Size(this.Size.Width,
this.widgetsLabel.Location.Y + this.widgetsLabel.Size.Height);
To paraphrase Tevye, would it have spoiled some vast eternal plan to write this instead?:
this.Height = this.widgetsLabel.Bottom;
I spent quite some time today applying shrinking transformations:
x.Size.Height --> x.Height
x.Location.Y --> x.Top
x.Top + x.Height --> x.Bottom
x.Size = new Size(x.Width, y); --> x.Height = y;
x.Location = new Point(x.Location.X, y); --> x.Top = y;
Believe me, it’s much more readable afterwards! Of course, I’ve a sneaking suspicion that a lot of this layout code could just be chucked by setting proper constraints in the forms designer! To quote another movie character, I can’t think about that today, I’ll think about that tomorrow.
I’ve slightly edited this post to remove asides about developers that were distracting from my point. Reactions from readers about those comments have also been removed.
Comments
Add a comment: