SlideShare a Scribd company logo
1 of 19
陈浩
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
}
好奇好奇 模式 / 规则模式 / 规则 述转述转
以小 大、不断 累……见 积以小 大、不断 累……见 积
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

Similar to Tow points of WebKit in design

HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
 HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記  HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記
HITCON FreeTalk 2022 - Zero Trust Architecture 讀書筆記 Hacks in Taiwan (HITCON)
 
Homework #5MEM ProgramOperations ExcellenceDue Start of Cla.docx
Homework #5MEM ProgramOperations ExcellenceDue Start of Cla.docxHomework #5MEM ProgramOperations ExcellenceDue Start of Cla.docx
Homework #5MEM ProgramOperations ExcellenceDue Start of Cla.docxpooleavelina
 
Public private-cloud
Public private-cloudPublic private-cloud
Public private-cloudJamie Taylor
 
Sql injection to enterprise Owned - K.K. Mookhey
Sql injection to enterprise Owned  - K.K. Mookhey Sql injection to enterprise Owned  - K.K. Mookhey
Sql injection to enterprise Owned - K.K. Mookhey OWASP-Qatar Chapter
 
Phishing Site Detected and Taken Down
Phishing Site Detected and Taken Down Phishing Site Detected and Taken Down
Phishing Site Detected and Taken Down Digital Shadows
 
Making Threat Modeling Useful To Software Development
Making Threat Modeling Useful To Software DevelopmentMaking Threat Modeling Useful To Software Development
Making Threat Modeling Useful To Software DevelopmentConSanFrancisco123
 
2012: The End of the World?
2012: The End of the World?2012: The End of the World?
2012: The End of the World?Saumil Shah
 
Honeypots, Deception, and Frankenstein
Honeypots, Deception, and FrankensteinHoneypots, Deception, and Frankenstein
Honeypots, Deception, and FrankensteinPhillip Maddux
 
Blue team reboot - HackFest
Blue team reboot - HackFest Blue team reboot - HackFest
Blue team reboot - HackFest Haydn Johnson
 
Perimeter Defense in a World Without Walls
Perimeter Defense in a World Without WallsPerimeter Defense in a World Without Walls
Perimeter Defense in a World Without WallsDan Houser
 
Agile and Beyond :: The Technical Debt Trap
Agile and Beyond :: The Technical Debt TrapAgile and Beyond :: The Technical Debt Trap
Agile and Beyond :: The Technical Debt TrapDoc Norton
 
Closed Loop Compliance: Achieving closed loop compliance with Brainwave integ...
Closed Loop Compliance: Achieving closed loop compliance with Brainwave integ...Closed Loop Compliance: Achieving closed loop compliance with Brainwave integ...
Closed Loop Compliance: Achieving closed loop compliance with Brainwave integ...ForgeRock
 
The Messy Underlay Dilemma - automating PKI at Defragcon
The Messy Underlay Dilemma - automating PKI at DefragconThe Messy Underlay Dilemma - automating PKI at Defragcon
The Messy Underlay Dilemma - automating PKI at Defragconrhirschfeld
 
CIS13: From Governance to Virtualization: The Expanding Arena of Privileged I...
CIS13: From Governance to Virtualization: The Expanding Arena of Privileged I...CIS13: From Governance to Virtualization: The Expanding Arena of Privileged I...
CIS13: From Governance to Virtualization: The Expanding Arena of Privileged I...CloudIDSummit
 
A Blueprint for Cloud-Native Financial Institutions
A Blueprint for Cloud-Native Financial InstitutionsA Blueprint for Cloud-Native Financial Institutions
A Blueprint for Cloud-Native Financial InstitutionsAngelo Agatino Nicolosi
 
Apache Druid Vision and Roadmap
Apache Druid Vision and RoadmapApache Druid Vision and Roadmap
Apache Druid Vision and RoadmapImply
 
Vulnerable Active Record: A tale of SQL Injection in PHP Framework
Vulnerable Active Record: A tale of SQL Injection in PHP FrameworkVulnerable Active Record: A tale of SQL Injection in PHP Framework
Vulnerable Active Record: A tale of SQL Injection in PHP FrameworkPichaya Morimoto
 
Honeypots, Deception, and Frankenstein
Honeypots, Deception, and FrankensteinHoneypots, Deception, and Frankenstein
Honeypots, Deception, and FrankensteinPhillip Maddux
 
The life of breached data and the attack lifecycle
The life of breached data and the attack lifecycleThe life of breached data and the attack lifecycle
The life of breached data and the attack lifecycleJarrod Overson
 

Similar to Tow points of WebKit in design (20)

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

More from Horky Chen

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

More from Horky Chen (10)

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

Recently uploaded

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Recently uploaded (20)

Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Tow points of WebKit in design