Help me prove that Visual Studio 2005's designer is better than writing code

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
I am working with someone who took some basic programming courses and is not a software engineer, but now writes code.

I need to explain why using the form designer in Visual Studio 2005 (VB.NET) is better than writing CODE to do it. This includes creating and setting up grid columns in the DataGridView. This person insists on writing half a page of code to set basic properties which are much easier and visually better to set via properties of the designer. I don't want to analyze half a page of code to see what the grid or form will look like, I just want to LOOK at it.

Am I right? What are the pro's I can present?

Thanks!
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
Well, IMO, it can go both ways. There are certainly arguments to doing things in code, especially if you are planning on reusing that code elsewhere, or need to re-initialize the grid at some point. Also, you may not want to initialize a form immediately when the form is created. Judging from your post, I'm assuming that this is not the case. I prefer to setup the basic aspects of my forms through the designer. If you know that the types of your data will never change, I don't see any reason not to arrange the grid columns in the designer. Perhaps your coworker is simply trying to practice all aspects of coding? You could point out that the same code will be generated in the InitializeComponent call to show him/her that it can waste time.
 

SoftwareEng

Senior member
Apr 24, 2005
553
4
81
Good point Tencntraze... But this done in code in FormLoad just kills me...

.Columns(0).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(1).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(3).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
.Columns(4).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
.Columns(5).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleLeft
.Columns(6).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(7).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(8).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(9).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(10).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter
.Columns(11).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter

.Columns(0).Width = 70
.Columns(1).Width = 120
.Columns(2).Width = 40
.Columns(3).Width = 40
.Columns(4).Width = 40
.Columns(5).Width = 110
.Columns(6).Width = 70
.Columns(7).Width = 70
.Columns(8).Width = 70
.Columns(9).Width = 70
.Columns(10).Width = 70
.Columns(11).Width = 70
.Columns(12).Width = 0
 

Snapster

Diamond Member
Oct 14, 2001
3,916
0
0
like Tencntraze said, there are good and bad things. For example, there are some things that you'll only find in code that won?t be displayed in designer, like summary rows and optional formatting on particular cells/rows. Designers are useful for quick and dirty thing and you can get the general feel, but as you know you can do more in the code. Personally if I ever use a datagrid I would set the basic structure out in designer view then edit it in code, ie add custom columns, rows etc that are not part of the data source bound to it. However given that I use templating allot I don't always get to see the designer view much nowadays anyway, let alone will it look the same as the final article once it's been niced up with CSS.
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
I often do it in ASP.Net (in code, not in designer) but have never once done it in a windows forms app. Makes sense in asp.net because often times you need to customize the layout to fit exact specifications and look & feel.
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
Basically, if all of the stuff that your coworker is doing in code is stuff like setting basic column properties, then I see no reason not to use the designer (unless the widths of the columns need to be calculated at run-time, or for one reason or another the alignment is dependent on some set of conditions). In VS2005, the separated the designer-generated code (InitializeComponent) into a separate file for a *reason*, in that it results in ugly clutter that makes finding the actual logic in the code that much more difficult.

You could also berate your coworker endlessly for time-wasting, annoying coding until they stop doing it :D
 

Jaxidian

Platinum Member
Oct 22, 2001
2,230
0
71
twitter.com
I don't know if an update has recently fixed it but when VS2k5 was first released, there was a bug in one of the controls (a splitter or something - I'm 95% asp.net, not winforms) where the IDE would try to change properties of the control before the control was actually initialized. This of course caused problems. The only fix at the time was to go and manually fix the code that IDE generated but because the IDE regenerates that code all the time, that was a horrible fix. So that left you with not configuring some properties in the IDE which meant you HAD to have them on your Load functions.

But generally, I agree with you. With WinForms, I use the IDE for 99% of stuff. ASP.NET, on the other hand, I use the IDE for 1% of stuff. :p

-Jax
 

Atheus

Diamond Member
Jun 7, 2005
7,313
2
0
I don't want some program writing my code for me, I know exactly what I want and I write it. Done. How could some automagic microsoft crap possibly be better?

I also hate VB, and wouldn't code it for £100 an hour, so I suppose it might be different in that language to the ones I do use.. can't see how though...
 

Tencntraze

Senior member
Aug 7, 2006
570
0
0
I feel equally strongly about VB, and during my days in Developer Support, I could tell a VB programmer before I knew what language they used (though I'm talking strictly about the .NET world). Luckily, I don't have to touch VB anymore; God help code readability if you have to do a few casts in a single line.

As for knowing exactly what you want and writing it, that makes sense for most cases and I'd agree, but there's no reason to manually type out all the little tedious details that can be auto-generated through the IDE, with the end result being the same code that you would have had to write anyway. However, I'm restricting this opinion to what I stated above, in that anything that requires any sort of complexity or dependencies is better done through code.

All of this being said, I still tend to do most of my stuff in code since it allows me to better structure everything and do certain things lazily/as-needed instead of initializing everything immediately.
 

Markbnj

Elite Member <br>Moderator Emeritus
Moderator
Sep 16, 2005
15,682
14
81
www.markbetz.net
Originally posted by: Tencntraze
Basically, if all of the stuff that your coworker is doing in code is stuff like setting basic column properties, then I see no reason not to use the designer (unless the widths of the columns need to be calculated at run-time, or for one reason or another the alignment is dependent on some set of conditions). In VS2005, the separated the designer-generated code (InitializeComponent) into a separate file for a *reason*, in that it results in ugly clutter that makes finding the actual logic in the code that much more difficult.

You could also berate your coworker endlessly for time-wasting, annoying coding until they stop doing it :D

Yeah, the challenge for a visual designer isn't in the functional stuff like setting properties. It's nice to have an automated way of coding all that. But I haven't yet used a tool that I want to code HTML for me. The ones I have used (WebMatrix, VS, nVu) universally suck. I don't know anyone who doesn't code HTML by hand.
 

Jaxidian

Platinum Member
Oct 22, 2001
2,230
0
71
twitter.com
Originally posted by: Atheus
I don't want some program writing my code for me, I know exactly what I want and I write it. Done. How could some automagic microsoft crap possibly be better?

I also hate VB, and wouldn't code it for £100 an hour, so I suppose it might be different in that language to the ones I do use.. can't see how though...

I wouldn't hire you, then. I only want to hire people who know how to and utilize their tools to their fullest potential. You just admitted that you are too stubborn to use a tool that can save tremendous time - not a good thing to say if you're looking for a job. Granted, you're not looking for a job here. But just an observation for constructive criticism. I feel where you're coming from in that you think you can do a better job. However, your attitude shouldn't be "I can do it better so I won't use it at all" but instead should be "I can do it better so I'll code-review the code that it generates and make it better but let it write 80% of the code that will be the same as what I would write".

Again, just some constructive criticism. :)
 

xtknight

Elite Member
Oct 15, 2004
12,974
0
71
Originally posted by: Atheus
I don't want some program writing my code for me, I know exactly what I want and I write it. Done. How could some automagic microsoft crap possibly be better?

I also hate VB, and wouldn't code it for £100 an hour, so I suppose it might be different in that language to the ones I do use.. can't see how though...

I don't want some compiler making the machine code for me. Only wussies write in C and VB. Writing in assembly is much more fun, you learn a lot more and you have much more control over it. Aside from that, using optimized libraries people have already made is just dumb. I code my own stuff, that way I know what's in it and since I'm the best programmer in the entire world, statically linking my program with my own super routines just gives me that huge ego boost.
 

tfinch2

Lifer
Feb 3, 2004
22,114
1
0
Originally posted by: xtknight
Originally posted by: Atheus
I don't want some program writing my code for me, I know exactly what I want and I write it. Done. How could some automagic microsoft crap possibly be better?

I also hate VB, and wouldn't code it for £100 an hour, so I suppose it might be different in that language to the ones I do use.. can't see how though...

I don't want some compiler making the machine code for me. Only wussies write in C and VB. Writing in assembly is much more fun, you learn a lot more and you have much more control over it. Aside from that, using optimized libraries people have already made is just dumb. I code my own stuff, that way I know what's in it and since I'm the best programmer in the entire world, statically linking my program with my own super routines just gives me that huge ego boost.

I don't want some interpreter running my assembly code. I want to interface directly to the hardware. Man you are a n00b!
 

PhatoseAlpha

Platinum Member
Apr 10, 2005
2,131
21
81
At any rate, have you by any chance simply offered to teach him how to use the designer properly?

Working with Datagrids in the designer in 2003 kind of frustrated me - it really wasn't superintuitive to find everything you wanted to find. It may be that he's writing it that way because that way he can lean on intellisense to find the settings he's looking for, simply because he doesn't know where to set them in the designer.
 

MmmSkyscraper

Diamond Member
Jul 6, 2004
9,472
1
76
Originally posted by: tfinch2
I don't want some interpreter running my assembly code. I want to interface directly to the hardware. Man you are a n00b!

Master Control Program: I feel a presence. Another warrior is on the mesa.