For the convenience of JavaRush students, we decided to collect lectures and articles about the most important topics in programming. The first selection is about design patterns. In the mini-guide, we briefly outline the essence of the articles, and if you follow the link, you can learn more about the topic of interest. Add the collection to your bookmarks and return to it when needed.
Lectures on the main design patterns
A singleton is one of the simplest design patterns that can be applied to a class. People sometimes say “this class is a singleton,” meaning that this class implements the singleton design pattern. Sometimes it is necessary to write a class for which only one object can be created. For example, a class responsible for logging or connecting to a database.
In this lecture we will introduce a pattern called "Adapter". “Its name is telling, and you’ve come across adapters in real life more than once. One of the most common adapters is card readers, which are equipped with many computers and laptops,” the author says about the pattern. As in previous lectures, a code example explains how the pattern works.
The article examines one of the most common patterns called “Strategy”. The Strategy pattern defines a family of algorithms, encapsulates each of them, and ensures that they are interchangeable. It allows you to modify algorithms regardless of their use on the client side.
Bridge solves this problem by dividing one or more classes into separate hierarchies - abstraction and implementation. A change in functionality in one hierarchy does not entail changes in another. The article lists the pros and cons of the pattern, where it is used, and explains in practice how it works.
The Proxy pattern helps solve problems associated with controlled access to an object. Using examples, the author examines in what situations knowledge of this pattern may be needed, its advantages and disadvantages. And a lot of useful code!
In this lecture, the author talks about the Factory: what problem is solved using this template, we will show an example of how the Factory helps open a coffee shop. This lecture also contains 5 simple steps to create a Factory.
You will learn what a factory method is and what problems this pattern is suitable for. We'll look at this design pattern in practice and explore its structure. The factory method design pattern solves the problem of creating different groups of products, each with some specificity.
You should read the lecture to find out what an abstract factory is and what problem this pattern solves. The lecture also shows an example of creating a framework for a cross-platform application for ordering coffee with a user interface. As a bonus, there is an Easter egg hidden in the lecture, thanks to which you will learn to determine the name of the operating system using Java and, depending on the result, perform one or another action.
A short article on design patterns in Java. It will be useful for those who are already in the subject for repetition and generalization. Or, on the contrary, for those who approached patterns for the first time - for the very first overview of the topic, before digging deeper.
In continuation of the previous article, the author shows how to use patterns.
Design Patterns in “Interview Questions and Answers”
When interviewing juniors, employers like to ask about patterns. This article will help you prepare for such questions. Among other things, it contains a lot of other useful information for a technical interview.
The entire text is devoted to the analysis of interview questions related to design patterns. What patterns are, what they are, why they are needed and where to use them - everything is in this article.
Lectures on antipatterns
It is quite possible that during the interview you may be asked about antipatterns - the evil twin brothers of patterns, so we decided to add them to this collection.
This article examines antipatterns in the management, architecture, and development domains.
The text examines such antipatterns as the golden hammer, premature optimization, spaghetti code, and magic numbers. In general, go read!
Bonus
This book is one of the top ten most popular on Stackoverflow, and for good reason. The ease of presentation, fundamental topic and high-quality examples make the book popular. Among people who are at least minimally familiar with the Head First series, there are many who consider such literature to be rather superficial reading for beginners. We recommend reading the review, or maybe the book, and drawing your own conclusions.
“Refactoring.Guru” is dedicated to the dark matters of programming: refactoring, design patterns, SOLID principles and other important topics from the world of programming. The site contains a catalog of patterns, describes the history of their appearance, benefits and disadvantages.
Other materials in the series: |
|
GO TO FULL VERSION