简体   繁体   English

Visual Studio解决方案/项目组织

[英]Visual Studio solution/projects organization

Let's say that you re creating a complex back-end system. 假设您正在创建一个复杂的后端系统。 Somewhere in the system, you have an IQueue interface. 在系统的某个地方,您有一个IQueue接口。 You are planning to have several implementations for the queue: 您计划为队列实现多个实现:

  • Naive "in-memory" 天真的“记忆中”
  • Database (where the queue is managed in a database) 数据库(队列在数据库中管理)
  • Amazon SQS (using Amazon SQS service in the cloud) Amazon SQS(在云中使用Amazon SQS服务)
  • MS/Google/Other Queuing service MS / Google /其他排队服务

Obviously, each implementation will require it's own class and implementation. 显然,每个实现都需要它自己的类和实现。 Each implementation will probably need different references (Database will require the DLLs to communicate with the relevant database, Amazon SQS will require the Amazon AWS DLLs, etc.) 每个实现可能需要不同的引用(数据库将要求DLL与相关数据库通信,Amazon SQS将需要Amazon AWS DLL等)

How would you organize the solution for such a scenario? 您将如何组织此类方案的解决方案?

Assuming the interface and the naive implementation are places in the project where the queue is used, I see the following possible options: 假设接口和朴素实现是项目中使用队列的位置,我看到以下可能的选项:

  • Separate Visual Studio (and therefore assembly) for each implementation: 为每个实现分离Visual Studio(以及它们的程序集):
    • Pro: Cleaner projects, "single responsibility" at the project level, easier to update specific implementation 专业:清洁项目,项目层面的“单一责任”,更容易更新具体实施
    • Con: Many projects, many assemblies to manage/deploy, slower Visual Studio Con:许多项目,许多管理/部署的程序集,较慢的Visual Studio
  • Single project for all "non-naive" implementations: 所有“非天真”实施的单一项目:
    • Pro/Con: exact opposite of first option. Pro / Con:与第一个选项完全相反。

In my opinion, going the first route you listed with a separate Visual Studio project for each implementation is the better one, for the reasons you have listed. 在我看来,出于你列出的原因,为每个实现进行单独的Visual Studio项目列出的第一条路线是更好的路线。 It also has the added benefit of being able to add implementations as you go along without have to replace binaries, which is kinda nice. 它还有一个额外的好处,即能够随时添加实现而无需替换二进制文件,这有点好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM