前控制器与立面模式 [英] Front Controller vs. Façade pattern

查看:75
本文介绍了前控制器与立面模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,我做了一些在线搜索,发现线程,但仍然无法完全解决。



Front到底有什么区别控制器模式和外观模式?



到目前为止,据我了解:
外观模式不包含任何业务逻辑,而只是集中访问多个对象



前端控制器也做同样的事情,但是可能包含业务逻辑以促进基于输入数据等的所谓决策逻辑。

>

要理解这一点,以下简单的伪代码片段是否表示drawLine是一个Façade,可以简化将坐标转换为点,然后实现实际起作用的draw方法?

  private void drawLine(Int32 StartX,In t32 StartY,Int32 EndX,Int32 EndY)
{
Point Start = new Point(StartX,StartY);
Point End = new Point(EndX,EndY);

开奖(开始,结束);
}

Façade可以调用应用程序的较低层吗?



据我了解,前端控制器负责协调完整的函数调用过程。



示例:Front控制器将检查数据,然后决定要采取的措施。然后它将为后续每次对低级别类的调用编译数据,直到到达可以提供给调用系统的适当响应为止。



我认为我的理解外观模式的错误或过于简单化。如果我错了,请纠正我。



如果我的理解是正确的,那么将ApplicationFaçade更改为Front Controller会没有多大意义。 Microsoft应用程序体系结构指南2.0 ?我在第18章中专门研究服务体系结构。(虽然我有Beta 2版本)



更新:谢谢回应符文。为什么说将Facade更改为Front控制器是不正确的?我是前端控制器的忠实拥护者,因为它可以使所有较低级别的事物得到更多的控制。因此,尽管这样做可能没有更多意义,但这样做完全错误吗?如果是,为什么?

解决方案

Front Controller模式定义一个负责处理应用程序请求的组件。通常用作(例如)引导请求的瓶颈,以巩固每次需要执行的标准行为。



请参阅以下链接以简明扼要地解释这些问题:





<另一方面,正面是用于包装其他方法/服务以提供统一的界面,隐藏复杂性或减少对外部系统的依赖性(在DDD的反腐败层中得到了示例: http://www.goeleven.com/blog/entryDetail.aspx?en try = 168 )等。



外观是一个薄包装,除了用于在两个系统之间进行转换的逻辑外,不应包含任何逻辑。 Front Controller没有这样的要求。



例如参见: http:// en。 wikipedia.org/wiki/Facade_pattern



回答有关AppArchGuide的问题:不,那是不正确的。


Okay, I have done a bit of searching online and found this thread, but it still does not quite clear it up for me.

What exactly is the difference between a Front Controller Pattern and a Façade pattern?

As I understand it so far: A Façade pattern does not contain any business Logic, but merely centralizes access to multiple objects.

A Front Controller does the same thing, but may contain business logic to facilitate the decision logic of what is called based on the input data and the like.

To make sense of this, does the following simplistic pseudo code snippet mean that drawLine is a Façade to simplify converting the coordinates to points and then implementing the draw method that actually does the work?

    private void drawLine(Int32 StartX, Int32 StartY, Int32 EndX, Int32 EndY)
    {
        Point Start = new Point(StartX, StartY);
        Point End = new Point(EndX, EndY);

        Draw(Start, End);
    }

Can a Façade call into lower layers of your application or is it really just to centralise access to many components on the same layer?

As I understand it, the front controller coordinates the complete function call process.

Example: A Front controller would examine the data, and then decide what action to take. Then it would compile the data for each subsequent call to lower level classes, until it arrives at a suitable response that can be provided to the calling system.

I think my understanding of the Façade pattern is wrong or just too simplistic. Please correct me if I'm wrong.

If my understanding of this is correct, would it then not make more sense to change the Application Façade, into a Front Controller in the Microsoft Application Architecture Guide 2.0? I'm specifically looking at the Service Architecture in chapter 18. (I have the Beta 2 version though)

Update: Thanks for a great response Rune. Why do you say it is not correct to change the Facade to a Front controller? I'm a big fan of the Front-controller because it keeps all lower level things a little more controlled. So although it may not make MORE sense, would it be completely wrong to do that? If yes: Why?

解决方案

The Front Controller pattern defines a single component that is responsible for processing application requests. Often used as a "bottleneck" to (for instance) channel requests through to consolidate standard behavior that needs to be performed each time.

See these links for short to the point explanations:

A facade is on the other hand rather used to wrap other methods/services to provide a unified interface, hide complexity or reduce dependency on external systems (Exemplified in DDD's anti-corruption layer: http://www.goeleven.com/blog/entryDetail.aspx?entry=168), etc.

A facade is a thin wrapper that shouldn't contains any logic except the logic used to translate between the two systems. Front Controller has no such requirements.

See for instance: http://en.wikipedia.org/wiki/Facade_pattern

And to answer your questions concerning AppArchGuide: No, that's not correct.

这篇关于前控制器与立面模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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