{"id":3220,"date":"2024-03-04T13:56:29","date_gmt":"2024-03-04T13:56:29","guid":{"rendered":"https:\/\/msgprogramator.sk\/?p=3220"},"modified":"2025-11-06T10:46:33","modified_gmt":"2025-11-06T10:46:33","slug":"java-design-patterns","status":"publish","type":"post","link":"https:\/\/msgprogramator.sk\/en\/java-design-patterns\/","title":{"rendered":"Java design patterns: definition and types"},"content":{"rendered":"<h2>Design patterns definition<\/h2>\n<p>A design pattern is generally a repeatable solution to a commonly occurring software design problem. A design pattern is not a finished design that can be taken and copied into your code. A pattern is not a specific piece of code, but a general concept or template for solving a specific problem that can be used in many different situations. Design patterns can speed up the development process by applying tested and proven development practices.   <\/p>\n<h2>Design patterns categories<\/h2>\n<p>Design patterns are categorized into three main types: creational, structural, and behavioural patterns.<\/p>\n<h2>Creational patterns<\/h2>\n<p>Patterns in this category deal with creating instances from classes.<\/p>\n<ul>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-singleton\/\">Singleton<\/a> &#8211; Ensures that the class has only one instance and provides that as an access point.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-builder\/\">Builder<\/a> &#8211; Allows the construction of a complex object to be broken down into a series of simple steps.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-prototype\/\">Prototype<\/a> &#8211; Creates an instance of a new object by cloning an existing one.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-factory\/\">Factory<\/a> &#8211; Provides an interface for creating objects of derived classes.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-abstract-factory\/\">Abstract factory<\/a> &#8211; Provides an interface for creating families of related objects without specifying their concrete classes.<\/li>\n<\/ul>\n<h2>Structural patterns<\/h2>\n<p>Patterns in this category deal with class structure such as inheritance and composition.<\/p>\n<ul>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-adapter\/\">Adapter<\/a> &#8211; Allows objects with incompatible interfaces to collaborate.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-bridge\/\">Bridge<\/a> &#8211; Separates an abstraction from its implementation so that both can vary independently.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-composite-design-pattern\/\">Composite<\/a> &#8211; Allows objects to be composed into tree structures and treated as individual objects.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-decorator\/\"> Decorator<\/a> &#8211; Dynamically adds or removes responsibilities from objects without affecting others of the same class.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-design-patterns-facade\/\">Facade<\/a> &#8211; Provides a simplified interface to a complex system.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-flyweight\/\">Flyweight <\/a> &#8211; Allows sharing parts of existing objects to reduce the number of created objects.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-proxy\/\">Proxy<\/a> &#8211; Acts as a surrogate to control access to the original object.<\/li>\n<\/ul>\n<h2>Behavioural patterns<\/h2>\n<p>Patterns in this category deal with communication between objects.<\/p>\n<ul>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-chain-of-responsibility\/\">Chain of responsibility<\/a> &#8211; Provides a way of passing a request between a chain of objects, where the currently addressed object has the ability to process it or send it on to the next object in the chain.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-command\/\">Command<\/a> &#8211; Implements the <strong>request<\/strong>&#8211;<strong>response<\/strong> model by wrapping a command and its metadata in an object.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-iterator\/\">Iterator<\/a> &#8211; Allows you to navigate through the items in a collection without revealing their base type.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-mediator\/\">Mediator<\/a> &#8211; Provides centralized communication between different objects in the system.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-memento\/\">Memento<\/a> &#8211; Allows you to save and subsequently restore the previous state of the object.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-observer\/\">Observer<\/a> &#8211; Provides a mechanism for notifying all interested objects when a change occurs to the observed object.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-state\/\">State<\/a> &#8211; Allows an object to alter its behaviour when its internal state changes.<\/li>\n<li><a href=\"https:\/\/msgprogramator.sk\/en\/java-strategy\/\">Strategy<\/a> &#8211; Defines a family of interchangeable algorithms, encapsulating each in a separate class.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>All Java design patterns (creational, structural, behavioural) summarized in one place. <\/p>\n","protected":false},"author":14,"featured_media":2848,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[57],"tags":[],"class_list":["post-3220","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java"],"acf":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/posts\/3220","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/comments?post=3220"}],"version-history":[{"count":5,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/posts\/3220\/revisions"}],"predecessor-version":[{"id":9393,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/posts\/3220\/revisions\/9393"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/media\/2848"}],"wp:attachment":[{"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/media?parent=3220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/categories?post=3220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/msgprogramator.sk\/en\/wp-json\/wp\/v2\/tags?post=3220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}