Sharing the same codebase across multiple apps

安稳与你 提交于 2019-12-07 23:46:43

问题


What are the options usually for re-using the same codebase across different apps (.e.g web application, winforms, etc).

My immediate, high-level thought is to use web services to expose a dedicated dll of the business logic. What other options are there?

Thanks


回答1:


Normally, you should have a separate layer for your business logic and another for your data access. It's from the very high level view. Depending on the complexity of your application, your business layer may divided into several components where there may be web services exposed to a Facade interface and other components that might have sole decision making logic may reside in another component. These are just vague ideas.

From your POV, one of your intention should be reduce duplicate code where there's several app having same functionality. Even if you have a separate business layer, does that solves the problem? Probably you will be invoking the same business functions from your different apps, but still there will be many codes in the UI layer where you have to manage separately.

Architecting your software comes here, to provide a framework that will minimize the effort of building for different platform.

Considering you have the same UI for both of your apps, one thing that comes to my mind for your UI end is have a common Controller and ViewModel which will be accessible from both web and win app, where Controller will talk to business layer facade interface through an agent, and this agent will be exposed to your UI layer, which will be tightly coupled to your Controller and ViewModel.

This may help you to visualize with this diagram:

+------------------------------------+
|                                    |
|         DATA ACCESS LAYER          |
+------------------------------------+
+------------------------------------+
|          BUSINESS LAYER            |
| +--------------------------------+ |
| |          COMPONENT A           | |
| +--------------------------------+ |
| +--------------------------------+ |
| |          COMPONENT B           | |
| +--------------------------------+ |
|+----------------------------------+|
||        WEB SERVICE FACADE        ||
|+----------------------------------+|
+------------------------------------+
+-----------------++-----------------+
|    WIN AGENT    ||    WEB AGENT    |
+-----------------++-----------------+
+------------------------------------+
|        PRESENTATION STACK          |
+------------------------------------+
|+----------------------------------+|
||       GENERIC CONTROLLER         ||
|+----------------------------------+|
+------------------------------------+
+-----------------++-----------------+
|     WIN APP     ||    WEB APP      |
+-----------------++-----------------+

Hope this helps.



来源:https://stackoverflow.com/questions/8227697/sharing-the-same-codebase-across-multiple-apps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!