Java Design Patterns

How you can get Java design patterns to do exactly what you want and accelerate your software career in less than 1 week


Finally...get the secret weapon every successful Java programmer uses to write code that is reusable, extensible and easy to maintain for many years to come...as used by the engineers that brought us the Java Virtual Machine and powerful ecosystem....

" First of all, best wishes for this new year ! I just wanted to tell you that I have completed the Java Design Patterns Course, it was very interesting the examples were very clear and the books recommendation was awesome, I was following the course with some of the books you mentioned that I already have and I put a couple of your recommendations on my Amazon wish list."

- Edison Martinez

Like so many programmers of my generation, I started coding in BASIC. After a short foray into Turbo Pascal, my university led me gently to C.

Professor MacGregor then introduced C++. His lectures were ramblings in a thick Glasgow accent with matching handwriting. Stroustrup's writing became my bible.

All through my university education, I struggled to rid myself of the bad habits endowed by years of BASIC and C. Polymorphism? No, I used switch statements and multi-conditional ifs.

Heinz writing switch statements in 1996

I was insanely productive through the generous application of CTRL+C and CTRL+V. Part of my masters was an editor for SDL, used for network protocols. My professor and I sold this to a company in France. They visited us at the University of Cape Town and liked my program. To make it perfect, they wanted a few changes. It only took me a few hours to finish everything they wanted.

IT WAS ONLY WHEN I STARTED WORKING THAT I DISCOVERED THAT EVERYTHING I HAD LEARNED ABOUT OBJECT-ORIENTATION WAS WRONG

I had used the same coding techniques from C and BASIC in my C++ code. The result were lots of switch statements distributed throughout my codebase. Whenever I had to add a new design element, I would have to find and change each switch statement in turn. If I forgot one, which happened a lot, then one feature would not work anymore. For example, if I didn't change the switch for printing, then my new element would show on the screen, but not in the printout. Each time I added one element, I had to test each function in turn to make sure everything worked.

This type of coding behaviour might be ok when you're the only one working on that code. But it doesn't make for happy team mates.

French colleagues sad to see Heinz leave, but happy they do not have to maintain his switch statemetns

At my first real job, my mentor handed me the GoF book and said: "Here, you have to read this."

Here, you have to read this.

I did. Most of the patterns seemed somewhat familiar from my years of coding C++. I put it aside. What could I possibly learn?

A year later I heard Martin Fowler at a conference in Cape Town. He described "Design Patterns" as the most significant software development book of the decade.

I picked it up for a second read. Perhaps I had missed something? It all seemed obvious the first time.

I DID NOT UNDERSTAND A WORD ON THE SECOND READ

How was it possible that a year of coding experience had made me so stupid? Surely real-world coding should have the opposite effect, making me more valuable as a programmer?

Indeed, it had. But the first time I read the book, I did not have enough insight to understand its true value. Martin Fowler's words had made me pick up the book for a second time that I had discarded as "completely obvious".

"If one has to choose to take a single design patterns course it should be Java Design Patterns by Heinz Kabutz. I can't recommend it enough.The class is very well organized and covers 30 design patterns. What sets it apart is how well each pattern is explained and the coverage of several less known design patterns like Memento, Essence, Object Recursion, Acyclic Visitor. Heinz spends enough time to give details how each pattern originated and its main usages. Currently its 5 edition the course covers the material in great depth, but at he same time doesn't spend more time that necessary on each pattern. What I find very useful are the comments about common pitfalls to avoid and ways to extend and improve the implementation of these design patterns using latest language features of Java 8,9 and 10. A personal favorite of mine are the exercises that follow each design pattern allowing the student to put to practice what she learned. And if you complete all the exercises and send them to Heinz he will issue you a course completion certificate."

- Stefan Dragnev

I struggled through each pattern, trying to think of places where I had seen it in our Java project. We even formed a design pattern study group that met every Friday lunch. I still remember the Visitor pattern described by my colleague Martin Booyens. He spoke about the dominee (Afrikaans for parson) visiting. Whilst I remember his analogy twenty years later, I was complete befuddled by his explanation of this rather simple pattern. Having lay people teach the patterns did not work as well as we had hoped.

TEACHING DESIGN PATTERNS IS HARD - MANY ONLINE PATTERNS COURSES HAVE SERIOUS ERRORS THAT WILL HURT YOU

During my third read through GoF, I finally had the Eureka! moment. Every pattern used polymorphism. Even the Singleton. This was the key concept used everywhere. Furthermore, most of the pattern used a combination of inheritance and composition. When in doubt, we used composition.

If only I had known all this during my university days, I could have avoided all those nasty switch statements.

I immersed myself in patterns, determined to understand the various nuances of each design. I bought books, read papers, reached out to one of the authors of the original GoF book - John Vlissides. I even did a technical review on some papers he authored for IBM (Composite1 and Composite2). I studied the writing of Christopher Alexander, famous architect whose pattern language the software community cloned. After months of preparation, I was ready to teach my first Java design patterns course.

BOOKS REFERENCED IN THIS COURSE

The Timeless Way of Building by Christopher Alexander

Pattern Hatching by John Vlissides

Pattern Language of Program Design 3

Pattern Language of Program Design 4

Head First Design Patterns

There are others. I own about 30 books on patterns. I read them so that you don't have to. But these are the most important. Especially Pattern Hatching. If you buy any one book, get that one.

SOMETHING INTERESTING HAPPENED

Something interesting happened. I would teach a small class at a company. A few months later, I would get an order for a much larger course. This often carried on until the entire development staff had gone through the course.

Why was this? Why did companies want everyone to learn this?

  • Programmers became far more productive with just one week of learning.
  • They improved their communication inside the team.
  • They understood existing designs faster.
  • Much easier to learn design patterns with a coach.
  • Biggest value for money Java training available.
  • Ordinary Java courses and university curricula focus on the syntax of the language, but are sparse on the semantics. If they are lucky, students will learn that there are three different types of patterns: creational, behavioral and structural. But they won't see the practical applications of where patterns are used.

    In my Java Design Patterns Course, I show where each of the patterns is used in the Java Development Kit. This makes our course immensely practical. The patterns are not just some abstract concepts. They are presented from the coal face of timeless software.

    DESIGN PATTERNS ARE RELEVANT TODAY

    Through its 18 year history, and with countless revisions, our Design Patterns Course has remained relevant and useful. The patterns of Iterator, Composite and Strategy are as important with Java 11 as they were with Java 1.1. As in the 90s, patterns still make programmers more productive and able to communicate better.

    Java 8 added lambdas and method references to the language. This makes some patterns such as Command easier to use. Default methods in interfaces means we are not always force d to use abstract classes.

    "Some of the exercises I managed to do alone.. and some not.. but those which I "copied" I tried to understood by going through code, debug it.. and of course I watched the walkthroughs after that.

    It's a great course, I will go through it again without too many breaks. Lots of patterns are covered, I like how it is explained and in combination with exercises containing good examples and use cases this is a great stuff..

    And not to forget you as instructor, I like the spontaneous way in which you teach and share your obviously big amount of the knowledge.. Overall great course worth the money!"

    - Vatroslav Vukovic

    Get started now!



    "The course has a lot of code examples to better understand the various design patterns.What I've learned: capturing/non-capturing lambdas, use only ConcurrentHashMap since Java 8, performance considerations, etc. The difficulty of the course is exactly right: difficult code samples and patterns are explained in more detail. What I also liked: Solution walkthroughs of the exercises with live coding. Sometimes Heinz came up with better solutions than he had in his model answers.He answers all questions very carefully."

    - Anonymous, Feedback from an in-house course presented in Graz, Austria

    No one likes forward references in books or courses. "Don't worry about this, we will do it in a later chapter" tends to distract us. We try to have as few of these as possible.

    We start with an extensive introduction to Java on modern virtual machines. A lot of the concerns in the original Gang-of-Four book stem from when we only had static compilation. Java can optimize our code on-the-fly. The JIT compiler can even inline polymorphic method calls, if it can determine that it is safe. If later on another type of subclass appears, it will undo that optimization. Indirection costs are also inlined. Too many objects? No worries, the garbage collector does a splendid job of managing these.

    One of the starting precepts is that of meronomy. This defines what we mean by "part-whole hierarchy". The reason we care about meronomy is because we need to avoid memory leaks in our designs. Memory leaks should be a thing of the past with Java's automatic memory management. Unfortunately they still happen when we ignore meronomy.

    Another important concept is intrinsic versus extrinsic state. It occurs in lots of the patterns. We can usually rewrite the implementations to move from one to the other. Neither is good or bad, but extrinsic usually allows us to share objects. Intrinsic is a bit more object-orientated.

    THE GOLDEN ORDER

    After our detailed introduction, we start with simple patterns that occur everywhere. Patterns like Strategy, Iterator, Proxy and Abstract Class.

    Most courses and books starts with the creational patterns Singleton and Factory Method. The thinking is that these are very simple patterns. They are not. Singleton has a lot of subtleties. The pattern allows polymorphism and multiple instances of the "Singleton". Lazy vs eager initialization? Most courses get this wrong, with code that can break in production.

    The Quintessential Singleton

    The patterns are sourced from both the original Gang-of-Four book by Erich Gamma et al, in addition to proceedings from the Pattern Language of Program Design conferences. They are categorized into behavioral (B), structural (S) and creational (C) patterns. Here is the golden order that we follow through this maze of patterns:

    Abstract Class (B), Builder (C), Essence (C), Memento (B), Proxy (S), Flyweight (S), Strategy (B), Null Object (B), Iterator (B), Factory Method (C), Template Method (B), Composite (S), Visitor (B), Acyclic Visitor (B), Object Recursion (B), Default Visitor (B), Adapter (S), Command (B), Decorator (S), Extension Object (S), Singleton (C), State (B), Facade (S), Prototype (C), Abstract Factory (C), Interpreter (B), Mediator (B), Observer (B), Bridge (S), Chain of Responsibility (B)

    EXERCISES, EXERCISES, EXERCISES, EXERCISES, EXERCISES

    We learn more by doing than by listening. Every pattern is followed by exercises that we solve to improve our understanding of the pattern. For each exercise we have model solutions and a detailed walkthrough, where I show you the thought process in solving the exercise. Some of the exercises are hard. Others easier.

    Exercises, exercises, exercises, exercises

    We have different types of exercises for the patterns:

  • Using Patterns in the JDK: Practical application of patterns using existing classes from the Java Development Kit.
  • Refactoring existing designs into patterns: Transform bad designs into more maintainable code by applying design patterns.
  • Fun fun fun: Not all exercises are entirely practical. Lab rats are reanimated with memento and rappers made to sing with the adapter pattern.
  • COURSE COMPLETION CERTIFICATE

    So your employer bought this nice shiny course for you. How can you prove to them that you have finished it?

    Teachable tracks your progress through the course. At the end of each section, you can mark it as "completed". Once you have finished at least 88% of the course, you can qualify for a course completion certificate. To claim this, you can submit your completed exercises to Heinz Kabutz for marking. The certificate and marking cost are included in your course price.

    UNHAPPY? GRAB A 100% REFUND WITHIN 30 DAYS!

    We believe that this is the best value-for-money course in the Java world. It is useful for all levels of Java knowledge: beginner, intermediate and advanced. Everyone will learn something that will help them become better Java programmers.

    To put our money where our mouth is, we are offering a 100% money-back guarantee within 30 days of purchasing the course. No questions asked. Simply let us know that this training wasn't for you and we will refund you.

    Course Curriculum


      Slides
    Available in days
    days after you enroll
      The Course
    Available in days
    days after you enroll

    "Revision of patterns I knew before, and learning of new patterns. Learning new Java features in the exercises. Best practices, like using ConcurrentHashMap. Learned useful new IntelliJ shortcuts. Live coding sessions by Heinz."

    - Anonymous, Feedback from an in-house course presented in Graz, Austria

    Get started now!



    "Pattern advantages / disadvantages in contrast with later Java versions (lots of small objects are not so expensive now...) Exercises were fun. Example unit test gave good direction towards solutions. Liked the structure checking tests."

    - Anonymous, Feedback from an in-house course presented in Graz, Austria

    Your Instructor


    Dr Heinz M. Kabutz
    Dr Heinz M. Kabutz

    Heinz Kabutz is the author of The Java Specialists’ Newsletter, a publication enjoyed by tens of thousands of Java experts in over 145 countries. His book “Dynamic Proxies (in German)” was #1 Bestseller on Amazon.de in Fachbücher für Informatik for about five minutes until Amazon fixed their algorithm. Thanks to a supportive mother, he has now sold 5 copies.

    Heinz’s Java Specialists’ newsletter is filled with amusing anecdotes of life on the Island of Crete. He is a popular speaker at all the best Java conferences around the world, and also at some of the worst. He teaches Java courses in classrooms around the world, where his prime objective is to make absolutely sure that none of his students fall asleep. He is not always successful.


    Frequently Asked Questions


    How long do I have access to a fully paid course?
    How does lifetime access sound? After enrolling, you have unlimited access to this course for as long as you like - across any and all devices you own. Furthermore, if we move to another platform, we will offer you a free transfer of your account for all the courses that you have purchased.
    What is the difference between a subscription, paying in installments and an outright purchase?
    With a subscription, you never own the rights to the material. If your card is declined or you cancel your subscription, you lose access to the course. The money you have paid so far is lost. Paying in installments is a bit better. You pay for 5 or 10 months and then once you have completed your installments you have lifetime access to the course. The safest is an outright purchase, where you pay the entire course in one amount. There is no risk of losing access.
    Can I pay via PayPal?
    Yes, you can for outright purchases, but not for recurring payments such as paying by installments or subscriptions.
    Can I get an EU VAT Invoice?
    Absolutely. First off, be sure to enter the VAT number in the appropriate field during the payment process. Then contact us for an EU VAT Invoice. Please tell us the receipt number for which you need the invoice.
    May I share my login details with my colleagues?
    Unfortunately not. The terms of usage are for a single license. Teachable tracks your progress through the curriculum, so you won't know how much you have watched. We offer a 50% discount on 15 licenses or more by one company. Please contact us for bulk licensing.
    May we use the course for running in-house courses?
    You may, as long as each of the students in the class has a valid license for that course. For example, a lot of companies run lunch time Design Patterns study groups using our material. This is an effective way to learn. Please contact us for bulk licensing.
    What if I am unhappy with the course?
    We would never want you to be unhappy! If you are unsatisfied with your purchase, contact us in the first 30 days and we will give you a full refund and deregister you from the course.
    When does the course start and finish?
    The course starts now and never ends! It is a completely self-paced online course - you decide when you start and when you finish. We do recommend putting time aside and setting goals to complete the course.
    Can I watch the course offline during my commute?
    Teachable have an iOS app that lets you watch offline. Android is not supported unfortunately.

    Get started now!