Avalon基本概念(5)-SoC模式

来源:互联网 发布:涉外域名纠纷案件板块 编辑:程序博客网 时间:2024/05/21 06:15
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

SoC的含义

SoC的简单形式就是将一个问题分离成不同的观点。例如,文档通过XMLXSL使用SoC模式,使其的表示和内容分离。任何一个都可以变化,而不会破坏其它。

在系统,Avalon包含独立的接口来标识对象的角色。例如,所有组件具有某些契约,那么任何实现组件接口的对象必须遵循这些契约。这允许开发者使用标准的接口来维护组件,而不必担心实现的语义。因为它们是分离Concerns的。

 

如何使用它

有很多方法来分离Concerns虑范围。在Avalon中使用接口来定义在代码中地址化的Concerns范围。

每次你在OOP时使用接口,你就在使用SoC模式。接口将实现的Concerns和接口用户的Concerns分离。例如,每个对象都可以被配置,来实现Configurable接口。Configurable接口的契约是对象的实例者传递配置对象给Configurable对象(参考IoC)。Configurable对象对传递的配置对象做了什么和实例者是无关的。

 

<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击