2

I am confused between choosing Web API or DLL reference for a project I am working on and want to understand recommendations for both the approach.

We are having a Web API which exposes an interface for the business logic(BL). We are using HTTP based service and the code is C#. We also have a Web Application which internally uses the BL. When I compile I get separate DLL for BL which can also be referenced and reused.

Now, I want to create a C# console app which will be run through task scheduler at a specific time of the day. I will be requiring to use the same BL to proceed with my logic. It's a background service and performance is not a major concern. What will be a better approach here, using compiled DLL or calling Web API? What things to consider when you have to decide between the two approach?

One more thing I would like to mention is that my organization is moving towards microservice architecture. Anything in this context will be highly appreciated.

  • With Web API when you make "internal" change in business logic you need update only one place - Web API, but with dll you need update Web API and dll – Fabio Mar 7 '17 at 5:59
  • Will the console app become part of the Web Application system, maintained by the same team, with coupled releases and versioning? Or will the console app be completely independent, having a different life cycle and versioning and maintainer than the Web Application? – Doc Brown Mar 7 '17 at 6:46
  • @DocBrown the console app will be managed separately – nak Mar 7 '17 at 13:51
  • Sorry, I meant the console app and the BL, not the Web Application. My point is: is the DLL of the BL the "official" API of the BL, and is it exposed to other applications intentionally? If yes, you can use it, if no, better use the Web API. – Doc Brown Mar 7 '17 at 14:28
  • Sorry, I don't exactly understand what "official" here represents but let me give an example. Consider a recommendation service, it is currently embedded in the web app, so my UI layer composes object of BL and uses it accordingly to show the output. We also have created a web API to expose this functionality to some other 3rd party apps, not within our control. Since it is a layered architecture, we get the DLL of each layer too. Now I want to use recommendation in our new internal jobs, let's say to send emails to client. What should be done in this case – nak Mar 8 '17 at 4:42
3

There are a few considerations to make:

  • Updates: changes to the BL will always be reflected in the API but you would need to install a new version of the DLL - Point for API
  • Connection: A DLL will work offline, provided nothing that it does requires online functionality - Point for DLL
  • Portability: An API can be accessed from just about anything and should just work while the DLL, or shared library, you would have to build for each potential platform - Point for API
  • Speed: Usually a DLL will run faster as it is not usually waiting for responses from a server - Point for DLL
  • Client Loading: If the BL is doing a lot of work this is done on the Server when accessed by the API not on the client - Usually point for API unless your server gets heavily loaded.
  • Data Storage/Currency: The API will use the latest data at the server whereas the DLL will need to download/update it first, it might be very large, or risk using out of date data - Point for API
  • Potential to use Micro-services: Most micro-services are run under Linux so you would need a shared library (.so) rather than a DLL for the BL and then you would need to consider how to communicate with an API based approach you are largely there already - Point for API
  • DLL is quick and easier to built - Point for DLL. It doenst require any extra operations over head like setting up a new web application and maintaining it - Point for DLL. – Yawar Murtaza Sep 27 '18 at 9:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.