For the convenience of CodeGym students, we decided to collect lectures and articles on 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 a collection to your bookmarks and return to it when you need to.
Lectures on the main design patterns
A singleton is one of the simplest design patterns that can be applied to a class. It is sometimes said "this class is a singleton", implying that this class implements the singleton design pattern. Sometimes it is necessary to write a class that can only have one object. For example, a class responsible for logging or connecting to a database.
In this lecture, we will get acquainted with a pattern called "Adapter". "It has a name that speaks, and you have met with 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 the previous lectures, the code example explains how the pattern works.
The article considers one of the most common patterns called "Strategy". The Strategy pattern defines a family of algorithms, encapsulates each of them, and makes them interchangeable. It allows you to modify the algorithms regardless of their use on the client side.
Bridge solves this problem by separating 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 applied, and in practice analyze how it works.
The Proxy pattern helps solve the problems associated with controlled access to an object. Using examples, the author analyzes 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 to open a coffee shop. And in this lecture there are 5 simple steps to create a Factory.
You will learn what a factory method is and what tasks this pattern is suitable for. We will look at this design pattern in practice and study its structure. The factory method design pattern solves the problem of creating different groups of products, each of which has some specifics.
The lecture should be read 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 how 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 to those who are already in the subject for repetition and generalization. Or vice versa, 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 are patterns, what they are, why they are needed and where to apply - everything is in this article.
Lectures on antipatterns
It may well be that at the interview you may be asked about anti-patterns - the evil twin brothers of patterns, so we decided to add them to this collection.
This article deals with anti-patterns in the field of management, architecture, and development problems.
The text analyzes such anti-patterns as the golden hammer, premature optimization, spaghetti code, magic numbers. In general, go read!
Bonus
This book is one of the top 10 most popular books on Stackoverflow, and for good reason. Ease of presentation, fundamental theme and quality examples make the book in demand. 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 matter for beginners. We recommend reading the review, and maybe the book, and draw your own conclusions.
“Refactoring.Guru” is dedicated to the dark matters of programming: refactoring, design patterns, SOLID principles and other important topics from the programming world. The site contains a catalog of patterns, describes the history of their appearance, benefits and disadvantages.
GO TO FULL VERSION