<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Pablo Cavalcante</title>
    <description>The latest articles on Forem by Pablo Cavalcante (@pablocavalcanteh).</description>
    <link>https://forem.com/pablocavalcanteh</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F915367%2F0e51ae05-397b-4fd3-9ec6-1a5e0c377cb5.jpeg</url>
      <title>Forem: Pablo Cavalcante</title>
      <link>https://forem.com/pablocavalcanteh</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/pablocavalcanteh"/>
    <language>en</language>
    <item>
      <title>Spring Framework  - Overview of main modules and annotations.</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Wed, 09 Apr 2025 22:31:50 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/spring-framework-overview-of-main-modules-and-annotations-4b12</link>
      <guid>https://forem.com/pablocavalcanteh/spring-framework-overview-of-main-modules-and-annotations-4b12</guid>
      <description>&lt;h2&gt;
  
  
  What is Spring Framework?
&lt;/h2&gt;

&lt;p&gt;The Spring Framework is one of the most popular and powerful frameworks in the Java ecosystem, widely used in the development of enterprise, web, and microservices applications. Originally created to facilitate the development of decoupled Java applications through dependency injection, the Spring Framework has evolved into a complete ecosystem with dozens of specialized modules.&lt;/p&gt;

&lt;p&gt;In this article, we will explore the main components of the Spring Framework, their functionalities, and the most used annotations for each module. However, before we delve deeper into this powerful tool, let's understand the Inversion of Control (or IoC) design principle on which Spring is based.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Inversion of Control?
&lt;/h2&gt;

&lt;p&gt;Inversion of Control (IoC) is the principle in which the creation and management of the lifecycle of dependencies is done by external code, often a container (Spring IoC Container in the case of Spring), instead of being done directly in the code that is using these dependencies. The main purpose of this principle is to minimize code coupling, increasing the maintainability, extensibility and testability of the code.&lt;/p&gt;

&lt;p&gt;Well, Inversion of Control is a principle, as said before, but how does Spring apply this principle? Spring applies this principle by implementing the Dependency Injection Design Pattern, which is one of the ways to apply this principle (Yes, there are other ways to do this).&lt;/p&gt;

&lt;h2&gt;
  
  
  Dependency Injection
&lt;/h2&gt;

&lt;p&gt;In simple terms, Dependency Injection is an implementation of the Inversion of Control principle that provides instances of dependencies that classes need without them having to create or manage their own life cycles. For us in the Java community with Spring, these are the famous beans.&lt;/p&gt;

&lt;p&gt;A bean is nothing more than a component instantiated, configured and managed by the Spring IoC Container. When a class is registered as a bean, Spring takes care of its life cycle, creation, dependency injection, destruction, etc. We can create beans through of the annotations that Spring makes available to us: &lt;code&gt;@Component&lt;/code&gt;, &lt;code&gt;@Service&lt;/code&gt;, &lt;code&gt;@Repository&lt;/code&gt;, &lt;code&gt;@Controller&lt;/code&gt; (or &lt;code&gt;@RestController&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Another way to create beans is, in a configuration class annotated with &lt;code&gt;@Configuration&lt;/code&gt;, to annotate with &lt;code&gt;@Bean&lt;/code&gt; in a method that returns the instance of a class that you want Spring to manage.&lt;/p&gt;

&lt;p&gt;We can apply dependency injection in one of the following ways:&lt;/p&gt;

&lt;h3&gt;
  
  
  Class attribute
&lt;/h3&gt;

&lt;p&gt;Using the &lt;code&gt;@Autowired&lt;/code&gt; annotation on a class attribute, we perform field injection. The &lt;code&gt;@Autowired&lt;/code&gt; annotation defines a point where dependency injection will be performed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Service&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Autowired&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Repository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// construtor, getters e setters&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's worth mentioning that Field Injection is not a way of applying dependency injection recommended by the Spring team. Learn more in this article: &lt;a href="https://www.baeldung.com/java-spring-field-injection-cons" rel="noopener noreferrer"&gt;Spring Field Injection Const&lt;/a&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  Class constructor
&lt;/h3&gt;

&lt;p&gt;In constructor injection, we simply declare the dependencies in the class constructor and then assign them to the attributes. This is how we usually instantiate a class in everyday life. The advantages of this injection method are increased code readability, ease of maintenance, and ease of building tests.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Service&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Repository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Service&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Repository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;repository&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="c1"&gt;// …&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is the way recommended by the Spring team.&lt;/p&gt;

&lt;h3&gt;
  
  
  Setter Method
&lt;/h3&gt;

&lt;p&gt;In setter injection, we create a default setter method and add the &lt;code&gt;@Autowired&lt;/code&gt; annotation. That's it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Service&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;Repository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Autowired&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setRepository&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Repository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;repository&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ok, now that we have seen what Inversion of Control is and how Spring implements this principle (using the Dependency Injection Design Pattern - DI) and how we can apply it, let's look at some of the main modules of this framework along with one of the most wonderful things about Spring and the focus of this article: annotations. Our lives are much easier with the annotations that Spring modules provide us. Really! Seriously!&lt;/p&gt;

&lt;p&gt;Note: Spring modules are not only made up of annotations, but also of classes, interfaces, etc. The focus of this article is on annotations. Therefore, if you want to know more about each module, I recommend looking at the official &lt;a href="https://docs.spring.io/spring-framework/reference/index.html" rel="noopener noreferrer"&gt;Spring documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Boot
&lt;/h2&gt;

&lt;p&gt;Spring Boot is an extension of the Spring Framework that abstracts, through convention over configuration, all the configuration overhead of web applications and microservices (“just run” philosophy), that is, we don’t need to worry much about configurations to make the application build and run. With Spring Boot:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We eliminate the need for extensive configuration (like giant XMLs).&lt;/li&gt;
&lt;li&gt;We achieve "quick start" of projects based on the Spring Framework.&lt;/li&gt;
&lt;li&gt;We have a built-in server, usually TomCat.&lt;/li&gt;
&lt;li&gt;We have intelligent autoconfiguration based on what is in the classpath.&lt;/li&gt;
&lt;li&gt;We generate standalone executables (.jar) so that we can run the application with a simple java -jar.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Spring Boot Starters
&lt;/h3&gt;

&lt;p&gt;Spring Boot starters are sets of pre-configured dependencies packaged together to solve specific use cases. Because they are pre-configured, they reduce the complexity of manually configuring the application. For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;dependency&amp;gt;&lt;/span&gt;
     &lt;span class="nt"&gt;&amp;lt;groupId&amp;gt;&lt;/span&gt;org.springframework.boot&lt;span class="nt"&gt;&amp;lt;/groupId&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;artifactId&amp;gt;&lt;/span&gt;spring-boot-starter-web&lt;span class="nt"&gt;&amp;lt;/artifactId&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This starter includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spring MVC.&lt;/li&gt;
&lt;li&gt;Jackson (for JSON).&lt;/li&gt;
&lt;li&gt;Embedded Tomcat.&lt;/li&gt;
&lt;li&gt;And other dependencies for building web APIs.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In other words, with a dependency declared in pom.xml, you already have everything you need to start building a REST API. Cool, right? That's awesome!&lt;/p&gt;

&lt;h3&gt;
  
  
  Main Spring Boot Starters
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Web&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spring-boot-starter-web&lt;/li&gt;
&lt;li&gt;spring-boot-starter-webflux&lt;/li&gt;
&lt;li&gt;spring-boot-starter-thymeleaf&lt;/li&gt;
&lt;li&gt;spring-boot-starter-mustache&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Persistence and Databases&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spring-boot-starter-data-jpa&lt;/li&gt;
&lt;li&gt;spring-boot-starter-jdbc&lt;/li&gt;
&lt;li&gt;spring-boot-starter-data-mongodb&lt;/li&gt;
&lt;li&gt;spring-boot-starter-data-redis&lt;/li&gt;
&lt;li&gt;spring-boot-starter-data-elasticsearch&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Security and Authentication&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spring-boot-starter-security&lt;/li&gt;
&lt;li&gt;spring-boot-starter-oauth2-client&lt;/li&gt;
&lt;li&gt;spring-boot-starter-oauth2-resource-server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Tests&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spring-boot-starter-test&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Others starters&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;spring-boot-starter-actuator&lt;/li&gt;
&lt;li&gt;spring-boot-starter-validation&lt;/li&gt;
&lt;li&gt;spring-boot-starter-mail&lt;/li&gt;
&lt;li&gt;spring-boot-starter-amqp&lt;/li&gt;
&lt;li&gt;spring-boot-starter-logging&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now that we've seen some of the main Spring Boot starters, how about we take a look at the amazing annotations for each module and what each annotation does? Let's go!&lt;/p&gt;

&lt;h2&gt;
  
  
  Annotations
&lt;/h2&gt;

&lt;p&gt;Before we continue to make the annotations in Java and the Spring ecosystem, we need to understand what they are. This annotation is a powerful resource for configuring and modifying the behavior of classes, methods, fields and parameters, often without the need to write additional code.&lt;/p&gt;

&lt;p&gt;The annotations are mainly supported by the Design Pattern Metadata, but their practical application is also associated with the use of two Proxy patterns, Reflection, Inversion Control (IoC) and Decorator, especially within Spring.&lt;/p&gt;

&lt;p&gt;The annotations have the following syntax: @. For example, in Spring we have to annotate &lt;code&gt;@Component&lt;/code&gt;, &lt;code&gt;@Autoriwed&lt;/code&gt;, &lt;code&gt;@Service&lt;/code&gt;, &lt;code&gt;@Repository&lt;/code&gt;, etc. The annotations always start with the @ character. They can also receive arguments, as in a method.&lt;/p&gt;

&lt;p&gt;In Java, we can create our own annotations with &lt;a class="mentioned-user" href="https://dev.to/interface"&gt;@interface&lt;/a&gt;. See an example:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Method annotation&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nd"&gt;@Retention&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;RetentionPolicy&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;RUNTIME&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nd"&gt;@Target&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;ElementType&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;METHOD&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nd"&gt;@interface&lt;/span&gt; &lt;span class="nc"&gt;MyCustomAnnotation&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;@Retention(RetentionPolicy.RUNTIME) - The annotation that we are creating is available during code execution.&lt;/li&gt;
&lt;li&gt;@Target(ElementType.METHOD) - restricts the use of annotation to only methods.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MyClass&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@MyCustomAnnotation&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt; &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above annotation was created to be used in class methods, but we can also use classes and attributes as well.&lt;/p&gt;

&lt;p&gt;The use of annotations have advantages and disadvantages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Advantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We do not need to repeat common configurations or behaviors.&lt;/li&gt;
&lt;li&gt;It allows us to add dynamic behaviors based on metadata.&lt;/li&gt;
&lt;li&gt;The code becomes more expressive.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;May impact application performance.&lt;/li&gt;
&lt;li&gt;When we use framework annotations, we couple our code to it.&lt;/li&gt;
&lt;li&gt;The logic of the hidden annotations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Well, now that we saw or what, for what purpose and how we can create the annotations in Java, how about we see the main annotations of each module of the Spring ecosystem? Let's go! (Now it's serious!)&lt;/p&gt;

&lt;p&gt;Just a small observation: it may be that you have placed an annotation that, in truth, belongs to another module, but don't worry, its functionality continues as described.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Boot Web/MVC
&lt;/h2&gt;

&lt;p&gt;Spring Web is used to build web applications, including RESTful, using Spring MVC. It is essential for creating web applications based on the Spring Framework.&lt;/p&gt;

&lt;p&gt;Furthermore, it is a module that helps create web applications in an easy, simple and elegant way, or that makes it possible to build robust and flexible web applications and, as the name suggests, is based on an MVC pattern.&lt;/p&gt;

&lt;p&gt;In Spring MVC, a controller is created using &lt;code&gt;@Controller&lt;/code&gt; or &lt;code&gt;@RestController&lt;/code&gt; annotations and for each method there is a mapping to the URL that the controller will be called.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@SpringBootApplication&lt;/code&gt; - combines &lt;code&gt;@Configuration&lt;/code&gt;, &lt;code&gt;@EnableAutoConfiguration&lt;/code&gt; and &lt;code&gt;@ComponentScan&lt;/code&gt;. In this way, we do not need to install a web server, just Spring Boot or an embedded Tomcat server.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableAutoConfiguration&lt;/code&gt; - active or automatic configuration resource based on classpath.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ComponentScan&lt;/code&gt; – used to scan packets for beans.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ConfigurationProperties&lt;/code&gt; - binds external properties (application.properties file) to POJO objects.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableConfigurationProperties&lt;/code&gt; - activate or use &lt;code&gt;@ConfigurationProperties&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ConditionalOnProperty&lt;/code&gt; - activating a bean/configuration if a property is present.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ConditionalOnClass&lt;/code&gt; - activates a certain class in the classpath.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ConditionalOnMissingBean&lt;/code&gt; - activate if the bean is not present.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SpringBootTest&lt;/code&gt; - used for integration tests with full context.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Configuration&lt;/code&gt; - define a class as a source of bean definitions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Bean&lt;/code&gt; - used in methods of annotated classes, generally, with &lt;code&gt;@Configuration&lt;/code&gt; indicating the Spring Container IoC that the instance returned by which method should be managed by it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Value&lt;/code&gt; - is used to insert values ​​into fields, methods or constructor parameters, usually from configuration files.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Autowired&lt;/code&gt; - defines dependency injection points within a class.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Scope&lt;/code&gt; - defines the lifetime of an object managed by the Spring Framework. We can combine with other annotations like &lt;code&gt;@Component&lt;/code&gt; or &lt;code&gt;@Bean&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Primary&lt;/code&gt; - it is used when we need to guide Spring on what class should be the injection pad when we have a context that we have two or more beans with the same type. It is very common to also use the &lt;code&gt;@Qualifier&lt;/code&gt; annotation also in context to indicate which instance to use instead of deixar or Spring to attach to the parent instance.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Profile&lt;/code&gt; - defines which profile a bean should be loaded for. Commonly, there are classes that only need to be carried out in a development, testing, homologation or production environment.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Component&lt;/code&gt; - indicates to Spring that the class instance will be created and managed by it.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Service&lt;/code&gt; - defines a class of service. There is a semantic extension of &lt;code&gt;@Component&lt;/code&gt; annotation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RestControllerAdvice&lt;/code&gt; - combination of &lt;code&gt;@ControllerAdvice&lt;/code&gt; and &lt;code&gt;@ResponseBody&lt;/code&gt; annotations. It indicates to Spring that it is an exceptionally specialized component and that the return two methods must be inserted in the body of the HTTP response and converted to JSON.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ControllerAdvice&lt;/code&gt; - Check with exceptions to a Spring MVC application. It is used for global error manipulation. Have full control over the response body and status code.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RestController&lt;/code&gt; - defines a class containing methods for a RESTful API. It's combines &lt;code&gt;@Controller&lt;/code&gt; and &lt;code&gt;@ResponseBody&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RequestMapping&lt;/code&gt; - map REST requirements for methods or classes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Controller&lt;/code&gt; - defines a class containing methods for the Spring MVC structure.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RequestBody&lt;/code&gt; – map the body of the HTTP request to an object.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PathVariable&lt;/code&gt; – map URL parts - parameters - as they vary.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RequestParam&lt;/code&gt; – map parameters (query strings) to the request for variables.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ExceptionHandler&lt;/code&gt; – defines methods that handle specific exceptions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ResponseStatus&lt;/code&gt; – with this annotation, we can specify the desired HTTP status of the response.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ModelAttribute&lt;/code&gt; - binds form data to objects.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@CrossOrigin&lt;/code&gt; - activates cross-domain communication for request manipulation methods.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SessionAttributes&lt;/code&gt; - declares the session attributes by listing the names of two model attributes that must be transparently stored in the session, serving as form support beans between subsequent requests.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@GetMapping&lt;/code&gt; - map HTTP GET requirements to methods or classes of a controller.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PostMapping&lt;/code&gt; - map HTTP POST requirements to methods or classes of a controller.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PutMapping&lt;/code&gt; - map HTTP PUT requirements to methods or classes of a controller.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@DeleteMapping&lt;/code&gt; - map HTTP DELETE requirements to methods or classes of a controller.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PatchMapping&lt;/code&gt; - map HTTP PATCH requirements to methods or classes of a controller.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Doc OpenAPI
&lt;/h2&gt;

&lt;p&gt;Spring Doc OpenAPI is a library that integrates Spring Boot with the OpenAPI 3 specification, allowing the automatic generation of documents of its REST API based on the annotations of two Spring drivers. It is a modern alternative to Springfox (Swagger 2) and provides full support for OpenAPI 3 with minimal configuration. With this, we can generate:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;OpenAPI specification in JSON/YAML at execution time (/v3/api-docs).&lt;/li&gt;
&lt;li&gt;A Swagger UI interface in real time (/swagger-ui.html or /swagger-ui/index.html).&lt;/li&gt;
&lt;li&gt;Support Grouped APIs, security, versioning and more.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@OpenAPIDefinition&lt;/code&gt; - defines the global API documentation (info, servers, tags, etc).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Info&lt;/code&gt; - API information (title, description, version, etc.).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Contact&lt;/code&gt; - contact information for the API.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@License&lt;/code&gt; - data from the license of the API.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Server&lt;/code&gt; - defines API servers (ex: base URL).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Servers&lt;/code&gt; - defines multiple servers.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ExternalDocumentation&lt;/code&gt; - defines a link for external documentation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Tag&lt;/code&gt; - defines reused tags.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Tags&lt;/code&gt; - allows multiple tags to be applied to a controller.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Operation&lt;/code&gt; - defines an API operation (GET, POST, etc).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ApiResponse&lt;/code&gt; - defines a possible response to the operation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ApiResponses&lt;/code&gt; - defines multiple responses for an operation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RequestBody&lt;/code&gt; - descreve o body da requisição.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Parameter&lt;/code&gt; - defines a parameter of rota, query, header or cookie.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Parameters&lt;/code&gt; - allows multiple parameters.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SecurityRequirement&lt;/code&gt; - assume that security schemes are applied to operations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SecurityScheme&lt;/code&gt; - defines a security scheme (ex: JWT, OAuth2, etc).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SecuritySchemes&lt;/code&gt; - allows you to declare multiple security schemes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Hidden&lt;/code&gt; - hides a class, method, parameter, etc. of the documentation.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Links&lt;/code&gt; - defines links between operations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Link&lt;/code&gt; - a link between responses and other operations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Callback&lt;/code&gt; - remove asynchronous callbacks (ex: webhooks).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Callbacks&lt;/code&gt; - define multiple callbacks.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Extension&lt;/code&gt; - allows adding custom properties to the OpenAPI.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Extensions&lt;/code&gt; - allows multiple extensions.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Data e Spring Data JPA
&lt;/h2&gt;

&lt;p&gt;Spring Data JPA is intended to facilitate the integration and use of JPA (Java Persistence API) in Java applications. It is one of the extensions of Spring Data. With him:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplify access to related data using JPA.&lt;/li&gt;
&lt;li&gt;Reduce boilerplate code (repetitive code).&lt;/li&gt;
&lt;li&gt;Provide a declarative interface to create data repositories.&lt;/li&gt;
&lt;li&gt;Help implement dynamic and customized queries in a simple way.&lt;/li&gt;
&lt;li&gt;Integrate with SQL databases through a layer of abstraction.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@Transactional&lt;/code&gt; – configures the transactional behavior of a method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@NoRepositoryBean&lt;/code&gt; – so that the Spring Framework does not create common repository interface beans for file repositories.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Repository&lt;/code&gt; – defines a repository bean (it is not part of Spring Data, but is associated with it).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Query&lt;/code&gt; – used to provide a JPQL implementation for a repository method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Param&lt;/code&gt; – defines named parameters that will be passed for queries.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Id&lt;/code&gt; – defines that the attribute is an identifier.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Transient&lt;/code&gt; – ​​marks a field of a model class as transient. Therefore, the dice arming mechanism is not the gravel or value of this field.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@GeneratedValue&lt;/code&gt; – defines that the management of the entity id will be managed by the persistence provider (JPA).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Entity&lt;/code&gt; - Mark a class as a JPA entity. Com isso, a classe tem seu state managed by context of underlying persistence.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Table&lt;/code&gt; – specifies the table of the annotated entity.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Column&lt;/code&gt; – specifies the mapping between a basic attribute and the column of the data bank table.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Lob&lt;/code&gt; – specifies which attribute currently annotated represents a type of large object.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@OneToOne&lt;/code&gt; – specifies a dice bank relationship one to one .&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ManyToOne&lt;/code&gt; – specifies a multiple dice bank relationship for um.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@OneToMany&lt;/code&gt; – specifies a dice bank relationship for many.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ManyToMany&lt;/code&gt; – specifies a data bank relationship many to many.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@JoinColumn&lt;/code&gt; – specifies the FOREIGN KEY column used to enter an association of entities or an incorporated collection.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@JoinTable&lt;/code&gt; – specifies a link table between two other data bank tables.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@MapsId&lt;/code&gt; – specifies that the identity identifier is mapped to the currently annotated &lt;code&gt;@ManyToOne&lt;/code&gt; or associated &lt;code&gt;@OneToOne&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ElementCollection&lt;/code&gt; – specifies a collection of basic or incorporated types.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Embeddable&lt;/code&gt; – specifies embedded types. As well as the basic types, the types are incorporated without their identity, being managed by their proprietary entity.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Embedded&lt;/code&gt; – specifies that a given entity attribute represents an embedded type.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Enumerated&lt;/code&gt; – specifies that an entity attribute represents an enumerated type.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@JoinColumns&lt;/code&gt; – used to group several &lt;code&gt;@JoinColumn&lt;/code&gt; annotations that are only used to map an association of entities or an incorporated collection using a composite identifier.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@NamedQuery&lt;/code&gt; – specifies a JPQL query that can be retrieved later by its name.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@OrderBy&lt;/code&gt; – specifies the attributes of the entity used to classify and search for the currently annotated collection.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PersistenceContext&lt;/code&gt; – specifies the EntityManager that needs to be grafted as a dependency.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Temporal&lt;/code&gt; – specifies the time type of the java.util.Date or java.util.Calendar entity attribute.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Access&lt;/code&gt; – specifies the access type of the associated entity class, associated superclass, or embedded entity class attribute.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Inheritance&lt;/code&gt; – specifies the inheritance strategy of a given hierarchy of entity classes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ForeignKey&lt;/code&gt; – specifies the foreign key associated with the &lt;code&gt;@JoinColumn&lt;/code&gt; mapping.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Mapkey&lt;/code&gt; – specifies the key of a java.util.Map association for which type of key is the primary key or attribute of the entity that represents the value of the map.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@NamedQueries&lt;/code&gt; – used to group various &lt;code&gt;@NamedQuery&lt;/code&gt; annotations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PersistenceUnit&lt;/code&gt; – specifies the EntityManagerFactory that needs to be grafted as a dependency.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PersistenceUnits&lt;/code&gt; – used to group various &lt;code&gt;@PersistenceUnit&lt;/code&gt; annotations.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PostLoad&lt;/code&gt; – specifies a call return method that is activated after an entity is loaded.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PostPersist&lt;/code&gt; – specifies a call return method that is activated after an entity is persisted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PostRemove&lt;/code&gt; – specifies a callback method that is activated after an entity is removed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PostUpdate&lt;/code&gt; – specifies a call return method that is activated after an entity is updated.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PrePersist&lt;/code&gt; – specifies a call return method that is activated before an entity is persisted.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PreRemove&lt;/code&gt; – specifies a call return method that is activated before an entity is removed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PreUpdate&lt;/code&gt; – specifies a call return method that is activated before an entity is updated.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Security
&lt;/h2&gt;

&lt;p&gt;Spring Security is the Spring module responsible for providing security to the application. It takes care of both authentication and authorization, as well as protecting against common errors.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableWebSecurity&lt;/code&gt; - enable security resources.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableAuthorizationServer&lt;/code&gt; - enables the AuthorizationServer.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableResourceServer&lt;/code&gt; – allows the application to behave like a Resource Server.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableGlobalMethodSecurity&lt;/code&gt; – activates global method security.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Secured&lt;/code&gt; – is used to specify a list of functions in a method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PreAuthorize&lt;/code&gt; – provides express-based access control.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PreFilter&lt;/code&gt; – filters a collection argument before executing the method, defining refined security rules using Spring EL. The filter is applied to a list that is being passed as an input parameter to the annotated method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@PosFilter&lt;/code&gt; – filters lists of objects based on the custom security rules that we define, ou seja, defines to filter the return list of a method applying that rule to all the elements of the list. If the value is authenticated, the item will be kept on the list, otherwise the item will be removed.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@AuthenticationPrincipal&lt;/code&gt; – indicates Spring to insert the user logged into the application.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Cache
&lt;/h2&gt;

&lt;p&gt;The Spring Cache is a Spring Framework module designed for data caching, in other words, it allows us to temporarily store results of expensive operations (such as database queries, calls to external APIs, or heavy calculations) to avoid unnecessary recomputations and improve application performance. This module:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We can improve performance by reducing the response time of methods that return the same given frequency.&lt;/li&gt;
&lt;li&gt;Reduce the load on external services or data repositories.&lt;/li&gt;
&lt;li&gt;Simplify caching implementation using declarative annotations instead of manual logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableCaching&lt;/code&gt; - enables or supports non-Spring caching. It must be placed in a configuration class.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Cacheable&lt;/code&gt; - indicates that the result of a method must be cached.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@CachePut&lt;/code&gt; - force the method to be executed and update the cache with the new result, regardless of whether there is anything in the cache.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@CacheEvit&lt;/code&gt; - remove cache entries (very useful for operations that alter the state of two dice.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Caching&lt;/code&gt; - groups multiple annotations.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Cloud
&lt;/h2&gt;

&lt;p&gt;The Spring Cloud is a Spring ecosystem project that provides tools to build distributed, resilient and scaled systems, especially intended for architectures based on microservices.&lt;/p&gt;

&lt;p&gt;It was designed to facilitate the development of applications that require addressing challenges such as service discovery, load balancing, centralized configuration, circuit breakers, API gateway, messaging, among others.&lt;/p&gt;

&lt;p&gt;O Spring Cloud solves several common technical challenges of distributed systems:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Discover and register services (with Spring Cloud Netflix Eureka).&lt;/li&gt;
&lt;li&gt;Load balancing (with Spring Cloud LoadBalancer or Ribbon).&lt;/li&gt;
&lt;li&gt;Centralized configuration (with Spring Cloud Config).&lt;/li&gt;
&lt;li&gt;Circuit Breaker / Fault tolerance (com Resilience4j ou Hystrix).&lt;/li&gt;
&lt;li&gt;Routing and Gateway (with Spring Cloud Gateway).&lt;/li&gt;
&lt;li&gt;Distributed messaging (with Spring Cloud Stream).&lt;/li&gt;
&lt;li&gt;Distributed monitoring and tracking (with Sleuth + Zipkin).&lt;/li&gt;
&lt;li&gt;Security in microservices (with OAuth2, via Spring Cloud Security).&lt;/li&gt;
&lt;li&gt;Event bus for configuration updates (with Spring Cloud Bus).&lt;/li&gt;
&lt;li&gt;etc&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is made up of several sub modules. Right now, you won't be able to set which module which annotation belongs to, but it's also not difficult to find which module it belongs to (name-I know you need to add the starter with pom.xml if you're using Apache Maven). To help nisso, follow the official &lt;a href="https://spring.io/projects/spring-cloud" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableConfigServer&lt;/code&gt; - active or centralized and remote configuration server.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RefreshScope&lt;/code&gt; - allows you to reload beans with new configurations without the need to reinitialize the application.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableEurekaServer&lt;/code&gt; - active or Eureka server.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableEurekaClient&lt;/code&gt; - register the service in Eureka.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableFeignClients&lt;/code&gt; - enables Feign clients.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@FeignClient&lt;/code&gt; - defines a declarative HTTP client.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableDiscoveryClient&lt;/code&gt; - allows the app to register and discover services.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RefreshScope&lt;/code&gt; - allows reloading properties like /actuator/refresh.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@LoadBalanced&lt;/code&gt; - insert a RestTemplate with load balancing inlay.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableCircuitBreaker&lt;/code&gt; - activate circuit breaker methods.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Headers&lt;/code&gt; - defines default headers for the Feign Client.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@CircuitBreaker&lt;/code&gt; - apply circuit breaker (Resilience4j library) to a method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RateLimiter&lt;/code&gt; - applies rate limiting.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Bulkhead&lt;/code&gt; - check consistency for critical methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And many, many other annotations…&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Validation
&lt;/h2&gt;

&lt;p&gt;The main objective of Spring Validation is to ensure that the input data is correct and consistent before being processed for the application. Isso avoids logic problems, unexpected exceptions, persistence of invalid data, among others.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@Valid&lt;/code&gt; - performs object validation. The class attributes need to be annotated with validation annotations, such as &lt;code&gt;@NotBlank&lt;/code&gt;, &lt;code&gt;@NotNull&lt;/code&gt;, &lt;code&gt;@NotEmpty&lt;/code&gt;, etc.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Validated&lt;/code&gt; - enables validation in Spring methods/classes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@NotNull&lt;/code&gt;, &lt;code&gt;@Size&lt;/code&gt;, &lt;code&gt;@Email&lt;/code&gt;, etc - bean validation annotations (javax.validation).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Pattern&lt;/code&gt; - validation with regex.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Positive&lt;/code&gt; and &lt;code&gt;@Negative&lt;/code&gt; - validation for positive or negative values.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And many, many other annotations…&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Scheduling
&lt;/h2&gt;

&lt;p&gt;Spring Scheduling is a Spring Framework module that allows you to schedule tasks for automatic execution on defined schedules or intervals. It is often used in applications that need to execute recurring processes, such as sending emails, generating reports, synchronizing data, etc.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableScheduling&lt;/code&gt; - activates the execution of scheduled tasks.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Scheduled&lt;/code&gt; - indicates that the method must be executed on a schedule. It can be used with various attributes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableAsync&lt;/code&gt; – when actions are required in the system in the background (another thread). This annotation must be placed in classes annotated with @Configuration, so that Spring enables and supports asynchronous execution.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Async&lt;/code&gt; – Enable or use the execution of asynchronous methods with &lt;code&gt;@EnableAsync&lt;/code&gt;, check any method of a managed bean. As such method is invoked, Spring will guarantee that its execution will be in another thread.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Batch
&lt;/h2&gt;

&lt;p&gt;Spring Batch is a Spring framework focused on batch processing. It provides tools and abstractions to process large volumes of data efficiently, safely and with robust monitoring. We use him to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Process large volumes of transactional data automatically and at scale.&lt;/li&gt;
&lt;li&gt;Execute scheduled tasks&lt;/li&gt;
&lt;li&gt;Guarantee reprocessing in case of failure (transactions with commit/rollback, retention).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableBatchProcessing&lt;/code&gt; - activate or support Spring Batch.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@BeforeStep&lt;/code&gt; and &lt;code&gt;@AfterStep&lt;/code&gt; - execute methods before/after a Step.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@BeforeJob&lt;/code&gt; and &lt;code&gt;@AfterJob&lt;/code&gt; - execute methods before/after a Job.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring AMQP (RabbitMQ)
&lt;/h2&gt;

&lt;p&gt;Spring AMQP is a Spring ecosystem module designed to facilitate asynchronous and decoupled communication between systems using AMQP (Advanced Message Queuing Protocol), with native support for RabbitMQ — the message broker most used with this protocol.&lt;/p&gt;

&lt;p&gt;Spring AMQP abstracts the complexity of communication with AMQP brokers, offering a more object-oriented and friendly Spring-style programming. It allows applications to produce and consume messages with RabbitMQ, naturally integrating with the functionalities already built in Spring, such as dependency injection, annotation configuration and event management.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableRabbit&lt;/code&gt; - enable detection of RabbitMQ listeners in Spring context.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@RabbitListener&lt;/code&gt; - listen to messages from a specific row.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring WebSocket
&lt;/h2&gt;

&lt;p&gt;Spring WebSocket provides support for real-time, two-way communication between client and server using the WebSocket protocol, as well as providing fallback for STOMP over WebSocket using SockJS when WebSocket is not available.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableWebSocket&lt;/code&gt; - activates WebSocket support.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@ServerEndpoint&lt;/code&gt; - defines a WebSocket endpoint.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@EnableWebSocketMessageBroker&lt;/code&gt; - enable or support WebSocket with STOMP.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@MessageMapping&lt;/code&gt; - map STOMP messages sent for that destination.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SendTo&lt;/code&gt; - defines where the response should be sent.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@SendToUser&lt;/code&gt; - send messages directly to a specific user.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Payload&lt;/code&gt; - mark or content of the message.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@DestinationVariable&lt;/code&gt; - extract variables from the STOMP URL.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Header&lt;/code&gt; - captures custom message headers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring Retry
&lt;/h2&gt;

&lt;p&gt;Spring Retry is a complementary module for the Spring ecosystem that provides an easy way to add automatic retries to operations that may be temporarily missing, such as API calls, data bank connections, or network operations. It adds resilience to the application.&lt;/p&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@EnableRetry&lt;/code&gt; - activate or support Spring Retry in the project.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Retryable&lt;/code&gt; - marks a method so that it is executed again in case of failure.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Recover&lt;/code&gt; - defines the method that will be called if all failed attempts are made.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Backoff&lt;/code&gt; - is used in conjunction with the &lt;code&gt;@Retryable&lt;/code&gt; annotation. This annotation defines a waiting strategy (delay) between attempts. When an exception occurs and the method is reexecuted, &lt;code&gt;@Backoff&lt;/code&gt; determines how long to wait before trying again — the so-called backoff interval.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Spring AOP
&lt;/h2&gt;

&lt;p&gt;Spring AOP (Aspect-Oriented Programming) is two modules of the Spring Framework that allows you to separate transversal logic (cross-cutting concerns) from the main business code. In other words, with AOP we can modularize behaviors that are only repeated in several parts of the application, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Logging.&lt;/li&gt;
&lt;li&gt;Authentication/authorization.&lt;/li&gt;
&lt;li&gt;Transactions.&lt;/li&gt;
&lt;li&gt;Handling of excesses.&lt;/li&gt;
&lt;li&gt;Metrics and monitoring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The main &lt;strong&gt;annotations&lt;/strong&gt; are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;@Aspect&lt;/code&gt; - declare a class as an Aspect (an advice container).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Before&lt;/code&gt; - execute the advice before the next method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@After&lt;/code&gt; - execute the advice after the next method (independent of the event).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@AfterReturning&lt;/code&gt; - executes the advice after or returns after a method.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@AfterThrowing&lt;/code&gt; - execute the advice case or method throw exception.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Around&lt;/code&gt; - wraps the method completely (full control gives execution).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;@Pointcut&lt;/code&gt; - define a reused expression to identify intercepted methods.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Conclusion&lt;/p&gt;

&lt;p&gt;Whew!! Gee! It was a lot of work and effort that I made to leave everything summarized and complete, but you knew that Spring and its modules are the most that I can address in this article. Much more... It is worth it to continue your search in perfecting your knowledge about it. I hope to contribute to building your knowledge and please feel free to contact me on LinkedIn, if desired.&lt;/p&gt;

&lt;p&gt;My linkedin: &lt;a href="https://www.linkedin.com/in/pablo-cavalcante/" rel="noopener noreferrer"&gt;https://www.linkedin.com/in/pablo-cavalcante/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Good studies! See you later!&lt;/p&gt;

</description>
      <category>spring</category>
      <category>springboot</category>
      <category>annotations</category>
      <category>java</category>
    </item>
    <item>
      <title>Singleton Design Pattern in TypeScript with Decorator</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Sun, 25 Jun 2023 19:14:42 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/singleton-design-pattern-in-typescript-with-decorator-4bpp</link>
      <guid>https://forem.com/pablocavalcanteh/singleton-design-pattern-in-typescript-with-decorator-4bpp</guid>
      <description>&lt;p&gt;In this article &lt;a href="https://dev.to/pablocavalcanteh/strategy-design-pattern-in-java-with-enum-nc7"&gt;Strategy Design Pattern in Java with Enum&lt;/a&gt; I have said that Design Patterns could be implemented in different ways. Well, today I’m going to introduce a way to implement the Singleton Design Pattern, a simple Design Pattern, but very useful in the programming’s world.&lt;/p&gt;

&lt;p&gt;First of all, what is this Design Pattern for? So, Singleton Design Pattern is meant to ensure that a class has only an instance and to provide an access global point for that same instance. That 's it.&lt;/p&gt;

&lt;p&gt;Here is the Design Patterns’ generic structure.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tgo12avpqhdm6jyo1al.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1tgo12avpqhdm6jyo1al.png" alt="Singleton Class Diagram"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Participants&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Singleton class&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;defines an Instance operation that allows the clients access to its unique instance.&lt;/li&gt;
&lt;li&gt;Instance is a class operation.
may be responsible for creating your own single instance.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;It's worth mentioning that Decorator is a design pattern too, but it isn't the focus of this article. However, it’ss understood that in TypeScript a Decorator is a special kind of declaration that can be attached to a class declaration, method, accessor, property, or parameter. Decorators use the form @expression (This’ how Singleton will be applied), where expression must evaluate to a function that will be called at runtime with information about the decorated declaration.&lt;/p&gt;

&lt;p&gt;The following images show two different ways to implement this pattern using Decorators.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7bglf5dtdzxaep3exg8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ff7bglf5dtdzxaep3exg8.png" alt="Singleton Design Pattern in TypeScript with Decorator"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, the TypeScript Generics feature has been used - common in other languages that support Object Orientation such as Java. It's worth knowing this resource, because it's very useful.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zkjzb3fu86rehl1yyr0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9zkjzb3fu86rehl1yyr0.png" alt="Singleton Design Pattern in TypeScript with Decorator"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As I said in other articles, there are so many other Design Patterns and I think we must know about them. Well, that's it. See you guys! 👋👨‍💻&lt;/p&gt;

</description>
      <category>singleton</category>
      <category>typescript</category>
      <category>designpattern</category>
      <category>programming</category>
    </item>
    <item>
      <title>Difference between Readonly and Const in TypeScript</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Thu, 08 Jun 2023 21:10:49 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/difference-between-readonly-and-const-in-typescript-420o</link>
      <guid>https://forem.com/pablocavalcanteh/difference-between-readonly-and-const-in-typescript-420o</guid>
      <description>&lt;p&gt;If you work with TypeScript or have already worked, it's likely that at some point you have asked yourself which would be the difference between Readonly or Const. Well, this article will answer that question. Let's go!&lt;/p&gt;

&lt;p&gt;In TypeScript, const and readonly are used to indicate that a value shouldn’t be changed, but they are applied in different ways.&lt;/p&gt;

&lt;p&gt;The const keyword is used to declare a constant that has an immutable value. This means that once a value is assigned to a constant using const, it can't be changed later, and that value must be assigned at the time of constant declaration.&lt;/p&gt;

&lt;p&gt;In the example below, PI is declared as a constant and assigned the value 3.14. Any further attempts to assign a new value to PI will result in a compilation error&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WV-CmcRv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z57fhjhcf9czmvh0ui59.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WV-CmcRv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z57fhjhcf9czmvh0ui59.png" alt="Code example" width="800" height="268"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the other hand, the readonly keyword is used to declare properties on a class or object that can only be read but not changed outside the scope in which they are defined. In other words, the property can still have its value changed as long as this change occurs within the scope of the class or object. See an example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qjpn0UTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4krthp9t1c7bqi1pbf06.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qjpn0UTo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4krthp9t1c7bqi1pbf06.png" alt="Class Person in TypeScript" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the example above, the arn property of the Person class is declared as readonly with a value already assigned. However, in the constructor of the class, this property could still be changed. Now, if there is an attempt to change this value outside the scope of the Person class, TypeScript will raise an error.&lt;/p&gt;

&lt;p&gt;In short, const is used to declare constants at declaration time with immutable values, while readonly is used to declare properties of objects or classes that can only be read outside the scope where they were declared.&lt;/p&gt;

&lt;p&gt;Well, that's it! See you guys! 👋👨‍💻&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>programming</category>
    </item>
    <item>
      <title>Binary Search Tree in Python</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Sun, 04 Jun 2023 04:13:39 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/binary-search-tree-n0n</link>
      <guid>https://forem.com/pablocavalcanteh/binary-search-tree-n0n</guid>
      <description>&lt;p&gt;A data structure is an efficient way to store and organize data with associated operations in order to take advantage as long as possible it. There are several data structures and, among them, this article will address one in particular: the binary search tree.&lt;/p&gt;

&lt;p&gt;First of all, a tree is an abstraction used to stand for non-linear hierarchical structures. There are several types of trees such as: binary tree, AVL tree, red-black tree, B-tree, and so on.&lt;/p&gt;

&lt;p&gt;A binary tree is a special type of tree in which each node can have zero, one, or at most two subtrees: the left and right subtrees. If the one doesn’t have any subtrees, it’s a leaf node.&lt;/p&gt;

&lt;p&gt;Binary trees are very useful for modeling situations in which at each point in the process, it’s needs to take a decision between two directions.&lt;/p&gt;

&lt;p&gt;There are three types of binary trees: strictly binary, full and complete; and they tell apart from each other by node’s the number of subtrees and by the node’s position in the tree.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Strictly binary:&lt;/strong&gt; it’s the one in which the node always has or none (in the case of a leaf node) or two subtrees, that is, there is no internal node with only one child, all always have two.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Nearly complete:&lt;/strong&gt; A nearly complete binary tree is a tree in which the height difference between the subtrees of any node is at most 1. In other words, each leaf node in the tree must be at either D or D-1.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete:&lt;/strong&gt; it's a strictly binary tree in which all its leaf nodes are at the same level. In this type of tree, it’s possible to calculate the number of nodes per level, as well as the tree’s node total number.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementation Types
&lt;/h2&gt;

&lt;p&gt;Generally, in the implementation a binary tree, there are two commonly used approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Using an array (static allocation).&lt;/li&gt;
&lt;li&gt;Using a linked list (dynamic allocation).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Which implementation to choose depends exclusively on the application and there is no one that is better than other one in all cases. Now, regardless of the type of implementation used, the following basic operations are possible:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tree creation.&lt;/li&gt;
&lt;li&gt;Insertion of an element.&lt;/li&gt;
&lt;li&gt;Removal of an element.&lt;/li&gt;
&lt;li&gt;Search for an element.&lt;/li&gt;
&lt;li&gt;Tree destruction.&lt;/li&gt;
&lt;li&gt;Obtaining information about the tree.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Introduced a little what trees are, now let’s go to the tree that is the title of this article. A binary search tree is a binary tree, therefore, it’s the same properties as a binary tree with the addition that each node has a value (key) associated with it in such a way that the value determines its position in the tree, that is, nodes is the left subtree have a numerical value lower than the root node (or parent node) and all nodes in the right subtree have a numerical value greater than the root node.&lt;/p&gt;

&lt;p&gt;Node insertion and removal operations in the binary search tree must be performed respecting this node placement rule. It’s a great alternative to using arrays for binary search operations and has a dynamic structure.&lt;/p&gt;

&lt;p&gt;The following are the costs associated with the main operations on a binary search tree containing N nodes. The worst case takes place when the tree isn’t balanced, that is, its height isn’t the minimum possible.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Insertion:&lt;/strong&gt; in the average case, O(log N) and in the worst case O(N).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Removal:&lt;/strong&gt; in the average case, O(log N) and in the worst case O(N).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Search:&lt;/strong&gt; in the average case, O(log N) and in the worst case O(N).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The following is a Python implementation of a binary search tree and its associated operations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="nn"&gt;typing&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Union&lt;/span&gt;


&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;show&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BinarySearchTree&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[]&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

        &lt;span class="n"&gt;node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;
            &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;

                &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                        &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
                        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                        &lt;span class="k"&gt;return&lt;/span&gt;
                &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                    &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
                    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                        &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
                        &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                        &lt;span class="k"&gt;return&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Union&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;

    &lt;span class="c1"&gt;# Root, lelf and right
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pre_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pre_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pre_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Left, root, right
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;in_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;in_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;in_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="c1"&gt;# Left, right, root
&lt;/span&gt;    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;pos_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;Union&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;bool&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'The tree is empty...'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;

        &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;
        &lt;span class="n"&gt;parent_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;
        &lt;span class="n"&gt;_left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;parent_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;value&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;_left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;
                &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;_left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;
                &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;False&lt;/span&gt;

        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="ow"&gt;and&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;

            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;

            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
        &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

            &lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;get_next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;     
                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;

            &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;_left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;

            &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

                &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
                &lt;span class="n"&gt;parent_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;

            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;
            &lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;links&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;append&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;'-&amp;gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nb"&gt;str&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;value&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;

            &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current_node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="bp"&gt;True&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_next&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="bp"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Node&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;next_parent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
        &lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;
        &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
        &lt;span class="k"&gt;while&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="bp"&gt;None&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;next_parent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;
            &lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;
            &lt;span class="n"&gt;current&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;current&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt; &lt;span class="o"&gt;!=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;next_parent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;left&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
            &lt;span class="nb"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;node&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;right&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nb"&gt;next&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"__main__"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;

    &lt;span class="n"&gt;tree&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;BinarySearchTree&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;53&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;14&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;39&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;9&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;34&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;49&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;72&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;61&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;84&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;79&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pre_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'----------------'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;in_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'----------------'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;pos_order&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;root&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'----------------'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;tree&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;search&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;79&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Found value!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;else&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;'Not found value!'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are many other data structures out there, worth looking into and learning more. The data structure presented here is just some of them. Well, that 's it! See you guys. 👋👨‍💻&lt;/p&gt;

</description>
      <category>binarysearchtree</category>
      <category>datastructure</category>
      <category>python</category>
      <category>programming</category>
    </item>
    <item>
      <title>JavaScript Techniques</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Tue, 23 May 2023 20:08:45 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/javascript-techniques-2eg2</link>
      <guid>https://forem.com/pablocavalcanteh/javascript-techniques-2eg2</guid>
      <description>&lt;p&gt;Programming techniques are concepts that are applied in software programming. Generally,  are good practices that help not only to perform the code but also make it more readable, in addition to other benefits. Next, will be exemplified by some more common techniques in software development.&lt;/p&gt;

&lt;h2&gt;
  
  
  Currying
&lt;/h2&gt;

&lt;p&gt;Created by Moses Schonfinkel and Gottlob Frege and independently by Haskell Curry, it’s a technique that consists of transforming a function that takes many parameters into a chain of function calls that take only one parameter. That’s basically it. In a way, it reminds a little of Fluent Interface (a technique created by Martin Fowler and Eric Evans for building classes that favor obtaining less expensive and more readable code).&lt;/p&gt;

&lt;p&gt;Here’s a simple example of applying this technique.&lt;/p&gt;

&lt;p&gt;Without the application of the technique.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qs219w2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83vlss0x2glc5j9qq1p8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qs219w2o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/83vlss0x2glc5j9qq1p8.png" alt="Without Currying" width="800" height="528"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the application of the technique.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--48idh1_m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0f355i8zfefu3unqy5to.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--48idh1_m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0f355i8zfefu3unqy5to.png" alt="With Currying" width="800" height="526"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Guard Clauses
&lt;/h2&gt;

&lt;p&gt;Also known as Early Return or Bouncer Pattern, it consists of an early boolean evaluation of preconditions in order to verify whether the execution of the program continues in that execution flow. It doesn't go much beyond a series of if conditionals, however, in the case of this technique, it’s done in a flatter way, the code source cleaner and more readable.&lt;/p&gt;

&lt;p&gt;Here’s an example of code without the use of Guard Clauses and later refactored using this technique.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5p1144Al--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tso4dg5qrxrm9xne7f43.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5p1144Al--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tso4dg5qrxrm9xne7f43.png" alt="Without Guard Clauses" width="800" height="815"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With Guard Clauses applied.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dBUa2ar4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p3fndenq9br5q2ivdktx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dBUa2ar4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p3fndenq9br5q2ivdktx.png" alt="With Guard Clauses" width="800" height="961"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Object Literal
&lt;/h2&gt;

&lt;p&gt;That’s a technique that aims to replace the switch condition structure, making the code more readable, also avoiding some problems with the use of this type of programming instruction. It’s nothing more than an object with its properties and their respective values.&lt;/p&gt;

&lt;p&gt;Here’s an example of code without the use of Guard Clauses and later refactored using this technique.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QiDT5dmC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf2vlstsjyhd0cg0zaqn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QiDT5dmC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nf2vlstsjyhd0cg0zaqn.png" alt="Without Object Literal" width="800" height="952"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With the technique.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WiQ8j5XV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q613tx57w2nssjiq756j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WiQ8j5XV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q613tx57w2nssjiq756j.png" alt="With Object Literal" width="800" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Closure
&lt;/h2&gt;

&lt;p&gt;It’s a function that can reference variables outside its scope, but variables around the lexical context that surrounds it. It’s declared inside another function and you can extend the scope of variables beyond the local scope, but not to the global scope, in other words, the inner function will have access to the variables of its immediately outer function.&lt;/p&gt;

&lt;p&gt;See image below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--H_c5yQKf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/89bhbc9815zuly044m5s.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--H_c5yQKf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/89bhbc9815zuly044m5s.png" alt="Closure" width="800" height="725"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are many other techniques out there, worth looking into and learning more. Those presented in this article are just some of them. Well, that 's it! See you guys. 👋👨‍💻&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>javascripttechniques</category>
      <category>programming</category>
    </item>
    <item>
      <title>Builder Design Pattern in Python with Fluent Interface</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Tue, 09 May 2023 14:48:37 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/builder-design-pattern-in-python-with-fluent-interface-29of</link>
      <guid>https://forem.com/pablocavalcanteh/builder-design-pattern-in-python-with-fluent-interface-29of</guid>
      <description>&lt;p&gt;In the article &lt;a href="https://dev.to/pablocavalcanteh/strategy-design-pattern-in-java-with-enum-nc7"&gt;Strategy Design Pattern in Java with Enum&lt;/a&gt;, it was introduced what Design Patterns are and also discussed one of them with an implementation in Java with Enum. Now, in this article, a very useful design pattern implemented with Fluent API or Fluent Interface will be covered.&lt;/p&gt;

&lt;h2&gt;
  
  
  Builder
&lt;/h2&gt;

&lt;p&gt;Builder is a design pattern from the creation category whose intention is to separate the construction of a complex object from its representation so that the same construction process can create different representations of the object. This pattern is applicable when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;algorithm for creating a complex object must be independent of the parts that make up the object and how they are assembled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;construction process must allow for different representations for the object that is constructed.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Generic structure
&lt;/h2&gt;

&lt;p&gt;That's Strategy’s generic structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdcacwzg67hrav2huq42l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdcacwzg67hrav2huq42l.png" alt="Strategy’s generic structure"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s talk about each of the components (or participants):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Builder&lt;/strong&gt;: specifies an abstract interface for creating parts of a product object.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ConcreteBuilder&lt;/strong&gt;: builds and assembles parts of the product by implementing the Builder interface. It also defines and keeps up the representation it creates and provides an interface for product retrieval.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Director&lt;/strong&gt;: constructs an object using the Builder interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Product&lt;/strong&gt;: represents the complex object under construction.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Builder with Fluent Interface
&lt;/h2&gt;

&lt;p&gt;As mentioned in the article &lt;a href="https://dev.to/pablocavalcanteh/strategy-design-pattern-in-java-with-enum-nc7"&gt;Strategy Design Pattern in Java with Enum&lt;/a&gt;, one of the characteristics of design patterns is customization. There are some ways  which it is possible to implement the Builder, and one of them and maybe the coolest is with Fluent Interface or Fluent API. &lt;/p&gt;

&lt;p&gt;This time, the Python programming language will be used. An important detail is that a Director class won’t be created, in other words, the pattern will be applied without this component.&lt;/p&gt;

&lt;p&gt;The figure below is the abstract Builder class. To make it abstract and therefore non-instantiable, &lt;strong&gt;metaclass=ABCMeta&lt;/strong&gt; is used. The &lt;strong&gt;&lt;a class="mentioned-user" href="https://dev.to/abstractmethod"&gt;@abstractmethod&lt;/a&gt;&lt;/strong&gt; annotation is complementary to the ABCMeta class and defines that the method is abstract. From the Builder class, it is noticeable that to build a sandwich, we can compose it in many ways. For example, you can make a sandwich with just bread, lettuce and tomato. Or we can do it with all the components that the Builder class allows us to add.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F416bam8hlkes3x6xedzs.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F416bam8hlkes3x6xedzs.png" alt="Builder class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is our Product class, that is, the complex object that will be built.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuv3uquh1zm85hhrhb40.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxuv3uquh1zm85hhrhb40.png" alt="Product class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And this is ConcreteBuilder. Several Builders could be created for different ways of composing the sandwich, but here we opted for only one class in order to explain the Fluent Interface later.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf6vhvh55o02618yzy8z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmf6vhvh55o02618yzy8z.png" alt="ConcreteBuilder"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, here is the execution of the design pattern with Fluent Interface. Notice that using the same builder, it was possible to create two different sandwiches.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyacndhyir6rx9lxqrm6e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyacndhyir6rx9lxqrm6e.png" alt="Execution"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Uuuhmm, made me hungry! Well, that's it! See you guys! 👋👨‍💻&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>python</category>
      <category>builderdesignpattern</category>
      <category>programming</category>
    </item>
    <item>
      <title>Strategy Design Pattern in Java with Enum</title>
      <dc:creator>Pablo Cavalcante</dc:creator>
      <pubDate>Sun, 07 May 2023 21:24:08 +0000</pubDate>
      <link>https://forem.com/pablocavalcanteh/strategy-design-pattern-in-java-with-enum-nc7</link>
      <guid>https://forem.com/pablocavalcanteh/strategy-design-pattern-in-java-with-enum-nc7</guid>
      <description>&lt;p&gt;If you are interested in this article it’s very likely you have already heard about design patterns, but if you haven’t heard or never had contact and just fell off here by parachute, let’s go to a timid introduction about what it’s.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design Patterns
&lt;/h2&gt;

&lt;p&gt;Design Patterns are reusable and customizable solutions to recurring problems in software development. Overall, a design pattern is made up of four elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pattern name:&lt;/strong&gt; the reference used to describe a design problem, its solutions and its consequences;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;  the context in which design pattern is applicable;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Solution:&lt;/strong&gt; the elementary composition of the design pattern, its relationships, its responsibilities etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Consequences:&lt;/strong&gt; the advantages and disadvantages of applying the design pattern.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Nowadays, there are 23 design patterns distributed categorically in: creation pattern; structural pattern and behavioral pattern. The pattern in question in this article is the Strategy, it belongs to the category of behavioral patterns.&lt;/p&gt;

&lt;h2&gt;
  
  
  Strategy
&lt;/h2&gt;

&lt;p&gt;Strategy is a behavioral design pattern whose intention is to define a family of algorithms, encapsulate each one of them and make them interchangeable, in other words, Strategy allows the algorithm to vary regardless of the clients use it.&lt;/p&gt;

&lt;p&gt;There are many scenarios where applying this design pattern is very useful. For example, in a backing application there may be several means by which we can transfer money from one account to another: PIX, TED, DOC, TEF.&lt;/p&gt;

&lt;p&gt;However, the intention is always the same: to transfer the money; and what changes is just how it will be done. In the context of software programming, what changes is the used algorithm.&lt;/p&gt;

&lt;h3&gt;
  
  
  Generic structure
&lt;/h3&gt;

&lt;p&gt;That is Strategy’s generic structure:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--pXGlKyIf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wivplemde08f8qa6ouap.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--pXGlKyIf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wivplemde08f8qa6ouap.png" alt="Strategy’s generic structure" width="537" height="469"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Let’s talk about each of the components (or participants):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Strategy:&lt;/strong&gt; defines the generic interface for all supported algorithms. The Context (client’s role) uses that interface to invoke the defined algorithm by a ConcreteStrategy.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;ConcreteStrategy:&lt;/strong&gt; it’s the algorithm itself that is implemented using the Strategy interface.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Context:&lt;/strong&gt; referentially keeps up a Strategy instance.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Strategy with Enum
&lt;/h3&gt;

&lt;p&gt;Previously, it has been said that one of the characteristics of design patterns besides reuse is customization. Well, implementing Strategy with Enum is one of the custom ways to implement this Design Pattern (and my favorite). To exemplify, I will use the Java programming language.&lt;/p&gt;

&lt;p&gt;That’s Enum Strategy groups the execution strategies (algorithms) and also already defines the common interface that the strategies must implement.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--GtTQjAZs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3fgo02kj1ujwinw0jg7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--GtTQjAZs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d3fgo02kj1ujwinw0jg7.png" alt="Enum Strategy groups the execution strategies" width="800" height="882"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here comes an intermediate and encapsulating class which the client can instantiate it already passing which strategy he wants to use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---WJGcBsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/co9gegopgucw64e1b8fh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---WJGcBsb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/co9gegopgucw64e1b8fh.png" alt="Intermediate and encapsulating class" width="800" height="536"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally, we have the client (or context) which keeps up one indirect reference to the chosen strategy using the UseStrategy class. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3BlPhORO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0b8vt1ugfdvcvj0yosct.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3BlPhORO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0b8vt1ugfdvcvj0yosct.png" alt="Client" width="800" height="380"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Furthermore, it’s worth remembering that design patterns can be creatively implemented in different ways and are very useful for common problems in software development. In other words, it’s worth getting to know each one of them. Well, that 's it! See you guys. 👋👨‍💻&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>programming</category>
      <category>java</category>
      <category>strategydesignpattern</category>
    </item>
  </channel>
</rss>
