<?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: Tatjana</title>
    <description>The latest articles on Forem by Tatjana (@developaw).</description>
    <link>https://forem.com/developaw</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%2F516056%2Fd4252a84-3eae-449e-a988-b94098d6d877.png</url>
      <title>Forem: Tatjana</title>
      <link>https://forem.com/developaw</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/developaw"/>
    <language>en</language>
    <item>
      <title>The thing with abbreviations - Programming Principles</title>
      <dc:creator>Tatjana</dc:creator>
      <pubDate>Thu, 19 Sep 2024 08:15:16 +0000</pubDate>
      <link>https://forem.com/developaw/the-thing-with-abbreviations-programming-principles-4j5i</link>
      <guid>https://forem.com/developaw/the-thing-with-abbreviations-programming-principles-4j5i</guid>
      <description>&lt;p&gt;Developers like to keep things short. We need to save time wherever possible, and that's why we also favor abbreviations. Abbreviations are common and useful in programming principles, but they are often not very descriptive. Here is an incomplete list of common programming principles abbreviations that you should have encountered at least once in your programming career:&lt;/p&gt;

&lt;h2&gt;
  
  
  KISS (Keep it simple, stupid!)
&lt;/h2&gt;

&lt;p&gt;KISS is the abbreviation of "Keep it simple, Stupid" or sometimes "Keep it simple and smart" or "Keep it simple and short". The principle encourages reducing the complexity of the code(-base) as much as possible. Simpler code is easier to read, maintain and test. While it may sound straightforward, simplifying code effectively takes hard work. Fortunately, many of the other programming principles, like DRY and YAGNI, support the KISS principle.&lt;/p&gt;

&lt;h2&gt;
  
  
  DRY (Don’t repeat yourself)
&lt;/h2&gt;

&lt;p&gt;DRY stands for "Don't repeat yourself", which, as the name suggests, aims to eliminate redundancy. However, does this mean you should never have the same code twice? Not necessarily. A good guideline is the Rule of Three: if you're writing the same code for the third time, it's probably time to de-couple, refactor or abstract the problem. Consider future maintenance — do you really want to update multiple code sections when something changes?&lt;/p&gt;

&lt;p&gt;By the way, did you know that there is also the opposite of DRY: WET - Write Everything Twice?&lt;/p&gt;

&lt;h2&gt;
  
  
  YAGNI (You Aren’t Gonna Need it)
&lt;/h2&gt;

&lt;p&gt;YAGNI means "You Aren't Gonna Need it", which in any case does not apply to this principle. When developing a feature, it can be tempting to add extra functionality for potential future use. You might anticipate future needs or create interfaces with additional functions, just in case. YAGNI advises focusing solely on what is needed right now. Plans often change, and what seems necessary today may be irrelevant tomorrow. Design for adaptability, but don't build more than what's required.&lt;/p&gt;

&lt;h2&gt;
  
  
  SOLID
&lt;/h2&gt;

&lt;p&gt;The SOLID principles are a set of five principles aimed at making software designs more understandable, flexible, and maintainable. They were developed by Robert C. Martin, Bertrand Meyer, and Barbara Liskov, with the acronym popularized by Michael Feathers. Each letter stands for a specific principle. Even though the principles talk about classes, they can also be applied to frontend development - especially for components. In frontend development, applying SOLID helps create more modular, scalable, and maintainable components.&lt;/p&gt;

&lt;h3&gt;
  
  
  S - Single Responsibility Principle
&lt;/h3&gt;

&lt;p&gt;"There should be only one reason for a class to change. In other words, every class should have only one responsibility."&lt;/p&gt;

&lt;p&gt;If you have a component for a product overview &lt;code&gt;ProductOverview&lt;/code&gt;, this component should not include getting the products from a backend. Better have a service or another component like &lt;code&gt;ProductFetcher&lt;/code&gt; getting the data.&lt;/p&gt;

&lt;h3&gt;
  
  
  O - Open Closed Principle
&lt;/h3&gt;

&lt;p&gt;"Classes should be open for extensions but closed for modifications."&lt;/p&gt;

&lt;p&gt;For instance a &lt;code&gt;BaseButton&lt;/code&gt; button component defines basic styles and behaviour. When creating variations like &lt;code&gt;PrimaryButton&lt;/code&gt; or a &lt;code&gt;SecondaryButton&lt;/code&gt;, they extend the base component without changing it's core logic.&lt;/p&gt;

&lt;h3&gt;
  
  
  L - Liskov Substitution Principle
&lt;/h3&gt;

&lt;p&gt;"If a base class is a subtype of a super class, it should be possible to replace the super class with the base class without disrupting the behavior of the program."&lt;/p&gt;

&lt;p&gt;In other words, this means the base class should be usable wherever you expect the super class.&lt;/p&gt;

&lt;p&gt;Coming back to the button example, if you have a &lt;code&gt;IconButton&lt;/code&gt; that extends a &lt;code&gt;Button&lt;/code&gt; component. The &lt;code&gt;IconButton&lt;/code&gt; could be used everywhere where the &lt;code&gt;Button&lt;/code&gt; is implemented.&lt;/p&gt;

&lt;h3&gt;
  
  
  I - Interface Segregation Principle
&lt;/h3&gt;

&lt;p&gt;"Interfaces should be split such that clients only need to know about methods that are of interest to them. No client should be forced to depend on methods it doesn't use."&lt;/p&gt;

&lt;p&gt;If you have a component that needs to have specific data like user information. Don't pass a &lt;code&gt;user&lt;/code&gt; object with all possible data to the component, but just the values the component needs like &lt;code&gt;username&lt;/code&gt; and &lt;code&gt;name&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  D - Dependency Inversion Principle
&lt;/h3&gt;

&lt;p&gt;"High-level modules should not depend on low-level modules; both should depend on abstractions."&lt;/p&gt;

&lt;p&gt;API calls for example should be wrapped in services, so whenever the interface changes the component is not effected by that.&lt;/p&gt;

&lt;h2&gt;
  
  
  TSR (The Scout Rule)
&lt;/h2&gt;

&lt;p&gt;Though I call this TSR, "The Scout Rule", there isn’t any official abbreviation for it. In fact, it's referred to as 'The Boy Scout Rule' by Uncle Bob. Regardless of the name, I think it’s an excellent principle.&lt;/p&gt;

&lt;p&gt;The rule comes from the Scouts' motto: “Always leave the campground cleaner than you found it”. Applied to coding, it means leaving the codebase better than it was. Whenever you touch the code, take a moment to improve it: re-format the file, remove unused dependencies or css styles or refactor a complicated function. Regularly tidying up will make your codebase more readable and maintainable over time.&lt;/p&gt;

&lt;h2&gt;
  
  
  Further Readings
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Clean Code by Robert C. Martin&lt;/li&gt;
&lt;li&gt;&lt;a href="https://martinfowler.com/bliki/Yagni.html" rel="noopener noreferrer"&gt;https://martinfowler.com/bliki/Yagni.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.baeldung.com/solid-principles" rel="noopener noreferrer"&gt;https://www.baeldung.com/solid-principles&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://docs.getdbt.com/terms/dry" rel="noopener noreferrer"&gt;https://docs.getdbt.com/terms/dry&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.baeldung.com/cs/kiss-software-design-principle" rel="noopener noreferrer"&gt;https://www.baeldung.com/cs/kiss-software-design-principle&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>solidprinciples</category>
      <category>programming</category>
      <category>frontend</category>
      <category>webdev</category>
    </item>
    <item>
      <title>(Commit) Message in a bottle</title>
      <dc:creator>Tatjana</dc:creator>
      <pubDate>Tue, 20 Aug 2024 12:00:40 +0000</pubDate>
      <link>https://forem.com/developaw/commit-message-in-a-bottle-3853</link>
      <guid>https://forem.com/developaw/commit-message-in-a-bottle-3853</guid>
      <description>&lt;p&gt;Imagine: You just finished writing the perfect piece of code. Spending hours - probably days - making it shiny and clean. Following all the best practices. Even adding some documentation! And you know. This code is ready to enter the world. You lean back. Ready to commit your code. Ready to commit you code? Oh no... you need a commit message... How to summarize the world changing code you just created? The blinking cursor jeers you. Your head is blank. It feels like the world is waiting for your genius commit message. Your fingers move carefully and slowly across the keyboard. You start typing. Quickly. "new stuff". Commit. Push. And that's it.&lt;/p&gt;

&lt;p&gt;Can you relate to that? Than you're probably not alone.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why good commit messages matter
&lt;/h2&gt;

&lt;p&gt;But well-written and meaningful commit messages can be of advantage. They help you, future-you and other developers to understand what and how you built your project. And they help you to work faster. If you have a consistent structure of commit messages, you can automatically create changelogs or software versions. You could also automatically trigger build and publish processes.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conventional Commits
&lt;/h2&gt;

&lt;p&gt;Luckily there already is a specification that helps to create better commit messages: Conventional Commits. Sometimes this specification is also referred to as semantic commits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Structure of Conventional Commits
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;type&amp;gt;[optional scope]: &amp;lt;description&amp;gt;

[optional body]

[optional footer(s)]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;feat(auth): add new authentication role

Add role of 'Witch' - a role that magically gets access to every page

Refs: TICKET-1337
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Types
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;type&lt;/code&gt; is mandatory and gives a first hint on what the commit contains. The following types are defined in the Conventional Commit:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;feat&lt;/code&gt; - introducing/removing a new feature&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fix&lt;/code&gt; - repairing a bug&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;build&lt;/code&gt; - adding/updating build system or external dependencies&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;chore&lt;/code&gt; - updating internal code, no production code change (e.g. initial commit, change &lt;code&gt;.gitignore&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ci&lt;/code&gt; - changing CI configuration&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;docs&lt;/code&gt; - adding/updating documentation&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;style&lt;/code&gt; - updating the code without changing the meaning (formatting, white-spaces, &amp;amp;c.)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;refactor&lt;/code&gt; - refactoring code&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;perf&lt;/code&gt; - improving performance&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;test&lt;/code&gt; - adding/updating tests&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sidenote: If you're more the picture-type, you could think about using &lt;a href="https://gitmoji.dev/" rel="noopener noreferrer"&gt;gitmoji&lt;/a&gt; as types.&lt;/p&gt;

&lt;h4&gt;
  
  
  Scope
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;scope&lt;/code&gt; is optional. It gives more information about where in the code the change is located. This could be a topic like &lt;code&gt;authentication&lt;/code&gt; or even a file like &lt;code&gt;auth-roles.ts&lt;/code&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  Description
&lt;/h4&gt;

&lt;p&gt;In addition to the &lt;code&gt;type&lt;/code&gt;, the &lt;code&gt;description&lt;/code&gt; is also mandatory. It is in an on point summary of what the commit contains.&lt;/p&gt;

&lt;h4&gt;
  
  
  Body
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;body&lt;/code&gt; is reserved for providing additional contextual information like a motivation or a more detailed description of the commit. The &lt;code&gt;body&lt;/code&gt; is optional.&lt;/p&gt;

&lt;h4&gt;
  
  
  Footer
&lt;/h4&gt;

&lt;p&gt;The &lt;code&gt;footer&lt;/code&gt; is also optional. Each commit message can have various footers. Each footer starts with a word token, followed by either a &lt;code&gt;:&lt;/code&gt; (or &lt;code&gt;#&lt;/code&gt; separator) and afterwards a string.&lt;/p&gt;

&lt;p&gt;Footer tokens can be e.g. &lt;code&gt;Refs&lt;/code&gt;, &lt;code&gt;Closes&lt;/code&gt;, &lt;code&gt;Acked-by&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you want to add a ticket number to your commit message. You can use the footer for that.&lt;/p&gt;

&lt;h4&gt;
  
  
  Breaking Change
&lt;/h4&gt;

&lt;p&gt;Breaking Changes can be introduced in two ways. Either with an &lt;code&gt;!&lt;/code&gt; after the &lt;code&gt;scope&lt;/code&gt; and right before the &lt;code&gt;:&lt;/code&gt; or with a footer that has &lt;code&gt;BREAKING CHANGE&lt;/code&gt; as a token and is followed by &lt;code&gt;:&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Tense of description/body-texts
&lt;/h3&gt;

&lt;p&gt;The Conventional Commit specification doesn't include rules about the tense for the description or the body text.&lt;/p&gt;

&lt;p&gt;Normally you find the texts in simple present or in the will-future.&lt;/p&gt;

&lt;p&gt;For the simple present form imagine that the text would start with &lt;code&gt;The commit&lt;/code&gt;. The describing verb then would be something like &lt;code&gt;adds&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;feat(auth): adds new authentication role
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the will-future form the text would start with &lt;code&gt;The commit will&lt;/code&gt;. The describing verb then would be something like &lt;code&gt;add&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;feat(auth): add new authentication role
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I personally prefer the will-future form. But I also think it's something where you can adapt to the majority of the team.&lt;/p&gt;

&lt;h3&gt;
  
  
  Conventional Commit in IntelliJ
&lt;/h3&gt;

&lt;p&gt;If you're using an IntelliJ product and you want a little bit support with your conventional commit message. I can recommend the Conventional Commit plugin from Edoardo Luppi. See&lt;br&gt;
&lt;a href="https://plugins.jetbrains.com/plugin/13389-conventional-commit" rel="noopener noreferrer"&gt;https://plugins.jetbrains.com/plugin/13389-conventional-commit&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Inspired by
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.conventionalcommits.org/en/v1.0.0/" rel="noopener noreferrer"&gt;https://www.conventionalcommits.org/en/v1.0.0/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13" rel="noopener noreferrer"&gt;https://gist.github.com/qoomon/5dfcdf8eec66a051ecd85625518cfd13&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://dev.to/safdarali/good-commit-vs-your-commit-how-to-write-a-perfect-git-commit-message-59ol"&gt;https://dev.to/safdarali/good-commit-vs-your-commit-how-to-write-a-perfect-git-commit-message-59ol&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>git</category>
      <category>conventionalcommit</category>
      <category>learning</category>
    </item>
  </channel>
</rss>
