Hello and a question

StoneDog

Newcomer
Joined
Jan 26, 2005
Messages
1
Hello everyone,

My real name is Jon Edwards and I'm a senior developer at a company that is adopting C# and .Net as the new development language and platform.

I've been hacking around with C# for many months now and now that the prototyping (ie "working" code) is done I need to come back and refactor or more likely completely re-write everything.

My question has to do with best practices involving solutions and projects. The application I will develop will have a primary screen, a number of user controls and at least two types of (very complicated) child windows. There will also be helper classes, classes to handle image resources, string translations and a remote-access "proxy" classes to talk to a legacy platform.

What should I be thinking about when deciding what warrants its own project? Is it considered acceptable to keep a 5 to 10 form classes in the same project? What about non-form classes like my image manager, etc?

And a quick follow-up question: what is the proper technique to get a form to invoke a form from another project? The FAQ mentions sharing - do I simply share the .cs between projects in my solution?


Jon
 
Jon:

StoneDog said:
What should I be thinking about when deciding what warrants its own project? Is it considered acceptable to keep a 5 to 10 form classes in the same project? What about non-form classes like my image manager, etc?

This really is left to the discretion of whoever is managing the development project based upon the requirements of the application, number of developers, logical code organization, etc. One aspect to consider is that if you have a large body of code that is really a generic set of utilities which could be shared across multiple applications, it may make sense to compile it into a separate library.


And a quick follow-up question: what is the proper technique to get a form to invoke a form from another project? The FAQ mentions sharing - do I simply share the .cs between projects in my solution?

You need to set the OutputType of the project to Class Library. This will compile your code into a .dll which you then reference from the projects of applications which need access to the classes. You'll need to comment out the project's Main() method if it began life as a Windows Forms application before compiling it as a Class Library. There are several other accessibility and security aspects to consider, but that is the basic gist of it.
 
Last edited:
Adding to RobEmDee, in my opinion the only reason to keep a class in your project vs a dll is if you're going to be editing the class often. Other than that, dlls remove code from your project, are easily transported and are usable anywhere, require the same declaration as a class, etc.
 
Back
Top