Quicksheet · Architecture, Design Patterns and DSA
Patterns Quicksheet: Architecture, Design Patterns and DSA on One Page
Khairul Alam · October 2026 · ~10 min to skim
Quicksheet Architecture Design patterns DSA Kotlin
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 Architecture patterns and app plumbing Principles Software design patterns DSA problem-solving patterns How to use this sheet
Popular onlyExpand all Collapse all
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 Pattern What it is Popular Learn more Layered: View, Logic, Data The 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 MVC Model, View, Controller. On Android the Activity often becomes a "Massive View Controller" that does everything. Arch Part 3 MVP A Presenter holds the logic and talks to the View through an interface, so the logic can be tested without Android. ★ Arch Part 3 MVVM A ViewModel exposes state (StateFlow/LiveData); the View observes it. Survives rotation and needs no View reference. ★ Arch Part 4 Redux / MVI One immutable state, intents/actions in, a reducer produces the next state. Unidirectional data flow, easy to replay and test. ★ Arch Part 4 VIPER View, Interactor, Presenter, Entity, Router. Five small roles with navigation pulled out; suits big teams, costs more boilerplate. Arch Part 5 Clean Architecture Concentric layers with the Dependency Rule: source code dependencies point only inward, toward business rules. Frameworks and databases are details. ★ Clean Architecture Modularization Split the app into Gradle modules by feature or layer for faster builds, clear ownership and enforced boundaries. ★ Arch Part 5 Repository One class that hides where data comes from (network, database, cache) behind a simple interface. ★ Arch Part 2 Unidirectional data flow State flows down to the view, events flow up to the logic. One direction makes bugs traceable. ★ Arch Part 4 Single source of truth Exactly one place owns each piece of data (often the local database); everything else observes it. ★ Arch Part 7 Dependency injection Pass dependencies in instead of creating them (Hilt, Dagger, Koin). Makes layers swappable and testable. ★ Arch Part 6 Async: coroutines, Flow, Rx Keep slow work off the main thread and deliver results back safely, tied to the lifecycle. ★ Arch Part 6 Configuration-change survival Keep state through rotation, language, font and screen-size changes (ViewModel, saved state, persistence). Arch Part 7 Bridge adapter migration Move 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 Pattern What it is Popular Learn 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 concerns Each part handles one kind of job (UI, logic, data). ★ Arch Part 2 KISS Keep it simple; the simplest design that works is usually best. ★ Arch Part 2 DRY Do not repeat knowledge; one fact lives in one place. ★ Arch Part 2 The Dependency Rule Source code dependencies point only inward toward higher-level policy. ★ Clean Architecture Clean Code habits Meaningful 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 Pattern What it is Popular Learn more Abstract factory A 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 Builder Build a complex object step by step, then validate and produce it in one go. ★ Details Dependency injection A class does not create what it needs. ★ Details Factory One place decides which class to create, so the rest of the code only knows the interface. ★ Details Lazy initialization Delay creating something expensive until the first time it is really needed, then remember it. ★ Details Singleton Exactly one instance of a class, reachable from everywhere. ★ Details Multiton Like Singleton, but one instance per key : a map of named, shared instances. Details Object pool Keep a set of ready-made, reusable objects and lend them out, instead of creating and destroying them again and again. Details Prototype Create 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 Pattern What it is Popular Learn more Adapter Make an object with the wrong interface fit the interface you need, by wrapping it. ★ Details Composite Treat a single object and a group of objects the same way, by giving both one interface. ★ Details Decorator Add behavior to an object by wrapping it in another object with the same interface, instead of creating a subclass for every combination. ★ Details Delegation An object hands part of its work to a helper object. ★ Details Facade One simple entry point in front of a group of complicated classes. ★ Details Module Group related code behind one public surface and hide the rest. ★ Details Proxy A 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 Bridge Split a thing into two separate hierarchies, an abstraction and an implementation, joined by a reference, so each can vary on its own. Details Extension object Add new behavior to a type without changing it. Details Flyweight Share the heavy, repeated part of many objects (the same tree type, the same icon) instead of storing a copy in each one. Details Marker An interface or annotation with no methods that only tags a class, so other code can treat tagged classes specially. Details
Behavioral16 items, 9 popular Pattern What it is Popular Learn more Chain of responsibility Pass a request along a chain of handlers. ★ Details Command Turn an action into an object with execute() (and often undo()). ★ Details Fluent interface Design an API so calls chain into readable, sentence-like code, usually by returning the same object from each method. ★ Details Iterator Walk through a collection one item at a time without knowing how it is stored inside. ★ Details Null object Instead of returning null and checking everywhere, return a harmless object that does nothing, so callers never need an if. ★ Details Observer An object (the subject) keeps a list of listeners and tells them whenever something changes, without knowing who they are. ★ Details State Represent each state as its own object that knows what may happen next, instead of one big when over a status field. ★ Details Strategy Put each interchangeable algorithm behind one small interface and let the caller choose which one to use. ★ Details Template method A base class fixes the order of the steps of an algorithm; subclasses fill in some of the steps. ★ Details Blackboard Several independent experts read and write a shared workspace (the blackboard). Details Interpreter Represent a small language as a tree of objects and give each node an evaluate step. Details Mediator Objects do not talk to each other directly. Details Memento Capture an object’s state in a snapshot so you can restore it later (undo), without exposing its insides. Details Servant Put behavior that many unrelated classes need into one helper class (the servant), instead of copying it into each of them. Details Specification Express business rules as small objects that answer yes or no, then combine them with and, or, not. Details Visitor Add new operations to a family of classes without editing them, by letting a visitor object handle each class. Details
Concurrency16 items, 3 popular Pattern What it is Popular Learn more Lock Only one thread at a time may run a critical section; the others wait their turn. ★ Details Scheduler Decide when and on which thread tasks run: now, later, repeatedly, on a pool. ★ Details Thread pool Keep a fixed number of worker threads and feed them tasks from a queue, instead of creating a new thread for each task. ★ Details Active object An object owns its own thread and a queue. Details Balking If an object is not in the right state for a request (already busy), the request is ignored instead of waiting. Details Binding properties Link two properties so that when one changes, the other follows automatically. Details Double-checked locking Check a condition without a lock first (fast path), and only lock and check again if work is really needed. Details Event-based asynchronous Start work in the background and get notified by an event (callback) when it finishes or fails, instead of waiting for it. Details Guarded suspension A thread waits until a condition is true (a message has arrived) before it continues. Details Join Wait 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 object An object whose methods are all mutually exclusive, so only one thread is inside it at a time. Details Reactor One event loop waits for events and dispatches each to the handler registered for it. Details Read-write lock Many threads may read at the same time, but a writer needs exclusive access. Details Thread-specific storage Give each thread its own private copy of a value, so threads do not need locks to share it. Details CPU atomic operation Use 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 Pattern What it is Popular Learn more Two pointers Sorted input, pair or triple, both ends, in-place edits O(n); O(1) ★ Part 8 §2 Sliding window Longest/shortest/fixed-size contiguous subarray or substring O(n); O(1) or O(k) ★ Part 8 §4 Prefix sum Many range sums; subarray sum equals k O(n) build, O(1) query ★ Part 8 §5 Hash map counting / grouping Frequency, 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 algorithm Maximum 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 sort Values in 1..n or 0..n: missing, duplicate or corrupt numbers O(n); O(1) Part 8 §11 Dutch national flag Group a few distinct values (0/1/2) in one pass O(n); O(1) Part 8 §11 Counting Tally or bucket by value to avoid a scan or sort O(n + range) Part 6 §7 Linear-time sorting Small fixed value range: counting or bucket sort beats O(n log n) O(n + k) Part 6 §7 Simulation Follow the described process step by step; the work is in clean state handling varies Summary only Bit manipulation / XOR Every 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 Pattern What it is Popular Learn 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 search Rotated array, boundaries, peak element: decide which half still holds the answer O(log n); O(1) ★ Part 6 §3 Merge intervals Overlaps, insert, meeting rooms: sort by start, then sweep O(n log n); O(n) ★ Part 8 §9 Top K elements k largest, smallest, most frequent, closest. Heap of size k, or buckets O(n log k) ★ Part 8 §10 Two heaps Running 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 merge Merge 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 map Sorted order with fast insert, delete, floor/ceiling (Kotlin: java.util.TreeMap/TreeSet) O(log n) per op Part 4 §5 Meet in the middle Search space 2^n too big: solve each half (2^(n/2)) and combine O(2^(n/2)) Summary only Mo's algorithm Many 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 Pattern What it is Popular Learn more Fast and slow pointers Middle of a list, cycle detection, sequences that may loop O(n); O(1) ★ Part 8 §3 In-place linked list reversal Reverse a list, a sublist or groups of k by rewiring next pointers O(n); O(1) ★ Part 3 §3 Stack Valid parentheses, nesting, undo, evaluate expressions O(n); O(n) ★ Part 3 §5 Monotonic stack Next greater/smaller, days until, histogram rectangle O(n); O(n) ★ Part 8 §8 Monotonic queue Sliding 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 Pattern What it is Popular Learn more Tree BFS (level order) Output grouped by level, shortest path in an unweighted graph O(n); O(w) ★ Part 4 §3 Tree DFS Root-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 sort Prerequisites, build order, dependencies in a DAG O(V + E) Part 5 §6 Union-find Same-group checks, merge groups, cycle in an undirected graph near O(1) per op Part 5 §8 Trie Prefix search, autocomplete, word search O(L) per word Part 4 §8 Serialize and deserialize Turn a tree/graph into a string and back (e.g. pre-order with null markers) O(n) Summary only Clone Deep 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 bridges Which node or edge disconnects the graph: DFS with discovery time and low-link values O(V + E) Summary only Segment tree Range query (sum/min/max) with updates in between O(log n) per op Summary only Binary indexed tree (Fenwick) Prefix sums with point updates; shorter than a segment tree O(log n) per op Summary only
Recursion, greedy and dynamic programming10 items, 5 popular Pattern What it is Popular Learn more Subsets, permutations, combinations Generate every choice set; branch on include/exclude O(2^n) or O(n!) ★ Part 7 §3 Backtracking N-Queens, Sudoku, word search: place, recurse, undo, prune exponential, pruned ★ Part 7 §3 Greedy Scheduling, activity selection, jump game, min coins (when the greedy choice is safe) O(n log n) or O(n) ★ Part 7 §4 Fibonacci-style DP Each state depends on the previous one or two: climbing stairs, house robber O(n); O(1) ★ Part 7 §6 0/1 knapsack Take or skip each item under a capacity: subset sum, partition O(n x W); O(W) ★ Summary only Unbounded knapsack Items reusable without limit: coin change, rod cutting O(n x W); O(W) Part 7 §7 Longest common subsequence Two strings, 2D table over prefixes: LCS, edit distance O(m x n) Part 7 §8 Palindromic subsequence / substring Longest palindrome: expand around the centre, or DP over [i, j] ranges O(n^2) Summary only Matrix / grid DP Each cell from its neighbours: min path cost, unique paths with obstacles O(m x n) Part 7 §8 DP on trees Post-order DFS where a node combines its children: tree diameter, house robber III O(n); O(n) Summary only
Concurrency1 items, 0 popular Pattern What it is Popular Learn more Multi-threaded patterns Alternate output between threads, shared state, producer-consumer. Tools: locks, semaphores, BlockingQueue, coroutines depends Summary only
How to use this sheet
Starting a project: pick an architecture (section 1), then apply the principles (section 2).Designing a class or module: scan the design patterns (section 3) for the family that matches your problem: creating, wrapping, coordinating or threading.Solving a problem: read the clue in the DSA description (section 4) and try the matching pattern first.Learning: start with the starred items in each family.
← Back to all writing