Skip to Content
流畅的Python(第2版)
book

流畅的Python(第2版)

by Luciano Ramalho
April 2023
Intermediate to advanced
769 pages
25h 16m
Chinese
Posts & Telecom Press
Content preview from 流畅的Python(第2版)
动态属性和特性
671
之一。第
11
章介绍了契约式设计,第
35
章阐述了他对几门重要的面向对象语言的评价,
包括
Simula
Smalltalk
CLOS
Common Lisp Object System
)、
Objective-C
C++
Java
还对其他语言做了简要评述。直到该书的最后一页他才披露,他使用的极具可读性的“表
示法”看似伪代码,其实出自
Eiffel
语言。
杂谈
从美学的角度来看,
Meyer
提出的统一访问原则很吸引人。作为使用
API
的程序员,
我不应该关心
product.price
只是获取数据属性还是执行计算。但是,作为消费者和
公民,我应该关心:在电子商务如此发达的今天,
product.price
的值通常取决于这个
问题由谁提出,因此它绝不仅仅是一个数据属性。其实,如果查询来自网店外部(例
如比价引擎),那么价格通常会低一些。显然,这对喜欢浏览特定网店的忠实消费者
来说,利益受到了损害。但是我不同意。
上一段内容离题了,可是提出了一个与编程有关的问题:虽然统一访问原则在理想的
世界中完全合理,但在现实中,
API
的用户可能需要知道读取
product.price
是否太
耗资源或时间。一般来说,这是编程抽象问题:抽象之后很难推算求解表达式的运行
时成本。另外,抽象能让用户用更少的代码完成更多的工作。这是一种权衡。
Ward
Cunningham
的维基对软件工程方面的话题有很多独到的见解,他对统一访问原则的功
过也做了富有洞察力的论述。
在面向对象编程语言中,是否遵守统一访问原则通常体现在句法上
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Python高级编程(第2版)

Python高级编程(第2版)

Posts & Telecom Press, Michał Jaworski, Tarek Ziadé
Python贝叶斯分析(第2版)

Python贝叶斯分析(第2版)

Posts & Telecom Press, Osvaldo Martin
高效能PYTHON程式設計

高效能PYTHON程式設計

Micha Gorelick, Ian Ozsvald

Publisher Resources

ISBN: 9787115612366