跨多个应用程序共享相同的代码库 [英] Sharing the same codebase across multiple apps

查看:34
本文介绍了跨多个应用程序共享相同的代码库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在不同的应用程序(例如 Web 应用程序、winforms 等)中重复使用相同的代码库通常有哪些选项?

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

我直接的、高级别的想法是使用 Web 服务来公开业务逻辑的专用 dll.还有哪些其他选择?

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

谢谢

推荐答案

通常,您应该有一个单独的层用于业务逻辑,另一个用于数据访问.这是从非常高的角度来看的.根据应用程序的复杂性,您的业务层可能分为几个组件,其中可能有 Web 服务暴露给 Facade 接口,而其他可能具有唯一决策逻辑的组件可能驻留在另一个组件中.这些只是模糊的想法.

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.

从您的 POV 来看,您的目的之一应该是减少存在多个具有相同功能的应用程序的重复代码.即使你有一个单独的业务层,这能解决问题吗?可能您会从不同的应用程序调用相同的业务功能,但 UI 层中仍然会有许多代码需要您单独管理.

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.

考虑到您的两个应用程序具有相同的 UI,对于您的 UI 端,我想到的一件事是有一个共同的 ControllerViewModel,它们将是可从 web 和 win 应用程序访问,其中 Controller 将通过 agent业务层外观界面对话,并且该代理将暴露给您UI 层,它将与您的 ControllerViewModel 紧密耦合.

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      |
+-----------------++-----------------+

希望这会有所帮助.

这篇关于跨多个应用程序共享相同的代码库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆