博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Individual Reading Assignment
阅读量:5233 次
发布时间:2019-06-14

本文共 2100 字,大约阅读时间需要 7 分钟。

Problems: 

1.Why it is better to hide implementation details than expose them.

  1.1 Changes don't affect the whols program.

  1.2 It is easier to improve performance.

  1.3 It will be easier to check codes and more confident to bilieve it is right.

  1.4 The program becomse more self-documenting.

  1.5 You don't have to pass data all over the program.

2.Do simple items need to be treated as ADTs?

  Yes. You don't have to have a formidable data type to justify using an abstract data type. For example, a Light class which only has routines TurnOn and TurnOff is also a good ADT. You might think that it would be a waste to isolate simple "on" and "off" operations in routines of their own, but even simple operations can benefit from the use of ADTs. Putting the light and its operations into an ADT makes the code more self-documenting and easier to change, confines the potential consequences of changes to the TurnLightOn() and TurnLight-Off() routines, and reduces the number of data items you have to pass around.

3.How can object oriented technology be used in a non-object-oriented environment?

  3.1 Pass ID to each routine.

  3.2 Explicitly provide the data used by the ADT services. In this approach, you declare the data that the ADT uses within each routine that uses an ADT service. 

  3.3 Use implicit instances (with great care) by something like SetCurrentXX(XXID).

4.Should a inhertion expose redunda functions?

  No. It fails the main test for inheritance, which is, "Is inheritance used only for "is a" relationships?" 

5.What tips make a good encapsulation?

  5.1 Minimize accessibility of classes and members  

  5.2 Don't expose member data in public

  5.3 Avoid putting private implementation details into a class's interface

  5.4 Don't make assumptions about the class's users

  5.5 Avoid friend classes

  5.6 Don't put a routine into the public interface just because it uses only public routines

  5.7 Favor read-time convenience to write-time convenience

  5.8 Be very, very wary of semantic violations of encapsulation

 

转载于:https://www.cnblogs.com/buaasts/p/4024980.html

你可能感兴趣的文章
mysql查询今天、昨天、7天、近30天、本月数据
查看>>
mysql 定时增量备份和全备脚本
查看>>
TCP/IP协议
查看>>
一般形式卡特兰数
查看>>
外键约束
查看>>
import
查看>>
网页配色方案大全
查看>>
[转]拓扑排序
查看>>
如何修改被编译后DLL文件 (转发)
查看>>
C++按格式接收输入字符(京东,滴滴,360笔试必用)
查看>>
POJ 2255 Tree Recovery
查看>>
代理ARP
查看>>
Python 的 sys 模块常用方法?
查看>>
Java hashCode() 方法深入理解 ...
查看>>
Modbus TCP 示例报文
查看>>
spring的annotation
查看>>
Node.js 回调函数
查看>>
robot framework selenium2library定位
查看>>
go 学习笔记(4) ---项目结构
查看>>
如何解决ORA-01033问题(转)
查看>>