SlideShare a Scribd company logo
1 of 14
Download to read offline
by Ismael Soares
@rkmael
Law of Demeter
What’s it?
The	
  Law	
  of	
  Demeter	
  (LoD)	
  or	
  principle	
  of	
  least	
  
knowledge	
  is	
  a	
  design	
  guideline	
  for	
  developing	
  software	
  
(https://en.wikipedia.org/wiki/Law_of_Demeter)
The Origin
The	
  guideline	
  was	
  proposed	
  at	
  
Northeastern	
  University	
  
towards	
  the	
  end	
  of	
  1987
Demeter is not a man,
is a Greek goddess!
It	
  is	
  so	
  named	
  for	
  its	
  origin	
  in	
  the	
  Demeter	
  Project,	
  an	
  adaptive	
  
programming	
  and	
  aspect-­‐oriented	
  programming	
  effort.
It means a philosophy of bottom-up
LoD Principle:
• Each	
  unit	
  should	
  have	
  only	
  limited	
  knowledge	
  about	
  other	
  units:	
  
only	
  units	
  "closely"	
  related	
  to	
  the	
  current	
  unit.	
  
• Each	
  unit	
  should	
  only	
  talk	
  to	
  its	
  friends;	
  don't	
  talk	
  to	
  strangers.	
  
• Only	
  talk	
  to	
  your	
  immediate	
  friends.
Advantages:
• More	
  maintainable	
  
• More	
  adaptable	
  
• Less	
  dependence	
  
• Very	
  useful	
  in	
  layered	
  architecture	
  
Disadvantages:
• More	
  code	
  
• In	
  some	
  cases,	
  this	
  can	
  add	
  noticeable	
  time	
  and	
  space	
  
overhead	
  
Bad Example
Fonte: https://www.javacodegeeks.com/2012/06/demeter-law.html
Good Example
Obrigado
@rkmael
rkmael@hotmail.com
rkmael.com

More Related Content

Similar to Law of Demeter Guideline Explained

Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven designRick van der Arend
 
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design DecisionsGeneric or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design DecisionsBert Jan Schrijver
 
Software quality
Software qualitySoftware quality
Software quality5minpause
 
Petit Humane Assessment, with Delphi
Petit Humane Assessment, with DelphiPetit Humane Assessment, with Delphi
Petit Humane Assessment, with DelphiESUG
 
Excavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsExcavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsUwe Friedrichsen
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven developmentDmitry Geyzersky
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven DesignBradley Holt
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural PatternsSameh Deabes
 
Software Design Notes
Software Design NotesSoftware Design Notes
Software Design NotesDiego Pacheco
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptxUmerUmer25
 
Importance Of Being Driven
Importance Of Being DrivenImportance Of Being Driven
Importance Of Being DrivenAntonio Terreno
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.pptsagarjsicg
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design PrinciplesSteve Zhang
 

Similar to Law of Demeter Guideline Explained (20)

Up to speed in domain driven design
Up to speed in domain driven designUp to speed in domain driven design
Up to speed in domain driven design
 
Generic or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design DecisionsGeneric or Specific? Making Sensible Software Design Decisions
Generic or Specific? Making Sensible Software Design Decisions
 
Software quality
Software qualitySoftware quality
Software quality
 
Minimalism
MinimalismMinimalism
Minimalism
 
Petit Humane Assessment, with Delphi
Petit Humane Assessment, with DelphiPetit Humane Assessment, with Delphi
Petit Humane Assessment, with Delphi
 
Six of the Best
Six of the BestSix of the Best
Six of the Best
 
Excavating the knowledge of our ancestors
Excavating the knowledge of our ancestorsExcavating the knowledge of our ancestors
Excavating the knowledge of our ancestors
 
Domain driven design and model driven development
Domain driven design and model driven developmentDomain driven design and model driven development
Domain driven design and model driven development
 
Domain-Driven Design
Domain-Driven DesignDomain-Driven Design
Domain-Driven Design
 
GoF Design patterns I: Introduction + Structural Patterns
GoF Design patterns I:   Introduction + Structural PatternsGoF Design patterns I:   Introduction + Structural Patterns
GoF Design patterns I: Introduction + Structural Patterns
 
Craftsmanship
CraftsmanshipCraftsmanship
Craftsmanship
 
Software Design
Software DesignSoftware Design
Software Design
 
Software Design Notes
Software Design NotesSoftware Design Notes
Software Design Notes
 
Intro to oop.pptx
Intro to oop.pptxIntro to oop.pptx
Intro to oop.pptx
 
Importance Of Being Driven
Importance Of Being DrivenImportance Of Being Driven
Importance Of Being Driven
 
DDD In Agile
DDD In Agile   DDD In Agile
DDD In Agile
 
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
1. OBJECT ORIENTED PROGRAMMING USING JAVA - OOps Concepts.ppt
 
How to code
How to codeHow to code
How to code
 
Code Smells
Code SmellsCode Smells
Code Smells
 
The OO Design Principles
The OO Design PrinciplesThe OO Design Principles
The OO Design Principles
 

More from Ismael

TDC 2020 - Trilha de Management 3.0 e Gestão Ágil
TDC 2020 - Trilha de Management 3.0 e Gestão ÁgilTDC 2020 - Trilha de Management 3.0 e Gestão Ágil
TDC 2020 - Trilha de Management 3.0 e Gestão ÁgilIsmael
 
Introducao ao Pensamento Sistemico
Introducao ao Pensamento SistemicoIntroducao ao Pensamento Sistemico
Introducao ao Pensamento SistemicoIsmael
 
Testes de unidade alem do basico
Testes de unidade alem do basicoTestes de unidade alem do basico
Testes de unidade alem do basicoIsmael
 
Bluesoft Culture
Bluesoft CultureBluesoft Culture
Bluesoft CultureIsmael
 
Como dar e receber feedbacks
Como dar e receber feedbacksComo dar e receber feedbacks
Como dar e receber feedbacksIsmael
 
Eficiencia de fluxo
Eficiencia de fluxoEficiencia de fluxo
Eficiencia de fluxoIsmael
 
Como você testa seu software TDC 2017
Como você testa seu software  TDC 2017Como você testa seu software  TDC 2017
Como você testa seu software TDC 2017Ismael
 
Como ter Entregas Frequentes
Como ter Entregas FrequentesComo ter Entregas Frequentes
Como ter Entregas FrequentesIsmael
 
JUnit 5 vs JUnit 4
JUnit 5 vs JUnit 4JUnit 5 vs JUnit 4
JUnit 5 vs JUnit 4Ismael
 
Conceitos por trás do Ágil
Conceitos por trás do ÁgilConceitos por trás do Ágil
Conceitos por trás do ÁgilIsmael
 
Boas Praticas de Testes, Bad Smell e Outros Macetes
Boas Praticas de Testes, Bad Smell e Outros MacetesBoas Praticas de Testes, Bad Smell e Outros Macetes
Boas Praticas de Testes, Bad Smell e Outros MacetesIsmael
 
8 passos para mudança de John Kotter
8 passos para mudança de John Kotter8 passos para mudança de John Kotter
8 passos para mudança de John KotterIsmael
 
Curva da Mudança Kubler-Ross
Curva da Mudança Kubler-RossCurva da Mudança Kubler-Ross
Curva da Mudança Kubler-RossIsmael
 
DevCamp 2016
DevCamp 2016DevCamp 2016
DevCamp 2016Ismael
 
7 Caracteristicas de um bom Lider Agil
7 Caracteristicas de um bom Lider Agil7 Caracteristicas de um bom Lider Agil
7 Caracteristicas de um bom Lider AgilIsmael
 
Junit Lambda
Junit LambdaJunit Lambda
Junit LambdaIsmael
 
Feedback dos Testes
Feedback dos TestesFeedback dos Testes
Feedback dos TestesIsmael
 
Refactoring Databases - Estrategias
Refactoring Databases - EstrategiasRefactoring Databases - Estrategias
Refactoring Databases - EstrategiasIsmael
 
Refactoring Databases - parte 1
Refactoring Databases - parte 1Refactoring Databases - parte 1
Refactoring Databases - parte 1Ismael
 
Como você testa seu software
Como você testa seu softwareComo você testa seu software
Como você testa seu softwareIsmael
 

More from Ismael (20)

TDC 2020 - Trilha de Management 3.0 e Gestão Ágil
TDC 2020 - Trilha de Management 3.0 e Gestão ÁgilTDC 2020 - Trilha de Management 3.0 e Gestão Ágil
TDC 2020 - Trilha de Management 3.0 e Gestão Ágil
 
Introducao ao Pensamento Sistemico
Introducao ao Pensamento SistemicoIntroducao ao Pensamento Sistemico
Introducao ao Pensamento Sistemico
 
Testes de unidade alem do basico
Testes de unidade alem do basicoTestes de unidade alem do basico
Testes de unidade alem do basico
 
Bluesoft Culture
Bluesoft CultureBluesoft Culture
Bluesoft Culture
 
Como dar e receber feedbacks
Como dar e receber feedbacksComo dar e receber feedbacks
Como dar e receber feedbacks
 
Eficiencia de fluxo
Eficiencia de fluxoEficiencia de fluxo
Eficiencia de fluxo
 
Como você testa seu software TDC 2017
Como você testa seu software  TDC 2017Como você testa seu software  TDC 2017
Como você testa seu software TDC 2017
 
Como ter Entregas Frequentes
Como ter Entregas FrequentesComo ter Entregas Frequentes
Como ter Entregas Frequentes
 
JUnit 5 vs JUnit 4
JUnit 5 vs JUnit 4JUnit 5 vs JUnit 4
JUnit 5 vs JUnit 4
 
Conceitos por trás do Ágil
Conceitos por trás do ÁgilConceitos por trás do Ágil
Conceitos por trás do Ágil
 
Boas Praticas de Testes, Bad Smell e Outros Macetes
Boas Praticas de Testes, Bad Smell e Outros MacetesBoas Praticas de Testes, Bad Smell e Outros Macetes
Boas Praticas de Testes, Bad Smell e Outros Macetes
 
8 passos para mudança de John Kotter
8 passos para mudança de John Kotter8 passos para mudança de John Kotter
8 passos para mudança de John Kotter
 
Curva da Mudança Kubler-Ross
Curva da Mudança Kubler-RossCurva da Mudança Kubler-Ross
Curva da Mudança Kubler-Ross
 
DevCamp 2016
DevCamp 2016DevCamp 2016
DevCamp 2016
 
7 Caracteristicas de um bom Lider Agil
7 Caracteristicas de um bom Lider Agil7 Caracteristicas de um bom Lider Agil
7 Caracteristicas de um bom Lider Agil
 
Junit Lambda
Junit LambdaJunit Lambda
Junit Lambda
 
Feedback dos Testes
Feedback dos TestesFeedback dos Testes
Feedback dos Testes
 
Refactoring Databases - Estrategias
Refactoring Databases - EstrategiasRefactoring Databases - Estrategias
Refactoring Databases - Estrategias
 
Refactoring Databases - parte 1
Refactoring Databases - parte 1Refactoring Databases - parte 1
Refactoring Databases - parte 1
 
Como você testa seu software
Como você testa seu softwareComo você testa seu software
Como você testa seu software
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetEnjoy Anytime
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your BudgetHyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
Hyderabad Call Girls Khairatabad ✨ 7001305949 ✨ Cheap Price Your Budget
 

Law of Demeter Guideline Explained