3

I am currently developing a Windows form application, that I plan to run on a cloud setup, the application will calculate new data, update within the database and act as sort of control panel for a live data feed RestFul API that I wish to create using ASP.NET MVC 5 Web API.

I am wondering is it viable to connect these 2 separate applications to a single database? It is unlikely that I'd have database entry clash issues as each application has a separate task of reading or writing data for certain tables.

If viable would that mean every-time i make table changes I'd have to update both Entity Framework database models? (Not a major chore).

Is there a better solution to this? Should I scrap the idea of running a Windows Form application to control certain elements of the backend of the public API?

What would be the future issues with designing something like this, if any?

4
  • Can you elaborate on Windows form application, that I plan to run on a cloud setup? Commented Aug 19, 2017 at 12:18
  • I think the main question is - do those two applications really need the same data? Also, if they do use the same data, will those two applications have different operations on those data, i.e. can you do something in WinForms app that you cannot do in the WebAPI and vice versa? Commented Aug 19, 2017 at 12:21
  • Yes they will need to use some of the same data. I said in the main post that each application has a separate task of reading/writing data. I don't think there will be a case of both apps requiring the function to add new data to the same table, however one may add new rows and the other may edit the data after it has used it. Commented Aug 20, 2017 at 10:53
  • I've posted an answer, please check it out Commented Aug 22, 2017 at 19:49

2 Answers 2

3

So you have a bunch of options there, assuming you have a layered architecture:

  1. Share your DB, DAL and also Business Layer
  2. Extend your WEB API and utilize it in your WinForms
  3. Reuse DAL only (not the best approach, as business systems are not only data, but also - behavior - which resides in Business Layer)
  4. Share the DB only - this is the worst option, with numerous drawbacks

See options 1 and 2 on an image:

enter image description here enter image description here

Sign up to request clarification or add additional context in comments.

6 Comments

I am wondering why you are suggesting to unify the business logic layer? Why contain the methods of either unique application in the same area? won't that just clutter the code, and increase the risk off high coupling?
@MortenBork, in my experience, IF you have an application that is more than simple CRUD, but really has some sophisticated business logic behind it, it is best modeled using DDD. In such a case, your data should live together with your behavior (business logic, validation, etc. ). Imagine for example a scenario that a customer can become "premium" if only he made purchases on a specific sum of money. How do you enforce it without sharing business logic? Do you duplicate your logic?
@MortenBork, as far as I remember you stated that the data for the two apps overlaps. I would presume there would be some business logic that overlaps as well. That should be shared instead of duplicated. If you have a set of APIs that are NOT shared, feel free to extract one extra layer - application services layer that would contain unique logic that is not shared
well, what if becoming premium is different depending on which application you are using? what if premium isn't even the same state? Duplication is the mother of maintaince burdens. Btw, I am not the author, I am merely a poster to the original question.
Not if the users are the same, but premium, might mean different things on a mobile app, compared to an application. Yet the users are the same, their subscription might be the same, warrenting a different design. In any case, the slight overhead on having separate business layers, considering that the UI will have different functions might just warrent a split,but I believe we need to have the OP specify workflow in order to be more specific.
|
2

Create a Data access layer, as a seperate component.

like a DAL.dll

Each application has a Logic layer, where "whatever you do" is handled.

Each layer, now uses a sort of Interfacelayer, that will translate objects from either layer of your applications, to the objects of the DAL.

When you change the DB now - you merely have to update the interface layer.

(Of course if you are adding more features, you will have to update all layers, but that isn't really any different.

I suggest this appoach, as it will make your debugging task much easier. And the slight extra code overhead won't affect performance, unless you have a massive communication requirement.

If you want more specifics, I would need examples of a classes from either program, and your SQL table design.

But there is nothing wrong with your approach.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.