<?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: vladyslav kuchmenko</title>
    <description>The latest articles on DEV Community by vladyslav kuchmenko (@vladern).</description>
    <link>https://dev.to/vladern</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%2F1150963%2F27977672-9250-438c-bf7e-d5ef4974c58e.jpeg</url>
      <title>DEV Community: vladyslav kuchmenko</title>
      <link>https://dev.to/vladern</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vladern"/>
    <language>en</language>
    <item>
      <title>How to use the facade pattern to create custom components and decouple your code from third-party libraries</title>
      <dc:creator>vladyslav kuchmenko</dc:creator>
      <pubDate>Mon, 11 Sep 2023 17:35:01 +0000</pubDate>
      <link>https://dev.to/vladern/how-to-use-the-facade-pattern-to-create-custom-components-and-decouple-your-code-from-third-party-libraries-4c13</link>
      <guid>https://dev.to/vladern/how-to-use-the-facade-pattern-to-create-custom-components-and-decouple-your-code-from-third-party-libraries-4c13</guid>
      <description>&lt;h2&gt;
  
  
  Problem 🤔
&lt;/h2&gt;

&lt;p&gt;In modern frontend development, component libraries such as MUI, Angular Material, Chakra UI, etc. are usually used. These libraries help us be faster in our development, but they also have their drawbacks. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;As the project grows and these components are used throughout our application, we become more and more coupled to these same libraries. If in the future we want to use another library for a component, there are many pages that would have to be touched to replace it.&lt;/li&gt;
&lt;li&gt;Time also passes and these libraries deprecate certain interfaces and update many others. Who hasn't experienced that when updating a version of a CSS framework they change the name of a CSS class and now it's time to change this name for the entire application.&lt;/li&gt;
&lt;li&gt;Furthermore, if you use several libraries in your project, every time you want to know what interface a component has you have to go to the official documentation of said library to see what properties it has and how they are used. Making your code difficult to understand and maintain.
How can we avoid these problems and make our code more readable, modular, and reusable? In this article, I'll show you how you can create your own custom components using front-end development best practices.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Practical example
&lt;/h3&gt;

&lt;p&gt;To illustrate the problem and the solution, let's use a simple example. Imagine that you have to create a page that lists desserts ordered by their calories. If you use MUI, a component library based on React, the first thing you will have to do is import the different components that make up the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you will use these components within the page where you want the table:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;TableContainer component={Paper}&amp;gt;
  &amp;lt;Table sx={{ minWidth: 650 }} aria-label="simple table"&amp;gt;
    &amp;lt;TableHead&amp;gt;
      &amp;lt;TableRow&amp;gt;
        &amp;lt;TableCell&amp;gt;Dessert (100g serving)&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Calories&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Fat&amp;amp;nbsp;(g)&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Carbs&amp;amp;nbsp;(g)&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Protein&amp;amp;nbsp;(g)&amp;lt;/TableCell&amp;gt;
      &amp;lt;/TableRow&amp;gt;
    &amp;lt;/TableHead&amp;gt;
    &amp;lt;TableBody&amp;gt;
      {rows.map((row) =&amp;gt; (
        &amp;lt;TableRow
          key={row.name}
          sx={{ '&amp;amp;:last-child td, &amp;amp;:last-child th': { border: 0 } }}
        &amp;gt;
          &amp;lt;TableCell component="th" scope="row"&amp;gt;
            {row.name}
          &amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.calories}&amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.fat}&amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.carbs}&amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.protein}&amp;lt;/TableCell&amp;gt;
        &amp;lt;/TableRow&amp;gt;
      ))}
    &amp;lt;/TableBody&amp;gt;
  &amp;lt;/Table&amp;gt;
&amp;lt;/TableContainer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, this table is very flexible and dynamic, but it also has some disadvantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;When using MUI components directly on the page, your code is coupled to this library and depends on its changes and updates.&lt;/li&gt;
&lt;li&gt;Also, if you use the same table component on different pages to display other things, your entire app is tied to this library, making it hard to maintain and scale.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solution 🧐
&lt;/h2&gt;

&lt;p&gt;In this part, I am going to explain how you can apply the facade pattern to improve the quality and maintainability of your code. The facade pattern is a type of structural design pattern used to simplify interaction with a complex subsystem. It consists of creating a facade object that implements a simple interface and unifies the different interfaces of the subsystem or subsystems. This reduces the coupling between clients and the subsystem and makes it easier to use and understand.&lt;/p&gt;

&lt;h3&gt;
  
  
  Application example
&lt;/h3&gt;

&lt;p&gt;To illustrate the use of the facade pattern, let's take the example of the table that lists desserts ordered by their calories. Instead of directly using the MUI components on the page that we're going to display to the end user, we're going to create a custom component that encapsulates the logic and styling of the table. This component will be our facade, and it will allow us to abstract the complexity of the MUI components and decouple our code from the library.&lt;/p&gt;

&lt;p&gt;The code for our page would look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import TableComponent from '@lib/componets/data-display/table';
const headElements: HeadElement&amp;lt;Desert&amp;gt;[] = [
    { id: 'name', label: 'Postre' },
    { id: 'calories', label: 'Calorías' },
    { id: 'fat', label: 'Grasa' },
    { id: 'carbs', label: 'Carbohidratos' },
    { id: 'protein', label: 'Proteinas' }
  ];
const data = [{name: 'Yogur', calories: 200, fat: 100, carbs: 0, protein: 130}];
export default function Page() {
    return (
      &amp;lt;TableComponent&amp;lt;Desert&amp;gt;
          rowKeys={['name', 'calories', 'fat', 'carbs', 'protein']}
          rows={data}
          headElements={headElements}
        /&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see, the code is much simpler and readable. We just have to import our custom component &lt;code&gt;TableComponent&lt;/code&gt; and pass it the data we want to display as props. We don't have to worry about the internal details of the MUI components, nor their possible changes or updates.&lt;/p&gt;

&lt;p&gt;The code for our &lt;code&gt;TableComponent&lt;/code&gt; component would be something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// TableComponent.tsx
import React from 'react';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';

type HeadElement&amp;lt;T&amp;gt; = {
  id: keyof T;
  label: string;
};

type Props&amp;lt;T&amp;gt; = {
  rowKeys: Array&amp;lt;keyof T&amp;gt;;
  rows: Array&amp;lt;T&amp;gt;;
  headElements: Array&amp;lt;HeadElement&amp;lt;T&amp;gt;&amp;gt;;
};

function TableComponent&amp;lt;T&amp;gt;(props: Props&amp;lt;T&amp;gt;) {
  const { rowKeys, rows, headElements } = props;

  return (
    &amp;lt;TableContainer component={Paper}&amp;gt;
      &amp;lt;Table sx={{ minWidth: 650 }} aria-label="simple table"&amp;gt;
        &amp;lt;TableHead&amp;gt;
          &amp;lt;TableRow&amp;gt;
            {headElements.map((headElement) =&amp;gt; (
              &amp;lt;TableCell key={headElement.id}&amp;gt;{headElement.label}&amp;lt;/TableCell&amp;gt;
            ))}
          &amp;lt;/TableRow&amp;gt;
        &amp;lt;/TableHead&amp;gt;
        &amp;lt;TableBody&amp;gt;
          {rows.map((row) =&amp;gt; (
            &amp;lt;TableRow
              key={row.name}
              sx={{ '&amp;amp;:last-child td, &amp;amp;:last-child th': { border: 0 } }}
            &amp;gt;
              {rowKeys.map((rowKey) =&amp;gt; (
                &amp;lt;TableCell key={rowKey} align="right"&amp;gt;
                  {row[rowKey]}
                &amp;lt;/TableCell&amp;gt;
              ))}
            &amp;lt;/TableRow&amp;gt;
          ))}
        &amp;lt;/TableBody&amp;gt;
      &amp;lt;/Table&amp;gt;
    &amp;lt;/TableContainer&amp;gt;
  );
}

export default TableComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here we can see how our &lt;code&gt;TableComponent&lt;/code&gt; component implements the table logic and styling using the MUI components and the props it receives. Our component is generic and can receive any type of data as a prop, as long as the keys and header elements are specified. This way, we can reuse our component in different pages and projects without depending on the MUI library.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusions 🙂
&lt;/h2&gt;

&lt;p&gt;Finally, let's summarize the advantages and disadvantages of the facade pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Advantages:

&lt;ul&gt;
&lt;li&gt;Helps us decouple our project from third-party libraries.&lt;/li&gt;
&lt;li&gt;Makes it easier to maintain and update our code.&lt;/li&gt;
&lt;li&gt;It can be applied to other dependencies of our application.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Disadvantages:

&lt;ul&gt;
&lt;li&gt;Our facade can become an all-powerful object (we must respect the single responsibility principle).&lt;/li&gt;
&lt;li&gt;It can hide the complexity of the subsystem and make it difficult to debug.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I hope this article has helped you better understand the facade pattern and how you can use it to improve the quality and maintainability of your code. If you have any questions or comments, do not hesitate to contact me. 😊&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://refactoring.guru/en/design-patterns/facade"&gt;Facade (design pattern)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mui.com/material-ui/react-table/"&gt;MUI: A popular React UI framework&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Single-responsibility_principle"&gt;Single Responsibility Principle - Wikipedia&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>frontend</category>
      <category>architecture</category>
      <category>react</category>
    </item>
    <item>
      <title>Cómo usar el patrón facade para crear componentes personalizados y desacoplar tu código de librerías de terceros</title>
      <dc:creator>vladyslav kuchmenko</dc:creator>
      <pubDate>Sun, 10 Sep 2023 17:28:28 +0000</pubDate>
      <link>https://dev.to/vladern/como-usar-el-patron-facade-para-crear-componentes-personalizados-y-desacoplar-tu-codigo-de-librerias-de-terceros-3mlm</link>
      <guid>https://dev.to/vladern/como-usar-el-patron-facade-para-crear-componentes-personalizados-y-desacoplar-tu-codigo-de-librerias-de-terceros-3mlm</guid>
      <description>&lt;h2&gt;
  
  
  Problema 🤔
&lt;/h2&gt;

&lt;p&gt;En el desarrollo frontend moderno, normalmente se suele utilizar librerías de componentes como MUI, Angular Material, Chakra UI, etc. Estas librerías nos ayudan a ser más rápidos en nuestro desarrollo, pero también tienen sus inconvenientes. Por ejemplo:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A medida que el proyecto crece y se van utilizando dichos componentes alrededor de toda nuestra aplicación, nos acoplamos más y más a estas mismas librerías. Si en el futuro queremos utilizar otra librería para un componente, muchas son las páginas que habría que tocar para sustituirlo.&lt;/li&gt;
&lt;li&gt;El tiempo también pasa y estas librerías se van deprecando ciertas interfaces y actualizando otras muchas. A quien no le ha pasado que al actualizar una versión de un framework CSS le cambian el nombre a una clase CSS y ya toca cambiar este nombre por toda la aplicación.&lt;/li&gt;
&lt;li&gt;Además, si utilizas varias librerías en tu proyecto, cada vez que quieras saber qué interfaz tiene un componente te toca ir a la documentación oficial de dicha librería para ver qué propiedades tiene y cómo se utilizan. Haciendo que tu código sea difícil de comprender y mantener.
¿Cómo podemos evitar estos problemas y hacer que nuestro código sea más legible, modular y reutilizable? En este artículo, te mostraré cómo puedes crear tus propios componentes personalizados usando las mejores prácticas de desarrollo frontend.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Ejemplo práctico
&lt;/h3&gt;

&lt;p&gt;Para ilustrar el problema y la solución, vamos a usar un ejemplo sencillo. Imagina que tienes que crear una página que liste postres ordenados por sus calorías. Si utilizas MUI, una librería de componentes basada en React, lo primero que tendrás que hacer es importar los distintos componentes que componen la tabla:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Luego utilizarás dichos componentes dentro de la página donde quieras la tabla:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;TableContainer component={Paper}&amp;gt;
  &amp;lt;Table sx={{ minWidth: 650 }} aria-label="simple table"&amp;gt;
    &amp;lt;TableHead&amp;gt;
      &amp;lt;TableRow&amp;gt;
        &amp;lt;TableCell&amp;gt;Dessert (100g serving)&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Calories&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Fat&amp;amp;nbsp;(g)&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Carbs&amp;amp;nbsp;(g)&amp;lt;/TableCell&amp;gt;
        &amp;lt;TableCell align="right"&amp;gt;Protein&amp;amp;nbsp;(g)&amp;lt;/TableCell&amp;gt;
      &amp;lt;/TableRow&amp;gt;
    &amp;lt;/TableHead&amp;gt;
    &amp;lt;TableBody&amp;gt;
      {rows.map((row) =&amp;gt; (
        &amp;lt;TableRow
          key={row.name}
          sx={{ '&amp;amp;:last-child td, &amp;amp;:last-child th': { border: 0 } }}
        &amp;gt;
          &amp;lt;TableCell component="th" scope="row"&amp;gt;
            {row.name}
          &amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.calories}&amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.fat}&amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.carbs}&amp;lt;/TableCell&amp;gt;
          &amp;lt;TableCell align="right"&amp;gt;{row.protein}&amp;lt;/TableCell&amp;gt;
        &amp;lt;/TableRow&amp;gt;
      ))}
    &amp;lt;/TableBody&amp;gt;
  &amp;lt;/Table&amp;gt;
&amp;lt;/TableContainer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Como puedes observar, esta tabla es muy flexible y dinámica, pero también tiene algunos inconvenientes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Al usar los componentes de MUI directamente en la página, tu código queda acoplado a esta librería y depende de sus cambios y actualizaciones.&lt;/li&gt;
&lt;li&gt;Además, si usas el mismo componente de tabla en distintas páginas para mostrar otras cosas, toda tu aplicación queda acoplada a esta librería, lo que dificulta su mantenimiento y escalabilidad.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solución 🧐
&lt;/h2&gt;

&lt;p&gt;En esta parte, te voy a explicar cómo puedes aplicar el patrón facade para mejorar la calidad y la mantenibilidad de tu código. El patrón facade es un tipo de patrón de diseño estructural que se usa para simplificar la interacción con un subsistema complejo. Consiste en crear un objeto de fachada que implementa una interfaz sencilla y unifica las distintas interfaces del subsistema o subsistemas. De esta forma, se reduce el acoplamiento entre los clientes y el subsistema, y se facilita su uso y comprensión.&lt;/p&gt;

&lt;h3&gt;
  
  
  Ejemplo de aplicación
&lt;/h3&gt;

&lt;p&gt;Para ilustrar el uso del patrón facade, vamos a retomar el ejemplo de la tabla que lista postres ordenados por sus calorías. En lugar de utilizar directamente los componentes de MUI en la página que vamos a mostrar al usuario final, vamos a crear un componente personalizado que encapsule la lógica y el estilo de la tabla. Este componente será nuestra fachada, y nos permitirá abstraer la complejidad de los componentes de MUI y desacoplar nuestro código de la librería.&lt;/p&gt;

&lt;p&gt;El código de nuestra página quedaría algo así:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import TableComponent from '@lib/componets/data-display/table';
const headElements: HeadElement&amp;lt;Desert&amp;gt;[] = [
    { id: 'name', label: 'Postre' },
    { id: 'calories', label: 'Calorías' },
    { id: 'fat', label: 'Grasa' },
    { id: 'carbs', label: 'Carbohidratos' },
    { id: 'protein', label: 'Proteinas' }
  ];
const data = [{name: 'Yogur', calories: 200, fat: 100, carbs: 0, protein: 130}];
export default function Page() {
    return (
      &amp;lt;TableComponent&amp;lt;Desert&amp;gt;
          rowKeys={['name', 'calories', 'fat', 'carbs', 'protein']}
          rows={data}
          headElements={headElements}
        /&amp;gt;
    )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Como puedes ver, el código es mucho más simple y legible. Solo tenemos que importar nuestro componente personalizado &lt;code&gt;TableComponent&lt;/code&gt; y pasarle los datos que queremos mostrar como props. No tenemos que preocuparnos por los detalles internos de los componentes de MUI, ni por sus posibles cambios o actualizaciones.&lt;/p&gt;

&lt;p&gt;El código de nuestro componente &lt;code&gt;TableComponent&lt;/code&gt; sería algo así:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// TableComponent.tsx
import React from 'react';
import Table from '@mui/material/Table';
import TableBody from '@mui/material/TableBody';
import TableCell from '@mui/material/TableCell';
import TableContainer from '@mui/material/TableContainer';
import TableHead from '@mui/material/TableHead';
import TableRow from '@mui/material/TableRow';
import Paper from '@mui/material/Paper';

type HeadElement&amp;lt;T&amp;gt; = {
  id: keyof T;
  label: string;
};

type Props&amp;lt;T&amp;gt; = {
  rowKeys: Array&amp;lt;keyof T&amp;gt;;
  rows: Array&amp;lt;T&amp;gt;;
  headElements: Array&amp;lt;HeadElement&amp;lt;T&amp;gt;&amp;gt;;
};

function TableComponent&amp;lt;T&amp;gt;(props: Props&amp;lt;T&amp;gt;) {
  const { rowKeys, rows, headElements } = props;

  return (
    &amp;lt;TableContainer component={Paper}&amp;gt;
      &amp;lt;Table sx={{ minWidth: 650 }} aria-label="simple table"&amp;gt;
        &amp;lt;TableHead&amp;gt;
          &amp;lt;TableRow&amp;gt;
            {headElements.map((headElement) =&amp;gt; (
              &amp;lt;TableCell key={headElement.id}&amp;gt;{headElement.label}&amp;lt;/TableCell&amp;gt;
            ))}
          &amp;lt;/TableRow&amp;gt;
        &amp;lt;/TableHead&amp;gt;
        &amp;lt;TableBody&amp;gt;
          {rows.map((row) =&amp;gt; (
            &amp;lt;TableRow
              key={row.name}
              sx={{ '&amp;amp;:last-child td, &amp;amp;:last-child th': { border: 0 } }}
            &amp;gt;
              {rowKeys.map((rowKey) =&amp;gt; (
                &amp;lt;TableCell key={rowKey} align="right"&amp;gt;
                  {row[rowKey]}
                &amp;lt;/TableCell&amp;gt;
              ))}
            &amp;lt;/TableRow&amp;gt;
          ))}
        &amp;lt;/TableBody&amp;gt;
      &amp;lt;/Table&amp;gt;
    &amp;lt;/TableContainer&amp;gt;
  );
}

export default TableComponent;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Aquí podemos ver cómo nuestro componente &lt;code&gt;TableComponent&lt;/code&gt; implementa la lógica y el estilo de la tabla usando los componentes de MUI y los props que recibe. Nuestro componente es genérico y puede recibir cualquier tipo de dato como prop, siempre que se especifiquen las claves y los elementos del encabezado. De esta forma, podemos reutilizar nuestro componente en diferentes páginas y proyectos sin depender de la librería MUI.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusiones 🙂
&lt;/h2&gt;

&lt;p&gt;Para terminar, vamos a resumir las ventajas e inconvenientes del patrón facade:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ventajas:

&lt;ul&gt;
&lt;li&gt;Nos ayuda a desacoplar nuestro proyecto de librerías de terceros.&lt;/li&gt;
&lt;li&gt;Facilita el mantenimiento y la actualización de nuestro código.&lt;/li&gt;
&lt;li&gt;Se puede aplicar a otras dependencias de nuestra aplicación.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;li&gt;Inconvenientes:

&lt;ul&gt;
&lt;li&gt;Nuestra fachada puede convertirse en un objeto todo poderoso (hay que respetar el principio de responsabilidad única) .&lt;/li&gt;
&lt;li&gt;Puede ocultar la complejidad del subsistema y dificultar su depuración.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Espero que este artículo te haya servido para comprender mejor el patrón facade y cómo puedes usarlo para mejorar la calidad y la mantenibilidad de tu código. Si tienes alguna duda o comentario, no dudes en contactarme. 😊&lt;/p&gt;

&lt;h2&gt;
  
  
  Referencias
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://refactoring.guru/es/design-patterns/facade"&gt;Facade (patrón de diseño)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://mui.com/material-ui/react-table/"&gt;MUI: A popular React UI framework&lt;/a&gt;
&lt;a href="https://es.wikipedia.org/wiki/Principio_de_responsabilidad_%C3%BAnica"&gt;Principio de responsabilidad única - Wikipedia&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>frontend</category>
    </item>
  </channel>
</rss>
