<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Ramon Silva</title>
    <description>The latest articles on Forem by Ramon Silva (@ramonsilvadev).</description>
    <link>https://forem.com/ramonsilvadev</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%2F1123072%2F9c1b0d9f-4236-4e08-8366-a345ef226b80.jpg</url>
      <title>Forem: Ramon Silva</title>
      <link>https://forem.com/ramonsilvadev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ramonsilvadev"/>
    <language>en</language>
    <item>
      <title>Stop Creating Useless Instances in TypeScript</title>
      <dc:creator>Ramon Silva</dc:creator>
      <pubDate>Tue, 10 Mar 2026 20:50:08 +0000</pubDate>
      <link>https://forem.com/ramonsilvadev/stop-creating-useless-instances-in-typescript-3en0</link>
      <guid>https://forem.com/ramonsilvadev/stop-creating-useless-instances-in-typescript-3en0</guid>
      <description>&lt;p&gt;Confess to me: how many times have you seen (or written) code where someone creates a class full of utility functions and, when it's time to use it, does a new CurrencyFormatter() just to call a method that formats a number?&lt;/p&gt;

&lt;p&gt;Yeah. We often do this on autopilot, but in practice, we are allocating memory for a whole object without any real need.&lt;/p&gt;

&lt;p&gt;If your function doesn't need to hold any internal "state" (meaning it doesn't use data from a specific instance), you don't need the &lt;code&gt;new&lt;/code&gt; keyword. That's exactly what the &lt;code&gt;static&lt;/code&gt; keyword is for.&lt;/p&gt;

&lt;p&gt;Let's see the difference in practice.&lt;/p&gt;




&lt;h3&gt;
  
  
  ❌ The useless &lt;code&gt;new&lt;/code&gt; nightmare (Without static)
&lt;/h3&gt;

&lt;p&gt;Imagine a simple utility class for formatting. If you don't use &lt;code&gt;static&lt;/code&gt;, TypeScript forces you to instantiate the class (create an object) every single time you want to use its function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CurrencyFormatter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`$&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// Wasting memory to create an object for no reason&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;formatter&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;CurrencyFormatter&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt; 
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;formatter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;150.5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  ✅ Straight to the point (With static)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CurrencyFormatter&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// The function now belongs to the class&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`$&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toFixed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// No 'new', no mess. Direct call!&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;CurrencyFormatter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;format&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;150.5&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h4&gt;
  
  
  🧠 Bonus: Sharing data across instances
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;static&lt;/code&gt; keyword isn't just for utility functions. It's incredibly powerful for creating variables that need to be shared across all objects of that class.&lt;/p&gt;

&lt;p&gt;Imagine you are processing transactions in a financial app and want to keep track of the total number of transactions created during a session. If you use a regular variable, each transaction will have its own isolated counter (which defeats the purpose). With &lt;code&gt;static&lt;/code&gt;, the whole class shares the same variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Transaction&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// This value is shared across the entire application&lt;/span&gt;
  &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nx"&gt;totalProcessed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nx"&gt;amount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Every time a transaction is created, we update the global counter&lt;/span&gt;
    &lt;span class="nx"&gt;Transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalProcessed&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;50&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Transaction&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;totalProcessed&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Output: 3&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  The Golden Rule
&lt;/h3&gt;

&lt;p&gt;Not sure if you should use it or not? Ask yourself this: &lt;strong&gt;"Does this method use the this keyword to access a variable that belongs only to this specific object?"&lt;/strong&gt; If the answer is no, slap a &lt;code&gt;static&lt;/code&gt; on it and be happy! Your code will be cleaner, more performant, and more professional.&lt;/p&gt;

&lt;p&gt;Do you use static methods often in your projects, or do you still have the habit of throwing &lt;code&gt;new&lt;/code&gt; at everything? Let me know in the comments!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Hype Doesn't Dictate the Market: The Real Deal on Development</title>
      <dc:creator>Ramon Silva</dc:creator>
      <pubDate>Wed, 26 Feb 2025 01:06:14 +0000</pubDate>
      <link>https://forem.com/ramonsilvadev/hype-nao-dita-mercado-a-real-sobre-desenvolvimento-30oh</link>
      <guid>https://forem.com/ramonsilvadev/hype-nao-dita-mercado-a-real-sobre-desenvolvimento-30oh</guid>
      <description>&lt;p&gt;Hey guys!&lt;/p&gt;

&lt;p&gt;I recently went to a dev meetup here in my city. While chatting about the job market, one comment really caught my attention: "Java is making a huge comeback after a slump." That made me stop and wonder: when did it ever leave?&lt;/p&gt;

&lt;p&gt;Honestly, I don't think Java ever left the stage. Even as a front-end dev, I see the demand for Java developers booming, especially in the enterprise world. Companies need people to build new features and maintain legacy systems. And let's face it, their real concern isn't chasing trends, but keeping everything running smoothly. Mission-critical systems aren't replaced overnight. Stability, security, and longevity matter way more.&lt;/p&gt;

&lt;p&gt;One thing we can't ignore is the role social media plays in this perception, constantly feeding us what we already search for and related topics. That's where the danger of "bubbles" lies. Algorithms are designed to show us content that reinforces our beliefs and interests, creating a vicious cycle of information that can lead us to believe a specific tech stack is the only relevant one, when in reality, the market is much more diverse.&lt;/p&gt;

&lt;p&gt;So, before you get swept up in the "X is dead" or "Y is going to dominate everything" narratives, remember that the market is way more complex than the current hype. At the end of the day, every language has its purpose. Knowing this is what helps you decide where to invest your time and energy as a dev. Seek information from diverse sources, talk to professionals from different fields, and experiment with new technologies. The real key to success is the ability to adapt and learn continuously.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>career</category>
      <category>development</category>
      <category>softwaredevelopment</category>
    </item>
  </channel>
</rss>
