简体   繁体   中英

Should I use a Bootstrapper class in a WebApi project?

Starting with ASP.Net 5, I wanted to lay the foundation to my project. As of now, I created 2 projects.

  1. Project - The WebApi project that comes with a Startup class.
  2. Project.Server - A dll project that will hold all the business logic.

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; In "Project"'s Startup class I'm calling many of my Bootstrapper class.

Does this extra layer of abstraction needed in a WebApi project? Although "Project.Server" is currently only referenced in "Project", but I still want to structure is correctly...

Different people will have different opinions on how to structure your web app. 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. 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. 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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