There are certain universal laws and principles in software development that guide architects, programmers, and anyone needing to design software. This page lists quite a few of those principles, although it's far from complete. This page is a fork of programming-principles repository by Lars Kappert, who has done most of the work collecting the material.
Inspired by 30 seconds of code, this is a collection of reusable
tested copy-pasteable Java 17 compatible code snippets that you can understand in 30 seconds or less. If you're
interested in contributing to this library, please see
the instructions.
- Abstract Document
- Abstract Factory
- Active Object
- Acyclic Visitor
- Adapter
- Aggregator Microservices
- Ambassador
- Anti-corruption layer
- API Gateway
- Arrange/Act/Assert
- Async Method Invocation
- Balking
- Bridge
- Builder
- Business Delegate
- Bytecode
- Caching
- Callback
- Chain of responsibility
- Circuit Breaker
- Client Session
- Collecting Parameter
- Collection Pipeline
- Combinator
- Command
- Commander
- Component
- Composite
- Composite Entity
- Composite View
- Context Object
- Converter
- CQRS
- CRTP
- Currying
- Data Access Object
- Data Bus
- Data Locality
- Data Mapper
- Data Transfer Object
- Decorator
- Delegation
- Dependency Injection
- Dirty Flag
- Domain Model
- Double Buffer
- Double-Checked Locking
- Double Dispatch
- Dynamic Proxy
- Embedded Value
- Event Aggregator
- Event-Based Asynchronous
- Event-Driven Architecture
- Event Queue
- Event Sourcing
- Execute Around
- Extension Objects
- Facade
- Factory
- Factory Kit
- Factory Method
- Fan-Out/Fan-In
- Feature Toggle
- Filterer
- Fluent Interface
- Flux
- Flyweight
- Front Controller
- Game Loop
- Gateway
- Guarded Suspension
- Half-Sync/Half-Async
- Health Check Pattern
- Hexagonal Architecture
- Identity Map
- Intercepting Filter
- Interpreter
- Iterator
- Layers
- Lazy Loading
- Leader Election
- Leader/Followers
- Lockable Object
- Log aggregation
- Marker Interface
- Master-Worker
- Mediator
- Memento
- Metadata Mapping
- Model-View-Controller
- Model-View-Intent
- Model-View-Presenter
- Model-View-ViewModel
- Module
- Monad
- Monitor
- MonoState
- Multiton
- Mute Idiom
- Naked Objects
- Notification
- Null Object
- Object Mother
- Object Pool
- Observer
- Optimistic Offline Lock
- Page Controller
- Page Object
- Parameter Object
- Partial Response
- Pipeline
- Poison Pill
- Presentation Model
- Priority Queue Pattern
- Private Class Data
- Producer Consumer
- Promise
- Property
- Prototype
- Proxy
- Queue based load leveling
- Reactor
- Reader Writer Lock
- Registry
- Repository
- Resource Acquisition Is Initialization
- Retry
- Role Object
- Saga
- Separated Interface
- Serialized Entity Pattern
- Servant
- Server Session
- Service Layer
- Service Locator
- Service to Worker
- Sharding
- Single Table Inheritance Pattern
- Singleton
- Serialized LOB
- Spatial Partition
- Special Case
- Specification
- State
- Step Builder
- Strangler
- Strategy
- Subclass Sandbox
- Table Module
- Template method
- Thread-local storage
- Thread Pool
- Throttling
- Tolerant Reader
- Trampoline
- Transaction Script
- Twin
- Type-Object
- Unit Of Work
- Update Method
- Value Object
- Version Number
- Visitor
Intent
The Abstract Document design pattern is a structural design pattern that aims to provide a consistent way to handle hierarchical and tree-like data structures by defining a common interface for various document types. It separates the core document structure from specific data formats, enabling dynamic updates and simplified maintenance.
Also known as
Kit
Intent
The Abstract Factory design pattern provides a way to create families of related objects without specifying their concrete classes. This allows for code that is independent of the specific classes of objects it uses, promoting flexibility and maintainability.
Intent
The Active Object design pattern provides a safe and reliable way to implement asynchronous behavior in concurrent systems. It achieves this by encapsulating tasks within objects that have their own thread and message queue. This separation keeps the main thread responsive and avoids issues like direct thread manipulation or shared state access.
Intent
The Acyclic Visitor pattern decouples operations from an object hierarchy, allowing you to add new operations without modifying the object structure directly.
Explanation
Real world example
We have a hierarchy of modem classes. The modems in this hierarchy need to be visited by an external algorithm based on filtering criteria (is it Unix or DOS compatible modem).
Also known as
Wrapper
Intent
The Adapter pattern converts the interface of a class into another interface that clients expect, enabling compatibility.
Explanation
Real-world example
Consider that you have some pictures on your memory card and you need to transfer them to your computer. To transfer them, you need some kind of adapter that is compatible with your computer ports so that you can attach a memory card to your computer. In this case card reader is an adapter. Another example would be the famous power adapter; a three-legged plug can't be connected to a two-pronged outlet, it needs to use a power adapter that makes it compatible with the two-pronged outlets. Yet another example would be a translator translating words spoken by one person to another
Intent
Streamline client's interactions with system's microservices by providing a single aggregation point that consolidates data and responses from multiple services. This simplifies the client's communication with the system, improving efficiency and reducing complexity.
Explanation
Intent
Provide a helper service instance on a client and offload common functionality away from a shared resource.
Also known as
- Sidecar
Explanation
Real world example
A remote service has many clients accessing a function it provides. The service is a legacy application and is impossible to update. Large numbers of requests from users are causing connectivity issues. New rules for request frequency should be implemented along with latency checks and client-side logging.