Clean Code Fundamentals by Martin Hock

Clean Code Fundamentals by Martin Hock

Author:Martin Hock [Martin Hock]
Language: eng
Format: epub
Publisher: leanpub.com
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 }



Download



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
In-Memory Analytics with Apache Arrow by Matthew Topol(2599)
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(999)
In-Memory Analytics with Apache Arrow: Perform fast and efficient data analytics on both flat and hierarchical structured data by Matthew Topol(935)
Mastering Azure Virtual Desktop: The Ultimate Guide to the Implementation and Management of Azure Virtual Desktop by Ryan Mangan(915)
Automated Machine Learning in Action by Qingquan Song Haifeng Jin Xia Hu(839)
Ansible for Real-Life Automation - A complete Ansible handbook filled with practical IT automation use cases (2022) by Packt(659)
Learn Wireshark - A definitive guide to expertly analyzing protocols and troubleshooting networks using Wireshark - 2nd Edition (2022) by Packt(633)
Data Engineering with Scala and Spark by Eric Tome Rupam Bhattacharjee David Radford(358)
Automated Machine Learning in Action by Qingquan Song & Haifeng Jin & Xia Hu(243)
Kubernetes Secrets Handbook by Emmanouil Gkatziouras | 
Rom Adams
 | Chen Xi(214)
Power BI for Jobseekers by Alan Murray(178)
Machine Learning for Imbalanced Data by Kumar Abhishek Dr. Mounir Abdelaziz(174)
Data Labeling in Machine Learning with Python by Vijaya Kumar Suda(156)
Asynchronous Programming in Rust by Carl Fredrik Samson;(154)
SWIFT AND C++ PROGRAMMING MADE SIMPLE: A BEGINNER’S GUIDE TO PROGRAMMING - 2 BOOKS IN 1 by STOKES MARK(153)
Learn PyCharm (Python Technologies) by HASANRAZA ANSARI(152)
The AWK Programming Language by Aho Alfred V. Kernighan Brian W. Weinberger Peter J. & Brian W. Kernighan & Peter J. Weinberger(152)
Programming for Problem-Solving with C by Kamaldeep;(149)
Mastering GPT-4 A Comprehensive Guide to Harnessing the Power of AI: Unleash the Potential of OpenAI's GPT-4 for Your Projects by Hussaini Saif(149)
Hands-On Scikit-Learn for Machine Learning Applications Data Science Fundamentals with Python by David Paper (Apress;2019;9781484253724;eng)(148)