Practical Design Patterns for Java Developers: Hone your software design skills by implementing popular design patterns in Java
Book information
Description
Unravel the power of Java design patterns by learning where to apply them effectively to solve specific software design and development problems Key FeaturesDecouple logic across objects with dependency injection by creating various vehicles with featuresFinalize vehicle construction by chaining handlers using the Chain of Responsibility PatternPlan and execute an advanced vehicle sensor initiation with the Scheduler PatternBook Description Design patterns are proven solutions to standard problems in software design and development, allowing you to create reusable, flexible, and maintainable code. This book enables you to upskill by understanding popular patterns to evolve into a proficient software developer. You'll start by exploring the Java platform to understand and implement design patterns. Then, using various examples, you'll create different types of vehicles or their parts to enable clarity in design pattern thinking, along with developing new vehicle instances using dedicated design patterns to make the process consistent. As you progress, you'll find out how to extend vehicle functionalities and keep the code base structure and behavior clean and shiny. Concurrency plays an important role in application design, and you'll learn how to employ a such design patterns with the visualization of thread interaction. The concluding chapters will help you identify and understand anti-pattern utilization in the early stages of development to address refactoring smoothly. The book covers the use of Java 17+ features such as pattern matching, switch cases, and instances of enhancements to enable productivity. By the end of this book, you'll have gained practical knowledge of design patterns in Java and be able to apply them to address common design problems. What you will learnUnderstand the most common problems that can be solved using Java design patternsUncover Java building elements, their usages, and concurrency possibilitiesOptimize a vehicle memory footprint with the Flyweight PatternExplore one-to-many relations between instances with the observer patternDiscover how to route vehicle messages by using the visitor patternUtilize and control vehicle resources with the thread-pool patternUnderstand the penalties caused by anti-patterns in software designWho this book is for If you are an intermediate-level Java developer or software architect looking to learn the practical implementation of software design patterns in Java, then this book is for you. No prior knowledge of design patterns is required, but an understanding of Java programming is necessary. Table of ContentsGetting Into Software Design PatternsDiscovering the Java Platform for Design PatternsWorking with Creational Design PatternsApplying Structural Design PatternsBehavioral Design PatternsConcurrency Design PatternsUnderstanding Common Anti-Patterns Cover Title Page Copyright and Credits Foreword Contributors Table of Contents Preface Part 1: Design Patterns and Java Platform Functionalities Chapter 1: Getting into Software Design Patterns Technical requirements Code – from symbols to program Examining OOP and APIE Only exposing what’s required – encapsulation Inevitable evolution – inheritance Behavior on demand – polymorphism Standard features – abstraction Gluing parts to APIE Understanding the SOLID design principles The single-responsibility principle (SRP) – the engine is just an engine The open-closed principle (OCP) The Liskov Substitution Principle (LSP) – substitutability of classes The interface segregation principle (ISP) The dependency inversion principle (DIP) Significance of design patterns Reviewing what challenges design patterns solve Summary Questions Further reading Chapter 2: Discovering the Java Platform for Design Patterns Technical requirements Knocking on Java’s door Exploring the model and functionality of the Java platform The JDK The JRE The JVM Reviewing GC and the Java memory model The JMM GC and automatic memory management Examining the core Java APIs Primitive data types and wrappers Working with the String API Introducing arrays Discovering a collection framework Math APIs Functional programming and Java Introducing lambdas and functional interfaces Using functional interfaces in lambda expressions Getting to grips with the Java Module System A quick review of Java features from 11 to 17+ The local variable syntax for lambda parameters (Java SE 11, JEP-323) Switch expressions (Java SE 14, JEP-361) Text blocks (Java SE 15, JEP-378) Pattern matching for instanceof (Java SE 16, JEP-394) Records (Java SE 16, JEP-395) Sealed classes (Java SE 17, JEP-409) UTF-8 by default (Java SE 18, JEP-400) Pattern matching for switch (Java SE 18, Second Preview, JEP-420) Understanding Java concurrency From a basic thread to executors Executing tasks Summary Questions Further reading Part 2: Implementing Standard Design Patterns Using Java Programming Chapter 3: Working with Creational Design Patterns Technical requirements It all starts with a class that becomes an object Creating objects based on input with the factory method pattern Motivation Finding it in the JDK Sample code Conclusion Creating objects from different families using the abstract factory pattern Motivation Finding it in the JDK Sample code Conclusion Instantiating complex objects with the builder pattern Motivation Finding it in the JDK Sample code Conclusion Cloning objects with the prototype pattern Motivation Finding it in the JDK Sample code Conclusion Ensuring only one instance with the singleton pattern Motivation Finding it in the JDK Sample code Conclusion Improving performance with the object pool pattern Motivation Finding it in the JDK Sample code Conclusion Initiating objects on demand with the lazy initialization pattern Motivation Finding it in the JDK Sample code Conclusion Reducing class dependencies with the dependency injection pattern Motivation Finding it in the JDK Sample code Conclusion Summary Questions Further reading Chapter 4: Applying Structural Design Patterns Technical requirements Incompatible object collaboration with the adapter pattern Motivation Finding it in the JDK Sample code Conclusion Decoupling and developing objects independently with the bridge pattern Motivation Finding it in the JDK Sample code Conclusion Treating objects the same way using the composite pattern Motivation Finding it in the JDK Sample code Conclusion Extending object functionality by using the decorator pattern Motivation Finding it in the JDK Sample code Conclusion Simplifying communication with the facade pattern Motivation Finding it in the JDK Sample code Conclusion Using conditions to select desired objects with the filter pattern Motivation Finding it in the JDK Sample code Conclusion Sharing objects across an application with the flyweight pattern Motivation Finding it in the JDK Sample code Conclusion Handling requests with the front-controller pattern Motivation Finding it in the JDK Sample code Conclusion Identifying instances using the marker pattern Motivation Finding it in the JDK Sample code Conclusion Exploring the concept of modules with the module pattern Motivation Finding it in the JDK Sample code Conclusion Providing a placeholder for an object using the proxy pattern Motivation Finding it in the JDK Sample code Conclusion Discovering multiple inheritance in Java with the twin pattern Motivation Sample code Conclusion Summary Questions Further reading Chapter 5: Behavioral Design Patterns Technical requirements Limiting expensive initialization using the caching pattern Motivation Finding it in the JDK Sample code Conclusion Handling events using the chain of responsibility pattern Motivation Finding it in the JDK Sample code Conclusion Turning information into action with the command pattern Motivation Finding it in the JDK Sample code Conclusion Giving meaning to the context using the interpreter pattern Motivation Finding it in the JDK Sample code Conclusion Checking all the elements with the iterator pattern Motivation Finding it in the JDK Sample code Conclusion Utilizing the mediator pattern for information exchange Motivation Finding it in the JDK Sample code Conclusion Restoring the desired state with the memento pattern Motivation Finding it in the JDK Sample code Conclusion Avoiding a null pointer exception state with the null object pattern Motivation Finding it in the JDK Sample code Conclusion Keeping all interested parties informed using the observer pattern Motivation Finding it in the JDK Sample code Conclusion Dealing with instance stages by using the pipeline pattern Motivation Finding it in the JDK Sample code Conclusion Changing object behavior with the state pattern Motivation Finding it in the JDK Sample code Conclusion Using the strategy pattern to change object behavior Motivation Finding it in the JDK Sample code Conclusion Standardizing processes with the template pattern Motivation Finding it in the JDK Sample code Conclusion Executing code based on the object type using the visitor pattern Motivation Finding it in the JDK Sample code Conclusion Summary Questions Further reading Part 3: Other Essential Patterns and Anti-Patterns Chapter 6: Concurrency Design Patterns Technical requirements Decoupling a method execution with an active object pattern Motivation Sample code Conclusion Non-blocking tasks using async method invocation pattern Motivation Sample code Conclusion Delay execution until the previous task is completed with the balking pattern Motivation Sample code Conclusion Providing a unique object instance with a double-checked locking pattern Motivation Sample code Conclusion Using purposeful thread blocking via a read-write lock pattern Motivation Sample code Conclusion Decoupling the execution logic with a producer-consumer pattern Motivation Sample code Conclusion Executing isolated tasks with the scheduler pattern Motivation Sample code Conclusion Effective thread utilization using a thread-pool pattern Motivation Sample code Conclusion Summary Questions Further reading Answers Chapter 7: Understanding Common Anti-Patterns Technical requirements What anti-patterns are and how to identify them Theoretical principles challenges Collecting technical debt as a bottleneck Inappropriately squeezing the capabilities of the Java platform Selecting the right tool Conclusion of the code smell anti-pattern Examining typical software anti-patterns Spaghetti code Cut and paste programming Blob Lava flow Functional decomposition Boat anchor Conclusion Understanding software architecture anti-patterns Golden hammer Continuous obsolescence Input kludge Working in a minefield Ambiguous viewpoint Poltergeists Dead end Conclusion Summary Further reading Assessments Index Other Books You May Enjoy
Similar books
Practical Design Patterns for Java Developers: Hone your software design skills by implementing popular design patterns in Java
EPUB
MySQL® Notes for Professionals book
2018 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
MrExcel 2022: Boosting Excel
2022 · PDF
Session C11: Ancient Cultural Landscapes in South Europe – their Ecological Setting and Evolution, Session C22: Gardeners from South America, Session S04: Agro-Pastoralism and Early Metallurgy Sessions, Session WS29: The Idea of Enclosure in Recent Iberian Prehistory, Session C88: Rhytmes et causalites des dynamiques de l'anthropisation en Europe entre 6500 ET 500 BC: Hypotheses socio-culturelles et/ou climatiques: Proceedings of the XV UISPP World Congress (Lisbon 4-9 September 2006) / Actes du XV Congrès Mondial (Lisbonne 4-9 Septembre 2006) Vol.36
2010 · PDF
THE BRITISH ARMY IN INDIA: ITS PRESERVATION BY AN APPROPRIATE CLOTHING, HOUSING, LOCATING, RECREATIVE EMPLOYMENT, AND HOPEFUL ENCOURAGEMENT OF THE TROOPS. with AN APPENDIX ON INDIA : THE CLIMATE OP ITS HILLS ; THE DEVELOPMENT OF ITS RESODRCBS, INDUSTRY, AND ARTS ; THE ADMINISTRATION OF JUSTICE ; THE BLACK ACT ; THE PROGRESS OF CHRISTIANITY ; THE TRAFFIC IN OPIUM ; THE VALUE OF INDIA ; PERMANENT CAUSES OF DISAFFECTION, AND OF THE RECENT REBELLION ; THE TRADITIONARY POLICY; MISGOVERNMENT BY NATIVE RULERS ; ANNEXATIONS OF THEIR TERRITORY, ETC.
1858 · PDF
Idries Shah 27 Books Collection : A Perfumed Scorpion, A Veiled Gazelle, Caravan of Dreams, Darkest England, Destination Mecca, Evenings with Idries Shah, Knowing How to Know, Learning How to Learn, Letters and Lectures of Idries Shah, Neglected aspects of Sufi study, Observations, Oriental Magic, Reflections, Seeker after Truth, Special Illumination, Special Problems in the study of Sufi ideas, Sufi thought and action, Tales of the Dervishes, The Dermis Probe, The Elephant in the Dark, The Englishman Handbook, Idries Shah Antology, The Magic Monastery, The natives are restless, wisdom of the Idiots PDF.
2022 · PDF
The travels of Capts. Lewis and Clarke from St. Louis, by way of the Missouri and Columbia rivers, to the Pacific ocean; performed in the years 1804, 1805 & 1806, by order of the government of the United States. Containing delineations of the manners, customs, religion, &c. of the Indians, comp. from various authentic sources, and original documents, and a summary of the Statistical view of the Indian nations, from the official communication of Meriwether Lewis. Illustrated with a map of the country, inhabited by the western tribes of Indians
1809 · PDF