SlideShare a Scribd company logo
陈浩
http://blog.csdn.net/horkychen
以小 大见以小 大见
WebKit 中两个小设计
AgendaAgenda
rivate Data Class Pattern
AII
Private Data Class PatternPrivate Data Class Pattern
绝对的权力必然产生绝对的腐败
Country
KingKing
-Slaves
-Properties
-Lands
-Slaves
-Properties
-Lands
+ 内政
+ 外交
- 人事
……
+ 内政
+ 外交
- 人事
……
3. 缺乏 性弹3. 缺乏 性弹
1. 高耦合1. 高耦合
2. 权力泛 来的滥带 风险2. 权力泛 来的滥带 风险
friend class ResourceHandleInternal;
OwnPtr<ResourceHandleInternal> d;
friend class ResourceHandleInternal;
OwnPtr<ResourceHandleInternal> d;
内部数据
内部数据
对外接口及业务逻辑
对外接口及业务逻辑
Opaque PointerOpaque Pointer
d-pointerd-pointer
为什么不直接使用私有成员变量?为什么不直接使用私有成员变量?
Three benefits of Opaque Pointer
1.To hide detail class implementation.
2.To add new data member without compatibility issue.
3.To includes less header files and get faster compilation time.
Three benefits of Opaque Pointer
1.To hide detail class implementation.
2.To add new data member without compatibility issue.
3.To includes less header files and get faster compilation time.
内部细节的实现逻辑
内部细节的实现逻辑
对外接口及业务逻辑
对外接口及业务逻辑
The benefits of Pimpl compared to OP
1.More pure encapsulation.
2.Minimize the coupling.
……
The benefits of Pimpl compared to OP
1.More pure encapsulation.
2.Minimize the coupling.
……
抽象与实现可以分开演进
抽象与实现可以分开演进
LibraryLibraryApplicationApplication
Fragile Binary Interface Problem
In C++, when anything in a class definition changes
(even private members) all users of that class must
be recompiled.
Fragile Binary Interface Problem
In C++, when anything in a class definition changes
(even private members) all users of that class must
be recompiled.
Class BClass B Class AClass A
添加新成员
添加新成员
RResourceesource AAcquisitioncquisition IIss IInitializationnitialization
简单直接
{
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
//Do Something
}
{
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
//Do Something
}
{
++m_scriptNestingLevel;
//Do Something
--m_scriptNestingLevel;
}
{
++m_scriptNestingLevel;
//Do Something
--m_scriptNestingLevel;
}
{
++m_scriptNestingLevel;
try
{
//Do Something
}
finally
{
--m_scriptNestingLevel;
}
}
{
++m_scriptNestingLevel;
try
{
//Do Something
}
finally
{
--m_scriptNestingLevel;
}
}
Not supported
in
C++
Not supported
in
C++
The idea is that an object's destructor is
responsible for freeing resources.
{
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
//Do Something
}
{
NestingLevelIncrementer nestingLevelIncrementer(m_scriptNestingLevel);
//Do Something
}
NestingLevelIncrementer::~NestingLevelIncrementer();NestingLevelIncrementer::~NestingLevelIncrementer();
{
MutexLocker locker(m_eventsLock);
//Do Something
}
{
MutexLocker locker(m_eventsLock);
//Do Something
}
Tow points of WebKit in design
好奇好奇 模式 / 规则模式 / 规则 述转述转
以小 大、不断 累……见 积以小 大、不断 累……见 积
ore C++ idioms <ore C++ idioms <LINKLINK>>
sing a d-pointer <LINK>sing a d-pointer <LINK>
rivate Data Class Pattern <LINK>rivate Data Class Pattern <LINK>
paque Pointer <LINK>paque Pointer <LINK>
impl idiom <LINK>impl idiom <LINK>
ast Pimpl idiom <LINK>ast Pimpl idiom <LINK>
Tow points of WebKit in design

More Related Content

PPTX
Stupid Index Block Tricks
PPT
Hibernate Session 3
PPTX
Macbeth intro
PDF
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
PPSX
Kanban Explained Clearly
DOCX
Ch. 2 pre-assessment skills
PDF
IAHR 2015 - Managing flood risk in coastal cities through an integrated model...
PDF
Charge Bliss Cloud Services v2.0
Stupid Index Block Tricks
Hibernate Session 3
Macbeth intro
DSD-INT 2014 - Delft3D Open Source Workshop - Qinghua Ye & Adri Mourits, Delt...
Kanban Explained Clearly
Ch. 2 pre-assessment skills
IAHR 2015 - Managing flood risk in coastal cities through an integrated model...
Charge Bliss Cloud Services v2.0

Similar to Tow points of WebKit in design (20)

PDF
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
DOCX
Homework #5MEM ProgramOperations ExcellenceDue Start of Cla.docx
PDF
Public private-cloud
PDF
Sql injection to enterprise Owned - K.K. Mookhey
PPT
Meletis Belsis -CSIRTs
PDF
Phishing Site Detected and Taken Down
PDF
Making Threat Modeling Useful To Software Development
PPTX
2012: The End of the World?
PDF
Honeypots, Deception, and Frankenstein
PDF
Blue team reboot - HackFest
PPT
Perimeter Defense in a World Without Walls
KEY
Agile and Beyond :: The Technical Debt Trap
PDF
Closed Loop Compliance: Achieving closed loop compliance with Brainwave integ...
PDF
The Messy Underlay Dilemma - automating PKI at Defragcon
PDF
CIS13: From Governance to Virtualization: The Expanding Arena of Privileged I...
PPTX
A Blueprint for Cloud-Native Financial Institutions
PDF
Apache Druid Vision and Roadmap
PDF
Vulnerable Active Record: A tale of SQL Injection in PHP Framework
PDF
Honeypots, Deception, and Frankenstein
PDF
The life of breached data and the attack lifecycle
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
Homework #5MEM ProgramOperations ExcellenceDue Start of Cla.docx
Public private-cloud
Sql injection to enterprise Owned - K.K. Mookhey
Meletis Belsis -CSIRTs
Phishing Site Detected and Taken Down
Making Threat Modeling Useful To Software Development
2012: The End of the World?
Honeypots, Deception, and Frankenstein
Blue team reboot - HackFest
Perimeter Defense in a World Without Walls
Agile and Beyond :: The Technical Debt Trap
Closed Loop Compliance: Achieving closed loop compliance with Brainwave integ...
The Messy Underlay Dilemma - automating PKI at Defragcon
CIS13: From Governance to Virtualization: The Expanding Arena of Privileged I...
A Blueprint for Cloud-Native Financial Institutions
Apache Druid Vision and Roadmap
Vulnerable Active Record: A tale of SQL Injection in PHP Framework
Honeypots, Deception, and Frankenstein
The life of breached data and the attack lifecycle
Ad

More from Horky Chen (10)

PDF
程序员发展漫谈
PPT
编程语言与自然语言
PPT
第五项修炼 (学习型组织的艺术与实践)
PPT
代码大全(内训)
PPTX
程序员实践之路
PPT
注重实效的编程(3)
PPT
注重实效的编程(2)
PPT
注重实效的编程(1)
PPTX
Java scriptcore brief introduction
PPTX
JavaScript closures
程序员发展漫谈
编程语言与自然语言
第五项修炼 (学习型组织的艺术与实践)
代码大全(内训)
程序员实践之路
注重实效的编程(3)
注重实效的编程(2)
注重实效的编程(1)
Java scriptcore brief introduction
JavaScript closures
Ad

Recently uploaded (20)

PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
cuic standard and advanced reporting.pdf
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
MYSQL Presentation for SQL database connectivity
PPT
Teaching material agriculture food technology
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
Spectroscopy.pptx food analysis technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Accuracy of neural networks in brain wave diagnosis of schizophrenia
PPTX
Tartificialntelligence_presentation.pptx
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
“AI and Expert System Decision Support & Business Intelligence Systems”
Reach Out and Touch Someone: Haptics and Empathic Computing
Digital-Transformation-Roadmap-for-Companies.pptx
A comparative analysis of optical character recognition models for extracting...
cuic standard and advanced reporting.pdf
Programs and apps: productivity, graphics, security and other tools
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Encapsulation_ Review paper, used for researhc scholars
MYSQL Presentation for SQL database connectivity
Teaching material agriculture food technology
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Spectroscopy.pptx food analysis technology
Spectral efficient network and resource selection model in 5G networks
Accuracy of neural networks in brain wave diagnosis of schizophrenia
Tartificialntelligence_presentation.pptx
Network Security Unit 5.pdf for BCA BBA.
Per capita expenditure prediction using model stacking based on satellite ima...

Tow points of WebKit in design