Skip to main content
Programming Principles

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.


iluwatarAbout 9 min
30 Seconds of Java

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.


iluwatarAbout 11 min
Design Pattern Catalog

iluwatarAbout 5 min
Abstract Document

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.


iluwatarAbout 4 minStructuralAbstractionExtensibilityDecoupling
Abstract Factory

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.


iluwatarAbout 3 minCreationalAbstractionDecouplingGang of Four
Active Object

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.


iluwatarAbout 2 minConcurrencyPerformance
Acyclic Visitor

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).


iluwatarAbout 2 minBehavioralDecouplingExtensibility
Adapter

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


iluwatarAbout 3 minStructuralCompatibilityGang of FourIntegration
Aggregator Microservices

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


iluwatarAbout 2 minArchitecturalAPI designCloud distributedDecouplingMicroservices
Ambassador

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.


iluwatarAbout 4 minStructuralDecouplingCloud distributed