Quicksheet · Architecture, Design Patterns and DSA

Patterns Quicksheet: Architecture, Design Patterns and DSA on One Page

Khairul Alam·October 2026·~10 min to skim
QuicksheetArchitectureDesign patternsDSAKotlin

127 patterns in one searchable list: 15 architecture and plumbing items, 10 principles, 53 software design patterns and 49 DSA patterns. Each has a title, a short description, a ★ Popular mark where it applies and a link to the full article.

About the stars

The ★ marks are my judgment, not a measured statistic: 67 items you meet most often in Android code. Everything else is real and useful, just less frequent. The architecture, design pattern and DSA lists are the ones taught on this site; the DSA list also merges two public quicksheets.

Contents
  1. Architecture patterns and app plumbing
  2. Principles
  3. Software design patterns
  4. DSA problem-solving patterns
  5. How to use this sheet

No pattern matches.

1. Architecture patterns and app plumbing

How an Android app is arranged and the supporting techniques every architecture needs.

Architecture and plumbing15 items, 11 popular
PatternWhat it isPopularLearn more
Layered: View, Logic, DataThe shape under every architecture below: the screen shows things, the logic decides, the data layer stores and fetches. Names differ; the three layers stay.★Arch Part 1
MVCModel, View, Controller. On Android the Activity often becomes a "Massive View Controller" that does everything.Arch Part 3
MVPA Presenter holds the logic and talks to the View through an interface, so the logic can be tested without Android.★Arch Part 3
MVVMA ViewModel exposes state (StateFlow/LiveData); the View observes it. Survives rotation and needs no View reference.★Arch Part 4
Redux / MVIOne immutable state, intents/actions in, a reducer produces the next state. Unidirectional data flow, easy to replay and test.★Arch Part 4
VIPERView, Interactor, Presenter, Entity, Router. Five small roles with navigation pulled out; suits big teams, costs more boilerplate.Arch Part 5
Clean ArchitectureConcentric layers with the Dependency Rule: source code dependencies point only inward, toward business rules. Frameworks and databases are details.★Clean Architecture
ModularizationSplit the app into Gradle modules by feature or layer for faster builds, clear ownership and enforced boundaries.★Arch Part 5
RepositoryOne class that hides where data comes from (network, database, cache) behind a simple interface.★Arch Part 2
Unidirectional data flowState flows down to the view, events flow up to the logic. One direction makes bugs traceable.★Arch Part 4
Single source of truthExactly one place owns each piece of data (often the local database); everything else observes it.★Arch Part 7
Dependency injectionPass dependencies in instead of creating them (Hilt, Dagger, Koin). Makes layers swappable and testable.★Arch Part 6
Async: coroutines, Flow, RxKeep slow work off the main thread and deliver results back safely, tied to the lifecycle.★Arch Part 6
Configuration-change survivalKeep state through rotation, language, font and screen-size changes (ViewModel, saved state, persistence).Arch Part 7
Bridge adapter migrationMove from one architecture to another safely by putting an adapter between old and new code.Arch Part 9

2. Principles

The rules of thumb that the patterns below put into practice.

Design principles10 items, 8 popular
PatternWhat it isPopularLearn more
Single responsibility (S)A class has one reason to change.★SOLID
Open/closed (O)Add behaviour by adding code, not by editing working code.★SOLID
Liskov substitution (L)A subtype must work anywhere its parent type is expected.SOLID
Interface segregation (I)Many small interfaces beat one fat one; no class depends on methods it does not use.SOLID
Dependency inversion (D)Depend on abstractions, not concrete classes. High-level code should not know low-level details.★SOLID
Separation of concernsEach part handles one kind of job (UI, logic, data).★Arch Part 2
KISSKeep it simple; the simplest design that works is usually best.★Arch Part 2
DRYDo not repeat knowledge; one fact lives in one place.★Arch Part 2
The Dependency RuleSource code dependencies point only inward toward higher-level policy.★Clean Architecture
Clean Code habitsMeaningful names, small functions, honest error handling, few comments that explain why.★Clean Code

3. Software design patterns

The 53 classic patterns in Kotlin, grouped by family. Popular patterns come first in each family.

Creational10 items, 6 popular
PatternWhat it isPopularLearn more
Abstract factoryA factory of factories: one interface that creates a whole family of related objects, so you can swap the entire family (light theme widgets, dark theme widgets) at once.★Details
BuilderBuild a complex object step by step, then validate and produce it in one go.★Details
Dependency injectionA class does not create what it needs.★Details
FactoryOne place decides which class to create, so the rest of the code only knows the interface.★Details
Lazy initializationDelay creating something expensive until the first time it is really needed, then remember it.★Details
SingletonExactly one instance of a class, reachable from everywhere.★Details
MultitonLike Singleton, but one instance per key: a map of named, shared instances.Details
Object poolKeep a set of ready-made, reusable objects and lend them out, instead of creating and destroying them again and again.Details
PrototypeCreate new objects by copying an existing one and changing a few fields, instead of building from scratch.Details
Resource acquisition is initialization (RAII)Tie a resource (file, connection, lock) to the lifetime of an object, so it is released automatically even when something fails.Details
Structural11 items, 7 popular
PatternWhat it isPopularLearn more
AdapterMake an object with the wrong interface fit the interface you need, by wrapping it.★Details
CompositeTreat a single object and a group of objects the same way, by giving both one interface.★Details
DecoratorAdd behavior to an object by wrapping it in another object with the same interface, instead of creating a subclass for every combination.★Details
DelegationAn object hands part of its work to a helper object.★Details
FacadeOne simple entry point in front of a group of complicated classes.★Details
ModuleGroup related code behind one public surface and hide the rest.★Details
ProxyA stand-in with the same interface as the real object, placed in front of it to add control: caching, lazy loading, access checks, logging.★Details
BridgeSplit a thing into two separate hierarchies, an abstraction and an implementation, joined by a reference, so each can vary on its own.Details
Extension objectAdd new behavior to a type without changing it.Details
FlyweightShare the heavy, repeated part of many objects (the same tree type, the same icon) instead of storing a copy in each one.Details
MarkerAn interface or annotation with no methods that only tags a class, so other code can treat tagged classes specially.Details
Behavioral16 items, 9 popular
PatternWhat it isPopularLearn more
Chain of responsibilityPass a request along a chain of handlers.★Details
CommandTurn an action into an object with execute() (and often undo()).★Details
Fluent interfaceDesign an API so calls chain into readable, sentence-like code, usually by returning the same object from each method.★Details
IteratorWalk through a collection one item at a time without knowing how it is stored inside.★Details
Null objectInstead of returning null and checking everywhere, return a harmless object that does nothing, so callers never need an if.★Details
ObserverAn object (the subject) keeps a list of listeners and tells them whenever something changes, without knowing who they are.★Details
StateRepresent each state as its own object that knows what may happen next, instead of one big when over a status field.★Details
StrategyPut each interchangeable algorithm behind one small interface and let the caller choose which one to use.★Details
Template methodA base class fixes the order of the steps of an algorithm; subclasses fill in some of the steps.★Details
BlackboardSeveral independent experts read and write a shared workspace (the blackboard).Details
InterpreterRepresent a small language as a tree of objects and give each node an evaluate step.Details
MediatorObjects do not talk to each other directly.Details
MementoCapture an object’s state in a snapshot so you can restore it later (undo), without exposing its insides.Details
ServantPut behavior that many unrelated classes need into one helper class (the servant), instead of copying it into each of them.Details
SpecificationExpress business rules as small objects that answer yes or no, then combine them with and, or, not.Details
VisitorAdd new operations to a family of classes without editing them, by letting a visitor object handle each class.Details
Concurrency16 items, 3 popular
PatternWhat it isPopularLearn more
LockOnly one thread at a time may run a critical section; the others wait their turn.★Details
SchedulerDecide when and on which thread tasks run: now, later, repeatedly, on a pool.★Details
Thread poolKeep a fixed number of worker threads and feed them tasks from a queue, instead of creating a new thread for each task.★Details
Active objectAn object owns its own thread and a queue.Details
BalkingIf an object is not in the right state for a request (already busy), the request is ignored instead of waiting.Details
Binding propertiesLink two properties so that when one changes, the other follows automatically.Details
Double-checked lockingCheck a condition without a lock first (fast path), and only lock and check again if work is really needed.Details
Event-based asynchronousStart work in the background and get notified by an event (callback) when it finishes or fails, instead of waiting for it.Details
Guarded suspensionA thread waits until a condition is true (a message has arrived) before it continues.Details
JoinWait until several concurrent tasks have all finished before continuing.Details
Messaging design pattern (MDP)Components communicate by sending messages into a queue instead of calling each other directly or sharing memory.Details
Monitor objectAn object whose methods are all mutually exclusive, so only one thread is inside it at a time.Details
ReactorOne event loop waits for events and dispatches each to the handler registered for it.Details
Read-write lockMany threads may read at the same time, but a writer needs exclusive access.Details
Thread-specific storageGive each thread its own private copy of a value, so threads do not need locks to share it.Details
CPU atomic operationUse a single indivisible hardware-supported step (like compare-and-set) so threads can update a value safely without locks.Details

4. DSA problem-solving patterns

The 49 patterns merged from the Grokking patterns quicksheet and AlgoArk. The grey text at the end of each description is time and space cost.

Arrays and strings12 items, 6 popular
PatternWhat it isPopularLearn more
Two pointersSorted input, pair or triple, both ends, in-place edits O(n); O(1)★Part 8 §2
Sliding windowLongest/shortest/fixed-size contiguous subarray or substring O(n); O(1) or O(k)★Part 8 §4
Prefix sumMany range sums; subarray sum equals k O(n) build, O(1) query★Part 8 §5
Hash map counting / groupingFrequency, seen-before, grouping, anagrams O(n); O(n)★Part 8 §6
Two Sum (complement lookup)Unsorted data: store what you have seen, look up target - x O(n); O(n)★Part 8 §6
Kadane's algorithmMaximum subarray sum or product: running sum that restarts when it turns negative. cur = max(x, cur + x); best = max(best, cur) O(n); O(1)★Summary only
Cyclic sortValues in 1..n or 0..n: missing, duplicate or corrupt numbers O(n); O(1)Part 8 §11
Dutch national flagGroup a few distinct values (0/1/2) in one pass O(n); O(1)Part 8 §11
CountingTally or bucket by value to avoid a scan or sort O(n + range)Part 6 §7
Linear-time sortingSmall fixed value range: counting or bucket sort beats O(n log n) O(n + k)Part 6 §7
SimulationFollow the described process step by step; the work is in clean state handling variesSummary only
Bit manipulation / XOREvery item twice but one; power of two; set bits; bitmask subsets O(n) or O(1); O(1)Part 8 §12
Searching, sorting and heaps9 items, 4 popular
PatternWhat it isPopularLearn more
Binary search (and on the answer)Sorted data, first/last position, smallest value that works (monotonic check) O(log n) or O(n log M)★Part 8 §7
Modified binary searchRotated array, boundaries, peak element: decide which half still holds the answer O(log n); O(1)★Part 6 §3
Merge intervalsOverlaps, insert, meeting rooms: sort by start, then sweep O(n log n); O(n)★Part 8 §9
Top K elementsk largest, smallest, most frequent, closest. Heap of size k, or buckets O(n log k)★Part 8 §10
Two heapsRunning median, split data into a low half (max-heap) and a high half (min-heap); rebalance sizes after each insert O(log n) per insert; O(n)Summary only
K-way mergeMerge k sorted lists/arrays: a min-heap holds the current head of each list; pop the smallest, push its successor O(N log k); O(k)Summary only
Ordered set / sorted mapSorted order with fast insert, delete, floor/ceiling (Kotlin: java.util.TreeMap/TreeSet) O(log n) per opPart 4 §5
Meet in the middleSearch space 2^n too big: solve each half (2^(n/2)) and combine O(2^(n/2))Summary only
Mo's algorithmMany offline range queries on a static array: sort queries by block, move two pointers between them O((n + q) sqrt n)Summary only
Linked lists and stacks5 items, 4 popular
PatternWhat it isPopularLearn more
Fast and slow pointersMiddle of a list, cycle detection, sequences that may loop O(n); O(1)★Part 8 §3
In-place linked list reversalReverse a list, a sublist or groups of k by rewiring next pointers O(n); O(1)★Part 3 §3
StackValid parentheses, nesting, undo, evaluate expressions O(n); O(n)★Part 3 §5
Monotonic stackNext greater/smaller, days until, histogram rectangle O(n); O(n)★Part 8 §8
Monotonic queueSliding window maximum/minimum: a deque of indexes whose values decrease; drop the front when it leaves the window O(n); O(k)Summary only
Trees and graphs12 items, 4 popular
PatternWhat it isPopularLearn more
Tree BFS (level order)Output grouped by level, shortest path in an unweighted graph O(n); O(w)★Part 4 §3
Tree DFSRoot-to-leaf paths, path sum, subtree properties, any traversal O(n); O(h)★Part 4 §2
Graph traversal (BFS and DFS)Connectivity, shortest path in unweighted graphs, components O(V + E)★Part 5
Island (matrix traversal)2D grid: count or fill regions with BFS/DFS from each unvisited cell O(rows x cols)★Part 5 §5
Topological sortPrerequisites, build order, dependencies in a DAG O(V + E)Part 5 §6
Union-findSame-group checks, merge groups, cycle in an undirected graph near O(1) per opPart 5 §8
TriePrefix search, autocomplete, word search O(L) per wordPart 4 §8
Serialize and deserializeTurn a tree/graph into a string and back (e.g. pre-order with null markers) O(n)Summary only
CloneDeep copy a graph or a list with random pointers: map old node to new node, copy in two passes or with DFS O(n); O(n)Summary only
Articulation points and bridgesWhich node or edge disconnects the graph: DFS with discovery time and low-link values O(V + E)Summary only
Segment treeRange query (sum/min/max) with updates in between O(log n) per opSummary only
Binary indexed tree (Fenwick)Prefix sums with point updates; shorter than a segment tree O(log n) per opSummary only
Recursion, greedy and dynamic programming10 items, 5 popular
PatternWhat it isPopularLearn more
Subsets, permutations, combinationsGenerate every choice set; branch on include/exclude O(2^n) or O(n!)★Part 7 §3
BacktrackingN-Queens, Sudoku, word search: place, recurse, undo, prune exponential, pruned★Part 7 §3
GreedyScheduling, activity selection, jump game, min coins (when the greedy choice is safe) O(n log n) or O(n)★Part 7 §4
Fibonacci-style DPEach state depends on the previous one or two: climbing stairs, house robber O(n); O(1)★Part 7 §6
0/1 knapsackTake or skip each item under a capacity: subset sum, partition O(n x W); O(W)★Summary only
Unbounded knapsackItems reusable without limit: coin change, rod cutting O(n x W); O(W)Part 7 §7
Longest common subsequenceTwo strings, 2D table over prefixes: LCS, edit distance O(m x n)Part 7 §8
Palindromic subsequence / substringLongest palindrome: expand around the centre, or DP over [i, j] ranges O(n^2)Summary only
Matrix / grid DPEach cell from its neighbours: min path cost, unique paths with obstacles O(m x n)Part 7 §8
DP on treesPost-order DFS where a node combines its children: tree diameter, house robber III O(n); O(n)Summary only
Concurrency1 items, 0 popular
PatternWhat it isPopularLearn more
Multi-threaded patternsAlternate output between threads, shared state, producer-consumer. Tools: locks, semaphores, BlockingQueue, coroutines dependsSummary only

How to use this sheet

← Back to all writing