Clean Code Fundamentals by Martin Hock

Clean Code Fundamentals by Martin Hock

Author:Martin Hock [Martin Hock]
Language: eng
Format: epub
Published: 2020-12-16T00:00:00+00:00

The draw method takes an array of Shape objects and uses a switch statement to determine the shape type and invoke the corresponding draw method. This approach violates the OCP because whenever a new shape type is added, the draw method needs to be modified to include a new case in the switch statement, which results in the method being open for modification.

Compliant Solution

Good code 1 public interface Shape { 2 void draw(); 3 }

The Shape interface is introduced to define the contract for shapes. It declares a single method draw that is responsible for drawing the shape.

Good code 1 public class Square implements Shape { 2 @Override 3 public void draw() {} 4 }


Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Popular ebooks
Cloud Auditing Best Practices: Perform Security and IT Audits across AWS, Azure, and GCP by building effective cloud auditing plans by Shinesa Cambric Michael Ratemo(838)
Ansible for Real-Life Automation - A complete Ansible handbook filled with practical IT automation use cases (2022) by Packt(516)
Learn Wireshark - A definitive guide to expertly analyzing protocols and troubleshooting networks using Wireshark - 2nd Edition (2022) by Packt(473)
Data Engineering with Scala and Spark by Eric Tome Rupam Bhattacharjee David Radford(314)
Kubernetes Secrets Handbook by Emmanouil Gkatziouras | 
Rom Adams
 | Chen Xi(177)
Machine Learning for Imbalanced Data by Kumar Abhishek Dr. Mounir Abdelaziz(139)
Power BI for Jobseekers by Alan Murray(134)
Data Labeling in Machine Learning with Python by Vijaya Kumar Suda(124)
Hands-On Scikit-Learn for Machine Learning Applications Data Science Fundamentals with Python by David Paper (Apress;2019;9781484253724;eng)(121)
The AWK Programming Language by Aho Alfred V. Kernighan Brian W. Weinberger Peter J. & Brian W. Kernighan & Peter J. Weinberger(120)
Programming for Problem-Solving with C by Kamaldeep;(117)
The Influence of a Self-Avatar on Space and Body Perception in Immersive Virtual Reality by Ivelina Piryankova(111)
Quantum Machine Learning by Claudio Conti(102)
Asynchronous Programming in Rust by Carl Fredrik Samson;(99)
Practical Machine Learning on Databricks by Debu Sinha(99)
Cyber Forensics up and Running by Vashishth Tarun;(94)
Machine Learning for Decision Makers by Unknown(91)
Addison-Wesley Learn Python the Hard Way, A Very Simple Introduction to the Terrifyingly Beautiful World of Computers and Code 3rd (2014) by Unknown(90)
Generative AI by Martin Musiol(86)
Graph Data Science with Python and Neo4j: Hands-on Projects on Python and Neo4j Integration for Data Visualization and Analysis Using Graph Data Science for Building Enterprise Strategies by Timothy Eastridge(84)