<?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: Mahezer Carvalho</title>
    <description>The latest articles on DEV Community by Mahezer Carvalho (@mahezer).</description>
    <link>https://dev.to/mahezer</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%2F1264083%2Fabd165d0-82b0-4665-8715-09b117951abc.png</url>
      <title>DEV Community: Mahezer Carvalho</title>
      <link>https://dev.to/mahezer</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mahezer"/>
    <language>en</language>
    <item>
      <title>Metaprogramming - how to be lazy and reach high levels of productivity</title>
      <dc:creator>Mahezer Carvalho</dc:creator>
      <pubDate>Tue, 23 Jan 2024 14:26:01 +0000</pubDate>
      <link>https://dev.to/mahezer/metaprogramming-how-to-be-lazy-and-reach-high-levels-of-productivity-1lhf</link>
      <guid>https://dev.to/mahezer/metaprogramming-how-to-be-lazy-and-reach-high-levels-of-productivity-1lhf</guid>
      <description>&lt;p&gt;I was recently tasked with abstracting a database into an API. The database had a lot of confusing data formatting functions which should also be abstracted in my API. Since it was a generic market system, the documentation for the database was available through a humongous Excel file explaining how each field should receive data.&lt;/p&gt;

&lt;p&gt;Initially, I worked with the tools from my text editor to have the maximum productivity I could get, but apparently, there was no end to these database tables. Each table had around 300 fields, and I needed to create files for data formatting, payload validation and unit tests.&lt;/p&gt;

&lt;p&gt;After a week, I was far away from finishing my first task, demotivated and my productivity was way smaller than I'd like. All I did was simply bash my head against the keyboard calling formatting functions for each field in a table the whole day, and even after a good night's rest, every day became a huge fight against falling asleep in front of the computer from boredom.&lt;/p&gt;

&lt;p&gt;It was right on a Monday that a question popped in my mind&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why should &lt;em&gt;I&lt;/em&gt; type all this?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I started my "new" task the same day: creating someone to type all that for me.&lt;/p&gt;

&lt;p&gt;I used one full day and a bit over 300 lines of code, and created a script that parsed the Excel file, filtered which was the table I was trying to abstract and generated the payload validation function. Then, all I had to do was to dump the generated file inside my original project and check to see if everything was working. The entire file generation process took around 350~400ms.&lt;/p&gt;

&lt;p&gt;I was in love with my new baby, and a week later, it was already generating every file and function that needed any heavy typing. Everyone got something out of this adventure. I had the oportunity to work on an exciting task, and the task was finished way quicker than I ever thought possible.&lt;/p&gt;

&lt;p&gt;I know this is a very isolated metaprogramming example, but my real goal with this article is to make you question yourself if you can't fit some of that in your current task. Do you feel bored with what you need to do? Are you tired of banging your keyboard mindlessly? So create "someone" to do it for you!&lt;/p&gt;

&lt;p&gt;The best part of being a programmer is to see the possibility of improving a situation, and to have the knowledge to actually improve it, so embrace this power!&lt;/p&gt;




&lt;h2&gt;
  
  
  Okay, but what about this &lt;em&gt;metaprogramming&lt;/em&gt;?
&lt;/h2&gt;

&lt;p&gt;The "meta-" prefix in this case means "reflection upon itself". Metaprogramming is the programming you do make some actual programming task easier :)&lt;/p&gt;

&lt;p&gt;This idea came from stretching out the concepts from Tim Ferriss' book &lt;a href="https://www.amazon.com.br/4-Hour-Workweek-Expanded-Updated-Cutting-Edge-ebook/dp/B002WE46UW/ref=sr_1_1?__mk_pt_BR=%25C3%2585M%25C3%2585%25C5%25BD%25C3%2595%25C3%2591&amp;amp;crid=13CAVGUBL38AI&amp;amp;keywords=4+hour+work+week&amp;amp;qid=1706017981&amp;amp;sprefix=4+hour+work+we%252Caps%252C202&amp;amp;sr=8-1&amp;amp;_encoding=UTF8&amp;amp;tag=mahezer-20&amp;amp;linkCode=ur2&amp;amp;linkId=1bd5cfbc4be98291ef3ea7402247bc3a&amp;amp;camp=1789&amp;amp;creative=9325"&gt;The 4-Hour Workweek&lt;/a&gt;. The original concept is that we should automate any task that takes us too long, and there are quite a few reasons to actually do this.&lt;/p&gt;

&lt;p&gt;First off, speed. A computer is much, much faster to execute repetitive tasks than any human. You can leave your computer working for hours or days and it will not feel tired, bored nor slow down.&lt;/p&gt;

&lt;p&gt;Second off, precision. A computer doesn't write typos or reads a text from the wrong place. The computer will always do what it was programmed to do. This is a double edged sword, since you'll need to know what is it that you want to do and how the computer should do it. But once you've got your code straight, you can simply execute the code and go do something else entirely.&lt;/p&gt;

&lt;p&gt;Last but not least, fun! Making a robot that automates tasks is challenging, and it is way more fun than typing repetitive stuff forever. Not to mention that it is super fun to see your script running and fixing a problem for you (boredom) and a problem for your boss (time).&lt;/p&gt;




&lt;p&gt;Bill Gates once said that he prefers to hire lazy people to do hard tasks because they will always find simple solutions for those problems.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;So here goes a controversial advice: Be lazier!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not in the sense of slacking at your job, or in the sense of procrastinating the things you need to do. But in the way that makes you avoid repetitive work.&lt;/p&gt;

&lt;p&gt;The biggest value a programmer brings to the table is exactly the ability to abstract complex tasks and automate repetitive tasks, &lt;strong&gt;and not our typing speed&lt;/strong&gt;. It's part of the job to find those tasks and automate them.&lt;/p&gt;

&lt;p&gt;Have your eyes sharp for any menial tasks that pop up and eliminate them. This will free you team's time to focus on what really matters, the complex problems.&lt;/p&gt;

&lt;p&gt;Do you have some report that takes hours to set up? Automate it.&lt;br&gt;
Do you have bureaucracy that hinders your work? Automate it.&lt;br&gt;
Do you have a task that pops up every single month? Automate it!&lt;/p&gt;

&lt;p&gt;Cover image: Foto de &lt;a href="https://unsplash.com/pt-br/@drewcoffman?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash"&gt;Drew Coffman&lt;/a&gt; na &lt;a href="https://unsplash.com/pt-br/fotografias/pessoa-na-rede-DzIt-fTYv4E?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash"&gt;Unsplash&lt;/a&gt;&lt;br&gt;
This article is also available in Portuguese &lt;a href="https://dev.to/mahezer/metaprogramacao-como-ser-preguicoso-e-alcancar-altos-niveis-de-produtividade-58k7"&gt;here&lt;/a&gt;&lt;br&gt;
Article originally published (in portuguese) at &lt;a href="https://www.holyscript.com.br/post/metaprograma%C3%A7%C3%A3o-como-ser-pregui%C3%A7oso-e-alcan%C3%A7ar-altos-n%C3%ADveis-de-produtividade"&gt;Holyscript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>programming</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Metaprogramação - como ser preguiçoso e alcançar altos níveis de produtividade</title>
      <dc:creator>Mahezer Carvalho</dc:creator>
      <pubDate>Tue, 23 Jan 2024 13:23:20 +0000</pubDate>
      <link>https://dev.to/mahezer/metaprogramacao-como-ser-preguicoso-e-alcancar-altos-niveis-de-produtividade-58k7</link>
      <guid>https://dev.to/mahezer/metaprogramacao-como-ser-preguicoso-e-alcancar-altos-niveis-de-produtividade-58k7</guid>
      <description>&lt;p&gt;Recentemente recebi a tarefa de abstrair um banco de dados em uma API. Além disso, o banco de dados também trabalhava com algumas formatações de dados muito confusas, que deveriam ser abstraídas na API também. Por ser um sistema de mercado, a documentação era disponibilizada através de um XLS gigantesco explicando como os campos deveriam ser inseridos nas tabelas.&lt;/p&gt;

&lt;p&gt;Inicialmente, eu contei com as ferramentas do meu editor de texto para ganhar o máximo de produtividade possível, mas aparentemente as tabelas não tinham fim. Cada uma das tabelas possuía cerca de 300 campos, e eu precisava criar arquivos de formatação, validação de payload e testes unitários. &lt;/p&gt;

&lt;p&gt;Passada uma semana, eu estava longe de terminar a primeira tarefa, desmotivado, e rendendo muito menos do que gostaria. Todo o meu trabalho era simplesmente bater teclado chamando funções de formatação para cada campo de uma tabela, e mesmo tendo descansado normalmente, os dias se tornaram uma eterna luta para não dar aquelas "pescadas" na frente do computador.&lt;/p&gt;

&lt;p&gt;Foi exatamente numa segunda-feira que me surgiu o questionamento. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Por que &lt;em&gt;eu&lt;/em&gt; preciso digitar tudo isso?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;No mesmo dia comecei minha "nova" tarefa: criar quem digitasse aquilo tudo por mim.&lt;/p&gt;

&lt;p&gt;Utilizando um dia de serviço e um pouco mais que 300 linhas de código, fiz um simples script que lia o arquivo XLS, filtrava qual era a tabela que eu estava querendo abstrair e gerava o arquivo de validação de payload. Depois era só jogar dentro do projeto e ver tudo funcionando. O processo completo de geração do arquivo demorava cerca de 350~400ms.&lt;/p&gt;

&lt;p&gt;Fiquei namorando o script, e uma semana depois, ele já estava gerando todos os arquivos que precisavam de digitação bruta. Com isso, todo mundo saiu ganhando. Eu tive a oportunidade de trabalhar em uma tarefa que me empolgasse, e a tarefa original foi concluída com muito mais velocidade do que eu imaginei que fosse possível. &lt;/p&gt;

&lt;p&gt;Eu sei que este é um exemplo de metaprogramação muito isolado, mas o meu real objetivo com este artigo é te fazer questionar se não cabe um pouco disso na sua tarefa atual. Você se sente entediado fazendo o que precisa ser feito? Cansou de bater teclado? Então crie alguém pra fazer isso pra você!&lt;/p&gt;

&lt;p&gt;A melhor parte de ser um programador é ver a possibilidade de melhorar alguma situação, e ter o conhecimento suficiente para realmente melhorar a situação, então aproveite esta posição!&lt;/p&gt;




&lt;h2&gt;
  
  
  Beleza, mas e a &lt;em&gt;metaprogramação&lt;/em&gt;?
&lt;/h2&gt;

&lt;p&gt;O prefixo "meta-" nesse caso tem o sentido de "reflexão sobre si". Metaprogramação é a programação que você faz para facilitar a programação final :)&lt;/p&gt;

&lt;p&gt;Esta ideia veio de uma extrapolação da ideia do livro do Tim Ferriss &lt;a href="https://www.amazon.com.br/Trabalhe-4-Horas-por-Semana/dp/8542211561/ref=sr_1_1?crid=2QW3U02C8X81R&amp;amp;keywords=trabalhe+4+horas+por+semana&amp;amp;qid=1704908002&amp;amp;sprefix=trabalhe+%252Caps%252C287&amp;amp;sr=8-1&amp;amp;_encoding=UTF8&amp;amp;tag=mahezer-20&amp;amp;linkCode=ur2&amp;amp;linkId=5ecbe5f891bf09891ea636747ac6869d&amp;amp;camp=1789&amp;amp;creative=9325"&gt;Trabalhe 4 horas por semana&lt;/a&gt;. A recomendação é que nós possamos automatizar qualquer tarefa que nos tome tempo demais e existem muitos motivos para isso.&lt;/p&gt;

&lt;p&gt;Em primeiro lugar, a velocidade. Uma máquina é muito mais rápida para executar tarefas repetitivas do que qualquer humano. Você pode deixar uma máquina funcionando por horas ou dias e a máquina não se sentirá cansada e não perderá rendimento.&lt;/p&gt;

&lt;p&gt;Em segundo lugar, a precisão. Uma máquina não comete erros de digitação, nem lê o campo errado. A máquina sempre irá fazer o que foi programada pra fazer. Isso tem seus desafios, uma vez que você irá precisar saber o que quer fazer e como fazer isso, mas uma vez que sua programação está correta, você pode simplesmente executar a rotina e ir fazer outra coisa.&lt;/p&gt;

&lt;p&gt;Por último, temos a diversão! Criar um robô que automatiza tarefas é desafiador, e é muito mais divertido do que ficar digitando coisas repetitivas por tempo indeterminado. Sem contar que também é super divertido ver ele sendo executado e resolvendo um problema para você (o tédio) e um problema para o seu empregador (o prazo).&lt;/p&gt;




&lt;p&gt;Bill Gates uma vez disse que prefere contratar pessoas preguiçosas para resolver tarefas difíceis porque elas vão sempre procurar soluções simples para os problemas.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Então, aqui vai um conselho controverso: Seja mais preguiçoso! &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Não no sentido de não querer trabalhar, ou no sentido de ficar procrastinando as coisas que você precisa fazer. Mas no sentido de evitar trabalhos repetitivos.&lt;/p&gt;

&lt;p&gt;O maior valor agregado de um programador é exatamente a capacidade de abstração de tarefas complexas e automatização de tarefas repetitivas, &lt;strong&gt;não nossa velocidade de digitação&lt;/strong&gt;. Faz parte do seu trabalho identificar estas tarefas e automatiza-las.&lt;/p&gt;

&lt;p&gt;Sempre tenha olhos afiados para encontrar tarefas repetitivas e eliminar todas elas. Isso vai permitir que o seu time se concentre naquilo que realmente importa, e nos problemas realmente complexos.&lt;/p&gt;

&lt;p&gt;Você tem algum relatório que leva horas para preparar? Automatize.&lt;br&gt;
Você tem alguma burocracia que dificulta seu trabalho? Automatize.&lt;br&gt;
Você tem alguma tarefa que aparece todo mês? Automatize!&lt;/p&gt;

&lt;p&gt;Imagem de cover: Foto de &lt;a href="https://unsplash.com/pt-br/@drewcoffman?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash"&gt;Drew Coffman&lt;/a&gt; na &lt;a href="https://unsplash.com/pt-br/fotografias/pessoa-na-rede-DzIt-fTYv4E?utm_content=creditCopyText&amp;amp;utm_medium=referral&amp;amp;utm_source=unsplash"&gt;Unsplash&lt;/a&gt;&lt;br&gt;
This article is also available in english &lt;a href="https://dev.to/mahezer/metaprogramming-how-to-be-lazy-and-reach-high-levels-of-productivity-1lhf"&gt;here&lt;/a&gt;&lt;br&gt;
Texto originalmente publicado no blog &lt;a href="https://www.holyscript.com.br/post/metaprograma%C3%A7%C3%A3o-como-ser-pregui%C3%A7oso-e-alcan%C3%A7ar-altos-n%C3%ADveis-de-produtividade"&gt;Holyscript&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
