Illustrious Consulting · Coding Practices · Part 1 of 2

Front-end laws, made touchable.

Every UX law and every front-end-facing security practice from the Coding Practices Manual — as a live interactive demo you can break and fix in place. Broken state first; every fix is a click.

28 interactive cards · 20 UX laws · 8 front-end security rules

UX laws — the 20 that shape every screen

Gestalt, cognition, and behavior laws with a broken/fixed toggle in each card.

UX Law 1

Hick's law

The more choices you show someone, the longer they take to decide. Every extra button, menu item, or option adds thinking time — so cut choices down to what people actually need, and hide advanced ones behind an 'Advanced' section.

Overloaded screens make people freeze or leave. Simple menus feel faster and get used more.

Tell your AI agentApply Hick's law: minimize visible choices on each screen; group or progressive-disclose advanced options; every screen should push toward one primary action.

Decision-time calculator · RT ≈ 250 + 150·log₂(N+1) ms

5 visible choices → 638 ms just to decide

Task: open Export data. Hit Start, then your first click stops the clock.

ready

Every extra visible choice adds log₂ decision cost. Progressive disclosure keeps the working set at 3 and hides the rest until asked.

UX Law 2

Fitts's law

The bigger and closer a button is, the faster you can click it. Make the important buttons big, put them where thumbs and eyes already are, and keep destructive ones far away from frequent actions.

Tiny, distant targets frustrate users and cause mis-taps — especially on phones.

Tell your AI agentApply Fitts's law: make primary buttons large and thumb-reachable on mobile, give all tap targets at least 44px, and separate destructive actions from frequent ones.

report-final-v3.txt

2.4 MB · edited 2 min ago

Tap Save three times. Delete sits one mis-tap away.

0/3 saves · 0 mis-taps on Delete ·

MT ≈ a + b·log₂(D/W+1): a 56px-wide button is roughly 2× faster to hit than a 24px one — and pulling Delete out of Save’s reach ends accidental deletes.

UX Law 3

Jakob's law

People spend most of their time on other websites, so they expect yours to work like those: logo top-left linking home, cart top-right, search up top. Innovation in layout confuses; innovation in product features delights.

When a site breaks familiar patterns, users waste effort re-learning basic navigation instead of getting their task done.

Tell your AI agentFollow Jakob's law: use familiar web conventions — logo top-left links home, primary actions in expected places — and spend innovation effort on the product, not the navigation.
PRODUCT — Ceramic mug, 12 oz · task: get back to the homepage

clicks used: 0

Users spend most of their time on other sites. Logo top-left linking home, cart top-right, search up top — convention is a feature; innovate the product, not the navigation.

UX Law 4

Law of proximity

Things placed near each other are perceived as belonging together. Group related items with closeness and whitespace; separate unrelated ones with distance — before reaching for lines and boxes.

Users read layout spatially. If the 'Cancel' button sits visually with a form's fields, people click it by accident.

Tell your AI agentApply the law of proximity: group related elements with spacing, separate unrelated ones with whitespace, and check every layout for items that 'sit' with the wrong group.

Username

We’ll never post without your permission.

Password

At least 12 characters.

Quiz: which cluster does each element “sit” with? Your eye decides before your brain does.

Same elements, different gaps. Proximity — not lines or boxes — is what groups them; in the broken layout the help text drifts toward the wrong neighbor and the buttons hug the fields.

UX Law 5

Miller's law

People can hold roughly 7 (plus or minus 2) items in working memory. Don't demand memorizing across screens — chunk information into digestible groups and keep key info visible.

Forms that ask users to remember things from a previous page cause errors and abandonment.

Tell your AI agentApply Miller's law: chunk content into groups of 5-9 items, never make users remember info across screens, and put labels next to the fields they describe.

❌ One endless page3 answers held in memory

Enter the account code (E-4291), the branch number (B-17) and the assignee (R. Alvarez) — they exist only in this sentence. Type all three from memory.

✅ Chunked wizard0 answers held in memory

Step 1/3 — Enter the account code. The value sits right here: E-4291

Working memory holds ~7±2 items — and an instruction 2 fields back is a memory demand, not a label. Chunked steps keep every answer visible at the point of use; nothing to recall, nothing to drift.

UX Law 6

Doherty threshold

If a system responds in under about 400 milliseconds, it feels instant and people stay in flow. Slow it down and users feel pain — but perceived speed counts too: show progress spinners and skeletons so waiting feels shorter.

Perceived speed is as important as real speed for user satisfaction.

Tell your AI agentApply the Doherty threshold: optimize responses under 400ms where possible, and use skeleton screens/progress indicators so anything slower still feels responsive.

❌ Blank-screen loadidle

Feed idle — click refresh and watch what users see.
time-to-first-anything

✅ Skeleton + progressidle

Feed idle — click refresh: same data, skeleton first.
time-to-first-anything

Same 1.6 s network in both. The blank box shows nothing for 1.6 s (feels frozen); the skeleton paints in <400 ms, so the wait feels active. Under ~400 ms is where systems feel instant — after that, perceived speed needs progress.

UX Law 7

Von Restorff effect

The thing that stands out is the thing that gets remembered and clicked. Use distinctive color, size, or shape for the one element that matters most on a screen — and resist decorating everything.

If everything is highlighted, nothing is. A single clear emphasis drives the action you want.

Tell your AI agentApply the Von Restorff effect: give each screen exactly one visually dominant call-to-action, distinct in color/weight from everything else, and avoid highlighting multiple competing elements.

❌ Trial A — every card highlighted

Five solid buttons, one job. If everything shouts, the eye samples randomly.

Click Upgrade. Any order works — that’s the problem.

✅ Trial B — one dominant CTA

Same screen, same position — one solid green card among muted neighbors.

Click Upgrade. Try to hit it first.

trial A — first click: ? · clicks to reach Upgrade:
trial B — first click: ? · clicks to reach Upgrade:

UX Law 8

Minimize target distance

The distance between a control and the thing it affects should be small — the button next to the item it acts on, confirmation near the action, feedback right where you clicked. (Companion to Fitts's law, which is about size/closeness to cursor.)

Every extra inch between cause and control adds error and delay.

Tell your AI agentMinimize target distance: place controls adjacent to the objects they act on, show feedback at the point of action, and keep related controls within one visual cluster.
TASK ▸ DELETE FILE_C.CSV CLICKS 0 FEEDBACK GAP —
UX Law 9

Serial position effect

People best remember the first and last items in a list or menu. Put the most important items at the beginning and end; bury the rest in the middle.

Middle items get ignored — important links there are effectively invisible.

Tell your AI agentApply the serial position effect: place the most critical navigation items first and last; avoid burying key actions in the middle of menus.
MENU ▸ 6 SLOTS · RECALL BY POSITION KEY ITEMS ▸ PRICING · GET STARTED
▮ estimated attention / recall per slot — 1st and 6th win (primacy + recency)
UX Law 10

Peak-end rule

People judge an experience by its most intense moment and how it ended — not by its average. Design the best moment deliberately and make the last step (checkout confirmation, final page) delightful.

A mediocre journey with a great ending feels great; a fine journey with a frustrating ending feels terrible.

Tell your AI agentApply the peak-end rule: identify the most intense moment in each flow, smooth the low points, and deliberately design a positive, clear ending for every task.
JOURNEY ▸ CHECKOUT · 4 STEPS · CLICK A STEP TO RELIVE IT PEAK + END SET THE RATING
OVERALL FEEL
UX Law 11

Zeigarnik effect

Unfinished tasks stay stuck in our minds more than finished ones. Use it honestly: progress bars, '3 of 5 steps done', saved-state indicators — they pull people back to finish.

Incompleteness is motivating; showing progress converts starters into finishers.

Tell your AI agentApply the Zeigarnik effect: show clear progress indicators on multi-step tasks, and let users save/resume partial work so unfinished tasks visibly call them back.
COURSE ▸ "SQL FUNDAMENTALS" STATE ▸ UNFINISHED
COMPLETE
UX Law 12

Law of Pragnanz

People interpret what they see in the simplest possible form. So: make the design itself simple — align elements, reduce visual noise, use clear structure so the 'simplest reading' of your UI is the correct one.

Ambiguous, cluttered layouts get misread; users invent wrong structures and get lost.

Tell your AI agentApply the law of Pragnanz: minimize visual complexity, align to a consistent grid, remove decoration that doesn't inform, so the simplest interpretation is the intended one.
REPORT ▸ Q3 SERVER SUMMARY READING ▸ CLUTTERED — WHICH NUMBER IS REVENUE?
UX Law 13

Law of similarity

Things that look alike are assumed to be alike. Give all buttons of one kind the same look; give different functions visibly different styles.

Users learn a visual language: if every clickable thing is blue, they'll click anything blue — and stop clicking things that look non-clickable.

Tell your AI agentApply the law of similarity: one consistent style for all interactive elements, visibly distinct styles for different functions, and no visual duplicates for different actions.
PAGE ▸ ARTICLE W/ LINKS + CTA FIND & CLICK THE LINKS
UX Law 14

Law of uniform connectedness

Elements visually connected (by a line, a shared background, a shared border) are seen as related. Use connecting visuals to show relationships and flow — e.g., steps joined by a line, tabs sharing a bar.

Without connection cues, users miss relationships that are obvious to the designer.

Tell your AI agentApply uniform connectedness: visually connect related items with shared containers, borders, or flow lines; make step sequences read as one connected path.
SETTINGS ▸ NETWORK TASK ▸ MAKE THE API FASTER
UX Law 15

Tesler's law

Every system has a fixed amount of complexity. Tesler's law says: move that complexity from the user to the machine wherever possible. Every complexity you remove from the interface has to be absorbed by the engineering.

Every simplification for users is engineering work for you. Know that trade-off consciously instead of pushing complexity onto users by default.

Tell your AI agentApply Tesler's law: shift complexity from users to the system (auto-detect, smart defaults, hide advanced internals) wherever engineering cost allows; never expose internal complexity to users.
USERdoes 4 things
    SYSTEMabsorbed 0 jobs
    • · Timezone lookup
    • · DST rules engine
    • · UTC conversion
    • · Invite formatting
    user carries 80%machine 20%
    Broken mode: the 4 steps above are YOUR job — click the button and count your clicks. Then flip to ✅.
    UX Law 16

    Postel's law

    Be liberal in what you accept from people, strict in what you produce. Accept 'New York', 'new york', and 'NY' as the same answer; but always output clean, normalized data. (Apply carefully: forgiving parsing of *input*, never lenient security checks.)

    Rigid forms treat innocent variations as errors and people give up. Forgiving input plus strict internal handling cuts errors without cutting safety.

    Tell your AI agentApply Postel's law to user input: accept common variants forgivingly, normalize silently (phone, address, dates), but never loosen validation of security-critical or structured data.
    try:
    DB— nothing saved
    ⚠️ Scope: be forgiving with human input only. Tokens, permissions and security checks stay strict — a parser that "guesses" there is a vulnerability, not a courtesy.
    UX Law 17

    Parkinson's law

    Work expands to fill the time available. In UX: don't give users endless steps or fields — people will fill whatever you provide. Ask for the minimum needed, and keep forms short.

    Long forms lose users at a predictable rate; every extra field is a tax on completion.

    Tell your AI agentApply Parkinson's law: minimize form fields and steps to only what's truly needed; every additional field must justify itself.
    FIELDS 11 fields
    FORM HEALTH
    Predicted completion35%
    Users lost before submit65%
    99sTIME TO FILL
    8UNJUSTIFIED FIELDS
    The charity example: 11 fields → 4 fields and donations rose. Every field beyond what's needed is a tax — each one must justify itself. Figures illustrative.
    UX Law 18

    Occam's razor

    Among designs that work equally well, the simplest is best. If two solutions both solve the problem, ship the one with fewer parts, fewer clicks, fewer dependencies.

    Every extra element is a potential bug, confusion point, and maintenance cost. Simple survives updates and team changes.

    Tell your AI agentApply Occam's razor: prefer the simplest solution that fully solves the problem; cut features and steps that add complexity without clear benefit.
    USER FLOW
    PAGE 1 OF 3 — ACCOUNT
    Team name
    Your email
    PAGE 2 OF 3 — WORKSPACE
    Workspace name
    Workspace URL slug
    Team size
    PAGE 3 OF 3 — PREFERENCES
    Timezone
    Theme
    Notification digest
    ✓ Workspace created — after 3 pages, 9 inputs, 4 clicks.
    0CLICKS
    9INPUTS
    11PARTS TO MAINTAIN
    USER FLOW
    ONE PAGE — SMART DEFAULTS FILLED FOR YOU
    Team name · auto from email
    Workspace · "chris-team" (edit if wrong)
    Timezone · America/Chicago (detected)
    0CLICKS
    0REQUIRED TYPING
    4PARTS TO MAINTAIN
    Both solutions work. Occam's razor asks: which one has fewer parts, fewer clicks, fewer dependencies — and still fully solves the problem? Try both.
    UX Law 19

    Pareto principle

    Roughly 80% of results come from 20% of causes. In products: ~20% of features serve ~80% of real usage. Find that core and polish it relentlessly; everything else is secondary.

    Teams spend equal effort everywhere and end up with a bloated product where nothing is excellent.

    Tell your AI agentApply the Pareto principle: identify the 20% of features users actually use, polish those first, and hide or remove the long tail.
    35 FEATURES — SHARE OF SESSIONS
    core (top 5, ~90% of use)long tail (30 features)polish applied
    OUTCOME
    91%USER SATISFACTION
    5FEATURES ENGINEERED HARD
    LowMAINTENANCE BURDEN
    Vital few: 5 features serve ~90% of sessions. Polish those five relentlessly — the other 30 get "good enough", or get hidden.
    UX Law 20

    Aesthetic-usability effect

    People perceive attractive things as working better — and they are more forgiving of small flaws in beautiful products. Beauty isn't decoration; it buys patience and trust.

    Users forgive friction on a beautiful interface but abandon an ugly one for identical flaws.

    Tell your AI agentApply the aesthetic-usability effect: invest in clean, polished, cohesive visuals early — aesthetics measurably increase perceived usability and user patience.
    APP A — UNPOLISHED
    dashboard.exe
    Same app logic as B. Load the dashboard.
    User patience50%
    APP B — POLISHED
    ✦ Dashboard
    Same app logic as A. Load the dashboard.
    User patience50%
    Identical features, identical bug. Click Load dashboard on each and watch the same 1.5s wait + glitch get judged completely differently.

    Front-end-facing security

    The security practices whose failure you can trigger from the browser itself.

    Security #15

    Escape user content

    Escaping means turning special characters into harmless display text, so anything a user posts is shown as words, never run as code. It's the fix for cross-site scripting (XSS).

    If a user posts a piece of script code and the site runs it for every visitor, the attacker hijacks everyone's session — the most common hole in user-generated-content sites.

    Tell your AI agentEscape all user-generated content before rendering: treat every user string as text, never HTML, and add a Content Security Policy as a second layer.
    attackervisitorserver
    attacker posts a "bio"
    visitor loads the profile page
    🚨 document.cookie sent to evil.server — every visitor hijacked
    visitors hit: 0
    the attack is invisible in the page — watch the visitor panel
    Security #14

    Validate all input

    Validation means checking every piece of incoming data: right type? right size? sensible range? expected format? Checking on the server, every time — the browser's checks are decoration.

    Bad input doesn't just break pages; it's the delivery method for most attacks and the cause of corrupted data. If it isn't checked at the door, it's trusted, and attackers live in that gap.

    Tell your AI agentValidate every input server-side: type, length, range, and format against an explicit allowlist; reject anything unexpected rather than trying to clean it up.
    clientserverdb
    order form quantity → server → database
    type: number ✓range 1–99: integer: size ≤ 4 chars:
    Submit ⚠ fakes a tampered request — the browser check never ran
    Security #18

    Add security headers

    Security headers are free instructions your site sends to browsers: don't run injected scripts (CSP), don't let other sites frame you (X-Frame-Options), only talk over HTTPS (HSTS), and more.

    They cost nothing to add and blunt whole categories of attacks — especially the ones that slip past your own code.

    Tell your AI agentAdd hardening headers to all responses: Content-Security-Policy, X-Content-Type-Options: nosniff, X-Frame-Options, Referrer-Policy, and Strict-Transport-Security, tuned to the app.
    serverbrowser
    server response headers
    Content-Security-Policy
    X-Content-Type-Options
    X-Frame-Options
    Referrer-Policy
    browser what actually happens
    click an attack — the header wall reacts instantly
    Security #19

    Force HTTPS

    HTTPS encrypts everything between the visitor and the site. Forcing it means any http:// visit is permanently redirected to https://, using HSTS so browsers remember and never try the unsafe version first.

    Without HTTPS, anything a user types — passwords included — crosses the internet in readable text, and attackers on the same network can read or rewrite it.

    Tell your AI agentForce HTTPS site-wide: redirect all HTTP traffic, enable HSTS, and fix any mixed-content resources still loaded over http://.
    userattackerserver
    user types a password on café Wi-Fi
    🔒
    attacker same network, free tools, 2 minutes
    redirect: · HSTS:
    watch the same login cross the room twice
    Security #16

    Restrict file uploads

    File uploads need a strict bouncer: check the file type, limit the size, rename the file, store it outside the code area, and never let it execute. Serve downloads separately from the app.

    A 'profile photo' upload that actually accepts a script file is a backdoor — attackers upload the script, then visit its address and it runs on your server with full privileges.

    Tell your AI agentRestrict all uploads: allowlist extensions and real file types (check the content, not just the name), cap file size, rename files server-side, store them outside the executable path, and disable execution in the upload folder.
    attackerupload gateserver
    attacker picks a file to upload
    ext allowlist:· magic bytes:
    rename:
    server uploads folder + what a visitor gets
    attacker visits an uploaded file's URL and hopes it runs
    Security #17

    Trim API responses

    Trimming means the server sends back only the fields each caller actually needs — and never extra internals like other users' data, internal flags, or password hashes.

    APIs built by dumping whole database rows often leak fields nobody meant to expose. Testers call it 'excessive data exposure' and it routinely leaks personal info through an app that looks fine.

    Tell your AI agentTrim all API responses: return only explicitly required fields per endpoint, never raw database objects, and audit endpoints for over-sharing (password hashes, internal IDs, other users' data).
    appattacker
    attacker phones log every API response in plaintext
    GET /api/me
    password_hash $2b$12$kJ9… ✂ admin:true ✂ internal_note
    PREMIUM-2 sniffing
    a normal app feature — but see what rides along on the wire
    Security #12

    Add bot protection

    Bot protection distinguishes humans from scripts: CAPTCHAs, hidden 'honeypot' fields bots fill in but humans never see, and request-signing. It targets the automated traffic that rate limits alone don't fully stop.

    Bots create fake accounts, spam reviews, scrape your content, and stuff stolen passwords into your login page — all at machine speed and volume.

    Tell your AI agentAdd bot protection to public forms and auth endpoints: use a CAPTCHA service, honeypot fields, and server-side checks for suspicious automation. Flag rather than delete on low confidence.
    attackerformserver
    public form comment box
    hidden honeypot
    ✓ I'm not a robot
    server posts feed
    posts: 0 · spam posted: 0
    bots autofill every field — including the ones they can't see
    Security #11

    Rate limit login

    Rate limiting means refusing too many tries in a short window — e.g., 5 failed logins per account per minute, then a wait. It turns password guessing from seconds into years.

    Without limits, a bot can try millions of passwords against your login form at full speed. With limits, automated guessing dies.

    Tell your AI agentAdd rate limiting and temporary lockouts to login, password-reset, and signup endpoints (per account and per IP), with sensible limits and a small artificial delay on failure.
    attackerserver
    attacker password-guessing bot
    attempts: 0 · throttle: none — full speed
    failed-login bucket (server side)
    server POST /login
    fails-per-minute limit: none
    endpoint state: accepting every try
    bot guesses common passwords as fast as the server allows
    Part of the Illustrious Visual Reference · Interactive companion to the Coding Practices Manual · 2026