其他分享
首页 > 其他分享> > 软件构造博客3

软件构造博客3

作者:互联网

这一篇是有关于面向复用的软件构造技术

首先是几个级别的复用。

源代码级别的服用,模块级别的复用,库级别的复用,系统级别的复用

然后是复用的好处:降低成本和开发时间 ,测试,可靠、稳定标准化,在不同应用中保持一致

衡量复用性的标准: 小、简单 与标准兼容 灵活可变 可扩展 泛型、参数化 模块化 变化的局部性 稳定  丰富的文档和帮助 最主要的复用是在代码层面,但软件构造过程中的任何实体都可能被复用 白盒复用:源代码可见,可修改和扩展  黑盒复用:源代码不可见,不能修改 白盒框架,通过代码层面的继承进行框架扩展 黑盒框架,通过实现特定接口/delegation进行 框架扩展 子类型多态:客户端可用统一的方式处理 不同类型的对象 Covariance (协变) § See this example: § More specific classes may have more specific return types § This is called covariance of return types in the subtype. class T { Object a() { … } } class S extends T { @Override String a() { … } } class T { void b( ) throws Throwable {…} } class S extends T { @Override void b( ) throws IOException {…} } class U extends S { @Override void b( ) {…} } § Every exception declared for the subtype’s method should be a subtype of some exception declared for the supertype’s method.   Contravariance (反协变、逆变) § What do you think of this code? § Logically, it is called contravariance of method arguments in the subtype. § This is actually not allowed in Java, as it would complicate the overloading rules. 目前Java中遇到这种情况,当作overload看待 L

标签:复用,构造,subtype,extends,博客,软件,源代码,级别,class
来源: https://www.cnblogs.com/fsscg/p/16332340.html