<?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: Bianca Camargo Machado</title>
    <description>The latest articles on DEV Community by Bianca Camargo Machado (@bianca_camargo_m).</description>
    <link>https://dev.to/bianca_camargo_m</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%2F2313430%2F70b4aafa-4667-45b4-86c7-6de5187b3f10.png</url>
      <title>DEV Community: Bianca Camargo Machado</title>
      <link>https://dev.to/bianca_camargo_m</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/bianca_camargo_m"/>
    <language>en</language>
    <item>
      <title>Componentization</title>
      <dc:creator>Bianca Camargo Machado</dc:creator>
      <pubDate>Thu, 14 Nov 2024 17:05:11 +0000</pubDate>
      <link>https://dev.to/bianca_camargo_m/componentization-16dh</link>
      <guid>https://dev.to/bianca_camargo_m/componentization-16dh</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Component is certainly a word you've heard in software development. It's a concept that can be used at different times and contexts.&lt;br&gt;
Here we will focus on the component used to develop user interfaces (UI).&lt;/p&gt;

&lt;h2&gt;
  
  
  What are components?
&lt;/h2&gt;

&lt;p&gt;The general concept of a component is: smaller parts of a whole.&lt;br&gt;
Component concept in UI: parts of a layout or screen that can be reused.&lt;br&gt;
Components ideally follow an important principle of software engineering: single responsibility. Each component should exist for a reason, and the clearer and more unique this reason is in the context of the application developed, the better.&lt;/p&gt;

&lt;p&gt;It's also important to note that the componentization process (creating and defining components) can be very personal. We follow good practices and common concepts, but in reality, different developers mapping components of the same application can give different results, and all of them are correct.&lt;/p&gt;

&lt;p&gt;This will depend on each developer's experience. But don't worry, there are concepts that everyone uses (or the vast majority) that can help you in the componentization process, and, together with practice, this will help you create your identity as a developer.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is the expected result?
&lt;/h2&gt;

&lt;p&gt;The first step is to look at the expected result.&lt;br&gt;
In this step, you should look at the layout you want to achieve and start thinking about the structure of components (smaller parts) that you are going to create to make up your UI.&lt;br&gt;
Let's start by looking at a simple layout example, a pet description page:&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%2F4bpkdlnwcyk5pexuc42t.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%2F4bpkdlnwcyk5pexuc42t.png" alt="UI image showing a photo of a cat with rounded edges and then a card with the cat's information: name, type, breed and allergies" width="430" height="786"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine that this page is part of a system for vets and that your client wants to be able to view a pet's data in summary form, after clicking on one of the pets in a table.&lt;/p&gt;

&lt;p&gt;Imagine that the application already exists and that you are only responsible for implementing this new functionality.&lt;br&gt;
Now look at the elements on this screen that have a blue border:&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%2Fjz2dts6ekoiclnrn4pei.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%2Fjz2dts6ekoiclnrn4pei.png" alt="Same image as the cat profile, but now highlighting in blue the component with the cat photo and the card component" width="430" height="786"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These are the main components that together make up this screen. Now that we've identified the main components, we can think about their names and responsibilities:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsibilities:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;(1)&lt;/strong&gt; Pet photo: the only responsibility is to show the photo with the expected style (rounded edges, in the defined size (width and height)).&lt;br&gt;
&lt;strong&gt;(2)&lt;/strong&gt; Pet data card: the responsibility is to have the correct style with the selected animal's data.&lt;/p&gt;

&lt;p&gt;The names of the components must be able to express their responsibility. In this case, I suggest the following &lt;strong&gt;names&lt;/strong&gt;:&lt;br&gt;
&lt;strong&gt;(1)&lt;/strong&gt; &lt;em&gt;ProfilePicture&lt;/em&gt; (or &lt;em&gt;FotoPerfil&lt;/em&gt; in Portuguese)&lt;br&gt;
&lt;strong&gt;(2)&lt;/strong&gt; &lt;em&gt;ProfileCard&lt;/em&gt; (or &lt;em&gt;CartaoPerfil&lt;/em&gt; in Portuguese)&lt;/p&gt;

&lt;p&gt;In the case of &lt;em&gt;ProfileCard&lt;/em&gt;, it could also be just “Card”, but realize that this is a more generic name and would be correct if I intended to use this card in different places, not just in the profile.&lt;br&gt;
There could also be a generic “Card” component whose responsibility would be to render any information in card format and which could also make it possible to define some custom styles, such as border rounding and background color.&lt;/p&gt;

&lt;p&gt;This decision would involve the following question, considering the context of the project:&lt;/p&gt;

&lt;p&gt;Are there other places in the application where I use a card?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If so, I create a card that can receive any content and reuse this card to create the &lt;em&gt;ProfileCard&lt;/em&gt; (more specific to the pet's profile) which would only receive the information needed for the pet's profile and would be responsible for presenting it in the correct order.&lt;/li&gt;
&lt;li&gt;If not, I could create only the &lt;em&gt;ProfileCard&lt;/em&gt;, considering that if in the future I need a card similar to this one, but with a different data structure, I could create this generic Card and modify the &lt;em&gt;ProfileCard&lt;/em&gt; to use this same Card.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Does this cover everything we need to show? Not yet. We also need a way of displaying the content. Notice that inside the &lt;em&gt;ProfileCard&lt;/em&gt; we also have more parts (more components):&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%2Fvgjwm11v0m0nh47iauyb.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%2Fvgjwm11v0m0nh47iauyb.png" alt="Same image as the cat profile, but now highlighting in blue the component that has the cat's photo, the card component and the components used inside the card to show the name, type, breed and allergies." width="430" height="786"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Note that I have listed all of them with the number 3, i.e. they are all instances of the same component reused for different contents, because, for this component, I see the following &lt;strong&gt;responsibility&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3)&lt;/strong&gt; Profile data. This component shows a pet's profile data in the expected style: it always has a title and content and can be center or left-aligned.&lt;/p&gt;

&lt;p&gt;And about the &lt;strong&gt;name&lt;/strong&gt; of the component:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3)&lt;/strong&gt; It would receive the name &lt;em&gt;ProfileInfo&lt;/em&gt; (or &lt;em&gt;InfoPerfil&lt;/em&gt; in Portuguese).&lt;/p&gt;

&lt;p&gt;Notice that we have created a semantic for the components that make up the pet's profile: they all start with “Profile”. This makes it easier to identify which components are related and belong to the same context.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where does this concept apply?
&lt;/h2&gt;

&lt;p&gt;This concept applies to any tool that allows you to use componentization to create interfaces, for example: ReactJS, VueJs, Angular, and others.&lt;/p&gt;

&lt;h2&gt;
  
  
  Share
&lt;/h2&gt;

&lt;p&gt;Would you do anything differently? Leave your suggestion here in the comments.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exercises
&lt;/h2&gt;

&lt;p&gt;In addition to understanding what the concept of components is, tips, and good practices, it is of the utmost importance that you practice so that you become more and more fluent in applying this concept.&lt;/p&gt;

&lt;p&gt;So &lt;a href="https://drive.google.com/file/d/1zf-mLHpfDkFubDCIgW3QrtxfSIZ4Ps0p/view?usp=sharing" rel="noopener noreferrer"&gt;here are some layouts for you to practice the concept of componentization&lt;/a&gt;. Download the file and edit it by defining the name and responsibility of the components.&lt;/p&gt;

&lt;p&gt;Note that the number of fields for component names and responsibilities is arbitrary and can be more or less than the numbers defined.&lt;/p&gt;

&lt;p&gt;In a future post, I'll provide my answer to these layouts.&lt;/p&gt;

&lt;p&gt;Feel free to share your results in the comments!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.starcoders.info/" rel="noopener noreferrer"&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%2Ff0gghyn8303nchhljuq2.png" alt="starcoders logo" width="500" height="81"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webcomponents</category>
      <category>ui</category>
      <category>react</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Componentização</title>
      <dc:creator>Bianca Camargo Machado</dc:creator>
      <pubDate>Mon, 11 Nov 2024 00:09:27 +0000</pubDate>
      <link>https://dev.to/bianca_camargo_m/componentizacao-270j</link>
      <guid>https://dev.to/bianca_camargo_m/componentizacao-270j</guid>
      <description>&lt;h2&gt;
  
  
  Contexto
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Componente&lt;/strong&gt; é certamente uma palavra que você já ouviu no mundo de programação de software. É um conceito que pode ser utilizado em diferentes momentos e contextos da área.&lt;br&gt;
Aqui focaremos no componente que é utilizado para desenvolvimento de interfaces de usuário (&lt;strong&gt;UI&lt;/strong&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  O que são componentes?
&lt;/h2&gt;

&lt;p&gt;O conceito geral de componente é: partes menores de um todo. &lt;br&gt;
Conceito de componente em UI: partes de um layout ou tela que podem ser reutilizados.&lt;br&gt;
Os componentes idealmente seguem um princípio importante da engenharia de software que é a responsabilidade única, ou seja, cada componente deve existir por um motivo e quanto mais claro e único este motivo é, no contexto da aplicação desenvolvida, melhor.&lt;/p&gt;

&lt;p&gt;Também é importante ressaltar que o processo de componentização (criar e definir componentes) pode ser muito pessoal. Seguimos boas práticas e conceitos em comum, mas, na verdade, diferentes desenvolvedores mapeando os componentes de uma mesma aplicação podem chegar em resultados diferentes e ambos estarem corretos.&lt;br&gt;
Isso vai depender da experiência e da forma de trabalhar de cada desenvolvedor. Mas não se preocupe, existem conceitos que todos utilizam (ou a grande maioria) e que podem te ajudar no processo de componentização e, junto com a prática, isto vai te ajudar  a criar sua identidade como desenvolvedor.&lt;/p&gt;

&lt;h2&gt;
  
  
  Qual o resultado esperado?
&lt;/h2&gt;

&lt;p&gt;O primeiro passo é observar o resultado esperado.&lt;br&gt;
Neste passo você deve observar o layout que deseja atingir e começar a pensar na estrutura de componentes (partes menores) que você vai criar para compor a sua UI.&lt;br&gt;
Vamos começar observando um exemplo simples de layout, uma página de descrição de um pet:&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%2F3jsmwt9segtnx4964dwb.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%2F3jsmwt9segtnx4964dwb.png" alt="Imagem de UI que mostra a foto de um gato com bordas arredondadas e em seguida um card com as informações do gato: nome, tipo, raça e alergias" width="800" height="1462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine que esta página faz parte de um sistema para veterinários e que o seu cliente quer poder visualizar os dados de um pet de forma resumida, após clicar em um dos pets de uma tabela.&lt;/p&gt;

&lt;p&gt;Imagine que a aplicação já existe e que você é responsável por implementar apenas esta nova funcionalidade.&lt;br&gt;
Agora, observe os elementos desta tela que estão com uma borda azul:&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%2Fg1zardv5ft1a6b0htua0.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%2Fg1zardv5ft1a6b0htua0.png" alt="Mesma imagem do perfil de gato, mas agora destacando na cor azul o componente que tem a foto do gato e o componente card" width="800" height="1462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Estes são os principais componentes que juntos formam esta tela. Agora que identificamos os principais componentes, podemos pensar no nome e responsabilidade deles:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsabilidades:&lt;/strong&gt;&lt;br&gt;
&lt;strong&gt;(1)&lt;/strong&gt; Foto do pet: a única responsabilidade é mostrar a foto com o estilo esperado (bordas arredondadas, no tamanho (largura e altura) definidos).&lt;br&gt;
&lt;strong&gt;(2)&lt;/strong&gt; Cartão dos dados do pet: a responsabilidade é ter o estilo correto com os dados do animal selecionado.&lt;/p&gt;

&lt;p&gt;Os nomes dos componentes devem ser capazes de expressar a responsabilidade deles. Neste caso, sugiro os seguintes &lt;strong&gt;nomes&lt;/strong&gt;:&lt;br&gt;
&lt;strong&gt;(1)&lt;/strong&gt; &lt;em&gt;ProfilePicture&lt;/em&gt; (ou &lt;em&gt;FotoPerfil&lt;/em&gt; em português)&lt;br&gt;
&lt;strong&gt;(2)&lt;/strong&gt; &lt;em&gt;ProfileCard&lt;/em&gt; (ou &lt;em&gt;CartaoPerfil&lt;/em&gt; em portugês)&lt;/p&gt;

&lt;p&gt;No caso do &lt;em&gt;ProfileCard&lt;/em&gt;, ele poderia também ser somente “Card”, mas perceba que este é um nome mais genérico e seria correto se eu pretendesse utilizar este card em diferentes lugares, não só no perfil.&lt;br&gt;
Ainda poderia existir um componente "Card" genérico cuja responsabilidade seria renderizar qualquer informação em formato de card e que poderia também possibilitar a definição de alguns estilos customizados, como arredondamento da borda e cor de fundo.&lt;/p&gt;

&lt;p&gt;Esta decisão envolveria a seguinte pergunta, considerando o contexto do projeto:&lt;/p&gt;

&lt;p&gt;Existem outros lugares na aplicação onde utilizo um card?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Se sim, crio um Card que pode receber qualquer conteúdo e reutilizo este Card para criar o &lt;em&gt;ProfileCard&lt;/em&gt; (mais específico para o perfil do pet) que receberia apenas as informações necessárias para o perfil do animal e teria a responsabilidade de apresentá-las na ordem correta.&lt;/li&gt;
&lt;li&gt;Se não, posso criar somente o &lt;em&gt;ProfileCard&lt;/em&gt;, considerando que, se no futuro eu vier a precisar de um card parecido com esse, mas com uma estrutura de dados diferente, poderei criar este Card genérico e modificar o &lt;em&gt;ProfileCard&lt;/em&gt; para utilizar este mesmo Card.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Isto cobre tudo o que precisamos mostrar? Ainda não. Precisamos também de uma forma de mostrar o conteúdo. Perceba que dentro do &lt;em&gt;ProfileCard&lt;/em&gt; também temos mais partes (mais componentes):&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%2F2kmzulkneqobygk9vte1.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%2F2kmzulkneqobygk9vte1.png" alt="Mesma imagem do perfil de gato, mas agora destacando na cor azul o componente que tem a foto do gato, o componente card e os componentes utilizados dentro do card para mostrar o nome, tipo, raça e alergias" width="800" height="1462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Perceba que listei todos eles com o número 3, ou seja, todos são instâncias de um mesmo componente reutilizados para conteúdos diferentes, pois, para este componente, vejo a seguinte &lt;strong&gt;responsabilidade&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3)&lt;/strong&gt; Dado do perfil. Este componente mostra o dado de perfil de um pet no estilo esperado: sempre tendo um título e um conteúdo, podendo estar alinhado no centro ou à esquerda.&lt;/p&gt;

&lt;p&gt;E sobre o &lt;strong&gt;nome&lt;/strong&gt; do componente:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;(3)&lt;/strong&gt; Receberia o nome &lt;em&gt;ProfileInfo&lt;/em&gt; (ou &lt;em&gt;InfoPerfil&lt;/em&gt; em português)&lt;/p&gt;

&lt;p&gt;Perceba que criamos uma semântica para os componentes que compõem o perfil do pet: todos iniciam com “Profile”. Desta forma, tornamos mais fácil de identificar, em meio a vários componentes, quais estão relacionados e pertencem ao mesmo contexto.&lt;/p&gt;

&lt;h2&gt;
  
  
  Onde este conceito se aplica?
&lt;/h2&gt;

&lt;p&gt;Este conceito se aplica a qualquer ferramenta que permita utilizar componentização para a criação de interfaces, por exemplo: ReactJS, VueJs, Angular e outros.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compartilhe
&lt;/h2&gt;

&lt;p&gt;Você faria algo diferente? Deixe aqui nos comentários a sua sugestão.&lt;/p&gt;

&lt;h2&gt;
  
  
  Exercícios
&lt;/h2&gt;

&lt;p&gt;Além do entendimento do que é o conceito de componentes, dicas e boas práticas, é de suma importância que você pratique para que fique cada vez mais fluente na aplicação deste conceito.&lt;/p&gt;

&lt;p&gt;Então &lt;a href="https://drive.google.com/file/d/1CXv4JRmjSFaD3cTsYp4u0qRHkojZGZCB/view?usp=sharing" rel="noopener noreferrer"&gt;deixo aqui alguns layouts para que você pratique o conceito de componentização&lt;/a&gt;. Baixe o arquivo e edite definindo nome e responsabilidade dos componentes.&lt;/p&gt;

&lt;p&gt;Note que o número de campos para colocar nome e responsabilidade dos componentes é arbitrário, podendo ter mais ou menos do que os números definidos.&lt;/p&gt;

&lt;p&gt;Em um próximo post, vou disponibilizar a minha resposta para estes layouts.&lt;/p&gt;

&lt;p&gt;Fique à vontade para compartilhar o seu resultado nos comentários!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.starcoders.info/" rel="noopener noreferrer"&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%2F9wzede7gk2q6jzmptio4.png" alt="Image description" width="500" height="81"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webcomponents</category>
      <category>components</category>
      <category>ui</category>
      <category>react</category>
    </item>
  </channel>
</rss>
