<?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: Victor Melo</title>
    <description>The latest articles on DEV Community by Victor Melo (@vctrsmelo).</description>
    <link>https://dev.to/vctrsmelo</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%2F382316%2F6181fc8f-dd61-453a-a785-1a2d1afe436e.png</url>
      <title>DEV Community: Victor Melo</title>
      <link>https://dev.to/vctrsmelo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/vctrsmelo"/>
    <language>en</language>
    <item>
      <title>The Declarative Advantage: Why Angular Prioritizes "What" Over "How"</title>
      <dc:creator>Victor Melo</dc:creator>
      <pubDate>Sat, 09 Aug 2025 13:25:52 +0000</pubDate>
      <link>https://dev.to/vctrsmelo/the-declarative-advantage-why-angular-prioritizes-what-over-how-4jgg</link>
      <guid>https://dev.to/vctrsmelo/the-declarative-advantage-why-angular-prioritizes-what-over-how-4jgg</guid>
      <description>&lt;h2&gt;
  
  
  Imperative vs. Declarative
&lt;/h2&gt;

&lt;p&gt;Programming paradigms can be divided into two categories:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Imperative Paradigms&lt;/strong&gt;: The programmer describes &lt;strong&gt;how&lt;/strong&gt; the software can achieve a result by providing a detailed sequence of instructions.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Declarative Paradigms&lt;/strong&gt;: The programmer describes &lt;strong&gt;what&lt;/strong&gt; the expected result is, and the underlying system figures out the steps to get there.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Procedural Programming and Object-Oriented Programming are examples of imperative paradigms, while Logic Programming and Functional Programming are paradigms that lend themselves well to a declarative style.&lt;/p&gt;

&lt;p&gt;It was once common for a programming language to be oriented around a single paradigm, for example, Haskell is a purely functional language. In contrast, languages are evolving to support multiple paradigms, with a growing emphasis on declarative patterns. You can now develop your Java code using lambdas, a concept that came from functional programming.&lt;/p&gt;




&lt;h2&gt;
  
  
  Where Is Angular's Declarativity?
&lt;/h2&gt;

&lt;p&gt;In the context of web development, an imperative approach would manipulate the Document Object Model (DOM) to update a list. You would write code to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Find the list element.&lt;/li&gt;
&lt;li&gt; Create a new list item element.&lt;/li&gt;
&lt;li&gt; Set the text of the new item.&lt;/li&gt;
&lt;li&gt; Append the new item to the list.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;A declarative approach, as seen in Angular, is simpler: you declare in your template that a list should be rendered based on a specific array of data. When the data changes, Angular automatically and efficiently updates the DOM to reflect the new state, without you having to write any of the manual update logic.&lt;/p&gt;

&lt;p&gt;Using plain JavaScript (imperative), you would do the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"my-list"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;onclick=&lt;/span&gt;&lt;span class="s"&gt;"addListItem()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add Item&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;itemCount&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addListItem&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// 1. Find the list element&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;list&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;my-list&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// 2. Create a new list item element&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;newItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;li&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// 3. Set the text content&lt;/span&gt;
  &lt;span class="nx"&gt;newItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Item &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="nx"&gt;itemCount&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="c1"&gt;// 4. Append the new item to the list&lt;/span&gt;
  &lt;span class="nx"&gt;list&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newItem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Meanwhile, in Angular (declarative), you do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  @for (item of items; track item) {
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;{{ item }}&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  } @empty {
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;No items found.&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  }
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;(click)=&lt;/span&gt;&lt;span class="s"&gt;"addItem()"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Add Item&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Component&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@angular/core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="p"&gt;@&lt;/span&gt;&lt;span class="nd"&gt;Component&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;selector&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app-list&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;templateUrl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./list.component.html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ListComponent&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="nx"&gt;itemCount&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;addItem&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;items&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Item &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;itemCount&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first example, you tell the code how to update the list; in the second, you describe the desired structure in the HTML template and let Angular figure out how to achieve that result. The &lt;code&gt;track&lt;/code&gt; keyword in the &lt;code&gt;@for&lt;/code&gt; loop is a key part of this, as it tells Angular how to uniquely identify each item, enabling the framework to efficiently update the DOM with minimal changes.  The optional &lt;code&gt;@empty&lt;/code&gt; block is another declarative feature, allowing you to describe a state for an empty list.&lt;/p&gt;




&lt;h2&gt;
  
  
  Advantages of Being Declarative
&lt;/h2&gt;

&lt;p&gt;Declarative code has the following benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improved readability and reduced code length.&lt;/li&gt;
&lt;li&gt;Enhanced predictability and easier debugging.&lt;/li&gt;
&lt;li&gt;Increased productivity and maintainability.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In a declarative approach, when you want to understand how a particular thing (like a variable) behaves, you just need to look at its declaration. Meanwhile, in an imperative approach, the declaration might be separated from its assignment, so you need to look at more places to completely understand the behavior.&lt;/p&gt;




&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;At its heart, Angular's declarative nature is about empowering developers. By shifting the focus from the low-level &lt;strong&gt;how&lt;/strong&gt; to the high-level &lt;strong&gt;what&lt;/strong&gt;, the framework allows you to think about your application in terms of states and desired outcomes, not a list of manual DOM manipulations.&lt;/p&gt;

&lt;p&gt;This isn't just an abstract programming principle; it's a practical choice that leads to more readable code, fewer bugs, and a more enjoyable development experience. As you continue your journey with Angular, remember that you're not writing instructions for the browser; you're declaring your intentions for the UI, and the framework is your trusted partner in bringing those intentions to life. This fundamental mindset is the key to mastering Angular and building robust, maintainable applications at scale.&lt;/p&gt;




&lt;h1&gt;
  
  
  References
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.geeksforgeeks.org/theory-of-computation/difference-between-imperative-and-declarative-programming/" rel="noopener noreferrer"&gt;Difference Between Imperative and Declarative Programming&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=ZnaThaXb7JM" rel="noopener noreferrer"&gt;A visual guide to why DECLARATIVE code is better&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>angular</category>
      <category>webdev</category>
      <category>typescript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Do you know what is an RFC?</title>
      <dc:creator>Victor Melo</dc:creator>
      <pubDate>Wed, 31 Aug 2022 10:27:59 +0000</pubDate>
      <link>https://dev.to/vctrsmelo/do-you-know-what-is-an-rfc-426m</link>
      <guid>https://dev.to/vctrsmelo/do-you-know-what-is-an-rfc-426m</guid>
      <description>&lt;p&gt;RFC is the document used to propose changes to Internet Engineering Task Force (IETF). A definition I found online is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The Request for Change (RFC) is formal request for the implementation of a Change. The RFC is a precursor to the 'Change Record' and contains all information required to approve a Change. Further information is added as the Change progresses through its lifecycle. The level of detail depends on the size and likely impact of the Change. Often there will be references to further documents containing more detailed information, e.g. a detailed 'Change Proposal'. As major Changes are typically implemented as projects, the RFC often takes on the role of what is also known as a "Project Charter".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;An RFC contains all information related to the proposal sent, so it is the source of truth for any question you have related to the theme.&lt;/p&gt;

&lt;p&gt;Interesting RFCs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IP: &lt;a href="https://www.rfc-editor.org/rfc/rfc791" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc791&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;TCP: &lt;a href="https://www.ietf.org/rfc/rfc793.txt" rel="noopener noreferrer"&gt;https://www.ietf.org/rfc/rfc793.txt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;HTML: &lt;a href="https://www.ietf.org/rfc/rfc1866.txt" rel="noopener noreferrer"&gt;https://www.ietf.org/rfc/rfc1866.txt&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;HTTP: &lt;a href="https://www.rfc-editor.org/rfc/rfc2616" rel="noopener noreferrer"&gt;https://www.rfc-editor.org/rfc/rfc2616&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;QUIC: &lt;a href="https://datatracker.ietf.org/doc/html/rfc9000" rel="noopener noreferrer"&gt;https://datatracker.ietf.org/doc/html/rfc9000&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
    </item>
  </channel>
</rss>
