AOP introduced a new way to do wishful thinking

本文介绍了AOP的核心思想“when x, do y”,它能在任意位置插入代码,改变编程设计方式。可先定义类方法不实现,后续通过编织切面实现行为,还给出示例代码展示如何使用切面编织行为,体现了AOP在编程中的新能力。
部署运行你感兴趣的模型镜像

http://spaces.msn.com/members/nctaowen/

The essence of AOP is the idea: when x, do y. It gives you the power to insert any code at any place. It might change the way you think given the ability to introduce new things after you written them. Actually, I do think it will change the way to design, as you can do wishful thinking but not relying on additional parameters (these parameters may be somewhat higher-order function in functional programming or other object instance in object-oriented programming). With AOP, you can write down methods of class but not implement them. By weaving aspects later, the behavior can be fully implemented. This is different from traditional ways, in the past, you have to specifiy which one to call or use at the point you want to call or use them.  By using AOP, you can define a method local to the object, and leave it blank. You give it some meanings, which may be a comlex collaboration between serval objects. But whatever the meaning is (or say pre-defined contracts), the method is still blank. You call it when you want to take the action which is binded to it in mind. Then, after you finished the work of designing the class, you can define a aspect to weave the behavior to the blank method. Now, you see AOP gives you a new power to use something before it is implemented, hence allows you to do wishful thinking which is the key to think and design complex computer programs.

 

I wrote a sample project which only doese trivial printing. You can download it at

http://www.cnblogs.com/Files/taowen/experiment.zip

public class ClassA {
 
 public void doSomething() {
  System.out.println("going to do something");
  takeAction();
  System.out.println("have done something");
 }
 
 @TakeAction
 private void takeAction() {
  
 }

}

when writing ClassA you don not care with who and how to take the action.

 

public aspect ABCollaboration {
 
 ClassB b = new ClassB();
 
 void around() : (call (@TakeAction * * (..))) {
  b.doSomething();
 }
 
 public static void main(String[] args) {
  new ClassA().doSomething();
 }

}

 

By using a aspect, you weave the behavior later.

您可能感兴趣的与本文相关的镜像

ACE-Step

ACE-Step

音乐合成
ACE-Step

ACE-Step是由中国团队阶跃星辰(StepFun)与ACE Studio联手打造的开源音乐生成模型。 它拥有3.5B参数量,支持快速高质量生成、强可控性和易于拓展的特点。 最厉害的是,它可以生成多种语言的歌曲,包括但不限于中文、英文、日文等19种语言

【EI复现】基于主从博弈的新型城镇配电系统产消者竞价策略【IEEE33节点】(Matlab代码实现)内容概要:本文介绍了基于主从博弈理论的新型城镇配电系统中产消者竞价策略的研究,结合IEEE33节点系统,利用Matlab进行仿真代码实现。该研究聚焦于电力市场环境下产消者(既生产又消费电能的主体)之间的博弈行为建模,通过构建主从博弈模型优化竞价策略,提升配电系统运行效率与经济性。文中详细阐述了模型构建思路、优化算法设计及Matlab代码实现过程,旨在复现高水平期刊(EI收录)研究成果,适用于电力系统优化、能源互联网及需求响应等领域。; 适合人群:具备电力系统基础知识和一定Matlab编程能力的研究生、科研人员及从事能源系统优化工作的工程技术人员;尤其适合致力于电力市场博弈、分布式能源调度等方向的研究者。; 使用场景及目标:① 掌握主从博弈在电力系统产消者竞价中的建模方法;② 学习Matlab在电力系统优化仿真中的实际应用技巧;③ 复现EI级别论文成果,支撑学术研究或项目开发;④ 深入理解配电系统中分布式能源参与市场交易的决策机制。; 阅读建议:建议读者结合IEEE33节点标准系统数据,逐步调试Matlab代码,理解博弈模型的变量设置、目标函数构建与求解流程;同时可扩展研究不同市场机制或引入不确定性因素以增强模型实用性。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值