Sunday, March 29, 2009

Microsoft's Guide to Windows Form... WTF?

I have just read this (for the first time): http://msdn.microsoft.com/en-us/library/ms229597(loband).aspx

This is the first article in the series of ones created by MS to help developer get started with Windows Form.

The last code snippet says:
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;

namespace FormWithButton
{
public class Form1 : Form
{
public Button button1;
public Form1()
{
button1 = new Button();
button1.Size = new Size(40, 40);
button1.Location = new Point(30, 30);
button1.Text = "Click me";
this.Controls.Add(button1);
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show("Hello World");
}
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new Form1());
}
}
}

If you notice the way the button size and location are specified, you may find it too bad.

Even for the purpose of simplifying the code in a getting started guide, they should not do that way.

WTF? At the very first step to Windows Form, Microsoft leads their developers to the most stupid mistake that any UI developer should avoid.

No comments: