?
Solved

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

Posted on 2004-08-25
13
Medium Priority
?
237 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 80 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
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
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 120 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
 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
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…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Watch the video to know the simple way to remove or recover or reset lost or forgotten passwords of Outlook PST file. With Kernel Outlook Password Recovery tool such operation is very easy to perform. It is a freeware with limitation to use with 500…

568 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