<?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>DEV Community: beatriz gracia</title>
    <description>The latest articles on DEV Community by beatriz gracia (@whathebea).</description>
    <link>https://dev.to/whathebea</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%2F1008272%2Ffd5a4e82-9440-4213-aefe-5079a0c4cd94.jpeg</url>
      <title>DEV Community: beatriz gracia</title>
      <link>https://dev.to/whathebea</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/whathebea"/>
    <language>en</language>
    <item>
      <title>O que é e como funciona o Cloud Native</title>
      <dc:creator>beatriz gracia</dc:creator>
      <pubDate>Sat, 04 Mar 2023 23:16:27 +0000</pubDate>
      <link>https://dev.to/whathebea/cloud-native-3ef6</link>
      <guid>https://dev.to/whathebea/cloud-native-3ef6</guid>
      <description>&lt;p&gt;Cloud Native é uma abordagem que permite construir software escalável, resiliente e de alta disponibilidade. Essa abordagem faz uso de tecnologias e princípios de computação em nuvem como arquitetura de microsserviços, containerização e DevOps para permitir uma rápida entrega de novas features e serviços para o usuário final. No entanto, aplicações Cloud Native não são simplesmente sistemas antigos migrados para a nuvem (Cloud Based) e sim novas aplicações e sistemas que foram desenvolvidas para a nuvem, aproveitando todas as vantagens que as plataformas de serviços Cloud oferecem. &lt;/p&gt;

&lt;h2&gt;
  
  
  Fundamentos
&lt;/h2&gt;

&lt;p&gt;Muitas tecnologias são utilizadas no desenvolvimento de aplicações Cloud Native no entanto alguns conceitos são essenciais para o melhor entendimento da abordagem. Do ponto de vista computacional temos, principalmente, funções e containers. De uma perspectiva arquitetural, temos a arquitetura de microsserviços. A seguir abordarei esses temas de maneira resumida e por fim indicarei algumas fontes que podem ser úteis no processo de aprendizagem.&lt;/p&gt;

&lt;h3&gt;
  
  
  Containers
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Containers são tecnologias que permitem que você isole aplicações em tempo de execução. São como pacotes prontos com todos os arquivos necessários para a aplicação rodar.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Tradução livre de Red Hat: Understanding Linux Containers&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;No diagrama abaixo podemos observar um exemplo de arquitetura de containers utilizando a ferramenta Docker.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G17_r8IG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0csgodvmeos0dn443jsr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G17_r8IG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0csgodvmeos0dn443jsr.png" alt="Arquitetura de containers" width="258" height="327"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Adaptado de: &lt;a href="https://geekflare.com/docker-architecture/"&gt;GeekFlare&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Benefícios
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Produtividade: Criar imagens de aplicações e iniciar containers com elas é muito mais rápido do que criar máquinas virtuais para rodar as aplicações.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deploy independente: Utilizando containers (mais especificamente na arquitetura de microsserviços) você poderá fazer o deploy individual de certos serviços da sua aplicação o que melhora também a manutenibilidade das aplicações.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Escalabilidade e otimização: Devido a habilidades dos containers de iniciar e parar em questão de segundos eles se tornam muito escaláveis pois podem reagir a mudanças de carga e necessidade de um sistema. Esse benefício geralmente é aproveitado com plataformas de orquestração de containers como, por exemplo, Kubernetes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Portabilidade: A famosa frase "Mas na minha máquina funciona" já não é mais tão importante. Como containers possuem todas as dependências necessárias para rodar um software acaba se criando um cenário agnóstico e independente para o software.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Desvantagens
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Não é pra tudo: Nem todas as aplicações necessitam de containerização e algumas podem até ser prejudicadas por ela. Monolitos, por exemplo, não tem a necessidade de escalabilidade de imediato e portanto a containerização desses poderia significar um atraso na produção.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Baixa isolação: Os containers compartilham um Kernel único e portanto se esse ficar suscetível a vírus, todos os outros serão afetados. O contrário ocorre com virtual machines, elas possuem isolação e uma não é afetada por um vírus na outra, por exemplo.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Serverless Computing
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Serverless é um modelo de desenvolvimento de aplicações que permite que desenvolvedores criem e rodem aplicações sem precisar provisionar ou administrar servidores ou infraestrutura de backend.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Tradução livre de IBM: What is serverless?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;É importante notar que, apesar da tradução de serverless ser "sem servidores" não é, de fato, isso. O nome serve para representar a interação que o desenvolvedor tem com servidores: nenhuma.&lt;/p&gt;

&lt;p&gt;Atualmente, a maioria das plataformas de serviços em cloud oferecem soluções serverless:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;AWS (Amazon Web Services) – AWS Lambda&lt;/li&gt;
&lt;li&gt;Microsoft Azure – Azure Functions&lt;/li&gt;
&lt;li&gt;GCP (Google Cloud Platform) – Google Cloud Functions&lt;/li&gt;
&lt;li&gt;IBM Cloud – IBM Cloud Code Engine&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Esses são somente alguns exemplos de serviços serverless, os exemplos acima se encaixam em FaaS (Functions-as-a-service) no entanto existem outros serviços que também são serverless porém não FaaS como por exemplo Azure Container Instances (ACI) e Azure SF Mesh.&lt;/p&gt;

&lt;p&gt;Abaixo uma tabela para comparação de functions (funções) com containerized services (serviços containerizados).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;FaaS (Function-as-a-service)&lt;/th&gt;
&lt;th&gt;Serviços em Container&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Faz somente uma coisa&lt;/td&gt;
&lt;td&gt;Faz mais de uma coisa&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Não pode fazer deploy de dependências&lt;/td&gt;
&lt;td&gt;Pode fazer deploy de dependências&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Precisa responder a um único tipo evento&lt;/td&gt;
&lt;td&gt;Pode responder a mais de um tipo de evento&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Microsserviços
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;A arquitetura de microsserviços permite que uma grande aplicação seja dividida em partes menores e independentes, cada uma com sua responsabilidade. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Tradução livre de Google Cloud: What is Microservices Architecture?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--cp_4pTdt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6l3f44axgx00fz5o26d.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--cp_4pTdt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6l3f44axgx00fz5o26d.png" alt="Exemplo arquitetura microsserviços" width="567" height="197"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Adaptado de: Cloud native: Using containers, functions, and data to build next-generation applications&lt;/em&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  Características
&lt;/h4&gt;

&lt;p&gt;Abaixo estão disponíveis algumas características da Arquitetura de Microsserviços, todas as informações abaixo foram retiradas das minhas anotações pessoais de quando fiz o curso Microservices Architecture – The Complete Guide do instrutor Memi Lavi e traduzidas. O link para o curso está disponível nas referências desse artigo.&lt;/p&gt;

&lt;h5&gt;
  
  
  Componentização de serviços
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Design modular é sempre uma boa ideia pois você pode realizar mudanças específicas ao invés de mudar uma grande quantidade de código. &lt;/li&gt;
&lt;li&gt;Componentes são partes que em conjunto compõem o software.&lt;/li&gt;
&lt;li&gt;Modularidade pode ser atingida utilizando:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Bibliotecas: chamadas diretamente dentro do processo&lt;br&gt;
Serviços: chamados por mecanismos fora do processo (API Web, RPC)&lt;/p&gt;

&lt;h5&gt;
  
  
  Por que usar serviços?
&lt;/h5&gt;

&lt;ul&gt;
&lt;li&gt;Deploy independente, usar serviços ao invés de bibliotecas faz com que seja possível realizar o deploy de somente uma parte da aplicação. Se todo o processo é uma biblioteca nós teriamos que fazer o deploy da aplicação inteira novamente (o que seria mais próximo de um monolito do que de microsserviços).&lt;/li&gt;
&lt;li&gt;Interface bem definida pois o componente deve ser pensado e arquitetado para exatamente o que deve fazer.&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  Decentralização
&lt;/h5&gt;

&lt;p&gt;Em projetos tradicionais quase sempre há um padrão para tudo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Linguagem&lt;/li&gt;
&lt;li&gt;Bancos de Dados&lt;/li&gt;
&lt;li&gt;Criação de logs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Com arquitetura de microsserviços cada equipe pode fazer suas próprias decisões, baseando-se no que será melhor para aquele serviço específico.&lt;/p&gt;

&lt;h4&gt;
  
  
  Automatização de Infraestrutura
&lt;/h4&gt;

&lt;p&gt;Na arquitetura de Microsserviços a automatização é essencial.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ciclos curtos de desenvolvimento são necessários.&lt;/li&gt;
&lt;li&gt;Teste e deploy não devem ser feitos manualmente.&lt;/li&gt;
&lt;li&gt;Muitas ferramentas para automatização: Azure DevOps, GitHub Actions, Jenkins etc.
Design for Failure&lt;/li&gt;
&lt;li&gt;Muitos processos e muito tráfego em redes então muita coisa pode dar errado.&lt;/li&gt;
&lt;li&gt;O código deve sempre assumir a falha e lidar com ela de maneira elegante.&lt;/li&gt;
&lt;li&gt;Observabilidade com logs, tracing é essencial.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Arquitetura Cloud Native
&lt;/h2&gt;

&lt;p&gt;Abaixo um diagrama da arquitetura Cloud Native para referência.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--IYuKr-2P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1ombtnsrjr9qegi002i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--IYuKr-2P--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s1ombtnsrjr9qegi002i.png" alt="Diagrama arquitetura cloud native" width="287" height="375"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Adaptado de: &lt;a href="https://www.alibabacloud.com/blog/what-is-cloud-native-and-how-to-design-cloud-native-architecture_597249"&gt;Alibaba Cloud &lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Infraestrutura
&lt;/h3&gt;

&lt;p&gt;A camada de infraestrutura é um elemento crucial na computação em nuvem. Ela se refere à infraestrutura física fornecida pelos provedores de serviços em nuvem, que oferecem todo o hardware necessário para a implantação de uma aplicação. Embora o hardware possa não ser visível para o usuário final, ele é vendido como um serviço, conhecido como Infrastructure-as-a-service (IaaS). Essa camada de infraestrutura fornece aos usuários acesso a recursos computacionais escaláveis, como servidores, armazenamento e redes, sem que eles precisem investir em hardware físico e infraestrutura de data center. &lt;/p&gt;

&lt;h3&gt;
  
  
  Orquestração
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Orquestração de Containers automatiza o provisionamento, implantação, networking, escalabilidade, disponibilidade e gestão do ciclo de vida de containers.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Tradução livre de IBM: What is container orchestration?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Existem diversas plataformas de orquestração de containers como Kubernetes, Docker Swarm e Apache Mesos. Nesse momento, a abordagem será feita pensando especificamente em Kubernetes.&lt;/p&gt;

&lt;p&gt;Para compreender melhor o conceito de orquestração de containers é mais fácil pensar sobre o problema que essa tecnologia resolve: Uma empresa possui um software grande e complexo, cada serviço é um container e esse software deve ter alta disponibilidade, sempre que um container cair ou parar outro deve ser iniciado no lugar. Esse é o problema resolvido por Kubernetes, controlar esse comportamento.&lt;/p&gt;

&lt;p&gt;Algumas vantagens de utilizar Kubernetes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Balanceamento de carga&lt;/li&gt;
&lt;li&gt;Gerenciamento de configuração e secrets&lt;/li&gt;
&lt;li&gt;Autocorreção&lt;/li&gt;
&lt;li&gt;Manutenção de escalabilidade automática&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Middleware
&lt;/h3&gt;

&lt;p&gt;A camada (layer) de Middleware é uma camada intermediária entre as aplicações e a infraestrutura. Abaixo alguns exemplos que podem facilitar o entendimento:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Bancos de Dados (JDBC, Hibernate, ODBC)&lt;/li&gt;
&lt;li&gt;Cache (Redis, Memcached)&lt;/li&gt;
&lt;li&gt;Mensageria (Apache Kafka, RabbitMQ)&lt;/li&gt;
&lt;li&gt;Servidores de Aplicação (Apache TomCat, Jboss, Websphere)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Service Mesh
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Uma service mesh, como o projeto open source Istio, é uma forma de controlar como diferentes partes de uma aplicação partilham dados entre si. Ao contrário de outros sistemas de gestão desta comunicação, uma service mesh é uma camada de infraestrutura dedicada construída diretamente numa aplicação. Esta camada visível de infraestrutura pode documentar quão bem (ou não) diferentes partes de uma aplicação interagem, pelo que se torna mais fácil otimizar a comunicação e evitar downtime à medida que uma aplicação cresce.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;em&gt;Tradução livre de Red Hat: What's a service mesh?&lt;/em&gt;   &lt;/p&gt;

&lt;p&gt;Essa pode parecer uma explicação complexa a primeira vista porém é mais simples do que parece. Na arquitetura de microsserviços que, como já comentamos, é importante no desenvolvimento de aplicações cloud native, cada serviço vai exercer somente a sua função. No entanto, por vezes, é possível que um serviço esteja exercendo mais do que a sua função pré-definida e por isso pode se adicionar a camada de service mesh. Ela será responsável por adicionar observabilidade, controle de tráfego e segurança nas suas aplicações, funcionando como um sidecar.&lt;/p&gt;

&lt;h2&gt;
  
  
  Princípios Cloud Native
&lt;/h2&gt;

&lt;p&gt;Irei abordar 4 dos princípios essenciais de Cloud Native, no entanto é importante notar que existem muitos outros que podem sim ser levados em consideração visto que ainda é um tema em constante discussão e avanço e, portanto, suscetível a mudanças.&lt;/p&gt;

&lt;h3&gt;
  
  
  Automação
&lt;/h3&gt;

&lt;p&gt;A automação é cada vez mais essencial em sistemas modernos. Ela vem com o objetivo de reduzir o impacto de tarefas repetitivas em implantação, configuração e gerenciamento de aplicações. A automação ajuda a manter a consistência e a segurança do ambiente e permite que desenvolvedores foquem em outras áreas.&lt;/p&gt;

&lt;h3&gt;
  
  
  Escalabilidade
&lt;/h3&gt;

&lt;p&gt;Possivelmente uma das palavras mais utilizadas nos dias de hoje: escalabilidade. Ela permite que os sistemas se ajustem dinamicamente às demandas em tempo real, como aumento ou diminuição do tráfego em uma aplicação. Para atender a esse requisito, os containers e orquestradores de containers oferecem soluções eficientes para escalar as aplicações. No Kubernetes, por exemplo, é possível usar o Horizontal Pod Autoscaler (HPA) e o Vertical Pod Autoscaler (VPA) para escalar horizontal e verticalmente, respectivamente.&lt;/p&gt;

&lt;h3&gt;
  
  
  Resiliência
&lt;/h3&gt;

&lt;p&gt;A resiliência é particularmente importante visto que aplicações em cloud são distribuídas estão em ambientes dinâmicos e instáveis. Tendo isso em mente, é necessário que as aplicações sejam projetadas para lidar com falhas e se recuperar rapidamente. As aplicações devem ser capazes de lidar com interrupções de serviços, falha de infraestrutura e problemas de rede. Portanto, se fazem também necessárias soluções de observabilidade para que seja possível detectar qualquer problema rapidamente.&lt;/p&gt;

&lt;h3&gt;
  
  
  Segurança
&lt;/h3&gt;

&lt;p&gt;Segurança é um aspecto crucial de aplicações cloud native. É necessário garantir criptografia, controle de acesso e também monitorar atividades suspeitas. Os grandes provedores de cloud já oferecem soluções robustas para a segurança. Abaixo estão listadas algumas das soluções da Azure para referência:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Azure Security Center: Recomendações de segurança&lt;/li&gt;
&lt;li&gt;Azure Active Directory: Autenticação e gerenciamento de acesso&lt;/li&gt;
&lt;li&gt;Azure DDoS Protection: Proteção contra ataques de negação de serviços distribuídos&lt;/li&gt;
&lt;li&gt;Azure Firewall: Proteção das redes virtuais&lt;/li&gt;
&lt;li&gt;Azure Information Protection: Proteção de dados confidenciais&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusão
&lt;/h2&gt;

&lt;p&gt;Esse artigo tratou sobre ferramentas atreladas ao cloud native, arquitetura de microsserviços, computação em nuvem serverless e princípios e arquitetura de uma aplicação cloud native. Espero que tenha sido de alguma ajuda à alguém interessado no tema. Todas as referências estão listadas abaixo para consulta.&lt;/p&gt;

&lt;h2&gt;
  
  
  Referências
&lt;/h2&gt;

&lt;p&gt;Scholl, B., Swanson, T., Jausovec, P. (2019). Cloud native: Using containers, functions, and data to build next-generation applications. O'Reilly.&lt;br&gt;
Microsoft Azure. Disponível em: &lt;a href="https://azure.microsoft.com/en-us/"&gt;https://azure.microsoft.com/en-us/&lt;/a&gt;. Acesso em: 03 mar. 2023.&lt;br&gt;
Red Hat: Understanding Containers. Understanding Containers. Disponível em: &lt;a href="https://www.redhat.com/en/topics/containers"&gt;https://www.redhat.com/en/topics/containers&lt;/a&gt;. Acesso em: 03 mar. 2023.&lt;br&gt;
IBM Developer: The true benefits of moving to containers. Disponível em: &lt;a href="https://developer.ibm.com/articles/true-benefits-of-moving-to-containers-1/"&gt;https://developer.ibm.com/articles/true-benefits-of-moving-to-containers-1/&lt;/a&gt;. Acesso em: 03 mar. 2023.&lt;br&gt;
Red Hat: What is container orchestration? Disponível em: &lt;a href="https://www.redhat.com/en/topics/containers/what-is-container-orchestration"&gt;https://www.redhat.com/en/topics/containers/what-is-container-orchestration&lt;/a&gt;. Acesso em: 04 mar. 2023.&lt;br&gt;
Red Hat: What is a service mesh? 2023. Disponível em: &lt;a href="https://www.redhat.com/en/topics/microservices/what-is-a-service-mesh"&gt;https://www.redhat.com/en/topics/microservices/what-is-a-service-mesh&lt;/a&gt;. Acesso em: 04 mar. 2023.&lt;br&gt;
IBM: Cloud Native Principles. Disponível em: &lt;a href="https://www.ibm.com/cloud/architecture/architecture/practices/cloud-native-principles/"&gt;https://www.ibm.com/cloud/architecture/architecture/practices/cloud-native-principles/&lt;/a&gt;. Acesso em: 04 mar. 2023.&lt;br&gt;
Lavi, M. (2023). Microservices Architecture - The Complete Guide. Udemy&lt;br&gt;
Imagem de capa disponível em: &lt;a href="https://pixabay.com/illustrations/cloud-computing-technology-network-4246668/"&gt;https://pixabay.com/illustrations/cloud-computing-technology-network-4246668/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>azure</category>
      <category>architecture</category>
    </item>
    <item>
      <title>How to use Junit and Mockito for unit testing in Java</title>
      <dc:creator>beatriz gracia</dc:creator>
      <pubDate>Sat, 14 Jan 2023 18:33:29 +0000</pubDate>
      <link>https://dev.to/whathebea/how-to-use-junit-and-mockito-for-unit-testing-in-java-4pjb</link>
      <guid>https://dev.to/whathebea/how-to-use-junit-and-mockito-for-unit-testing-in-java-4pjb</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally posted on whathebea.github.io on 23/10/2022&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I know today is Sunday but I really felt like writing something. It seems like I can't stop thinking about coding and trying to perfect everything that I am learning. This may be personal but, does anyone else feel this way? Before my internship although I was very dedicated it seems that now I am much more focused. Also, I lost two Valorant matches in a row so I'm feeling a bit down. Maybe writing a post is a way of distracting myself from my losses... &lt;/p&gt;

&lt;p&gt;Ok, so today I decided to talk about testing. Answering the question "Why is testing so important?" which I asked myself and talking a little bit about tools and some more things.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is testing important?
&lt;/h2&gt;

&lt;p&gt;Imagine you wrote some code and then, later, someone changes something on it. If you have tests ready is very easy to know if the code still works as expected. If you don't have tests, you will have to test the code manually. This is very time consuming and it is very easy to miss something, also, it is expensive, especially if you are working on a big project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Junit
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;What is Junit?&lt;/em&gt; Junit is a unit testing framework for Java. It is used to test the smallest unit of code, which is a method.&lt;br&gt;&lt;br&gt;
Here is an example of a Junit test:&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;@Test&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;testAdd&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;calculator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&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;When you are testing you must use the &lt;code&gt;@Test&lt;/code&gt; annotation. The &lt;code&gt;assertEquals&lt;/code&gt; method is used to check if the result of the method is the same as the expected result. If the result is not the same as the expected result, the test will fail.&lt;br&gt;
Here is a test that will fail:&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;@Test&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;testAdd&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;calculator&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;add&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&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;It fails because 1+2 is not equal to 4.&lt;/p&gt;

&lt;h2&gt;
  
  
  Mockito
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;What is Mockito?&lt;/em&gt; Mockito is a mocking framework for Java. It is used to mock the dependencies of the class that you are testing.&lt;/p&gt;

&lt;p&gt;To use Mockito you have to use @Mock and @InjectMocks annotations. The @Mock annotation is used to create a mock object. The @InjectMocks annotation is used to inject the mock object into the class that you are testing. Here is a full example:&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;@ExtendWith&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MockitoExtension&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&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;UserServiceTest&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Mock&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;UserRepository&lt;/span&gt; &lt;span class="n"&gt;userRepository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@InjectMocks&lt;/span&gt;
    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="nc"&gt;UserService&lt;/span&gt; &lt;span class="n"&gt;userService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Test&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;testGetUserById&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setId&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setName&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Beatriz"&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;when&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;userRepository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;findById&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;)).&lt;/span&gt;&lt;span class="na"&gt;thenReturn&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Optional&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;));&lt;/span&gt;

        &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;userService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getUserById&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

        &lt;span class="n"&gt;assertEquals&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;result&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;In this example I am testing the &lt;strong&gt;getUserById&lt;/strong&gt; method of the &lt;strong&gt;UserService&lt;/strong&gt; class. I am mocking the &lt;strong&gt;UserRepository&lt;/strong&gt; class because the &lt;strong&gt;UserService&lt;/strong&gt; class depends on the &lt;strong&gt;UserRepository&lt;/strong&gt; class. I am using the &lt;strong&gt;when&lt;/strong&gt; method to mock the &lt;strong&gt;findById&lt;/strong&gt; method of the &lt;strong&gt;UserRepository&lt;/strong&gt; class. I am using the &lt;strong&gt;thenReturn&lt;/strong&gt; method to specify what the &lt;strong&gt;findById&lt;/strong&gt; method will return. In this case it will return an &lt;strong&gt;Optional&lt;/strong&gt; object that contains a &lt;strong&gt;User&lt;/strong&gt; object. I am using the &lt;strong&gt;assertEquals&lt;/strong&gt; method to check if the result of the &lt;strong&gt;getUserById&lt;/strong&gt; method is the same as the expected result, which is the &lt;strong&gt;User&lt;/strong&gt; object that I created manually.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test Coverage
&lt;/h2&gt;

&lt;p&gt;Test coverage is a measure of how many lines of code are executed during the tests. It is used to measure how much of the code is tested. There are different types of test coverage, but the most common one is the line coverage. It measures how many lines of code are executed during the tests.&lt;br&gt;
IBM has an article talking about how to see your Junit test coverage and you can read it &lt;a href="https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.lnx.80.doc/user/testcoverage.html" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  TDD (Test Driven Development)
&lt;/h2&gt;

&lt;p&gt;TDD means Test Driven Development and the name itself is pretty self-explanatory. It is a software development process that relies on the repetition of a very short development cycle: requirements are turned into very specific test cases, then the software is improved to pass the new tests, only. &lt;br&gt;
There are different types of TDD, but the most common one is the Red-Green-Refactor cycle. It is a cycle that consists of three steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Write a test&lt;/li&gt;
&lt;li&gt;Run the test&lt;/li&gt;
&lt;li&gt;Refactor the code&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So you pretty much write the test and then you write the code to make the test pass. Then you refactor the code to make it more readable and efficient. IBM has a lot of free content about TDD and you can read it &lt;a href="https://www.ibm.com/garage/method/practices/code/practice_test_driven_development/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;I hope my post was helpful! I feel like it really helps me to write about what I learn. I have to push myself a little bit to make code examples and write about it, but I think it is worth it. I hope you liked it and if you have any questions or suggestions, please let me know in the comments! Thanks for reading!&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://junit.org/junit5/docs/current/user-guide/" rel="noopener noreferrer"&gt;JUnit 5 User Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://javadoc.io/static/org.mockito/mockito-core/3.12.4/org/mockito/Mockito.html" rel="noopener noreferrer"&gt;Mockito Documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ibm.com/support/knowledgecenter/SSYKE2_8.0.0/com.ibm.java.lnx.80.doc/user/testcoverage.html" rel="noopener noreferrer"&gt;IBM - How to see your Junit test coverage&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.ibm.com/garage/method/practices/code/practice_test_driven_development/" rel="noopener noreferrer"&gt;IBM - Test Driven Development&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>react</category>
      <category>webdev</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Connecting an API (Java Spring) to an Android application</title>
      <dc:creator>beatriz gracia</dc:creator>
      <pubDate>Sat, 14 Jan 2023 18:31:51 +0000</pubDate>
      <link>https://dev.to/whathebea/connecting-an-api-java-spring-to-an-android-application-1ph4</link>
      <guid>https://dev.to/whathebea/connecting-an-api-java-spring-to-an-android-application-1ph4</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Originally posted on whathebea.github.io on 21/10/2022&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It has been a while since my last post but I swear I haven't given up! It's quite the opposite, actually. &lt;/p&gt;

&lt;p&gt;I had to do a project for my internship program which was basically creating a Rest API and connecting it to an Android Application. As it turns out, connecting an API to an app is more of a chore than I thought it would be. I hope I can stick with web development.&lt;/p&gt;

&lt;p&gt;I am not allowed to show all the code because it is stored in enterprise GitHub but I want to talk about everything I did and many some things that I struggled.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2FAndroid-3DDC84%3Fstyle%3Dfor-the-badge%26logo%3Dandroid%26logoColor%3Dwhite" alt="Android" width="106" height="28"&gt; Android
&lt;/h2&gt;

&lt;p&gt;First: These badges are way too cute for me NOT to use them.&lt;/p&gt;

&lt;p&gt;I created the app on Android Studio and to make the HTTP requests I used RetroFit.&lt;/p&gt;

&lt;h5&gt;
  
  
  Android App Structure
&lt;/h5&gt;

&lt;h4&gt;
  
  
  API and Service
&lt;/h4&gt;

&lt;p&gt;Before we move on to the activities I just want to take a look at the configuration for RetroFit.&lt;/p&gt;

&lt;h5&gt;
  
  
  API
&lt;/h5&gt;

&lt;p&gt;In order to make RetroFit work we have to create an interface with the paths and types of HTTP requests we want to make. Since mine was a pretty simple application there wasn't much to write here.&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="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;YourAPI&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@GET&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/api/yourapi"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;Call&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getAll&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="nd"&gt;@GET&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/api/yourapi/{id}"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
    &lt;span class="nc"&gt;Call&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getById&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nd"&gt;@Path&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"id"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="nc"&gt;Long&lt;/span&gt; &lt;span class="n"&gt;id&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 first get request is to retrieve a list of objects and the second one is to get a single one. You can read more about RetroFit &lt;a href="https://square.github.io/retrofit/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h5&gt;
  
  
  RetroFit Service
&lt;/h5&gt;

&lt;p&gt;The Service part is pretty much standard.&lt;br&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="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RetrofitService&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;Retrofit&lt;/span&gt; &lt;span class="n"&gt;retrofit&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;RetrofitService&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;initializeRetrofit&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;initializeRetrofit&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;Gson&lt;/span&gt; &lt;span class="n"&gt;gson&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;GsonBuilder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="n"&gt;retrofit&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Retrofit&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Builder&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;baseUrl&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"your_ip_address"&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;addConverterFactory&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;GsonConverterFactory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;gson&lt;/span&gt;&lt;span class="o"&gt;))&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Retrofit&lt;/span&gt; &lt;span class="nf"&gt;getRetrofit&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;retrofit&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;h4&gt;
  
  
  Activities
&lt;/h4&gt;

&lt;p&gt;Some of the activities that I created are the following (these are not the actual names but I was trying to be descriptive about what each one is)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Main Activity&lt;/li&gt;
&lt;li&gt;  Splash Activity&lt;/li&gt;
&lt;li&gt;  Get all Activity&lt;/li&gt;
&lt;li&gt;  Get by ID  Activity&lt;/li&gt;
&lt;/ul&gt;
&lt;h5&gt;
  
  
  Main Activity
&lt;/h5&gt;

&lt;p&gt;This activity was the first one that was created together with the app. It was an empty activity and I added a logo + 2 buttons.&lt;/p&gt;

&lt;p&gt;In Android Studio you can just click and drag components and you also have constraint layouts so, creating a simple screen is not that hard. After you create the screen with the components you have to access the Java Class and add your components so they can do something. Imagine you add a button and you give it the ID myButton, then you would retrieve it like this:&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="nc"&gt;Button&lt;/span&gt; &lt;span class="n"&gt;myButton&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;findViewById&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="no"&gt;R&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;myButton&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My buttons would redirect to another activity. To do that I had to take the button and use a onClickListener. Android Studio is quite useful because as long as you have an idea of what you are doing it does the job of creating most of the code structures for you.&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="n"&gt;myButton&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;setOnClickListener&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;View&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;OnClickListener&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="nd"&gt;@Override&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;onClick&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;View&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
               &lt;span class="nc"&gt;Intent&lt;/span&gt; &lt;span class="n"&gt;intent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Intent&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;MainActivity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;this&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;GetAllActivity&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
               &lt;span class="n"&gt;startActivity&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;intent&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;So there you have it, that's all you have to do to change from one activity to another. &lt;/p&gt;

&lt;h5&gt;
  
  
  Splash Activity
&lt;/h5&gt;

&lt;p&gt;The Splash Activity is simply a Splash that shows up when you open the app. I will be honest &lt;em&gt;MINE DIDN'T TURN OUT BEAUTIFUL&lt;/em&gt;. I can't talk much about Splash Screens because I actually had to search a little bit about them. I found this &lt;a href="https://medium.com/geekculture/implementing-the-perfect-splash-screen-in-android-295de045a8dc" rel="noopener noreferrer"&gt;medium article&lt;/a&gt; very thorough and helpful. I probably should work a little bit on my design skills…&lt;/p&gt;

&lt;h5&gt;
  
  
  Get All Activity
&lt;/h5&gt;

&lt;p&gt;This screen is basically a list with information that was received from the API and so I had to use RecyclerView on it.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What is RecyclerView?&lt;/em&gt; you make ask yourself (or me). According to the &lt;a href="https://developer.android.com/develop/ui/views/layout/recyclerview?gclid=EAIaIQobChMI8vOz5u3x-gIVDUJIAB3IZAYeEAAYASAAEgJnufD_BwE&amp;amp;gclsrc=aw.ds" rel="noopener noreferrer"&gt;Android Developer Docs&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;RecyclerView makes it easy to efficiently display large sets of data. You supply the data and define how each item looks, and the RecyclerView library dynamically creates the elements when they're needed.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And honestly, couldn't have said it better than that myself. In order to use RecyclerView I created an extra layout: the list_item.xml. What is that? Well, it is what ONE item would look like. Take a look at the &lt;a href="https://learn.microsoft.com/pt-br/xamarin/android/user-interface/layouts/recycler-view/" rel="noopener noreferrer"&gt;picture below&lt;/a&gt; for a second.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Flbftam3dd0pxlzn4b6jw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Flbftam3dd0pxlzn4b6jw.png" alt="RecyclerView" width="536" height="434"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you see that the structure for each e-mail is the same and what changes is the content on each one? Well, that is a RecyclerView!&lt;/p&gt;

&lt;p&gt;In this case the list_item.xml would have a name, a subject, the start of a message, how long ago it was sent and a start.&lt;/p&gt;

&lt;p&gt;In order to use a RecyclerView you need an Adapter, you can read more about adapters on &lt;a href="https://developer.android.com/reference/androidx/recyclerview/widget/RecyclerView.Adapter" rel="noopener noreferrer"&gt;Android Developer Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And how do we get the information now? Well, now it's finally RetroFit's time to shine!&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Create a method to load information&lt;/li&gt;
&lt;li&gt; Start retrofit service inside the method&lt;/li&gt;
&lt;li&gt; Using our API class with Retrofit&lt;/li&gt;
&lt;li&gt; Make the call&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;After you do all of that then you will have something like this:&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="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;loadInfo&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;RetrofitService&lt;/span&gt; &lt;span class="n"&gt;retrofitService&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;RetrofitService&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
        &lt;span class="nc"&gt;YourApi&lt;/span&gt; &lt;span class="n"&gt;yourApi&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;retrofitService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getRetrofit&lt;/span&gt;&lt;span class="o"&gt;().&lt;/span&gt;&lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;YourApi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="n"&gt;yourApi&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt;
                &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;enqueue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Callback&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                    &lt;span class="nd"&gt;@Override&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;onResponse&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Call&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Response&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;response&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                        &lt;span class="c1"&gt;// what will you do with the response?&lt;/span&gt;
                    &lt;span class="o"&gt;}&lt;/span&gt;

                    &lt;span class="nd"&gt;@Override&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;onFailure&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Call&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;call&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Throwable&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
                        &lt;span class="c1"&gt;// what will it do if it fails? e.g: a toast&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;h5&gt;
  
  
  Get by Id Activity
&lt;/h5&gt;

&lt;p&gt;I think you can guess that this activity is pretty similar to the last one except we don't have a RecyclerView. It's just layout with what would be equivalent to a single item from the list.&lt;/p&gt;

&lt;p&gt;The loadInfo method is almost exactly the same but one thing: I won't be calling or receiving a list.&lt;/p&gt;

&lt;h5&gt;
  
  
  Why did I struggle with RetroFit?
&lt;/h5&gt;

&lt;p&gt;Looking back now the answer would be: because I didn't pay enough attention to small things.&lt;/p&gt;

&lt;p&gt;Things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Typos&lt;/li&gt;
&lt;li&gt;  Mistaking the path for the requests&lt;/li&gt;
&lt;li&gt;  Remembering that when I make the get request by ID I don't get an array of objects as a response, I get a single object&lt;/li&gt;
&lt;li&gt;  Importing the wrong class&lt;/li&gt;
&lt;li&gt;  Trying to make things much more complicated than what they truly are.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fimg.shields.io%2Fbadge%2Fspring-%25236DB33F.svg%3Fstyle%3Dfor-the-badge%26logo%3Dspring%26logoColor%3Dwhite" alt="Spring" width="95" height="28"&gt; Spring
&lt;/h2&gt;

&lt;p&gt;Spring was a &lt;em&gt;MUCH&lt;/em&gt; easier ride than Android. Did I make mistakes? Nope! Where there things I could have done better? Most definitely yes. I made a checklist and I'll leave it here for you people to read it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  [x] Create Project Structure (Spring Initializr)&lt;/li&gt;
&lt;li&gt;  [x] Create Model&lt;/li&gt;
&lt;li&gt;  [x] Create Controller&lt;/li&gt;
&lt;li&gt;  [x] Service Layer Implementation&lt;/li&gt;
&lt;li&gt;  [x] Create Repository to deal with database operations&lt;/li&gt;
&lt;li&gt;  [x] Creating Dto and Dto converter&lt;/li&gt;
&lt;li&gt;  [x] Unit tests on Controller layer&lt;/li&gt;
&lt;li&gt;  [x] Unit tests on Service Layer&lt;/li&gt;
&lt;li&gt;  [x] Connect API to MySql database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;An api for big companies probably has much more than this but well, that's what I did.&lt;/p&gt;

&lt;h3&gt;
  
  
  Dependencies
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;  Spring Data JPA&lt;/li&gt;
&lt;li&gt;  Spring Web&lt;/li&gt;
&lt;li&gt;  Spring Boot Dev Tools&lt;/li&gt;
&lt;li&gt;  MySql Driver&lt;/li&gt;
&lt;li&gt;  SpringFox Boot Starter&lt;/li&gt;
&lt;li&gt;  SpringFox Swagger 2&lt;/li&gt;
&lt;li&gt;  SpringFox Swagger UI&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Overview
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Model
&lt;/h4&gt;

&lt;p&gt;Here is an example of something the model should look like.&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;@Entity&lt;/span&gt;
&lt;span class="nd"&gt;@Table&lt;/span&gt;&lt;span class="o"&gt;(&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;"YOURAPI"&lt;/span&gt;&lt;span class="o"&gt;)&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;MyEntity&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;@Id&lt;/span&gt;
    &lt;span class="nd"&gt;@GeneratedValue&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;strategy&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;GenerationType&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;IDENTITY&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;Long&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@Column&lt;/span&gt;&lt;span class="o"&gt;(&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;"name"&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;String&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// constructors&lt;/span&gt;
    &lt;span class="c1"&gt;// getters and 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 pretty self-explanatory:&lt;br&gt;&lt;br&gt;
The @Entity annotation specifies that the class is an entity and is mapped to a database table. The @Table annotation specifies the name of the database table to be used for mapping. &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt; specifies that it is the primary key and @GeneratedValue specifies how it should be generated. Then we have a single &lt;a class="mentioned-user" href="https://dev.to/column"&gt;@column&lt;/a&gt; which specifies the name of the column.&lt;/p&gt;

&lt;p&gt;After that, you just have your constructors and getters and setters. For my project I had a default constructor (empty) and two others, one with the id field and other without it. The getters and setters are also pretty standard, you can just generate them as you would. (Right Click &amp;gt; Source &amp;gt; Generate Getters and Setters)&lt;/p&gt;
&lt;h4&gt;
  
  
  Controller
&lt;/h4&gt;

&lt;p&gt;There isn't anything special about the controller just like there wasn't with the model.&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;@RestController&lt;/span&gt;
&lt;span class="nd"&gt;@RequestMapping&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/api/yourapi"&lt;/span&gt;&lt;span class="o"&gt;)&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;MyEntityController&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;MyService&lt;/span&gt; &lt;span class="n"&gt;myService&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nd"&gt;@GetMapping&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;ResponseEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;List&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;MyEntityDto&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;getAll&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ResponseEntity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&amp;gt;(&lt;/span&gt;&lt;span class="n"&gt;myService&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getAll&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="nc"&gt;HttpStatus&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;OK&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;I actually forgot to put the @RestController annotation the first time I wrote the code and guess what? It didn't work. Don't forget your annotations! &lt;/p&gt;

&lt;p&gt;@RequestMapping just maps the url path, you have @Autowired to do dependency injection of the service class and you have a pretty standard get request.&lt;/p&gt;

&lt;h4&gt;
  
  
  The DTO Pattern
&lt;/h4&gt;

&lt;p&gt;DTO means Data Transfer Object. Is it a must? I am not sure. I mean, if you are just studying and making an api that will possibly never see the sunrise, then yeah, I would guess it's not a must. But as far as I've read it is an Enterprise application architecture pattern which means it solves problems in large systems. It's probably very interesting to know how it works.&lt;/p&gt;

&lt;p&gt;The best explanation for the DTO pattern that I found is from &lt;a href="https://www.baeldung.com/java-dto-pattern" rel="noopener noreferrer"&gt;Baeldung&lt;/a&gt; and I definitely would recommend the read!&lt;/p&gt;

&lt;h2&gt;
  
  
  Happy Endings
&lt;/h2&gt;

&lt;p&gt;The happy ending is that I actually finished my project and can go back to studying Angular and keep finding more stuff to do. I came to the conclusion that I also must practice a little bit more of my designing skills because they are lacking quite a bit.&lt;/p&gt;

&lt;p&gt;Besides that, everything is great! I focused a lot on Android here because my main issues were there and finding the solutions was not as easy as one would expect.&lt;/p&gt;

&lt;p&gt;If you have any questions or want to know more about anything that I post here just contact me!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://twitter.com/whathebea" rel="noopener noreferrer"&gt;@whathebea&lt;/a&gt; on Twitter&lt;/p&gt;

&lt;p&gt;&lt;a href="https://br.linkedin.com/in/beatriz-gracia-dos-santos-2762bb21b" rel="noopener noreferrer"&gt;Beatriz Gracia&lt;/a&gt; on Linkedin&lt;/p&gt;

</description>
      <category>top7</category>
      <category>community</category>
      <category>gratitude</category>
    </item>
  </channel>
</rss>
