iluwatar/java-design-patterns
Java Design Patterns
This project is a comprehensive educational knowledge base designed to help developers master software engineering excellence through a structured catalog of design patterns and architectural principles. It provides a curated repository of best practices, programming heuristics, and implementation examples, all organized to facilitate skill acquisition and improve code quality in Java.
The repository distinguishes itself by offering a navigable hierarchy of reusable design patterns and architectural strategies that promote interface-centric design and decoupled implementation. By emphasizing clean code standards and established design heuristics, it serves as a reference-based resource for understanding how to build maintainable, modular, and robust object-oriented systems.
Beyond its core architectural focus, the project includes a broad library of functional code snippets and algorithmic implementations. These resources cover a wide range of common programming challenges, including data structures, mathematical computations, file operations, and utility tasks, providing practical, stateless examples that demonstrate idiomatic coding standards.
Features
- Code Snippets - ```java public class CreatingObjectSnippet { /** * Create object using reflection. * * @param cls fully qualified name of class includes the package name as String * @return object * @throws NoSuchMethodException if a me
- Design Pattern Catalogs - A comprehensive collection of architectural patterns and software design principles implemented in a standard programming language for educational reference.
- Algorithmic Implementations - A collection of common algorithmic implementations and utility functions providing practical examples for solving recurring programming challenges.
- Algorithms - ```java public class InsertionSortSnippet { /** * Sort an array with insertionSort algorithm. * * @param arr array to sort */ public static void insertionSort(int[] arr) { for (var i = 1; i < arr.length; i++) { var tmp =
- Pattern-Based Taxonomies - Organizes complex software engineering concepts into a structured, navigable hierarchy of reusable design patterns and architectural principles.
- Architectural Principles - | Learning established design patterns and architectural principles to build maintainable, scalable, and robust object-oriented software systems.
- Search Algorithms - ```java public class LinearSearchSnippet { /** * Search an item with linearSearch algorithm. * * @param arr array to search * @param item an item to search * @return if item is found, return the index position of the arr
- Sorting Algorithms - ```java public class BubbleSortSnippet { /** * Sort an array with bubbleSort algorithm. * * @param arr array to sort */ public static void bubbleSort(int[] arr) { var lastIndex = arr.length - 1; for (var j = 0; j < lastI
- Technical Reference Hubs - A structured knowledge hub offering developers high-quality documentation and learning materials to master complex software design concepts.
- Software Engineering Knowledge Bases - A curated repository of best practices, programming principles, and architectural guidelines designed to improve code quality and maintainability.
- Developer Learning Resources - Acts as a centralized, curated index of best practices and implementation examples to facilitate developer learning and skill acquisition.
- Interface-Centric Architectures - Promotes the use of abstract contracts to hide implementation details, enabling flexible system evolution and adherence to substitution principles.
- YAGNI Principles - YAGNI stands for "you aren't gonna need it": don't implement something until it is necessary. Why - Any work that's only used for a feature that's needed tomorrow, means losing effort from features that need to be done f
- Decoupled Implementations - Isolates specific computational logic into independent, interchangeable units to minimize dependencies and maximize code reuse across different contexts.
- Command Query Separation - The Command Query Separation principle states that each method should be either a command that performs an action or a query that returns data to the caller but not both. Asking a question should not modify the answer. W
- Coupling Management - Coupling between modules/components is their degree of mutual interdependence; lower coupling is better. In other words, coupling is the probability that code unit "B" will "break" after an unknown change to code unit "A
- DRY Principles - Every piece of knowledge must have a single, unambiguous, authoritative representation within a system. Each significant piece of functionality in a program should be implemented in just one place in the source code. Whe
- Interface Segregation Principles - Reduce fat interfaces into multiple smaller and more specific client specific interfaces. An interface should be more dependent on the code that calls it than the code that implements it. Why - If a class implements meth
- Inversion of Control - Inversion of Control is also known as the Hollywood Principle, "Don't call us, we'll call you". It is a design principle in which custom-written portions of a computer program receive the flow of control from a generic f
- Law of Demeter - Don't talk to strangers. Why - It usually tightens coupling - It might reveal too much implementation details How A method of an object may only call methods of: 1. The object itself. 2. An argument of the method. 3. Any
- Liskov Substitution Principles - The LSP is all about expected behavior of objects: > Objects in a program should be replaceable with instances of their subtypes > without altering the correctness of that program. Resources - [Liskov substitution princi
- Maintainability Principles - Why - Maintenance is by far the most expensive phase of any project. How - *Be* the maintainer. - Always code as if the person who ends up maintaining your code is a violent psychopath who knows where you live. - Always
- Robustness Principles - > Be conservative in what you do, be liberal in what you accept from others Collaborating services depend on each others interfaces. Often the interfaces need to evolve causing the other end to receive unspecified data.
- Simplicity Principles - Why - Real progress against the real problem is maximized if we just work on what the problem really is. How - Ask yourself: "What is the simplest thing that could possibly work?" Resources - [Do The Simplest Thing That
- Algorithmic Utilities - Provides a collection of stateless, functional code snippets that perform discrete algorithmic tasks without maintaining internal object state.
- File System Utilities - ```java public class ListAllFilesSnippet { /** * Recursively list all the files in directory. * * @param path the path to start the search from * @return list of all files */ public static List<File> listAllFiles(String
- Java Best Practices - | Adopting idiomatic coding standards and proven design patterns to improve code quality and developer productivity in Java projects.