Solved

Best Practice Windows App Development - Handwrite Code or Drop objects from Toolbox on Screen?

Posted on 2004-08-25
13
224 Views
Last Modified: 2010-04-23
Hi guys,
I am trying to create dataadpaters by writing the code rather than dropping the objects on my form... (avoid generating ALL the sql statements and code behind the scenes when I only want a select statement)
How come these don't now appear in the DataSource Property drop down list in the ComboBox? It also doesn't appear with the other Adapters that I created by dropping on the form.
What's the story here? Are we supposed to use these drag and drop facilities or is it better to 'handwrite' the code as suggested by my trainer in my ADO.Net course last week.
??
I'm trying to know what the 'best practice' is for creating a Windows Application.
THanks for your advice,
Marnie.
0
Comment
Question by:MarnieHook
  • 5
  • 3
  • 3
  • +2
13 Comments
 
LVL 10

Expert Comment

by:Clif
ID: 11890948
The best practise is, simply, whatever works best.  Programming is one of the few things where the ends do indeed justify the means.

It is not always better to handwrite code.  You trainer may simply want you to know how to write the code so that you have a better understanding of the logic behind it.  Sort of like teaching you to do long division even though you have a calculator on your desk.
0
 
LVL 3

Expert Comment

by:DJ_Back-Q
ID: 11890955
If you don't use the darg and drop, some of the IDE functionnality's will not work. Just like you mentioned about the drop list not showing the DataSource.

If you want these IDE functionnality's I suggest that you do drag and drop and then just clean up the code you don't want.

If you able to write yourself, then you will be able to clean the mess the drag and drop made.


Andre, MCSD
0
 
LVL 14

Accepted Solution

by:
ptakja earned 20 total points
ID: 11893653
My take on this is this:

When you hand write the code you have more control over exactly what you want the code to do/look like.  When you use the drag-drop tools, particularly with respect to database stuff, the IDE makes a lot of assumptions AND uses generic variable names like SqlSelectCommand1, etc...

As others have commented, drag-drop enables some IDE functionality.  But in the end, all it does is add a line of code to your Form's class.   Personally, I prefer to write the code myself.  It gives me more control on variable scope, lifetime, and eliminates unneccessary overhead associated with extra code the IDE puts in that I may not even use.

I think the Drag/Drop functionality is great for beginners, but as one becomes more advanced, they tend to steer toward the hand coding.
0
 
LVL 10

Expert Comment

by:Clif
ID: 11893946
ptakja,
"I think the Drag/Drop functionality is great for beginners, but as one becomes more advanced, they tend to steer toward the hand coding."
Wait a few more years, you'll come back to drag and drop.  ;)
0
 
LVL 3

Assisted Solution

by:DJ_Back-Q
DJ_Back-Q earned 30 total points
ID: 11894706
Clif, you are right.

Hand coding is great for a programmer who wants to learn, play, experience and has some time to spare. When the time you spend developing affects the money you make, drag and drop is a great tool. Back in the days, I use to always tell people that drag and drop is for losers. Now that I own my own consulting and developing firm, I can tell you that we here use the drag and drop tools has often has we can.

ptakja : it's not because you use the drag and drop that you have to leave your objects their given names. I have writting guidelines established for my whole firm and they follow it by the letter.

Back in the days, drag and drop was less efficient, but now it's pretty accurate and doesn't generate alot of garbage.

The future is actually drag and drop. Just look at the programs that uses visual UML to build the application.

But I think people shoudn't use drag-n-drop if they cannot understand the code that is generated. it's common sense. Do not use drag-n-drop to write code you can't, use it to quickly write the code you can.


Andre,
MCSD
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11894819
Well said Andre.  

Let me rephrase what I was trying to say.  I DO use drag/drop for building GUI interfaces.  What I don't prefer it for is the database connectivity.  I prefer to hand code that for efficiency and scope reasons.

Jeff
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 3

Expert Comment

by:DJ_Back-Q
ID: 11894861
That does make more sens hehehe, I don't use drag and drop for database connectivity either.


Andre
0
 
LVL 10

Expert Comment

by:Clif
ID: 11894927
For database connectivity it depends.

For quick and dirty, proof of concept, I will.  For release, though, I won't.
0
 
LVL 3

Expert Comment

by:DJ_Back-Q
ID: 11894976
I totally agree.

One thing I can't use the drag n drop for is Web Forms. I guess I'm just used to using plain notepad. As the days go, I guess I may switch one day.
0
 
LVL 14

Expert Comment

by:ptakja
ID: 11894980
I agree Clif.  I do the same thing.
0
 
LVL 2

Expert Comment

by:Mehrdad_Y
ID: 11895478
If you put your code in the Initialize sub for the form (Where the other dropped items are defined) you will have all the functionality for your adapters like designer. In some cases, you need to define your controls in the Resource file for your form, exactly like the designer defines it. Open the .resx file for your form and check it out.
0
 
LVL 3

Expert Comment

by:DJ_Back-Q
ID: 11895750
That is a possibility, but is it worth all these problems? Certainly not for controls. In the end you will have the exact same code as if using the drag n drop.
0
 

Author Comment

by:MarnieHook
ID: 11908453
Thankyou everybody for your useful comments. I shall do a bit of a combination I think. I guess as a beginner, I get scared when the objects I have created don't appear in the IDE as it makes me think it must be out of scope or not a valid choice. I am sure that with more practice i will learn to walk without all the lovely assistance provided by VB.Net and trust my own knowledge of where my 'self coded' objects can be referenced from.
Back to it.... thanks!
PS. I wanted to give you all points! Next time I will assign 100 points so I can split them up more effectively!
Thanks again.
Marnie.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now