开发者

Basic Application Organization + Publishing (.NET 4.0)

I'm trying to figure out the best way to keep my program organized. Currently I have many class files in one project file, but some of these classes do things that are very different, and some I would like to expose to other applications in the future. One thought I had to organizing my application was to create multiple project files, with one "Main" project, which would interact with all the other projects and their relevant classes as needed. Does this make sense?

I was wondering if anyone had any suggestions in regards to using multiple project files in one solution (and how do you create something like this?), and if it makes sense to have multiple namespaces in o开发者_开发问答ne solution...

Cheers ----Edit Below----

Sorry, my fault. Currently my program is all in one console project. Within this project I have several classes, some of which basically launch a BackgroundWorker and run an endless loop pulling data. The BackgroundWorker then passes this data back to the main business logic as needed. I'm hoping to seperate this data pull material (including the background worker material) into one project file, and the rest of the business logic into another project file. The projects will have to pass objects between eachother though (the data to the main business logic, and the business logic will pass startup parameteres to the dataPull project)... Hopefully this adds a bit more detail.


Of course you can have multiple project files in a single solution. All you have to do (and I am assuming you are using Visual Studio) is add one or more new projects to the existing solution.

You need to decide which of the projects in the solution is your "Main" project and you do this by right-clicking on the project in Solution Explorer and choosing "Set as Startup project". Generally speaking, the startup project will be the one that contains the user interface for your application.

You need to make sure that the main project references the other projects - as @driis has mentioned, you do this through the Add Reference dialog and click the "Projects" tab.

To organize your project, you should think about the different functional areas of the application. Usually, an application is divided up into presentation, business logic and data access components, but this is not the only approach. You might have various methods and classes that you want to re-use in future projects, so you might create some "Utility" or "Helper" libraries.

You can choose your namespaces along the same lines as the project names, or other different functional areas of the application. For general guidance, check out this MSDN article or this one.

Good luck!


Yes. Both multiple projects and multiple namespaces make a lot of sense if you are building something non-trivial.

Your idea about having general functionality in one project, that you can reuse for other solutions, is a good one. It's all about code reuse and separation of concerns.

To use types from other projects in your Main Project, you should add a reference to the required projects using the Add Reference dialog.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜