简体   繁体   English

我应该在WebApi项目中使用Bootstrapper类吗?

[英]Should I use a Bootstrapper class in a WebApi project?

Starting with ASP.Net 5, I wanted to lay the foundation to my project. 从ASP.Net 5开始,我想为我的项目打基础。 As of now, I created 2 projects. 到目前为止,我创建了2个项目。

  1. Project - The WebApi project that comes with a Startup class. 项目-带有启动类的WebApi项目。
  2. Project.Server - A dll project that will hold all the business logic. Project.Server-一个包含所有业务逻辑的dll项目。

At first I though I should write a Bootstrapper class in "Project.Server" that will allow me to hide many parts of that dll (that "Project" doesn't need to know about), but then I found myself thinking I may be doing some extra work; 起初,我虽然应该在“ Project.Server”中编写一个Bootstrapper类,该类将允许我隐藏该dll的许多部分(“ Project”无需了解),但是后来我发现自己以为做一些额外的工作; In "Project"'s Startup class I'm calling many of my Bootstrapper class. 在“项目”的Startup类中,我调用了许多Bootstrapper类。

Does this extra layer of abstraction needed in a WebApi project? WebApi项目中是否需要这种额外的抽象层? Although "Project.Server" is currently only referenced in "Project", but I still want to structure is correctly... 虽然“ Project.Server”当前仅在“ Project”中被引用,但是我仍然希望结构正确...

Different people will have different opinions on how to structure your web app. 对于如何构建Web应用程序,不同的人会有不同的意见。 Personally, for me, it's a matter of how much work is involved. 就我个人而言,这涉及到多少工作。 If it's fairly easy for you to separate out your business logic into a separate DLL, then do it. 如果您很容易将业务逻辑分离到一个单独的DLL中,请执行此操作。 Even though there may not be any immediate advantages now (since Project is the only consumer of Project.Server), in the future, if you ever decide there needs to be another consumer of the business logic, it will be a lot easier to make that work. 即使现在可能没有立即的优势(由于Project是Project.Server的唯一使用者),将来,如果您决定需要业务逻辑的另一使用者,那么使之变得容易得多。那个工作。 However, if it's a lot of work to create this extra layer, then I'd say it's not worth it, since you can't really predict what the future might bring, and so why spend a ton of effort trying to code for a future that is unknown. 但是,如果要创建此额外的层需要很多工作,那我就说那是不值得的,因为您无法真正预测未来的发展,为什么还要花大量的精力尝试编写一个新的层呢?未知的未来。

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

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