
Design patterns simplified part 2 introduces 13 Gang of Four patterns with UML diagrams and pseudocode, guiding you from problem to pattern-based design through practical examples and quizzes.
The example contrasts credit and debit card processors handling validation, reserve or charge flows, and settlement, highlighting code duplication and the need for refactoring to enforce consistent payment steps.
Refactor card processors into a base IPaymentProcessor with a unified PaymentInfo structure and a template method pattern for processing payments, handling validation, funding, and settlement.
Apply the template method pattern to define a base payment processor’s skeleton, with subclasses implementing primitive steps; hook methods enable optional fraud analysis before and after payment.
Explore how the template method defines the algorithm skeleton in a base class while derived classes implement abstract steps, using hooks and the hollywood principle to balance flexibility and simplicity.
Demonstrate how ItemInventory provides items by high or low demand via next and hasNext, with initializeItemsByHighDemand and initializeItemsByLowDemand, and how ReportGenerator consumes them without exposing internal arrays.
Extract traversal logic into TopDownItemsIterator to separate iteration from ItemInventory, and implement IItemsIterator with createTopDownIterator to decouple clients like ReportGenerator and support bottom-up traversal.
Demonstrate the iterator pattern by refactoring NextGenItemInventory with a single ItemsIterator for topDown and bottomUp lists, using IItemsInventory and a factory to generate monthly reports.
The iterator pattern enables sequential access to an aggregate's elements without exposing its underlying representation, using concrete iterators for top-down or bottom-up traversal.
Explore internal versus external iterators, a template method approach, and how abstract processing elements enable customizable operations, illustrated with report generation and top-down versus bottom-up item processing.
Explore replacing internal and external iterators with Java's iterator interface, leverage ArrayList traversal, and address synchronization in multi-threaded inventories using synchronized blocks and read-write locks.
Trace the iterator pattern from exposing inventory items to external and internal iterators with interfaces and language-specific implementations, enabling the ReportGenerator while preserving single responsibility and synchronization.
Explore a simplified vending machine design illustrating interactions among UI, payment processor, bill acceptor, change dispenser, item dispenser, item inventory, and stock manager.
Introduce a promotion class to manage active offers, calculate discounted prices or freebies, update the UI and payment flow, and reduce redundancy while highlighting design trade-offs in coupling.
Introduce a mediator to centralize interactions and reduce complexity among the UI, item inventory, payment processor, and dispensers, with the main program wiring and registering components.
Explore extending a mediator pattern with promotions by introducing promotion and offer classes, updating UI and mediator to apply discounts, show offers, and dispense freebies.
The mediator design reduces tight coupling by centralizing communication to the mediator, enabling IMediator and IPaymentProcessor interfaces to swap implementations and reuse across systems, boosting testability.
The mediator pattern encapsulates object interactions to promote loose coupling, letting you vary interactions independently through a mediator shared by report generator (getDemandSummary), item inventory, and UI components.
Explore how the mediator pattern reduces tight coupling by routing interactions through a mediator, enabling testing and replacement through interfaces for mediator and colleague classes, and handling promotional offers.
Explore a multi document viewer with tabbed documents, page numbers, and scrolling, and learn a two-level design using document view, document model, document controller, and MDIView, MDIModel, MDIController.
This lecture shows how MDI model, view, and controller coordinate opening documents, with a document controller creating model and view, reading files, and displaying content in a tabbed pane.
Trace the high level design of the click tab flow across MDI controller and MDI view, where the selected tab activates the child view and retrieves model data.
Explore extending the viewer to restore last opened documents after an abnormal shutdown by saving document data, order, and active document via MDIModel and DocModel, triggered by the controller.
Learn how to persist and restore application state by tracking doc models, the active document, and viewer state with the MDI model and MDIViewerState, including serialization and restoration.
Explore how to automatically save the viewer state when the document model changes, by notifying the MDI controller via a subscriber interface during scroll or page updates.
Learn how the MDI controller restores a prior session after abnormal termination by deserializing state and reopening DocModel objects and the active document, noting single responsibility violations and tight coupling.
The lecture contrasts two solutions by moving save and restore logic from the MDI controller to the MDI model, improving encapsulation, removing tight coupling, and upholding the single responsibility principle.
Explore implementing date-based save and restore by creating a file per day, using FileUtil to generate the file name and the MDI controller to pass the date.
This lecture presents an alternative solution implementing the memento pattern, where the MDI model saves and restores state via IState, while the MDI controller handles serialization, deserialization, and timing.
Learn how the memento pattern captures and externalizes an object's internal state without breaking encapsulation. See how originator, memento, and caretaker interact, with MDI model examples and inner class variations.
The memento pattern reduces coupling by letting the caretaker save and restore originator state, while the originator maintains its state; access is controlled via IState or inner class.
Explore how the patent filter tool reads patent documents, extracts attributes, and shortlists items using algorithm, networking, date, and submitter criteria to prioritize reviews.
Translate repetitive file-copy problems into simple sentences, build an interpreter, and execute left-to-right checks to copy files that match given criteria.
Apply the interpreter pattern to parse condition sentences, define grammar with BNF, and build a class hierarchy (expression, contains, beforeDate, lessThan, or, and) to evaluate matches.
Build and traverse abstract syntax trees from patent condition text using ContainsExpression, OrExpression, and AndExpression; parse with a Parser and evaluate with the interpreter.
Implement an interpreter design pattern to filter patent documents by parsing a condition text into an AST of expressions, then evaluate contains, before date, and less-than submitters to copy matches.
Learn how the parser turns condition text into an abstract syntax tree by tokenizing keywords like beforeDate and lessThan, plus contains, or, and, and building expressions on a stack.
Define a language's grammar and an interpreter using that representation. Employ an abstract expression with terminal and nonterminal expressions, a context, and a client evaluating an AST.
Define how the interpreter pattern uses grammar to form a class hierarchy and an abstract syntax tree, enabling dynamic query interpretation with PatentDocument as context.
Create a scatter plot tool that maps years of experience to decimal satisfaction ratings, using shapes for software engineers, managers, and senior managers, with point sizes adapting to team size.
Initialize the plotter with scatter plot model data, draw the graph skeleton with axis labels and tick marks, build legend markers via a factory, and render the data points.
Design a scatter plot app with a dot shape hierarchy and an abstract base class. Use a factory to create shapes and apply the flyweight pattern to reduce memory.
Apply flyweight to share color, label, and dimension across thousands of dot shapes, reducing instances to three while externalizing position to the plotter for efficient rendering.
Flyweight redesign for dot shapes separates intrinsic dot shape int from extrinsic position data, uses a factory to share shapes and a plotter that manages positions.
Evaluate flyweight patterns through intrinsic and extrinsic state in dot shapes, comparing pre-flyweight, flyweight A, B, and C, and learn when memory reduction occurs.
Apply the flyweight pattern to textured shapes to share texture data and reduce memory usage. The lecture contrasts 10,000 dots versus three textures and 800 positions, highlighting efficiency.
Master the flyweight pattern by sharing intrinsic state to support thousands of fine-grained objects and save memory. Separate intrinsic and extrinsic state and enforce factory-managed access to flyweights.
Examine the flyweight structure, detailing intrinsic state shared by concrete flyweights, unshared flyweights with no intrinsic state, and how the factory supplies objects while clients provide extrinsic state.
Identify how the flyweight pattern enables sharing many fine-grained objects by separating intrinsic and extrinsic state. Maintain that intrinsic state stays constant; move extrinsic state to the client.
Explore a pricing engine that discounts items by age using a discount info object, and note how CSV export reveals a single responsibility principle concern across electronics, books, and consumables.
Explore how the visitor pattern lets a sales reporting component generate top selling products across consumables, books, and electronics using minimum sales count, without changing product classes or duplicating logic.
Explore how the visitor pattern adds new operations to product classes by implementing an accept method and the I visitable interface, enabling per-class visit methods.
Understand how the visitor pattern delegates operation selection through accept and visit to enable print and export across a collection of components without client type checks.
This lecture shows how accept and visit implement double dispatch, letting a print visitor call get A1 on an A object, with the operation depending on both receivers.
Apply the visitor pattern by adding an accept method to the product hierarchy and defining an i visitor with visit methods for consumable, book, electronics, enabling slash price by age.
Introduce a csv export visitor to generate csv strings from products and write them to a file, and a top selling items visitor using double dispatch.
Explore applying the composite pattern to model a product hierarchy as a tree. Extend it with the visitor pattern to search for products by name across leaves and nodes.
Explore the visitor pattern, which defines operations via a separate visitor hierarchy and element accept methods, enabling new behavior on lists and trees without altering element classes.
Explains how the visitor pattern avoids adding new methods, highlights double dispatch via accept and visit, and warns about single responsibility principle, encapsulation, heterogeneous interfaces, and a stable element hierarchy.
Explore how a cross-cutting error management system routes component errors via email, WhatsApp, SMS, or log files using a configurable error info object per component.
Analyze the error info hierarchy where EMS creates channel-specific error info objects via create error info, using I error info abstract base class for email, WhatsApp, and log file channels.
Explore how the builder pattern simplifies complex ErrorInfo construction across channels, with EMS delegating to EmailErrorInfoBuilder, WhatsApp, and logfile builders, including validation and step methods.
Introduce an ErrorInfoDirector to encapsulate construction steps within the builder pattern, guiding EmailErrorInfoBuilder to assemble the EmailErrorInfo object. Map the EMS as client and redefine responsibilities for builder and director.
Demonstrate how a director remains unaware of concrete object types by using separate Builder1 and Builder2 classes to produce ClassA and ClassB, with the client calling getObjectA or getObjectB.
Extend the design patterns course with an HTML error info builder, override key methods, and update the director to produce HTML strings for the HTML Report Manager's error reports.
Explore the final variation of the builder pattern with an optional director and learn method chaining to build error info objects directly from the client, improving modularity and maintainability.
Explain how the builder pattern separates construction from representation, enabling the same construction steps to produce different representations like email, whatsapp, and html error info objects.
Summarizes the builder pattern for constructing a complex error info object across representations like email, WhatsApp, sms, and log file, using a director and builders.
Refactor a flower show and go karting ticketing system to apply the single responsibility and open-closed principles by introducing a ticket printer and type-specific printers, using the template method pattern.
Explore implementing bulk ticketing by converting multiple tickets into a single csv-based printable ticket with a ticket processor, while evaluating open-closed principle implications.
Examine how two base classes share common text and CSV ticket printing logic via the ITicketPrinter interface, using a template method to generate formats while addressing single responsibility concerns.
Explore applying the single responsibility principle by separating ticket data preparation from format-specific printing, using a printer hierarchy that delegates to text or csv print implementations.
Refactor ticket printing with a base template method that collects title, details, and date. Derived printers supply details, while a factory and bridge pattern enable text, csv, and html formats.
Apply the bridge pattern to decouple abstraction from implementation, allowing the entity and its behavior to vary independently and be extended without disruption.
Explore how the bridge pattern decouples ticket printers from print formats. See how adding new formats like CSV, text, and HTML becomes easy via separated abstractions.
Description:
- Are you looking for a different, yet deep and engaging course on design patterns?
- Are you better able to understand the concepts through diagrams & visual effects?
- Do you have basic object oriented concepts and now looking to acquire software design concepts?
- Have you struggled to understand design patterns from the books?
If you relate to one or more of the above criteria then this course is for you.
It is part 2 of my earlier design patterns course which covers 13 patterns that were remaining from Part 1 course.
But this part 2 course takes the visual communication to another level that promises to make your learning experience even more enjoyable.
The course follows a step-wise approach where you will begin every pattern with a unique and interesting example problem. Examples are not overly simple nor too complex - They have just the right balance to help you relate back to your project.
The course then begins with a design to solve the problem, without applying a pattern.
After you have understood the shortcomings of the design, the course then applies the design pattern by altering the design. This helps you to clearly understand and appreciate the usage of the pattern.
You will be able to assess your knowledge by answering several quizzes & questions popped up throughout the course.
If you have registered for this course with an intention to strengthen your base for software design patterns, you will never lose interest during the course.
Join the course with a visually stimulating and engaging content!
Who this course is not for?
- If you are looking at working code that can be compiled and executed, then this course is not for you. This course focuses on concepts and demonstrates using java like pseudo-code, UML class and sequence diagrams, without bogging you much with language specific syntaxes.
- This course focuses on most important concepts through practical examples to help you apply them in real life projects. It does not serve as a replacement for reference books.
Who is the target audience?
- Fresh as well as experienced software developers
- Aspiring software architects
- Junior software architects