Design Principle, Design Patterns And Refactoring

 

https://refactoring.guru/smells/feature-envy

 https://stackoverflow.com/questions/1242994/effective-c-sharp-tips 

 Inversion of control   <= https://en.wikipedia.org/wiki/Inversion_of_control

                                  <= https://en.wikipedia.org/wiki/Template_method_pattern

 

 如何创建一个对象?  采用多层的办法,可以获得更强的对象 => 1. new class;

 2. Create() {   ...     }

public SimpleSamepleEntity Create()
ProxyGenerator generator = new ProxyGenerator();
            CallingLogInterceptor interceptor = new CallingLogInterceptor();
            SimpleSamepleEntity entity = generator.CreateClassProxy<SimpleSamepleEntity>(interceptor);

            return entity ;

}
View Code

 

ProxyGenerator generator = new ProxyGenerator();
            var options = new ProxyGenerationOptions(new InterceptorFilter()) { Selector = new InterceptorSelector() };
            SimpleSamepleEntity entity = generator.CreateClassProxy<SimpleSamepleEntity>(
                options,
                new SimpleLogInterceptor(), new CallingLogInterceptor());
            entity.Name = "Richie";
            entity.Age = 50;
View Code

 3. Object factor =>

 

Template of Define a class  ?? => virtual, interface, delegate. 有些工具,像AOP,MOQ 只适用于virtual, interface. 因此,写类时要考虑。

 c#-回调callback是什么原理,机制? C#   =>

调用者(Caller)向回调函数(Callee)发出调用,被调用函数启动后,不等被调函数执行完毕,程序执行流立即返回到调用者继续执行。此时,程序中至少有两个执行流,一个是调用者执行流;另一个是被调用函数执行流同时执行。当被调函数所执行处理完毕时,被调函数反过来调用一个指定的函数(称为回调函数)向调用者返回处理结果或通知调用者处理结束。这个过程称为回调(Callback)。通常,调用者发出调用时,以函数参数方式将回调函数传递给被调函数。
在C#中,回调过程与其他语言没有区别,只是回调函数是以委托方式传递的。
View Code

 4. Sort

 5. Debug information,

 6. Event  => standard Event Pattern

 7. Testable ? How

 8. Readability ?

 9. Maintainance ?

 

 

 

 

END

转载于:https://www.cnblogs.com/kevinygq/p/7753697.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值