![]() | Ned Batchelder : Blog | Code | Text | Site My own private WTF? » Home : Blog : March 2005 |
My own private WTF?Thursday 31 March 2005 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, 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 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
Looks like their code was generated by a GUI page design mode.
"You are in a maze of twisty little passages, all different."
If you try to set widget.Location.Y I think it complains that Y is a read-only property, as I recall. Perhaps whoever wrote this assumed that the same would apply to widget.Top and never checked once they had found an incantation that works. I think I've done the same with some of this widget stuff.
Add a comment: