加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

我什么时候应该使用OO Perl?

发布时间:2020-12-15 21:58:20 所属栏目:大数据 来源:网络整理
导读:我只是在学习Perl. 什么时候建议使用OO Perl而不是非OO Perl? 我倾向于总是喜欢OO,除非项目只是的代码片段. 10行. TIA 解决方法 From Damian Conway: 10 criteria for knowing when to use object-oriented design Design is large,or is likely to become
我只是在学习Perl.

什么时候建议使用OO Perl而不是非OO Perl?

我倾向于总是喜欢OO,除非项目只是<的代码片段. 10行. TIA

解决方法

From Damian Conway:

10 criteria for knowing when to use object-oriented design


  1. Design is large,or is likely to become large

  2. When data is aggregated into obvious structures,especially if there’s a lot of data in each aggregate

    For instance,an IP address is not a good candidate: There’s only 4 bytes of information related to an IP address. An immigrant going through customs has a lot of data related to him,such as name,country of origin,luggage carried,destination,etc.

  3. When types of data form a natural hierarchy that lets us use inheritance.

    Inheritance is one of the most powerful feature of OO,and the ability to use it is a flag.

  4. When operations on data varies on data type

    GIFs and JPGs might have their cropping done differently,even though they’re both graphics.

  5. When it’s likely you’ll have to add data types later

    OO gives you the room to expand in the future.

  6. When interactions between data is best shown by operators

    Some relations are best shown by using operators,which can be overloaded.

  7. When implementation of components is likely to change,especially in the same program

  8. When the system design is already object-oriented

  9. When huge numbers of clients use your code

    If your code will be distributed to others who will use it,a standard interface will make maintenence and safety easier.

  10. When you have a piece of data on which many different operations are applied

    Graphics images,for instance,might be blurred,cropped,rotated,and adjusted.

  11. When the kinds of operations have standard names (check,process,etc)

    Objects allow you to have a DB::check,ISBN::check,Shape::check,etc without having conflicts between the types of check.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读