Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Long story short, I'm president of a programming club at my university. We're all 1st and 2nd year programming students. We have a project we're about to start working on (converting a console program to a gui program, in c#). Only two of us have any experience working with winforms and event driven programming in general.

We want to balance learning with production (getting the project finished) as most of us don't have time to commit to a full on, 40 hour a week project. Our adviser is trying to steer us in the direction of not using VS2010's winform designer, he's trying to make it a requirement that we code everything in a "notepad++" type environment.

So basically, I need to get some answers to a few questions that I'm having trouble researching, so when we discuss how to proceed later today and tomorrow, I'm armed with some actual knowledge.

(We are all, including the adviser, generally "new" to winforms,c#, and .net)

In "real world" situations with winforms, how frequent is it that the designer would not at all be used?

Are we (the club officers) right in our estimation that what we have figured at a 4-6 month project (using the designer) would double, if not triple coding everything without it?

What are the merits of not using the designer at all as a learning tool to "see how its done"?

Is it a valid learning opportunity if we use the designer, then look at the generated code to get more familiar with how our custom controls/event handlers should be done?

I'm currently at a bit of a loss, and thank you all for your responses.

(Also, if possible could you list your years in field, and degrees if you respond, our adviser is huge on only taking opinions from who he considers "qualified", thanks).

Edit -- Also take into account that learning is also one of our priorities, not just time constraints (We're trying to strike a balance between learning every single thing that we can, and having a project that needs so much time invested in it that it becomes unfeasible for us).

share|improve this question

migrated from stackoverflow.com Aug 10 '11 at 2:32

This question came from our site for professional and enthusiast programmers.

    
Yeah, I'm just not exactly sure how to phrase the question without a bit of the backstory... I'll start editing to see what I can cut out. –  Tyler W Aug 9 '11 at 21:55
    
I suspect your adviser reads Charles Petzold... –  Benjol Aug 10 '11 at 5:02

6 Answers 6

up vote 3 down vote accepted

Two things I noticed from the (engineer) schools I went to (and I did quite a few...) is that teachers all prefer open source stuff, and to use the most basic tools in general.

Now for the first matter, it's a question of budget, and it's irrelevant to the actual industrial world. Let's be honest, I've never seen a company make its employees code .NET with notepad(++).

For the second matter, I would agree to some extent, it teaches you how to code without coupling to a particular IDE.

As for the WPF debate, it is really not a good way to start .NET technologies, as I said in a comment, the learning curve may just kill your group (and you won't achieve anything in 4-6 months).

That said, VS2010 is the best IDE there is, and I thoroughly recommend it for your project: you can first abstract out a few things (like basic event handling as it's done automatically by the designer) and focus on implementing the easy parts of your project - gives you confidence.

Later on, you will need to make custom events, you will also need to make dynamic GUI features (adding tabs to a tabpanel for example) and then you can learn more about controls, and who knows? maybe some custom controls inheriting or not from windows controls.

Bottom line, the learning curve with VS2010 will be much smoother, and allow you to chose when you're ready for the next level, instead of starting from scratch and getting at the worst from the very start which can be discouraging.

And I'd add a particular note: if you go to an interview, and explain that you never used VS2010 but you have ".NET experience/background", your interviewer will have trouble retaining his laughter. Seriously, you would look bad.

As for the "degree" part, I have none, but I'm a professional anyway ;)

share|improve this answer
    
re: Being laughed at in interview. One may professionally use Visual Studio without ever touching forms designer. Even when working on GUI it makes sense to avoid designer for small changes because of the merge hell it creates. –  Constantin Aug 23 at 20:37

This is an odd question, but in the real world time equals money. The designer generated code is not difficult to understand, so writing it by hand is an unnecessary time and money sink. Use the designer. Furthermore, the designer generated code is probably in a format that you will not use in any other aspects of programming, and it actually uses some conventions that a lot of C# experts would say are bad anyway. Realistically, in the real world, debating whether to use the designer or not is not a question. It isn't a subject that is brought up. Your focus should be on getting the project done in the most efficient and cost-effective manner possible. Programming is always going to be a constant learning experience, on the fly.

In C++, you almost have to write your user interface by hand, because the tools for it aren't that great. (They have probably improved last I used them). The point still remains, the .NET WinForms designer is pretty polished for what it is. Aside from that, if you write designer code by hand, you may find VisualStudio overwriting some of your designer code with its own. As the commented MSFT conventions state, do not touch the designer generated code unless you have to.

You also asked for some information about your answerers.. I developed heavily in C++ for years, but have been developing in C# since I was 14 (7-8 years now), and professionally for the past 3-4 years (in the field) and I now own a software development business here locally.

I think your adviser is going about this in the wrong manner, though. Sorry to say. If you really need an adviser I would suggest looking into someone who actually has expertise in C#/.NET or at least has a wide diversity of experience in different technologies and languages rather than one C++ guy (from back in the day it sounds like?). There is more to developing a successful software project then debating things like to code-by-hand or using a designer. How you create the UI should be the least of your worries compared to things like software architecture, construction, standards, time, money, etc.

In conclusion, use the designer. It is efficient and not using it is going to be more of a road block than a help. Invest in books for your developers (C# language specification, WinForms, WPF), make sure they have internet access to find their own resources. But your advisor should know that programming is a never-ending learning experience. This question and the method he seems to be handling this is the strangest I've seen recently.

Also you stated these are programming students. In the real-world, programmers are expected to be able to learn on their own, self-motivated, and use best practices. Have them use the designer, show them how to find the designer code, but don't focus on it so much. In the real world you may look at the designer generated code 1% of the time in a project and it does not reflect good standards or conventions.

Hope this helps.

share|improve this answer

If we're talking WinForms here (no WPF), designer is a must.
It's very hard to create a good-looking app by creating controls and positioning them in the code, and this will certainly slow you down (and begin to frustrate at some point).

To understand how the things work behind the scenes, just create a test project and play with the classes used by designer. WinForms component model is very simple so you'll understand it in a couple of days--but this is typical boilerplate code that you should avoid.

Because using designer is easy, you might end up with a lot of badly-written spaghetti code where different forms heavily depend on each other, access each other's controls, et cetera. To avoid this, read about using MVP pattern in Windows Forms applications. I've personally noticed how my code became a lot easier to maintain once I cooked up my own MVP implementation.

Also, you may want to drop the WinForms idea and start with WPF.
It's the currently endorsed GUI API, it uses a markup language for UI and is more powerful.
However, as Baboon points out, its learning curve is much steeper than with WinForms so while you'll get more productive in the end, it can take a little too much effort to learn.

In case of WPF, the designer generates XAML but usually you have them open side by side because XAML designer does not erase your code like WinForms designer, and manually editing XAML is just as normal part of the workflow as having some of it generated.

Finally, whatever framework you choose, it is extremely important to use a good UI pattern (usually MVP for WinForms, MVVM for WPF) and not just throw a bunch of controls on a form. By separating the view interfaces from their actual implementations, you also open the door to portability. Although WPF is not supported by Mono and WinForms look plain ugly on Linux, there is absolutely no problem with re-implementing the GUI layer in GTK#. Personally, I wrote an app in WinForms using MVP and it took just a week to port it to GTK# because I only had to implement the interfaces, without changing the logic.

share|improve this answer
1  
Starting with WPF is NOT a good idea at all, the learning curve is just too big for such a project. –  Baboon Aug 9 '11 at 22:22
    
@Baboon: thanks for the note, I included this in the answer. –  Dan Aug 9 '11 at 22:28

You need to use Visual Studio's designer and you need to scrap WinForms and teach them WPF.

Just go to these sites and have your class watch a few videos and they will learn more than you could ever teach them about the UI.

Developers:

1 - http://windowsclient.net/learn/videos_wpf.aspx

2 - http://www.wpfsharp.com/learning/wpf-self-training-course-for-developers/

Designers:

1 - http://expression.microsoft.com/en-us/cc136535

2 - http://www.wpfsharp.com/2011/06/07/expression-studio-training-videos/

share|improve this answer
    
I know WPF is the up and coming "replacement" for WinForms, but given the level of the club, we feel that learning winforms first may be the route to go, especially considering the project, and that the end program needs to run on pre-vista/pre-SP2/3 XP machines (with a possible mono conversion for linux/unix). –  Tyler W Aug 9 '11 at 22:06
    
@Tyler: Did you vote down this answer? Because if you did, let's be fair and note that you didn't include the pre-SP2 requirement in your original question. –  Dan Aug 9 '11 at 22:09
    
If mono is something you are looking for, then WinForms works there too and that is valid reason to use it. However, many who are in Mono still use WPF for windows and use GTK# for Linux and prefer to write two UIs than to use WinForms for both. –  Rhyous Aug 9 '11 at 22:12
    
This is true. Windows Forms look horrible on Linux, and by following MVP pattern I was able to write an app that took just a week to be re-written for Linux with GTK#. –  Dan Aug 9 '11 at 22:14

I know some old die-hards swear by coding with text-editors only, to be 'closer to the metal', but I'm guessing that you (like me) are neither Donald Knuth (actually, he codes on paper too :)), nor Charles Petzold.

It's true with some older versions of Visual Studio (2005 and previous, I believe), you were sometimes well advised to leave the designer well alone, because if it choked on something, it was quite capable of ditching all your work. The more recent versions play a bit nicer.

As others have said, there is nothing interesting about designer-generated code, it's just boiler plate and probably, if the designer didn't exist, your advisor would be setting your the task of creating one :)

Let the tools do the grunt work, concentrate on solving whatever the real problem is.

Exceptions:

  • If the designer is choking on something 'clever' you're trying to do (you can't design a control that is inherited from an abstract class - not that I'd advise trying).
  • If you have to dynamically generate controls (but even then, you could look in the designer to see what code you need to generate).

Note that you didn't really specify what you're supposed to be learning, so it's difficult to be more precise.

(My 'credentials'? 7+ years of VB6, 4+ C#, 2+ F#, so I've seen all the versions of 'VS' since Visual Interdev...)

share|improve this answer

Professional developer for 11 years here. (C++/C#/others...)

I agree with danderson. Time is money. Nobody would avoid using the designer. The Winforms designer works pretty well, and the generated code is the most readable of any generated code I've seen.

I can't agree that a 4-6 month project would double. Impossible to say without knowing how complicated the UI is. (How much of the 4-6 months is designing the UI?)

There is value in looking at the designer generated code. For Winforms it is not bad. It certainly helps to see what the designer is doing. Avoiding the designer entirely? I don't see it as useful.

For example, design a form and put a button on it. Then, select the button and set GenerateMember to false. Take a look at how the designer generated code changes.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.