# CS5010 > Narrated video lessons and articles for CS5010 Programming Design Paradigms: design patterns, code smells, testing and object-oriented fundamentals in Java. - [Testing](/testing/): Lessons on testing Java code: unit tests with JUnit 5, coverage with JaCoCo, mutation testing with PIT, test doubles with Mockito, and TDD. - [Code Smells](/code-smells/): The 23 code smells from the CS5010 refactoring guide: how to spot each one, the refactoring that removes it, and when it is fine to leave it. - [Design Patterns](/patterns/): All 23 Gang of Four design patterns, each with a narrated video, a running Java example, a class diagram, and advice on when not to use it. - [Programming Fundamentals](/fundamentals/): The object-oriented ideas every pattern builds on: polymorphism, encapsulation and dynamic dispatch, each with a narrated video and Java code. - [Page not found](/404/): The page you're looking for doesn’t exist or has moved. Check the URL, use the navigation to browse sections, or return to the homepage. - [Privacy Policy](/privacy/): Learn how we collect, use, and protect your personal data, what rights you have over your information, and how to contact us with questions. ## Testing > Lessons on testing Java code: unit tests with JUnit 5, coverage with JaCoCo, mutation testing with PIT, test doubles with Mockito, and TDD. - [Unit Testing with JUnit 5](/testing/junit5-unit-testing/): Write your first Java unit tests with JUnit 5 and Gradle: arrange-act-assert, assertEquals, assertThrows, parameterized tests, best practices and pitfalls. - [Code Coverage with JaCoCo](/testing/jacoco-code-coverage/): Measure Java test coverage with JaCoCo and Gradle: read the report, line vs branch coverage, enforce a rule in check, best practices and pitfalls. - [Mutation Testing with PIT](/testing/pit-mutation-testing/): Mutation testing in Java with PIT and Gradle: mutants, killed vs survived, mutation score, fixing a survivor, best practices, pitfalls and when not to use it. - [Test Doubles with Mockito](/testing/mockito-test-doubles/): Test doubles in Java with Mockito 5 and JUnit 5: dummy, stub, spy, mock, fake, verify, argument captors, best practices, pitfalls, when not to mock. - [Test-Driven Development](/testing/test-driven-development/): Learn test-driven development in Java with JUnit 5: red, green, refactor on a small example, fake it and triangulate, best practices and common pitfalls. ## Code Smells > The 23 code smells from the CS5010 refactoring guide: how to spot each one, the refactoring that removes it, and when it is fine to leave it. - [Alternative Classes with Different Interfaces](/code-smells/alternative-classes-different-interfaces/): Alternative Classes with Different Interfaces in Java: two classes, one job, different shapes. Rename Method, Extract Superclass, and an Adapter. - [Comments](/code-smells/comments/): The Comments code smell in Java: why comments that explain what code does go stale, and how Extract Method, Rename and Introduce Assertion fix them. - [Data Class](/code-smells/data-class/): The Data Class code smell in Java: why a class that only holds data invites copied rules, and how Move Method and Encapsulate Collection fix it. - [Dead Code](/code-smells/dead-code/): Dead Code in Java: methods, fields and branches nobody uses or can reach, how to find them, and why Remove Dead Code is safe because version control remembers. - [Divergent Change](/code-smells/divergent-change/): Divergent Change in Java: one class edited for many unrelated reasons. Spot it, split it with Extract Class, and tell it from Shotgun Surgery and Large Class. - [Duplicate Code](/code-smells/duplicate-code/): Duplicate Code in Java: one rule copied into many places. Spot it, fix it with Extract Method, Pull Up Method or Extract Class, and know when to leave it. - [Inappropriate Intimacy](/code-smells/inappropriate-intimacy/): The Inappropriate Intimacy code smell in Java: classes that reach into each other's fields, and how Move Method and Extract Class keep them apart. - [Incomplete Library Class](/code-smells/incomplete-library-class/): Incomplete Library Class in Java: a library lacks a method and the fix-up is copied everywhere. Look first, then Foreign Method or Local Extension. - [Lazy Class](/code-smells/lazy-class/): Lazy Class in Java: classes that do too little to earn their upkeep. Spot them, fold them in with Inline Class or Collapse Hierarchy, and know when to leave them. - [Message Chains](/code-smells/message-chains/): Message Chains in Java: why a client that walks through other objects breaks when they change, how Hide Delegate fixes it, and when to leave a chain alone. - [Middle Man](/code-smells/middle-man/): The Middle Man code smell in Java: a class that only forwards calls adds a hop and nothing else. How to spot it, Remove Middle Man, and when forwarding is fine. - [Parallel Inheritance Hierarchies](/code-smells/parallel-inheritance-hierarchies/): Parallel Inheritance Hierarchies in Java: two class families that must grow in lockstep. Spot them, fold one into the other with Move Method, and tell them from Bridge. - [Speculative Generality](/code-smells/speculative-generality/): Speculative Generality in Java: classes, parameters and hooks built for a future that never came, and how Collapse Hierarchy, Inline Class and Remove Parameter remove them. - [Temporary Field](/code-smells/temporary-field/): The Temporary Field code smell in Java: fields that only matter during one job, why they crash, and how Extract Class and Null Object fix them. - [Data Clumps](/code-smells/data-clumps/): Data Clumps in Java: groups of values that always travel together, how to spot them with the take-one-away test, and how Introduce Parameter Object and Extract Class fix them. - [Long Parameter List](/code-smells/long-parameter-list/): Long Parameter List in Java: why every parameter costs every caller, and how Preserve Whole Object, Replace Parameter with Query, Remove Flag Argument and Introduce Parameter Object shrink a signature. - [Primitive Obsession](/code-smells/primitive-obsession/): Primitive Obsession in Java: domain values kept in raw doubles, ints and strings, how to spot them, and how Replace Primitive with Object and small records give units, IDs and kinds their rules. - [Switch Statements](/code-smells/switch-statements/): The Switch Statements code smell in Java (Repeated Switches): why the same switch in many places hurts, how polymorphism fixes it, which switch stays, and when an exhaustive switch over a sealed type is the better tool. - [Feature Envy](/code-smells/feature-envy/): Feature Envy in Java: methods that use another class's data more than their own, how to spot them, and how Move Method and Extract Method fix it. - [Large Class](/code-smells/large-class/): Large Class (God class) in Java: why classes that do everybody's job hurt, five signals to spot them, and how Extract Class, Extract Subclass and Extract Interface fix them. - [Long Method](/code-smells/long-method/): Long Method in Java: why methods that do too much hurt, five signals to spot them, and how Extract Method, Replace Temp with Query and Decompose Conditional fix them. - [Refused Bequest](/code-smells/refused-bequest/): Refused Bequest in Java: subclasses that throw UnsupportedOperationException or leave empty overrides, the Liskov Substitution Principle, and fixes like Replace Inheritance with Delegation. - [Shotgun Surgery](/code-smells/shotgun-surgery/): Shotgun Surgery in Java: one change, many small edits in many classes. How to spot it, consolidate with Move Method and Inline Class, and vs Divergent Change. ## Design Patterns > All 23 Gang of Four design patterns, each with a narrated video, a running Java example, a class diagram, and advice on when not to use it. - [Flyweight](/patterns/flyweight-pattern/): The Flyweight pattern in Java: share the identical part of many objects, pass in the rest. Map pins, intrinsic vs extrinsic state, Integer's cache, and when not to. - [Interpreter](/patterns/interpreter-pattern/): The Interpreter pattern in Java: one class per grammar rule, so a rule written as a sentence becomes a tree. Feature-flag rules, records, sealed types, regex, and when not to. - [Memento](/patterns/memento-pattern/): The Memento pattern in Java: let an object save and restore its own state through a snapshot only it can read. Covers deep copies, memory cost and undo. - [Abstract Factory](/patterns/abstract-factory-pattern/): The Abstract Factory pattern in Java: one object per family so related pieces always match, the roles, its real cost, Swing's look and feel, and Factory Method. - [Bridge](/patterns/bridge-pattern/): The Bridge pattern in Java: split a class hierarchy that varies two ways into two hierarchies joined by a field. Notifications, JDBC, and Bridge vs Adapter vs Strategy. - [Composite](/patterns/composite-pattern/): The Composite pattern in Java: treat single items and groups the same way, let groups answer by asking their parts, and choose safety or transparency for add. - [Iterator](/patterns/iterator-pattern/): The Iterator pattern in Java: hasNext and next, Iterable and for-each, fail-fast removal, an iterator over a paged API, and internal iteration with streams. - [Mediator](/patterns/mediator-pattern/): The Mediator pattern in Java: replace many-to-many chatter between widgets with one hub, keep the hub small, ButtonGroup, and Mediator vs Facade and Observer. - [Prototype](/patterns/prototype-pattern/): The Prototype pattern in Java: copy an object through its interface with a copy constructor, avoid the shallow-copy trap, and see why clone() is not the pattern. - [Proxy](/patterns/proxy-pattern/): The Proxy pattern in Java: a stand-in with the same interface that controls access. Lazy, protection and remote proxies, Hibernate, java.lang.reflect.Proxy. - [Visitor](/patterns/visitor-pattern/): The Visitor pattern in Java: add operations without touching element classes, why a new element breaks every visitor, and sealed types with a pattern switch. - [Adapter](/patterns/adapter-pattern/): The Adapter pattern in Java: make a class you can't change fit the interface your code expects, object vs class adapter, Arrays.asList, and Facade vs Decorator. - [Decorator Pattern](/patterns/decorator-pattern/): The Decorator pattern in Java: add logging, retries and caching to one object by wrapping it in classes with the same interface, choose the stacking order, java.io streams, and Decorator vs Proxy and Strategy. - [Facade](/patterns/facade-pattern/): The Facade pattern in Java: give a multi-step task one method over many classes, keep the parts public, Files.readString, and Facade vs Adapter. - [Factory Method](/patterns/factory-method-pattern/): The Factory Method pattern in Java: move a new behind an overridable method, the four roles, Iterable.iterator(), and how it differs from static factories. - [Observer Pattern](/patterns/observer-pattern/): The Observer pattern in Java: let a subject keep a list of listeners behind one small interface, push or pull, avoid lapsed-listener leaks, and Observer vs publish-subscribe. - [Singleton](/patterns/singleton-pattern/): The Singleton pattern in Java, honestly: its two promises, eager, holder and enum forms, Runtime, the costs of global state, and dependency injection instead. - [Builder Pattern](/patterns/builder-pattern/): The Builder pattern in Java: why long constructors and setters fail, the fluent builder with build() validation, the GoF Director, and Builder vs Factory. - [Chain of Responsibility Pattern](/patterns/chain-of-responsibility-pattern/): The Chain of Responsibility pattern in Java: replace an if/else ladder with handlers that handle a request or hand it on. Servlet filters, vs Decorator. - [Command Pattern](/patterns/command-pattern/): The Command pattern in Java: turn a call into an object with execute and undo for undo/redo, macros and job queues, plus Command vs Strategy. - [State Pattern](/patterns/state-pattern/): Learn the State design pattern with a vending machine, a traffic light, and a publishing workflow: why switch statements rot, the behavior-table insight, Java code, diagrams, and State vs Strategy. - [Strategy Pattern](/patterns/strategy-pattern/): The Strategy pattern in Java: replace a switch on an algorithm type with interchangeable classes or lambdas chosen by the client, plus Strategy vs State. - [Template Method Pattern](/patterns/template-method-pattern/): The Template Method pattern in Java: a final method fixes an algorithm's steps, subclasses fill them in. Hooks, the Hollywood Principle, pitfalls, vs Strategy. ## Programming Fundamentals > The object-oriented ideas every pattern builds on: polymorphism, encapsulation and dynamic dispatch, each with a narrated video and Java code. - [Encapsulation](/fundamentals/encapsulation/): Encapsulation in Java beyond getters and setters: invariants, one door in, information hiding (Parnas), Tell Don't Ask, LocalDate and records. - [Polymorphism](/fundamentals/polymorphism/): Polymorphism in Java as a design idea: write to a role, the three kinds (subtype, parametric, ad hoc), Liskov substitution, List.of, and when not to use it. - [Dynamic Dispatch](/fundamentals/dynamic-dispatch/): How Java picks which method runs: static vs dynamic type, method tables, what isn't dispatched, overloading vs overriding, and double dispatch.