Design Patterns in Java | Class Count, Cost, Runnable Code

Count the concrete classes Bridge saves over subclassing (A × I vs A + I) and price the gap at your own hourly rate: 8 inputs, 12 formulas, 6 runnable Java files (JDK 17) that print the same class counts, and a 23-pattern GoF map.

Your numbers

Your result

Concrete classes with subclassing (A × I)-
Concrete classes with Bridge (A + I)-
Classes the plan adds with subclassing-
Classes the plan adds with Bridge-
Extra classes with subclassing after the plan-
Extra hours with subclassing-
Cost of subclassing over Bridge-

Everything updates as you type. Nothing is uploaded. This runs in your browser.

The same counts, printed by Java

Example (made-up): 4 notification types (Alert, Reminder, Receipt, Digest) × 3 senders (Email, SMS, Push). java BridgeBefore.java prints 12 concrete classes; java BridgeAfter.java prints 7, and both send the same "SMS +1-555-0100: RECEIPT". Add Slack and Webhook and subclassing needs 11 more classes than Bridge: 22 hours, $1,320.00 at $60 an hour.

interface Sender { String deliver(String to, String text); }
abstract static class Notification {
    protected final Sender sender;          // the bridge
    Notification(Sender sender) { this.sender = sender; }
    abstract String send(String to);
}
new Receipt(new SmsSender()).send("+1-555-0100");

Free tutorials draw Bridge with two shapes and two colours. This page counts your own classes. The paid pack adds the Visitor sheet (edits vs new visitor classes, setup cost, saving), 6 runnable Java files for Bridge, Visitor and Strategy before and after (JDK 17, about 145 lines in all), and PATTERNS.md: all 23 GoF patterns, one line each on the smell it fixes.

Full version — $21 once: workbook with the Visitor sheet, 6 Java files, the 23-pattern map. Get the pack

Get the full calculatorFull version: all tabs, your own file, works offline.

Get the full version $21

What you need after the check: the .xlsx workbook with the Visitor sheet (edits vs new visitor classes, setup cost, saving), 6 runnable Java files (Bridge, Visitor, Strategy, each before and after) that print their own class counts, and PATTERNS.md mapping all 23 GoF patterns to the code smell each

One payment, one licence key for this tool. The key is shown right after payment.

Gumroad 'design patterns in java' sells one-time courses and books (store measurement 2026-10-31, about 606 dollars a day across 2 selling products); training firms list 100 dollars for courseware and 3,750 dollars for a classroom

Buy the full version — $21

This tool is 1 of 301 paid tools in English. All 301 with one key: Freelancer & Small Business Pass — $9.99/month · $79/year · Deadline reminders by email (free)

Need more than this one? ReadyStack Pass opens all 635 files and 540 full versions — $29/month or $199/year. See the Pass →

Embed this calculator on your site (free)

Paste this code into your page. It runs in your visitor’s browser and stays up to date. Nothing your visitors type is stored.

 All embeddable tools

For businesses: your name and logo instead of ours, and each visitor’s result + e-mail in your inbox (only when they tick consent) — Pro from $19/month. See Pro →

Email me this result
A copy of what you see above, in your inbox — the tool stays free, nothing here is locked.

· ReadyStack

Worked example

Real numbers from this tool, line by line.

Cost of subclassing over Bridge: 1,320.00 dollars. That is the result for a made-up Java team that sends 4 notification types (Alert, Reminder, Receipt, Digest) through 3 senders (Email, SMS, Push) and plans to add Slack and Webhook, at 2 hours to write and test a class and 60 dollars an hour.

LineResult
Concrete classes with subclassing (A × I)12
Concrete classes with Bridge (A + I)7
Classes the plan adds with subclassing8
Classes the plan adds with Bridge2
Extra classes with subclassing after the plan11
Extra hours with subclassing22
Cost of subclassing over Bridge1,320.00 dollars

How the count works

With plain subclassing, every notification type needs one class per sender: EmailAlert, SmsAlert, PushAlert and so on. That is A x I = 4 x 3 = 12 concrete classes. Bridge splits the two directions into two hierarchies: the notification types hold a Sender field, and each sender is its own class. That is A + I = 4 + 3 = 7 concrete classes. The two base types (the abstract Notification and the Sender interface) exist in both designs, so they are left out of both counts.

The gap grows with every sender you add. Slack and Webhook cost 4 x 2 = 8 new classes with subclassing and 2 with Bridge. After the plan, subclassing needs 20 classes and Bridge needs 9: 11 extra classes. At 2 hours each that is 22 hours, and at 60 dollars an hour it is 1,320.00 dollars.

The same numbers from real Java

The pack has BridgeBefore.java and BridgeAfter.java. Both run with one command on JDK 17 (java BridgeAfter.java, no build tool). Both send the same message, "SMS +1-555-0100: RECEIPT". BridgeBefore counts its own concrete classes with reflection and prints 12. BridgeAfter prints 7, then prints 11 extra classes, 22 hours and 1,320.00 dollars.

Three teams, three answers

That third case matters. A pattern is not free: Bridge adds a field, a constructor argument and a second hierarchy to read. The count tells you when that price is worth paying, in your code, before the code review.

Visitor has a price too

The workbook adds a second sheet for Visitor. Without Visitor, every new operation is a new method in every element class. With 6 element classes and 3 new operations that is 18 edits, 18 hours at 1 hour an edit. With Visitor, the one-time setup is 6 accept() methods (6 hours), and each operation is one new visitor class (3 x 2 = 6 hours). Saving with Visitor: (18 - 6 - 6) x 60 = 360.00 dollars. With only 1 new operation the saving turns negative, and a new element class means editing every visitor.

What is free and what is paid

Free: the whole Bridge check on the page, with your own numbers, as often as you like. Paid, once: the .xlsx workbook with the Visitor sheet, 6 runnable Java files (Bridge, Visitor and Strategy, each before and after, about 145 lines in all, with their printed output) and PATTERNS.md, a one-line map of all 23 GoF patterns to the code smell each one fixes.

15 seconds — what it actually does

Full walk-through

Questions people ask

What does this design patterns in Java calculator do?

It counts the concrete classes your own hierarchy needs with plain subclassing (A × I) and with the Bridge pattern (A + I), now and after the implementations you plan, then prices the extra classes at your hours and hourly rate. The example of 4 notification types and 3 senders plus 2 planned shows 11 extra classes, 22 hours and 1,320.00 dollars.

Who is it for?

Java developers who must justify a refactor to a tech lead, and students who want a design pattern interview answer backed by numbers. You type 8 inputs from your own code: variants, planned additions, hours per class and edit, and your rate. The 12 formulas do the counting the same way in the browser and in the workbook.

Why not just read a free tutorial?

Free tutorials draw the Bridge diagram with two shapes and two colours and stop there. They never count your own classes or say what the subclass explosion costs you in hours. This check prints that number for your hierarchy, and the 6 Java files print the same class counts when you run them on JDK 17.

What is free and what is in the paid file?

Free: the whole Bridge check on screen with your own numbers, any number of times. Paid, once: the .xlsx workbook that keeps your numbers and adds the Visitor sheet (edits, setup, saving), 6 runnable Java files for Bridge, Visitor and Strategy before and after, and PATTERNS.md mapping all 23 GoF patterns to the smell each fixes.

How does the price compare?

Design-pattern courses and books sell as one-time products on Gumroad, and training firms list 100 dollars for courseware and 3,750 dollars for a classroom course. This is one payment for a workbook and runnable code that answer one practical question: when does a pattern pay off in your code, in classes and hours.

Ask about this tool

One question, answered by the person who built it. Your email only if you want the answer sent.