<?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: Emphie</title>
    <description>The latest articles on DEV Community by Emphie (@emphie).</description>
    <link>https://dev.to/emphie</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%2Forganization%2Fprofile_image%2F5204%2F023e57d2-8f9f-4bbf-8b87-276a145bd1e0.jpg</url>
      <title>DEV Community: Emphie</title>
      <link>https://dev.to/emphie</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/emphie"/>
    <language>en</language>
    <item>
      <title>Programmers, beware! Designers attack!</title>
      <dc:creator>Mateusz Zdrzałek</dc:creator>
      <pubDate>Wed, 31 May 2023 09:55:00 +0000</pubDate>
      <link>https://dev.to/emphie/programmers-beware-designers-attack-33oa</link>
      <guid>https://dev.to/emphie/programmers-beware-designers-attack-33oa</guid>
      <description>&lt;p&gt;&lt;strong&gt;Obligatory&lt;/strong&gt; (my editor made me add it) &lt;strong&gt;Disclaimer&lt;/strong&gt; 😉&lt;br&gt;
&lt;em&gt;All scenarios presented in this article are intended purely for humorous purposes and reflect the personal opinions of the author. The intention is not to offend anyone or specifically target real situations or projects. Any resemblance to actual events or projects is purely coincidental.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;Are you familiar with that feeling when you come across a design that immediately triggers a cascade of expletives in your mind, making you question every decision that brought you to that particular moment? No? Well, consider yourself fortunate. Certain design practices have the uncanny ability to evoke such reactions from front-end developers. Regrettably, encountering one of these design challenges in a project often implies a high likelihood of encountering more. In this article, we will delve into the realm of designs that pose significant obstacles during development. Brace yourself for an insightful journey into the world of frustrating design choices. Let's embark on this adventure together!&lt;/p&gt;

&lt;h2&gt;
  
  
  Diagonal lines
&lt;/h2&gt;

&lt;p&gt;Let's dive into a common predicament that many web developers face, regardless of their experience level. CSS, known for its love affair with rectangles, tends to make life difficult when it comes to anything else. You can squeeze out some rounded corners if you're lucky, but anything beyond that requires delving into the realm of hacky solutions. And that's exactly what we're about to explore. Picture this: a well-intentioned designer decides to spice things up with a "dynamic" and "interesting" divider between different sections of a website.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwuxi3cc5b5r279458in9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwuxi3cc5b5r279458in9.png" alt="A website design with a diagonal divider"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;There are numerous approaches to tackle this problem, but my personal preference would be to employ an SVG triangle, as demonstrated in the illustration below. Implementing this solution isn't overly complicated, but &lt;strong&gt;how should it behave when scaling the browser&lt;/strong&gt;? This crucial consideration should be in every designer's mind when creating any application element. Should the triangle maintain a fixed height or scale down accordingly? How will it affect the elements positioned below it? These are the pivotal questions that must be addressed in the design notes if the designer chooses to incorporate this element.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylk1am08hgjdcl6v2z75.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fylk1am08hgjdcl6v2z75.png" alt="Illustration. Square and triangle under it on the left and two different scaling suggestions on the right."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Floating elements
&lt;/h2&gt;

&lt;p&gt;I can’t count how many times I had to deal with this one. Picture this scenario: the designer sees a bit of empty space on the page and starts thinking: “How can I make it more interesting?”, after exactly 0.01 seconds he figures it out: “Let’s add some floaty stuff and make the devs hate me!”.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67se2b2ba1k9wxq9h6f8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F67se2b2ba1k9wxq9h6f8.png" alt="Block of text with image inside. There are floating icons over the image."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hate them so much 🥲 Those things are impossible to make them responsive. Usually, I just implement them on desktops, pray that they work on all the desktop screen sizes and completely remove them on mobile and tablets.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tgcgetblox09j31v5mn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3tgcgetblox09j31v5mn.png" alt="Illustration. Image between text with icons fitting the desktop on the left and icons outside the screen on mobile on the right."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Inconsistent components
&lt;/h2&gt;

&lt;p&gt;Here is another scenario. Your team has dedicated an entire week to diligently implementing the sleek and modern form components meticulously crafted by your designer. As the next sprint kicks off, you eagerly await the designs for a new contact page, only to be greeted by a jarring sight. The designer, seemingly in a quest for uniqueness, has opted for completely different components on this particular page. Faced with this situation, you have two possible routes to take:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Take a break to cry in the toilet and implement a second set of components to confuse the rest of the devs working on the project&lt;/li&gt;
&lt;li&gt;Try to persuade the designer to use the already implemented elements, fail at it and finally go with route no. 1&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4bjx2s5pokqbnpf33h6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc4bjx2s5pokqbnpf33h6.png" alt="Two forms on top of each other. Each has a different styling."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Untranslatable design
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4hrymsm72vwr026tc8x4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4hrymsm72vwr026tc8x4.png" alt="Block of text within a gradient box. Image behind it."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's another familiar scenario that frontend developers often encounter. Imagine you're working on a multilingual page, and everything seems to be going smoothly with the design in the English version. However, as soon as you delve into different languages, the trouble begins to rear its head. Take a glance at the design above: a visually appealing offset image positioned behind a text box. Yet, when you switch to a language with more condensed text, such as Chinese, or one with wider text, like German, things start to appear a bit off.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fffd6kfmmj60bf2vjlx1l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fffd6kfmmj60bf2vjlx1l.png" alt="Illustration. Long “German” text on the left, short “Chinese” text on the right."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So, how can we address this issue effectively? Well, the key here is open communication and collaboration with the designer. It's essential to consult with them and discuss potential solutions. And here's the twist: we might just need to make those delightful language-specific adjustments. Oh, the joy of adding complexity and messiness to our code! Who needs streamlined and clean code anyway, when we can have a tangled web of exceptions? However, by actively collaborating with the designer, we can find the right balance between accommodating different languages and maintaining code cleanliness. Together, we can navigate these challenges and ensure that the design looks fantastic, regardless of the language used.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ending notes
&lt;/h2&gt;

&lt;p&gt;One of the fundamental aspects of working with designers is creating a collaborative environment and ensuring a seamless exchange of ideas and experiences. As a programmer involved in a project, it's crucial to actively participate in the design process. By providing thoughtful notes and explaining your reasoning behind them, you can save valuable time by avoiding the need for extensive revisions or complicated design implementations. It's important to acknowledge that as a developer, you may not always have the final say in design decisions. After all, applications are built for users, not for developers. Keeping this perspective in mind will help foster a user-centric approach and ensure the ultimate success of the project. Remember, effective collaboration and embracing the user's perspective are key ingredients for creating remarkable applications!&lt;/p&gt;

&lt;p&gt;The example design used in this article is available here: &lt;a href="https://www.figma.com/file/ed9Ol9c4H2QAbYLtqvNodb/Programmer-Hell?type=design&amp;amp;node-id=0%3A1&amp;amp;t=CyAz3cN5nluGW3yl-1" rel="noopener noreferrer"&gt;Figma Design&lt;/a&gt;. Send it to all your designer friends to either teach them something or just have a laugh! Those are only some of the annoying elements to code. Are you interested in learning more? Let me know in the comments because believe me, I have a lot more of them…&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>design</category>
      <category>frontend</category>
      <category>programming</category>
    </item>
    <item>
      <title>5 topics you should touch on during the recruitment process</title>
      <dc:creator>Maciej Płatek</dc:creator>
      <pubDate>Thu, 20 Apr 2023 09:46:53 +0000</pubDate>
      <link>https://dev.to/emphie/5-topics-you-should-touch-on-during-the-recruitment-process-3hgh</link>
      <guid>https://dev.to/emphie/5-topics-you-should-touch-on-during-the-recruitment-process-3hgh</guid>
      <description>&lt;p&gt;The recruitment processes can be weary and after answering countless questions you only think about leaving the interview, but you should never lose an opportunity to ask your interlocutors some questions. Why? There are a couple of reasons. First of all, there are a lot of things you should know before you accept the job offer.  Another reason is more practical, when you are asking questions you look less intimidated and more experienced and so why not score some more points?&lt;/p&gt;

&lt;p&gt;It’s important, however, to keep in mind that you shouldn't ask technical questions to HR people and vice versa, which can lead to uncomfortable situations. If you want to address any technical doubts you can ask if you may rise them on the next step of the recruitment process or maybe the recruiter can get you in touch with someone who can answer them. &lt;/p&gt;

&lt;p&gt;I don’t want to crush you with an overwhelming list of all possible questions, because it may bring only more confusion. I present to you which topics you should stick to during the conversation to finish it with the most possible amount of information that should be handy. &lt;/p&gt;

&lt;h2&gt;
  
  
  1. Work organization
&lt;/h2&gt;

&lt;p&gt;If you think about work organization, probably the first thing that comes to your mind is how your typical work day will look like. And that's the correct approach because that defines how your life will be going. Ask about hours, is it typical nine to five? Are there any office hours? Or maybe the company is totally flexible and you only should stick to the meetings? After you get the answer you will be sure if such day's composition suits you. So we already covered the meeting topic and to be frank - meetings can be harsh. Ask how many meetings you are scheduled to attend in a week. Some people prefer fewer meetings and if you are not sure what your preferences are - trust me, you prefer fewer ;) &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feuaz37xblq2woxas1eff.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feuaz37xblq2woxas1eff.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Usually, based on the job offer, you already know if it is a remote, stationary or hybrid position, but even so, you should ask about that. Sometimes companies interpret remote jobs as “2 times a week in an office” or hybrid as “1 time a month from any location”. So better be sure than sorry. If you are expected frequently in an office, ask for free parking, because that can be a really big struggle in cities. &lt;/p&gt;

&lt;p&gt;At this point you should know where and how you will work, so your next concern is equipment. Will the company provide you with a brand-new Macbook Pro? Can you expect to expand your home office to 8 monitors? Are peripherals even an option? Or will you need to use your old PC with a keyboard that is a house for a family of spiders?&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Responsibilities and technicalities
&lt;/h2&gt;

&lt;p&gt;Technical people should have technical responsibilities, that is obvious. Or at least it should be…but it’s not always the case. That’s why you should always ask about your responsibilities - what you need to do from starting working on a task till you mark it as “Done”. Will you be responsible for one project? Maybe besides the project, you are expected to handle something extra? Be inquisitive about it, and stick to this topic until your curiosity is satisfied.&lt;/p&gt;

&lt;p&gt;After you finish the cross-examination about responsibilities, ask more specific questions. What does the technology stack look like? Which version of the framework is currently used? Unless you like working with legacy code, that is a good sign if a company uses one of the latest versions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgqdhlygxfdec5cplqqk.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqgqdhlygxfdec5cplqqk.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another good idea is to ask about some advanced subjects. Is there Continuous Integration/Continuous Delivery used? How big is the test coverage? Are you working in Test Driven Development? Such questions will get you some bonus points. &lt;/p&gt;

&lt;h2&gt;
  
  
  3. Team organization
&lt;/h2&gt;

&lt;p&gt;After you get knowledge about your responsibilities, now is the time to ask about people who will be sharing them with you. Will you be working in a team? How big is the team? Do teams cooperate on the same product? What roles do people have in your team? It is really important to know that. Workflow varies significantly between a team of 5 programmers and a team of 3 programmers, QA and Product Manager.&lt;/p&gt;

&lt;p&gt;The next step will be to ask about the methodology the team is working on. Is it Agile? Maybe Scrum? Waterfall? Or some in-house implementation of principles? Trust me it is more important than you can think. If the recruiter is avoiding the answer then you can assume that something is wrong with the team organization (or it's not for just one particular project!).&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Your future
&lt;/h2&gt;

&lt;p&gt;Your future should always be your concern, even if you are treating the company as a temporary stop. Courses, conferences, training, and certifications are the things that can positively affect your future and have a really good impact on your career. For junior developers such opportunities can be even more valuable than financial benefits. Ask if there is any budget for such activities. &lt;/p&gt;

&lt;p&gt;On the other hand, consider asking about your career in the company. How often can you expect an evaluation meeting where you can ask about a pay raise? Can you get a promotion to higher positions? Don’t be afraid to ask that, it will not be considered rude, but rather appreciated that you are looking forward to developing and planning to build a career path.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Benefits and events
&lt;/h2&gt;

&lt;p&gt;The last position on our list is focused on benefits and events. Benefits consider all kinds of bonuses you can expect from a company. For example, it can be private insurance, private healthcare, a lunch card or some kind of sports card. It varies between companies, some of them are giving you a lot of benefits, while others prefer giving you more on your paycheck.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d6ecfqzrcwfk6ekmj7b.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9d6ecfqzrcwfk6ekmj7b.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Other things considered bonuses are company events. Such an event can be a typical activity that is helping build bonds with a team, so parties in restaurants, go-karts, bowling etc. Even if you are a hardcore introvert and you have no interest in them you should know what to expect. But social events are not the only activity you can expect a company to host. Ask about a hackathon or some kind of internal knowledge-sharing meeting. &lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;Repeating “don’t be afraid to ask” can be a good summary of my pieces of advice list ;).&lt;/p&gt;

&lt;p&gt;Treat recruitment meetings as a source of information, both for the recruiter and you. Before accepting a position be sure that there are no unknowns. This is especially important if you are in more than one recruitment process because you shouldn’t decide on an offer only salary-wise. Asking important questions should get you a brief understanding of how a company is doing and if it is the right place for you.&lt;/p&gt;

&lt;p&gt;Good luck with your next job interview, I’m sure that you will make a good impression!&lt;/p&gt;

</description>
      <category>interview</category>
      <category>career</category>
      <category>programming</category>
      <category>job</category>
    </item>
    <item>
      <title>Monorepo - when to choose it for your project? 5 heuristics worth considering</title>
      <dc:creator>Adrian Piętka</dc:creator>
      <pubDate>Thu, 09 Feb 2023 10:54:00 +0000</pubDate>
      <link>https://dev.to/emphie/monorepo-when-to-choose-it-for-your-project-5-heuristics-worth-considering-1jn0</link>
      <guid>https://dev.to/emphie/monorepo-when-to-choose-it-for-your-project-5-heuristics-worth-considering-1jn0</guid>
      <description>&lt;p&gt;Only a few years ago, I kept everything that was connected to the project in one repository. But then dividing projects into smaller parts became the norm. It was a fascination with microservices -  every service was put into a new repository.&lt;/p&gt;

&lt;p&gt;This approach caused several problems like versioning and compatibility, duplication of the code, dependent implementations, and multiple coding standards, even though we kept all the repositories as one, etc... &lt;/p&gt;

&lt;p&gt;Nowadays, more and more frequently, we go back to the monorepo pattern - only one repository. It’s not in pursuit of the trend, rather for me, it’s an additional technique that I can use when it will be useful. &lt;/p&gt;

&lt;p&gt;Should we choose the monorepo pattern in a new (or already existing and under development) project? In this article, I will try to explain five heuristics worth using for discussion and decision-making. &lt;/p&gt;

&lt;p&gt;But be careful!&lt;/p&gt;

&lt;p&gt;Don’t instantly use this list with your team! My intention is to give you inspiration for preparing your own list. Then to develop it, transform it. In the end, various conditions can affect the decisions.&lt;/p&gt;

&lt;p&gt;Usually, it’s not easy to answer the question “is monorepo suitable for my project?”.&lt;/p&gt;

&lt;p&gt;With the below list, you’ll be a step ahead when you don’t know where to start. &lt;/p&gt;

&lt;h2&gt;
  
  
  Do I have technological consistency?
&lt;/h2&gt;

&lt;p&gt;During the requirements analysis and architecture design phases we are able to see the boundaries between particular parts of the project very quickly. It can occur for various reasons eg.&lt;br&gt;
different business context another scaling model a specific way of data processing&lt;/p&gt;

&lt;p&gt;This is the moment to extract particular parts of the project and map them to applications with specific purposes. It’s also worth asking yourself a question at this moment... &lt;/p&gt;

&lt;h2&gt;
  
  
  Is it still going to be the same programming language?
&lt;/h2&gt;

&lt;p&gt;If the answer to this question is yes, then we have technological compliance. It’s important information and if we have it, it’s worth keeping the applications together. &lt;/p&gt;

&lt;p&gt;Going further, it’s worth asking another question... &lt;/p&gt;

&lt;h2&gt;
  
  
  Is it still going to be the same framework?
&lt;/h2&gt;

&lt;p&gt;If the answer to this question is yes, then we have perfect technological compliance.&lt;/p&gt;

&lt;p&gt;In this case, we will probably be using the same tools: CLI applications (supporting code generation), package manager, statistical analysis of the code tool, the code formatting tool, etc...&lt;/p&gt;

&lt;p&gt;There is no need to introduce the same configurations or change them later for a few repositories. Let’s keep them together. &lt;/p&gt;

&lt;h2&gt;
  
  
  Do I share the code between applications?
&lt;/h2&gt;

&lt;p&gt;Let me tell you a story. A project that I was a part of started struggling with sharing API interfaces. We wanted to be common and reflect the current API state. &lt;/p&gt;

&lt;p&gt;In the beginning, we could have taken the submodule principle. The ones we know from Git. But it’s still a separate repository that you need to take care of. Many times someone forgot to introduce an appropriate fix after the changes in API... It simply didn’t work. &lt;/p&gt;

&lt;p&gt;Later on, code fragments appeared that were so big they could have been external libraries. It’s still the same problem. We add a new function to the library and we need to update it everywhere to the newest version.&lt;/p&gt;

&lt;p&gt;Some new Merge Requests, appropriate scaling order… Eh… Pain in the neck. &lt;/p&gt;

&lt;p&gt;Private libraries, published and applied on the basis of external dependencies generated more general service than the value added from the function. &lt;/p&gt;

&lt;p&gt;When I see code duplication between applications I usually want to extract it to the independent library. The idea is good but not without, often unforeseen, flaws. Cycling of versions, backward compatibility (because we don’t want to use a newer version yet), and bouncing up versions in applications that use the library. It’s quite a lot of things to take care of. &lt;/p&gt;

&lt;p&gt;Monorepo gives a faster service for this kind of shared code. Especially if we are the only ones using it. An actual duplication shouldn’t be in a library that is used outside our project. &lt;/p&gt;

&lt;p&gt;It’s just a reusable code in our system. Nowhere else. &lt;/p&gt;

&lt;h2&gt;
  
  
  Do I have a similar implementation model (CI/CD)?
&lt;/h2&gt;

&lt;p&gt;In certain moments a few of our applications are implemented into a test or production environment.&lt;/p&gt;

&lt;p&gt;Perhaps the implementation process is identical and for example, it may consist of the below steps (example strongly generalized) for all of our applications:&lt;br&gt;
Build a Docker Image with an application&lt;br&gt;
Publish an image in Docker Registry&lt;br&gt;
Update service to the new version in Amazon ECS&lt;/p&gt;

&lt;p&gt;When the implementation process matches between applications, then we have a good control point. We will be able to use automation scripts again, without the need for copying them between repositories. &lt;/p&gt;

&lt;p&gt;One Jenkins Job was able to implement every application from a big system. A joint process for all of the applications was prepared. Thanks to that, when a change in the process appeared (eg. adding a notification on Slack) then it was immediately used in every implementation. &lt;/p&gt;

&lt;h2&gt;
  
  
  Do I need to sustain compatibility between applications?
&lt;/h2&gt;

&lt;p&gt;Sustaining compatibility between communicating applications (with API, and queues) is not an easy challenge. When a new structure of data appears or the existing one changes, there is a need for adequate preparation - eg. supporting new and old structures in a temporary manner. &lt;/p&gt;

&lt;p&gt;The matter may be even more complex when the structure isn’t dependent on us and it needs to be suited to a cycle. &lt;/p&gt;

&lt;p&gt;Implementation of the all necessary changes between projects at the same time becomes easier. For example, adding one necessary box. We can deliver everything at the same time and be certain that the actual state of the code as it allows us to use the change in all of the applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is there only one application development team?
&lt;/h2&gt;

&lt;p&gt;I worked for the teams that were sustaining polyrepo for the project. Every microservice had its own repository. &lt;/p&gt;

&lt;p&gt;Maintaining attention with constant changes being introduced by the team was exhausting. I had seven repositories that I needed to watch. I was constantly looking for changes, updating each of them, rebuilding the application, or installing new packs…&lt;/p&gt;

&lt;p&gt;Not to mention introducing new people to repositories. I can remember the look on their faces when there was a need of installing seven different applications so that the project can operate in its entirety. Sometimes there was no need to do that but as a team, we each looked after all of the applications, so in the end everyone could program everywhere else. &lt;/p&gt;

&lt;p&gt;In monorepo it’s easier to organize the automation of that kind of process. Installing the project, starting it, or updating it after the implemented changes, go much smoother. Especially when we use the tools supporting working with monorepo eg. rush. &lt;/p&gt;

&lt;h2&gt;
  
  
  Monorepo - is it a good idea?
&lt;/h2&gt;

&lt;p&gt;Remember that every project, team, or business expectation affects decision-making. If after a few months of work, we start to feel uncomfortable working with monorepo / polyrepo then it's worth having retrospective thoughts and thinking of improvements. &lt;/p&gt;

&lt;p&gt;These problems can always be solved differently. It can occur that CI/CD implementation looks a little different, but it’s still worth putting the application in with the rest in monorepo. &lt;/p&gt;

&lt;p&gt;Sometimes creating suitable scripts or doing an additional pipeline in CI/CD is all that it takes. And sometimes we are gonna be forced to change our approach. &lt;/p&gt;

&lt;p&gt;My propositions are not set in stone. They are points to be discussed. Their main goal is to encourage team talks about it. &lt;/p&gt;

&lt;p&gt;And what do you put attention to? Do you have any control points?&lt;/p&gt;

</description>
      <category>vibecoding</category>
      <category>watercooler</category>
    </item>
    <item>
      <title>Source of most problems in projects? Miscommunication!</title>
      <dc:creator>Michał Żurakowski</dc:creator>
      <pubDate>Wed, 16 Nov 2022 07:43:27 +0000</pubDate>
      <link>https://dev.to/emphie/source-of-most-problems-in-projects-miscommunication-19lj</link>
      <guid>https://dev.to/emphie/source-of-most-problems-in-projects-miscommunication-19lj</guid>
      <description>&lt;p&gt;Poor choice of technology, Friday afternoon releases, infrastructure problems, package-dependent conflicts, legacy code... or as I call them – developers’ nightmares. There are many problems with the projects we’re working on. Surprisingly, the most common, is at the same time, the most obvious. Even Robert Plant from Led Zeppelin sang about it in one of his songs... yeah, I am referring to ‘Communication Breakdown’ ;) – an issue that is relevant even in the 21st century.&lt;/p&gt;

&lt;h2&gt;
  
  
  Open-secret
&lt;/h2&gt;

&lt;p&gt;I have worked as a dev for over 6 years now and believe me, I have come across communication issues too many times, more than I would have liked. Let me share a few stories and some thoughts with you, it may help you look at it from a different perspective.&lt;/p&gt;

&lt;p&gt;Ok, time for some ‘revealing’ insight – in my opinion, the source of most communication problems is the difference in people's characters. People are different and being on the same wavelength isn’t common. What one person perceives as a clear message, is often ambiguous and confusing to someone else.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NyLoiKF5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/111sczcdtrv6je2uuzet.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NyLoiKF5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/111sczcdtrv6je2uuzet.jpg" alt="" width="620" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Many times, when I was sure that I gave a detailed description of the problem, I later realized that my message was too complicated... and often too long! Similarly, I remember situations when I was given brief and vague information, resulting in a lot of time spent trying to understand someone else's riddle. After reading the text a few times, I still wasn’t sure if I understood all the information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep it &lt;del&gt;real&lt;/del&gt; clear!
&lt;/h2&gt;

&lt;p&gt;Finding a balance and a happy medium is key. It’s important to avoid unnecessary details that are clouding your message. You should remember that simple requests like “set an environment” or “make a nice contact form” could not be enough. It could be fine when you have known and worked with someone for a long time and you have built a mutual understanding, but when you are texting someone you have known only for a few weeks, or with an inexperienced intern, the end result of your simple request, may be something quite unexpected...&lt;/p&gt;

&lt;p&gt;I have noticed that dividing your message into sections and subsections can work miracles. It’s good to split your message with titles and headings, or with formatting features. Text editing tools are very useful for making the message more digestible to the reader.&lt;/p&gt;

&lt;p&gt;Pro tip – read your message before you send it. I bet that in 9 out of 10 cases you will correct some typos or change some sentences. If you follow these rules you will avoid some serious f*ups.&lt;/p&gt;

&lt;h2&gt;
  
  
  Story time!
&lt;/h2&gt;

&lt;p&gt;Let me tell you a story my friend shared with me. It is about communication issues leading to a monumental f*up. He worked for a small company with just one requirement – to use Git. Some time ago two juniors (but with some experience) were given a task to code a simple web page. Let’s be honest – it’s a week of work for an intermediate dev. And how did our heroes handle this project? Well, they met, divided the tasks, put the headphones on, and focused on themselves for five days. On Friday they reviewed their progress. It turned out they failed to implement a few critical elements. They both thought that the other person would be handling those specific things. It ended with them working all weekend to finish the project, only just before Monday’s deadline, with the whole office making fun of them. Both did not work there for too much longer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Commas, in wrong, locations ;) and talking to people
&lt;/h2&gt;

&lt;p&gt;What may appear to be foolish, but is not, is not paying attention to punctuation. Punctuation is very important! It’s crucial for text messaging. I mean - you don’t have to become the Stephen King of the company’s Slack, but it’s worth thinking about how many ways your message could be interpreted. For example, the sentence “install Visual Studio Code npm Angular Git Docker We will configure later” is not very clear. By using appropriate punctuation you will make sentences readable, as per the author’s intention.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9zO9oBIy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wc4wfuc96lg5mox8p6d5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9zO9oBIy--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wc4wfuc96lg5mox8p6d5.jpg" alt="" width="600" height="327"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s the same with spoken language. Ambiguity can lead to miscommunication, but more than that, it has the potential to affect working relationships if done without due care. In face-to-face meetings, it is often a necessity to adapt to others. Of course, you could scold an intern for not making a backup, but you should ask yourself a question, what would you achieve with that? You will most certainly ruin your relationship and jeopardize the chances for successful future cooperation.&lt;/p&gt;

&lt;p&gt;Time for my second piece of clichéd advice - treat others the same way you would like to be treated. As I mentioned earlier, people are different, and it’s worth keeping that in mind. Some enjoy it when Jean Michel Jarre tickles their eardrums with his music. Others love the gentle sounds of Napalm Death. Some get annoyed with people invading their personal space, while others are driven mad by people who avoid them. It’s worth being aware of others’ differences and developing empathy within ourselves. I’m not talking about pretending to be someone you’re not. What I mean is to respect and understand others to make sure they feel comfortable around you. And that is the key to successful communication.&lt;/p&gt;

&lt;h2&gt;
  
  
  A few words at the end from... an introvert
&lt;/h2&gt;

&lt;p&gt;This text is from the perspective of a guy who has problems expressing his thoughts. But the things I highlighted above are helping me improve my communication. I feel that being aware of your weak points is the first step to improvement. The next step is learning from your mistakes and then practicing to avoid repeating them.&lt;/p&gt;

&lt;p&gt;So don’t give up, even after f*ups. You’ll get better with every message and meeting!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--C7xZ8rgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zn58zkaukazjwg60m6v.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--C7xZ8rgw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1zn58zkaukazjwg60m6v.jpg" alt="" width="393" height="330"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>devjournal</category>
      <category>programming</category>
      <category>communication</category>
      <category>teamwork</category>
    </item>
    <item>
      <title>f*ups that made me a better programmer</title>
      <dc:creator>Michał Hadamik</dc:creator>
      <pubDate>Thu, 29 Sep 2022 09:58:41 +0000</pubDate>
      <link>https://dev.to/emphie/fups-that-made-me-a-better-programmer-4kil</link>
      <guid>https://dev.to/emphie/fups-that-made-me-a-better-programmer-4kil</guid>
      <description>&lt;p&gt;How about not spending your weekends on fixing bugs that could have been easily predicted and not rushing because you underestimated the time you will spend on a project? &lt;/p&gt;

&lt;p&gt;Well, read about my f*ups guide to learn from my mistakes and avoid your own! &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do backups regularly&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let me tell you a story. In one of my previous jobs, I was the person responsible for making manual backups for WordPress websites. I did it every month, but one month I forgot! Guess what happened... Yeah, our website server was attacked, I didn’t think it would be significant as I made backups regularly. I thought I could just upload the last version I had, but after checking the folder on the NAS server and looking for copies, I nearly had a mini heart attack! It transpired that that month, there were a lot of changes to the website. As a result, I spend two weekends making the changes and cleaning the server. I never forget to backup now!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faa8ytn8pw5x37cqcvja7.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faa8ytn8pw5x37cqcvja7.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
Pro tip – It is also good practice to make backups before making plugins and theme updates!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Double check the sandbox version with someone before releasing it&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We have all been in a situation when a client asked for “a little amendment”? Something along the lines of “Please, make this change quickly in the live environment, it’s small and won’t affect anything”. It’s an accident waiting to happen! You agree because it’s a “small” change/fix and of course, you decide not to test in the sandbox because it’s 4pm on Friday and all you can think about is the weekend. What could possibly go wrong? Well… everything!&lt;/p&gt;

&lt;p&gt;It happened to me a few times in my developer career, but the story I will remember forever happened on Christmas Eve… The client had asked to introduce some changes to a WordPress-based website. It wasn’t complicated but there were a few changes and very little time to implement. I still remember applying changes late in the evening when all of the guys from my team were already sipping drinks at the work’s Christmas party. I was trying to fix one tiny change that didn’t work, it became apparent that one of the elements had the ‘!important’ attribute added to its style. Of course, it was a great evening and a fantastic party (I DID NOT GET TO ENJOY). &lt;/p&gt;

&lt;p&gt;But I learned an important lesson from this - when you are pushing some changes that are not tested in the sandbox they won’t usually work. Finding issues can be quick but fixing them can take a long time, that time it resulted in my weekend starting at 7pm instead of 4pm!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41zzx0owun00aee0aprl.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F41zzx0owun00aee0aprl.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now I always remember to check the fixes, changes, and features in sandbox before deploying them. It is important to ALWAYS do it, even if it’s a “small” change. It’s also good practice to check the changes with someone else.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Take your time with the estimate&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;At the beginning of my career, when I received a project to do an estimate, I usually rushed it because I didn't want to spend a lot of time on this and of course, I didn't check the details of each element in the project. &lt;/p&gt;

&lt;p&gt;Time for the story number 3 ;) &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsvanpz82r0qsb2wnzlh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnsvanpz82r0qsb2wnzlh.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was working on finishing a website project for a client. The last part of the development was adding a blog section. Before I progressed with this piece of work, the PM asked for an estimate. Well... I didn’t analyse it properly nor did I ask any detailed questions. I just took a look at the designs and picked one in less than 2 minutes! During coding, it turned out that they were all supposed to have some extra features and be based on Google Analytics… long story short – a few questions and a couple of minutes spent on choosing the right design would have spared me a few hours of adapting the design to the website.   &lt;/p&gt;

&lt;p&gt;What did I learn from this? Always remember to take time to complete an estimation. Don’t ever think; “this page is very simple, just search box and a list of posts”, and instead ask the questions and pick a solution carefully. You will save yourself a lot of time in the long run!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Summary&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I’ve shared with you a few of the f*ups I’ve made over the years. I made mistakes and I am sure I will make more in the future. It’s impossible to avoid them because programming is so dynamic and ever-changing. But it’s always better to learn from somebody else’s mistakes instead of your own ;)&lt;/p&gt;

&lt;p&gt;Let me summarise, these tips will help you avoid mistakes in the future:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Remember to make regular backups &lt;/li&gt;
&lt;li&gt;Let somebody else check your work in a sandbox before deploying to production&lt;/li&gt;
&lt;li&gt;Don’t be in a rush to estimate the job, always research thoroughly&lt;/li&gt;
&lt;li&gt;Don’t deploy a product to production at 4pm on Friday... It will be 7am on Monday before you know it ;)&lt;/li&gt;
&lt;li&gt;If you don’t know something, do some proper research or ask your co-workers for advice.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading and I hope my f*ups help you avoid mistakes! &lt;/p&gt;

</description>
      <category>php</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>wordpress</category>
    </item>
    <item>
      <title>3 effective methods of learning new programming technologies (and tips on how to use them)</title>
      <dc:creator>Dariusz Cichorski</dc:creator>
      <pubDate>Wed, 31 Aug 2022 08:13:19 +0000</pubDate>
      <link>https://dev.to/emphie/3-effective-methods-of-learning-new-programming-technologies-and-tips-on-how-to-use-them-aio</link>
      <guid>https://dev.to/emphie/3-effective-methods-of-learning-new-programming-technologies-and-tips-on-how-to-use-them-aio</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Software development is a profession that requires great flexibility in the ever-changing world of technology and programming languages. It doesn't matter if you're just at the beginning of your career or if you're already an experienced dev, you'll have to adapt and learn new things.&lt;/p&gt;

&lt;p&gt;Here's a list of 3 effective methods of learning new technologies that you can use.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcerebk06mxmkmlsvbd6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flcerebk06mxmkmlsvbd6.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 1: Learn from video tutorials
&lt;/h2&gt;

&lt;p&gt;Video tutorials are a great way of learning new things. You can easily find free ones on popular video-streaming websites that will be enough for most cases. If you're unsure what exactly you should learn on your path of, let's say, front-end mastery, you can search for Bootcamp-type video tutorials curated by professionals. That will help you develop new skills along some predefined path.&lt;/p&gt;

&lt;p&gt;When starting learning from a video tutorial it's good to skim it before spending much time on it. There are many reasons the tutorial might not be suitable for you - it may not teach the things you're interested in or its style might not fit your preferences. If that's the case, don't waste your time on it and search for another one. The internet’s resources are endless, therefore it's worth learning how to pick the good ones.&lt;/p&gt;

&lt;p&gt;The important thing to note is that just watching videos is not enough. You can spend hours binge-watching and learn nothing. That's because the human mind always tries to save energy whenever it's possible and loses focus easily. To take the most out of watching video tutorials, don't rush it. Take the time you need to process the knowledge. If the tutorial takes 1 hour, it doesn't mean you have to finish it just as quickly. No time pressure, it's not a race! You'll benefit more from a learning process divided into days than rushing through one take.&lt;/p&gt;

&lt;p&gt;Usually, you're asked to code along to the video. That's a good idea in most cases, as it boosts learning straight away, but there are drawbacks to that! You are forced to constantly pause the video and it may lead to losing focus. If that's the case for you, I recommend fully focusing on only the part of the tutorial, as they are usually divided into shorter, 10-30min sections, and then after finishing it, trying to write the same code (or solve the same problem) as the teacher from memory. If you can't remember something, try googling it - this way you'll learn effectively and practice searching (which will quickly become beneficial). If you're unable to find the solution this way, rewind the video and get back to it.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcdkxag1iv79sos9fzkle.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcdkxag1iv79sos9fzkle.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 2: Learn from blog posts and written tutorials
&lt;/h2&gt;

&lt;p&gt;Another effective method of learning is reading blog posts and written tutorials. There are tons of those all over the internet. You can find ones created by respected teachers or code enthusiasts.&lt;/p&gt;

&lt;p&gt;Written tutorials are no different from videos when it comes to approaching the problem and building your knowledge, so they can be treated as an alternative. Naturally, everyone is different so it's down to personal preferences which method you will like more.&lt;/p&gt;

&lt;p&gt;The good thing about reading tutorials is that you can easily search through them (CTRL + F), which comes in handy in many situations and reduces the time needed to find something. What's more, you don't have to rewrite the code, as you can copy the snippets straight away. It's not always a good thing, as rewriting something may help in understanding and remembering it, so it's up to you to decide and use it as you need.&lt;/p&gt;

&lt;p&gt;The nature of online publications keeps them easy to create and maintain. That's great because if you're interested in some novelty technology, there's a big chance someone has already written something about it. This form of learning has an advantage over reading official documentation as it's more human-user-friendly and often written in the non-robotic language. Most of the time it's also covering real-world scenarios and it's easier to use that knowledge in your work.&lt;/p&gt;

&lt;h2&gt;
  
  
  Method 3: Learn from the official documentation
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnz6y22dgpkvuo7zkrra.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmnz6y22dgpkvuo7zkrra.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Another alternative for learning new technology is going through its official documentation. In contrast to written tutorials, official docs have a particular form, as they are written in the specialized, more robotic language, which often makes them sound uninteresting. This can often be a problem for beginner programmers and can lead to not fully understanding it, but there's another side of the coin - this &lt;em&gt;reference book&lt;/em&gt; form makes it great if you're already familiar with the technology and looking for some specific detail.&lt;/p&gt;

&lt;p&gt;The great advantage of docs over other types of materials is that it packs the most accurate answers to all potential questions in one place, which saves you time searching them in other places.&lt;/p&gt;

&lt;p&gt;Nowadays, good technology docs should contain a "Getting Started" guide, which often gives you a huge boost in getting on board with it and quickly learning the basics. Many other materials (video and written tutorials included) are based on them - or even just paraphrasing them. Despite that, docs may not be the perfect place to start for beginner programmers as they often assume that you already know a lot of programming fundamentals. This makes them great as an additional source of knowledge to tutorials or if you're learning a programming language, textbooks.&lt;/p&gt;

&lt;p&gt;The docs are perfect when you want to search for something specific. You often find yourself in a situation where you remember the function name and want to learn the details - that's when you should use the docs &lt;em&gt;search tool&lt;/em&gt; and you will be quickly redirected to the right place. It's always easier than trying to find it in a 700-page book or several hours-long video tutorials.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Those are 3 of the methods I've used the most while learning new technologies during my programming journey. It is very important to learn what method fits your preferences and is the most effective for you.&lt;/p&gt;

&lt;p&gt;It's worth mentioning that whatever method you use, it's crucial to practice everything on your own. Those methods are just boosters for the learning process, and they should always be considered support for practical training.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbsnd2o6szakto64mdwt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbsnd2o6szakto64mdwt.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Which methods of learning do you find the most effective and what are your opinions on them? The comment section is yours!&lt;/p&gt;

</description>
      <category>learning</category>
      <category>beginners</category>
      <category>productivity</category>
      <category>discuss</category>
    </item>
    <item>
      <title>5 things I wish I knew before starting serious development (a journey into code perfection)</title>
      <dc:creator>Dariusz Cichorski</dc:creator>
      <pubDate>Thu, 23 Jun 2022 10:00:43 +0000</pubDate>
      <link>https://dev.to/emphie/five-things-i-wish-i-knew-before-starting-serious-development-a-journey-into-code-perfection-2e3j</link>
      <guid>https://dev.to/emphie/five-things-i-wish-i-knew-before-starting-serious-development-a-journey-into-code-perfection-2e3j</guid>
      <description>&lt;p&gt;Writing code that does the job is easy. Writing a beautiful code that is worthy of being called clean could be more troublesome. There are many opinions about what a clean code is. Some say it should be elegant, nice and pleasant. Others say it should be easily readable. Whatever definition you find, you can notice that the idea is for the author to care about the code that's being created. &lt;/p&gt;

&lt;p&gt;According to Uncle Bob, the ratio between reading and writing code is equal to 10:1. Because of this, it's important to make sure the code meets the principles mentioned in this article (and many, many more that are not mentioned). Writing quality code is harder and takes more time, but trust me, it's a good investment.&lt;/p&gt;

&lt;p&gt;There are several rules that you can follow while writing code that will improve its quality and take you a step closer to clean code mastery.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffnmbt5nwnarqmrqgzb6f.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffnmbt5nwnarqmrqgzb6f.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Use names that represent your intentions
&lt;/h2&gt;

&lt;p&gt;Names are a fundamental part of writing code. There are names of the functions, parameters, classes, files, and folders. Using the right name can be crucial. Look at it as a time investment - it takes some, but it saves more.&lt;/p&gt;

&lt;p&gt;The name of the function or class should be an answer to every potential question - it should indicate why it exists, what it does and how it's meant to be used. If the name requires a comment it may be an indication it does not represent the intention. &lt;/p&gt;

&lt;p&gt;You can notice it's not easy to understand what the meaning of the field (even with the comment as the description):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;m&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// solving time&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The name &lt;em&gt;m&lt;/em&gt; does not explain anything - it doesn't indicate what the actual purpose of the field, and even the comment isn't precise enough. The below example of the name is much better as it answers every potential question about it and does not require any additional explanation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;solvingTimeInMinutes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The same goes for functions. What's the purpose of the function below?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculate&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="nx"&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="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;9&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;value&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;32&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;It's quite difficult to say, even though it's just a one-liner function. That's because the name and the parameter are not self-explanatory. Here's the same function, but represented with a clear intention:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fahrenheitToCelsius&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fahrenheit&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&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="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="mi"&gt;9&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;fahrenheit&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;32&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;To learn more about good naming practices search for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;programming naming conventions&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Avoid comments (until you really need them)
&lt;/h2&gt;

&lt;p&gt;A good comment can be a lifesaver. An unclear  one can be deceptive and cause confusion. Unnecessary comments should be avoided, as the clean code should be self-explanatory and should tell the story on its own. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv18zls1xp0i4wc9du8xg.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv18zls1xp0i4wc9du8xg.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here's an exaple of a very bad comment:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Always returns true&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;returnFalse&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="kc"&gt;false&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;The function above does not do what the comment says. Just imagine using a wrongly commented function in some real-world scenario. The consequences could be bad, right?&lt;/p&gt;

&lt;p&gt;Same goes for the below situation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Checks if player takes part in rating&lt;/span&gt;
&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;contexts&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;PlayerContext&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;RankPlayer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isActive&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's much better to restructure the code and use something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;takesPartInRating&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The instruction above is much cleaner than its previous version - it clearly explains its purpose without the need for a comment.&lt;/p&gt;

&lt;p&gt;But there's more than this - having code that regurarly uses comments as a sort of documentation requires more resources to keep it updated. You not only have to work on the code, but you also have to work on the comments to make sure they represent the intention behind the code. You also have to remember to keep them updated!&lt;/p&gt;

&lt;p&gt;Another example of poor practice is keeping the commented-out code in the repository. There's nothing worse than the code like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;player&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;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPlayer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;initializeSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// player.setSessionStartTime();&lt;/span&gt;
&lt;span class="c1"&gt;// player.setNewlyCreatedSession();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The other developers working on that code will think the commented-out part is an important one and it should be kept for some reason. This leads to keeping some old junk code in the codebase, which should be avoided. Instead of commenting on the code, it should be removed. &lt;/p&gt;

&lt;p&gt;In most cases seeing a comment means the code could be better, but there are some exceptions. One of them is a TODO comment.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// @TODO: integrate with amazing-service once it's ready&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doSomethingAmazing&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&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;TODO comments indicate tasks that should be done, but are impossible to do right now. It can be a reminder to remove old functions or an indication that some problem should be solved. Most of the IDEs have features that allow targeting TODO comments quickly - they should be regularly targeted and solved.&lt;/p&gt;

&lt;p&gt;Another example of a valuable comment is the one that describes the decision behind the code. Sometimes we are forced to use some frameworks or browser-specific stuff - in that case, a comment can be a lifesaver and reduce the time needed to understand it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Fix for scroll position computations&lt;/span&gt;
&lt;span class="c1"&gt;// See https://github.com/swimlane/ngx-datatable/issues/669 for details&lt;/span&gt;
&lt;span class="nf"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; 
  &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's important to get rid of any noise in the code, but also take advantage of the knowledge that some comments are valuable and can be helpful.&lt;/p&gt;

&lt;p&gt;To learn more about good comments practices and how to write code without the need for comments search for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;programming comments best practices&lt;br&gt;
programming self-documenting code&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Keep your code formatted
&lt;/h2&gt;

&lt;p&gt;You only get one chance to make a first impression. That's why you should really focus on the code formatting as it's the first thing everyone reading the code sees. It's an aspect that instantly makes a statement about code quality and its consistency. The code should always be perfectly formatted and it's every line polished.&lt;/p&gt;

&lt;p&gt;It's important to specify the rules of formatting code in the project to keep it consistent. Each project is different so the rules may also be different, but once we decide on them, they should be respected. Many tools can help to automatically format the code according to the rules.&lt;/p&gt;

&lt;p&gt;What do you think about the below code?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;  &lt;span class="kd"&gt;function&lt;/span&gt;  &lt;span class="nf"&gt;doSomethingAmazing&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&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;data&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;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loadData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executeImportantLogic&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;somethingHappening&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;

&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executeMoreImportantLogic&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;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;saveData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&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;The function above would compile without any problem, but is it even readable? It's formatted very poorly and it becomes impossible to understand. As you can see the indent level is not respected (or even specified), there are many unnecessary blank spaces and blank lines that make it impossible to effectively read it.&lt;/p&gt;

&lt;p&gt;We can format the function above like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doSomethingAmazing&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&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;data&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;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;loadData&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executeImportantLogic&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;somethingHappening&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;executeMoreImportantLogic&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;service&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;saveData&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;data&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;It's much better this way, right?&lt;/p&gt;

&lt;p&gt;It's important to stick to the guidelines of the language we use while formatting the code. Each language or framework comes with its own formatting standards that should be known and respected. Respecting them is crucial as it helps new team members in writing their first code in the project. With every new custom formatting rule, it becomes more difficult for newcomers to quickly adapt to it (and also for older team members).&lt;/p&gt;

&lt;p&gt;Creating code that works is not enough. To keep code clean we need to focus on its formatting, which will improve its quality.&lt;/p&gt;

&lt;p&gt;To learn more about code formatting search for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;code formatting best practices&lt;br&gt;
&lt;strong&gt;&lt;em&gt;insert your technology&lt;/em&gt;&lt;/strong&gt; coding style guide&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Keep your functions short (and their purpose straight)
&lt;/h2&gt;

&lt;p&gt;One of the main principles of creating functions should be to keep them short and simple. Functions should be easy to understand as they focus on one thing only. Honoring that rule will greatly reduce the time needed to understand it.&lt;/p&gt;

&lt;p&gt;It should also operate on one level of abstraction to prevent mixing up less important technical details with crucial logic. The abstraction in this case means a metaphorical layer in which we create the functions. If we had a function that creates a list and increments it, it would operate on two levels of abstraction: first for creating the list, second for incrementing it.&lt;/p&gt;

&lt;p&gt;Let's analyse the below function (but don't spend too much time on this):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;solveTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TaskSolution&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&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;player&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;playerService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPlayer&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;gamingProfile&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;profileService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createNewProfileForPlayer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&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;playerService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startSession&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="k"&gt;if &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;settingsService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;notificationsEnabled&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;notificationService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Player profile session started.&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="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;solutions&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;trainingService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getTaskSolutions&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;solutions&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;any&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;sol&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;sol&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;solution&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&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;trainingService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reportPlayerSolution&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;solution&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &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;settingsService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;notificationsEnabled&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;notificationService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Task completed!&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;achievementReached&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;achievementService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reportSolutionEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;solution&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;achievementReached&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&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;settingsService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;notificationsEnabled&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;notificationService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;notify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Achievement unlocked!&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="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;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1ybwh07o4fdtpqkor4n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1ybwh07o4fdtpqkor4n.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see the function above is not too long, but it fails the important principles we've covered before. Firstly, it does more than one thing. Secondly, it does not operate on one abstraction level - it mixes different abstraction levels. Also, there's a code duplication there as the same code exists more than once. This function could be restructured by decomposing as per the below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;solveTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TaskSolution&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&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;player&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;playerService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getPlayer&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="nf"&gt;handleGamingProfileCreation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&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="nf"&gt;handleReportingSolvedTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;solution&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;Which would then use the functions below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;handleGamingProfileCreation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Player&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &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="nf"&gt;hasGamingProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&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="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="nf"&gt;createPlayerGamingProfile&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;);&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;handleReportingSolvedTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;solution&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;TaskSolutin&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &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="nf"&gt;alreadySolvedTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;solution&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="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="nf"&gt;reportSolvedTask&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;player&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;solution&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;The functions &lt;em&gt;handleGamingProfileCreation&lt;/em&gt; and &lt;em&gt;handleTaskSolving&lt;/em&gt; have been decomposed from the original function.&lt;/p&gt;

&lt;p&gt;This way &lt;em&gt;solveTask&lt;/em&gt; function does one thing only - solves a task. It's operating on its abstraction level and it delegates its original logic into functions that are smaller, more focused, and easier to understand. Note that each function operates on a different abstraction level - one handles gaming profile creation and the other one handles reporting of the solved task.&lt;/p&gt;

&lt;p&gt;The decomposing process we've covered may become very handy in restructuring (or creating) complex functions and can lead to a cleaner and better code.&lt;/p&gt;

&lt;p&gt;It's worth mentioning that not all of the code should be decomposed into small functions. Some cases could lead to having 10 different functions that are used only in our decomposed function. It's a trap that should be avoided if possible. You should make decisions about decomposition based on the function readability. If you struggle with that, there are some questions worth asking that may be helpful in making the decision:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Will someone else make use of that function?&lt;/li&gt;
&lt;li&gt;Can the decomposed function be public?&lt;/li&gt;
&lt;li&gt;Will it help in creating unit tests?&lt;/li&gt;
&lt;li&gt;Am I getting rid of complexity or adding it?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To learn more about creating quality functions search for:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;programming functions good practices&lt;br&gt;
programming functions abstractions&lt;br&gt;
programming refactoring decomposition&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Be a team player
&lt;/h2&gt;

&lt;p&gt;The last (but not least) rule while working on the code quality is to be a team player. Most of the projects are developed by a multi-developer team. That's why it becomes crucial to cooperatively work on the code quality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1w88funcgb9gba3mqz4.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fu1w88funcgb9gba3mqz4.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Being a team player is also treating the code as &lt;em&gt;ours&lt;/em&gt;, not &lt;em&gt;mine&lt;/em&gt; or &lt;em&gt;theirs&lt;/em&gt;. Each team member is evenly responsible for its quality. There will be many cases in which you will encounter code blocks that were written in the past and require some treatment, e.g. badly named fields or wrongly formatted functions. In those cases the rule of leaving the code in a better shape than we saw it comes to life - it's not forbidden to improve code that someone else wrote earlier as we all work on the same codebase. The code will benefit greatly from respecting this rule, as its quality will always increase.&lt;/p&gt;

&lt;p&gt;It's also important to remember, especially while doing code reviews, that we are reviewing someone else's code and not the actual person - this is a crucial part of keeping team spirit and respecting each other. This way of thinking about the code also helps in sharing code with others - as it decreases the fear of being offended by another project member. It also increases the discussions about the code itself, which is a key aspect of constantly increasing code quality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A professional developer should always write the best code possible. It isn't easy, it's the process of constantly learning new aspects of improving things, but it's the way to go as it decreases many potential issues and increases overall quality. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Writing code is a work of art - it should be perfect, but perfect doesn't always mean the same.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>codequality</category>
      <category>programming</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Pair Programming: are two heads better than one?</title>
      <dc:creator>Cezary Michalak</dc:creator>
      <pubDate>Wed, 27 Apr 2022 09:36:04 +0000</pubDate>
      <link>https://dev.to/emphie/pair-programming-are-two-heads-better-than-one-53nn</link>
      <guid>https://dev.to/emphie/pair-programming-are-two-heads-better-than-one-53nn</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;First things first - what is pair programming?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Pair programming is a development practice in which two programmers work together in one workspace. It allows developers to learn from each other and improve code quality through knowledge sharing and discussion.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;When and why should we use it?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;For the difficult or most important parts of the software&lt;/strong&gt;&lt;br&gt;
You are more likely to make mistakes or to miss something in the more complex tasks. The second person could help to improve the quality of the code, by looking from a different perspective, reviewing your code live, or discussing a problem.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--M2myU1tI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bl4a29gt6v6dp3r29w8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--M2myU1tI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2bl4a29gt6v6dp3r29w8.png" alt="Image description" width="880" height="777"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When recruiting new employees&lt;/strong&gt;&lt;br&gt;
Pair programming can be a great tool in the recruitment process. It allows you to easily verify both the technical and soft skills of the potential employee. However, it is worth remembering that this method may generate more stress in the candidate, which may adversely affect the result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;For the introduction of a new person to the project&lt;/strong&gt;&lt;br&gt;
It always takes a little time to adapt to a new project. If a person that is already in it, shows you the code and explains it to you, it can really increase the speed at which you will get accustomed to methodologies used in the project and increase your understanding of it. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When training technical and soft skills&lt;/strong&gt;&lt;br&gt;
Not only is this a good method for less advanced programmers to learn from more advanced programmers, but also more advanced programmers can learn from each other through discussion.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Variations of programming in pairs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;There are three options for working in pairs based on the experience of the people involved:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Newbie-newbie&lt;/strong&gt;: Novice programmers can effectively resolve the hardest problems as a pair&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expert–newbie&lt;/strong&gt;: Useful as a teaching method, because an expert can share their knowledge easily&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expert–expert&lt;/strong&gt;:  A good choice for creating very important parts of the software&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The main techniques&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;There are quite a few types of pairings, some of which are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Driver-navigator&lt;/strong&gt;: The most popular technique. One developer (“driver”) writes code while the other (“navigator”) reviews each line of code, asks questions and thinks ahead&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Backseat navigator&lt;/strong&gt;: When we hit the wall while solving a problem, sometimes we don't see alternative ways. Then when someone looks at the problem from a different perspective, this canl be useful&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Tour Guide&lt;/strong&gt;: A good way to implement a new programmer to the project. A developer who was already in the project codes and explains how the application works whilst a new developer observes and asks questions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ping-Pong&lt;/strong&gt;: Perfect when we use Test-Driven Development (TDD) methodology, one programmer writes the tests while the other the code to be tested&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Unstructured&lt;/strong&gt;: This is total freestyle without any patterns. It is effective if the developers trust each other&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Advantages of pair programming&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here are some reasons why you should consider using this methodology:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mistakes are usually detected immediately&lt;/li&gt;
&lt;li&gt;Code is shorter and more qualitative&lt;/li&gt;
&lt;li&gt;Problems are resolved faster&lt;/li&gt;
&lt;li&gt;Developers learn from each other&lt;/li&gt;
&lt;li&gt;Programmers train their soft skills&lt;/li&gt;
&lt;li&gt;The whole team is more integrated&lt;/li&gt;
&lt;li&gt;The individual parts of the application don’t depend on one developer, which makes absence problematic&lt;/li&gt;
&lt;li&gt;It's easier to get to know the other developers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Is working in pairs free from disadvantages?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Like everything else, this kind of work also has its downsides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Coding is slower while discussing&lt;/li&gt;
&lt;li&gt;It can quickly becomes tiring&lt;/li&gt;
&lt;li&gt;Conflicts between developers may occur&lt;/li&gt;
&lt;li&gt;It can be difficult for introverted programmers&lt;/li&gt;
&lt;li&gt;The coder may feel stressed by being watched all the time&lt;/li&gt;
&lt;li&gt;The navigator may be reluctant to give feedback to the driver&lt;/li&gt;
&lt;li&gt;In stationary pair programming, problems may be caused by the difference in chair height, screen brightness, mouse, keyboard, or IDE&lt;/li&gt;
&lt;li&gt;It takes some time and practice to get used to it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fwF77Qrg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx6fw0tg00eg8d9tcha2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fwF77Qrg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx6fw0tg00eg8d9tcha2.png" alt="Image description" width="647" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Remote pair programming&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;These days we work remotely more often, but this is not an obstacle to working in pairs unless programmers work asynchronously.&lt;/p&gt;

&lt;p&gt;Visual Studio Code has an awesome tool called “Live Share” which is Made by Microsoft. It allows you not only to see what another programmer is coding, but also we can code with them, talk, and share the terminals and ports. It makes work more comfortable and easier to get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What rules should be followed?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For pair programming to work, the following rules must be followed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Swap roles&lt;/strong&gt;: Don't occupy the keyboard all the time, let your co-worker prove themselves&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Be nice&lt;/strong&gt;: It's easier to work together in a relaxed atmosphere&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Use a familiar environment&lt;/strong&gt;: Communication will be easier when both of you are comfortable&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ask questions&lt;/strong&gt;: Don't be afraid to ask questions&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Take a break&lt;/strong&gt;: Take a 5-minute break every hour or when you need to&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Trust each other&lt;/strong&gt;: Don't criticize in advance, be patient&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Control your ego&lt;/strong&gt;: Your partner doesn’t criticize you, but your code, so listen to them and if you disagree, have a discussion&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Say I'm sorry&lt;/strong&gt;: Sometimes we get carried away, or we unknowingly hurt someone, be mindful&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Don't be skeptical&lt;/strong&gt;: If you have a negative approach, you will fail&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Think about your differences as something good&lt;/strong&gt;: Don't take the difference in another person's thinking as a disadvantage, but as an advantage&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Watch the time&lt;/strong&gt;: Long sessions lose their effectiveness and can tire you out. Sessions should last between 2 to 2.5 hours&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Change your partner&lt;/strong&gt;: It is worth getting to know the skill sets of new people so you can learn from them&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remember - you are a team&lt;/strong&gt;: Everything you produce is a joint effort&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;So should I start my adventure with pair programming?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Well, it depends. Each case is different and the methods should be adapted to the problem, never the other way around.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;If you think this might work for your situation, you should consider trying it out!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>discuss</category>
      <category>pairprogramming</category>
    </item>
    <item>
      <title>A quest to find TypeScript's inheritance tree (with top and bottom types as main NPCs)</title>
      <dc:creator>Dariusz Cichorski</dc:creator>
      <pubDate>Thu, 07 Apr 2022 11:00:02 +0000</pubDate>
      <link>https://dev.to/emphie/a-quest-to-find-typescripts-inheritance-tree-with-top-and-bottom-types-as-main-npcs-4m79</link>
      <guid>https://dev.to/emphie/a-quest-to-find-typescripts-inheritance-tree-with-top-and-bottom-types-as-main-npcs-4m79</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;I need you to imagine that you’re a lvl 5 software developer aka. computer mage trying to level up fast. What’s the quickest way to do that? By doing NPC’s quests!&lt;/p&gt;

&lt;p&gt;And today’s mission is to find TypeScript's inheritance tree. You constantly need to get some experience to develop your skills.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6u1at7dnwi1xe98gg57z.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6u1at7dnwi1xe98gg57z.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Object-oriented programming is a way of reflecting anything with the usage of objects with specific behaviors. As in life, those objects can share certain similarities - that's where inheritance comes in.&lt;/p&gt;

&lt;p&gt;It's a very important aspect of programming, as it is one of the key factors that impact the code quality, especially in highly scalable systems.&lt;/p&gt;

&lt;p&gt;TypeScript, as an example of object-oriented programming language, also supports inheritance, but it comes with some specifics worth knowing.&lt;/p&gt;

&lt;p&gt;Join me in a quest of finding TypeScript's inheritance tree and learning about the associated top and bottom types. And trust me, such a quest can become a real journey with highs and lows on our way (literally).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Quest started - Difficulty level: MEDIUM&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finding class inheritance tree
&lt;/h2&gt;

&lt;p&gt;To start, let's get straight to the point and create our first class: a Hero:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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;name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;name&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;With that sorted out, let's go further and create two other classes which will extend the Hero class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Jedi&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hero&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Luke Skywalker&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="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;BountyHunter&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Hero&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="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;super&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Bossk&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is a perfect example of how inheritance works in TypeScript. By extending the base class Hero, we've created two other classes: Jedi and BountyHunter, which now share all of the Hero's attributes (in our case: a name).&lt;/p&gt;

&lt;p&gt;We can therefore say that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A Jedi is a child class and the Hero is the parent class.&lt;/p&gt;

&lt;p&gt;A BountyHunter is a child class and the Hero is the parent class.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If you think about it, we've just created a simple inheritance tree, which in our case looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyvtz3k3khtmxj71b1e3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftyvtz3k3khtmxj71b1e3.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The class inheritance tree is a reflection of how different classes extend each other and what the relationships are between them. Every type in TypeScript is part of the inheritance tree&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The tree always has multiple levels - like the one above has two (one with Hero, the second one with Jedi and BountyHunter).&lt;/p&gt;

&lt;p&gt;Looking at the inheritance tree we can see how specific the types are on certain levels. In our case, the Hero class is the least specific type because it's above the others. Jedi and BountyHunter are more specific extensions of the Hero type.&lt;/p&gt;

&lt;h2&gt;
  
  
  Climbing up the inheritance tree
&lt;/h2&gt;

&lt;p&gt;What if I told you there's more than that at the top of our tree? Right now the tree looks more like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bbmnt99i0u4jsgkeav6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bbmnt99i0u4jsgkeav6.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In TypeScript every type inherits from the Object type, which means that our Hero class is the extension of that type, too. This type comes with some familiar methods that we can use, e.g. toString(), hasOwnProperty().&lt;/p&gt;

&lt;p&gt;What's interesting in the tree is that when you look closely, you will notice the String class is another type extending the Object and it's at the same level as our Hero! There are in fact more types on this level - including all of the classes we create.&lt;/p&gt;

&lt;p&gt;But the Object isn't our final destination. At the very top of our tree is the Unknown type - it's the least specific type in TypeScript's inheritance mechanism. You're probably wondering what's the purpose of this type, as it is in fact completely empty, without any properties and methods. Let me explain, as this is a very useful one.&lt;/p&gt;

&lt;h2&gt;
  
  
  Into the unknown
&lt;/h2&gt;

&lt;p&gt;I'm sure you've had thousands of situations in which it was hard to specify what the exact type of the value was. It happens a lot when you work with some external APIs or libraries. I've seen the type Any being used many times in such scenarios. But that's actually a big antipattern and potential danger for our code. Unknown type requires some additional handling but it also decreases the potential for bugs thanks to the help of a compiler.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feijo4pghfoyfrkntvqe9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Feijo4pghfoyfrkntvqe9.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's worth noting that a lot of the time, a programmer is responsible for using the Unknown type. It's a clear indication that the type you're dealing with should be double checked before using. And such indication comes with a lot of support from the compiler, as you'll learn in the cases below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Type guards
&lt;/h3&gt;

&lt;p&gt;The cases in which there is no guarantee what the value is, are a perfect opportunity to use the Unknown type. It makes sure that those values are not used without being strictly checked. To do so we can implement type guards:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isString&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="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;typeof&lt;/span&gt; &lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;string&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="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isHero&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;maybeHero&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;maybeHero&lt;/span&gt; &lt;span class="nx"&gt;is&lt;/span&gt; &lt;span class="nx"&gt;Hero&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;maybeHero&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nx"&gt;Hero&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;Using such functions makes us secure about the type of the value. As you can see it is a very easy way of checking if the unknown value is some simple type (e.g. string) or some complex class (e.g. Hero). What's more is that once you use such a function, the compiler will know the type of checked value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;something&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;unknown&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;something&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nf"&gt;isString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;something&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// something is of type unknown here&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Unsupported type.&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="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;something&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// something is of type string here&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Type assertions
&lt;/h3&gt;

&lt;p&gt;You can use type assertions while working with Unknown type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;func&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="nx"&gt;unknown&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="nx"&gt;value&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;number&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Such an assertion tells the compiler the type of the value, so it becomes possible to use type specific methods (e.g. toFixed() for a number). But at this point, as the NPC would say, "BEWARE! This way you are responsible for the type, not the compiler!"&lt;/p&gt;

&lt;h3&gt;
  
  
  Equality
&lt;/h3&gt;

&lt;p&gt;In cases where you want to execute some logic when the Unknown type equals some specific value, you can do as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doSomethingAmazing&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="nx"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;123&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;amazeMe&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="c1"&gt;// value is of type number&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;What's interesting here is that the compiler knows exactly what the type of the value is if it passes the above conditional expression. So if the value equals 123, it means the value is a number! If a string (or any other type) is passed to the above function, it will execute without any error, but the conditional result will not be positive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Falling down from the tree
&lt;/h2&gt;

&lt;p&gt;We've already reached the top of the inheritance tree, but there's some unexplored area at the bottom of it. From that perspective it looks like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6k5ye3seqnk6h59fevjf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6k5ye3seqnk6h59fevjf.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The Never type is the bottom of the inheritence tree. It inherits from every other type in the tree. Thanks to that nothing else is assignable to it. It's more specific than any other type so it can be assigned to everything else. There are some specific cases in which this type may be helpful.&lt;/p&gt;

&lt;h3&gt;
  
  
  Exhaustive checking
&lt;/h3&gt;

&lt;p&gt;The most common use for the Never type is to achieve exhaustive checking in conditionals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;heroOrHunter&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Jedi&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nx"&gt;BountyHunter&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;Jedi&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;heroOrHunter&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nx"&gt;Jedi&lt;/span&gt;&lt;span class="p"&gt;)&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I am a Jedi&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="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;heroOrHunter&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nx"&gt;BountyHunter&lt;/span&gt;&lt;span class="p"&gt;)&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;I am a BountyHunter&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="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="na"&gt;exhaustiveCheck&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;heroOrHunter&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Unknown type &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;exhaustiveCheck&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code checks the type of heroOrHunter and executes some conditional logic. But in case there will be some other type in it, it will mark the type as Never, to make sure the compiler will stand strong against any other specific usage of that value. It can be very helpful and provide a higher level of code safety in more complex cases.&lt;/p&gt;

&lt;h3&gt;
  
  
  Error throwing function
&lt;/h3&gt;

&lt;p&gt;Another common use of the Never type is as the return type of a function that exists only to throw an error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;throwError&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="nx"&gt;never&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;message&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;This way we can prevent someone from using the value returned from this function as it now returns the Never type - which is the bottom type, so it cannot be assigned to anything. This makes it a reasonable alternative for returning Void.&lt;/p&gt;

&lt;p&gt;In TypeScript a function that does not return a value returns undefined. Returning the Never type instead of Void produces a compiler error and prevents us from such a scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;sayHi&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hi&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hi&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sayHi&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;speech&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Outputs: undefined&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion and gaining EXP
&lt;/h2&gt;

&lt;p&gt;We've explored TypeScript's inheritance tree and in doing so, we've covered the top and bottom types. That knowledge is one of the milestones of TypeScript's mastery.&lt;/p&gt;

&lt;p&gt;Writing code that compiles successfully is one thing, the other is writing the code that is effective and bug-free. Using the knowledge we've learned during our quest will surely make it so.&lt;/p&gt;

&lt;p&gt;Our quest is now complete and you, dear reader, are reaching the next level of your technical skills. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;+1500 EXP!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Congrats! You are now lvl 6 software developer/computer mage.&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;Your next Quest awaits...&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>typescript</category>
    </item>
    <item>
      <title>A ‘wise’ guy tactic for effective code review practice? Use checklist templates!</title>
      <dc:creator>Maciej Płatek</dc:creator>
      <pubDate>Tue, 05 Apr 2022 08:13:08 +0000</pubDate>
      <link>https://dev.to/emphie/a-wise-guy-tactic-for-effective-code-review-practice-use-checklist-templates-3mel</link>
      <guid>https://dev.to/emphie/a-wise-guy-tactic-for-effective-code-review-practice-use-checklist-templates-3mel</guid>
      <description>&lt;p&gt;I think everybody agrees on how important and useful practicing code review is. It helps you catch bugs early in the process and reduces long-term development time. It also has the benefits of sharing knowledge, improving estimation skills, and keeping the code consistent with established conventions within the project. In one sentence - it improves the overall quality of code. But how do you do it like the 'wise guy' from this article's title? The answer is simple.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4i4wxieomdmr41gq7tc.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fv4i4wxieomdmr41gq7tc.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sometimes being a developer is all about trying to be structured - simply following rules and using the right tools. I know that performing Code Review (CR) can be a problem for some devs. To avoid all the traps and make the whole process easy and effective I recommend using checklists. They should be the first choice when you're performing semi repetitive tasks. So what's the argument against using them as templates? Yea, I don't know any either.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Basic rules - keep the lists short&lt;/strong&gt;&lt;br&gt;
    The principal rule is to keep it simple. Lists that are too long are overwhelming and can backfire. Stick to the fundamentals and focus on the most important parts, however, it is meant to be useful so don’t hesitate to fit it to your needs. Rules should be listed in a specific order, because in most cases if one of the points is not fulfilled you should stop reviewing and contact the author. Of course, a checklist is beneficial not only for the reviewer, but the author of the code should be able to use it before submitting PR to remove obvious mistakes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Automated tools are the key&lt;/strong&gt;&lt;br&gt;
    Any automated tools that are used in a project must succeed.  If any static program analysis or automated test reports a problem it has to be fixed before review. Automats are the first obstacle you need to overcome to start CR.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are changes ready to be merged?&lt;/strong&gt;&lt;br&gt;
    If PR has conflicts with the target branch there is no point in checking the code because you will probably need to perform a review one more time. This should be obvious, but often changes that are merged earlier can lead to new conflicts, and resolving them is the responsibility of the PR author.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are commits messages correct?&lt;/strong&gt;&lt;br&gt;
    Before you take a look at the code, check the commits messages. Comments like “Minor fix” or “Added new feature” are meaningless. Developers must stick to the commit convention used in the project, with no excuses.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is PR small enough?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyti67qy98w6uww58eip4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyti67qy98w6uww58eip4.png" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
    Neither you nor me have Chuck Norris' skills. Our perception is limited, so if PR consists of 3000 changed lines, you will have problems understanding changes. Remember to keep it small, but without forcing strict limits, because it needs to be flexible. If you have worries that your PR is too big, it probably is, so just check out the new children’s branch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Are requirements met?&lt;/strong&gt;&lt;br&gt;
    Requirements are the reason why the feature branch exists, so always check if changes fulfil them. Believe me - you don't want to spend time reviewing the whole code if requirements are not met. Been there, done that. Don't recommend it. Check ticket description, look if something is missing or is incorrectly implemented, and immediately report to the author if there is a problem.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do you understand the code?&lt;/strong&gt;&lt;br&gt;
    The question may seem odd, but it's important. To perform CR you must understand the code and be able to do it in a reasonable time. So code should be self-explanatory. If some functions don’t make sense or classes look messy, the code probably needs to be reorganized. You may be the next developer working on this part of the code, so take into account that this code will be merged to the main branch after your acceptance. Clicking the merge button or accepting the code review means you are now sharing responsibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dev's first commandment - stick to the coding guide&lt;/strong&gt;&lt;br&gt;
    I'll say it one more time - always stick to the coding guide. No excuses. Ever. Check if everything is correctly named, files have the correct structure and if the approach is consistent with principles, DRY, SOLID, or any other clean code rules team is using. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do we need a library for that?&lt;/strong&gt;&lt;br&gt;
    Libraries are a double-edged sword. Sometimes developers import huge and resource-consuming libraries and use only one function. It is only justified in cases when we can use more of it in future tasks. The second case is when developers add libraries that are similar to one already present in the project and duplicatesare never welcome. The last thing is to check is if the library is not maintained any longer or marked as deprecated&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Duplication is not welcome&lt;/strong&gt;&lt;br&gt;
    In most cases finding unnecessary duplications can be a part of the coding guidelines, but it is worth mentioning it as a separate point on the checklist. New team members in particular can have problems with creating duplications, so just point out which part of the code they should use. There is no need to reinvent the wheel, use language features and already existing functions instead of implementing similar features.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Test, test, test!&lt;/strong&gt;&lt;br&gt;
    Yes, writing tests is also part of a task so check if they are correctly implemented and cover all coding paths. Just like normal code, tests should also meet coding guide standards and be consistent with project assumptions. Verify that all tests are passing for the right reason and take a second and think if there are any edge cases that haven’t been tested.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documentation is a must&lt;/strong&gt;&lt;br&gt;
    Right now you and the author of the code know what is going on. But will other team members be able to easily catch up and use or develop it? If you are reviewing API - check if all endpoints are correctly notated and documented. For frontend checks, you can confirm if everything is available at Storybook or another component explorer. Any libraries used or architecture solutions must be put into a decision log.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A ‘wise-guy’ conclusion ;)&lt;/strong&gt;&lt;br&gt;
This article provides you with several suggestions, but a good CR checklist must be agreed with the whole team. Keep in mind that checklists should be a live organisms, if you encounter problems in the development process just add new points or keep more than one type of CR template based on task type.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;em&gt;There you have it. Good luck with your next code review!&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>codereview</category>
      <category>checklist</category>
      <category>productivity</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Code development guide: working with small chunks</title>
      <dc:creator>Adrian Piętka</dc:creator>
      <pubDate>Fri, 18 Mar 2022 08:47:48 +0000</pubDate>
      <link>https://dev.to/emphie/code-development-guide-working-with-small-chunks-28e4</link>
      <guid>https://dev.to/emphie/code-development-guide-working-with-small-chunks-28e4</guid>
      <description>&lt;p&gt;Final work with the code can be a real pain in the… neck. It is often a long and tedious process of going through and verifying all the changes which can bring you to a moment when frustration is directly proportional to the time spent on writing the code. Is there a way to tidy up the work and avoid those tears under the shower at the thought of another implementation? Yes, there is. You can work with small chunks.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What’s the prob, dev?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Imagine waking up after tens of minutes (or even hours!) of coding trance and seeing 50 changes in your editor. Changes were made in totally different places of the application. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgw5b2p42q02q5rf1qxx.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvgw5b2p42q02q5rf1qxx.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;You look at this code-battlefield and ask yourself *&lt;em&gt;the same question the Ant-Man did. *&lt;/em&gt;“What the hell happened here?”&lt;/strong&gt;...  To make matters worse, not everything is working and you have a lot more to do because you poked your thumb in too many pies. Part of the changes has to be verified again and it will pull further changes. On top of that - you haven’t corrected even one test. &lt;/p&gt;

&lt;p&gt;You know that means one thing - &lt;strong&gt;a need to go through and verify all the changes, remove the unwanted code, and fix the tests&lt;/strong&gt;. Well, you could probably say that you’re starting iteration number 2. The problem is, you are tired and you lean towards leaving work for tomorrow. After all, you did a great job today. Isn’t it enough? ;) &lt;/p&gt;

&lt;p&gt;Eventually, that approach drives me to the moment I don’t feel like working at all. It’s like complaining about other people’s work and making a much worse mess than the others. Frustrating, isn't it?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9x9g838mjq3f1kypkpfi.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9x9g838mjq3f1kypkpfi.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That’s why I try to organize my process of creating software by the little approach. &lt;strong&gt;Small, but thought through and effective steps.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let me guide you through all the stages of the work and point out its important elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Let’s start with a good plan&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Think over carefully how to approach the problem to finish the task as a whole. Focus only on your goal and only those changes that will lead you to achieving it.&lt;/p&gt;

&lt;p&gt;What’s important - I rarely pay attention to the tasks I’ll be working on next week or in two weeks' time. I focus on it when the time is right. Not once and not twice I had prepared implementation for the future changes and finally, there was no need of doing all that work because requirements changed in the meantime. All the work that was done turned out to be a waste of time. &lt;/p&gt;

&lt;p&gt;It’s hard because you’re often overwhelmed with tasks. You hear about SOLID, DRY, and the rest of the acronyms that make the whole thing messy and abstract. You end up wasting your time instead of just working on a specific piece of code. &lt;/p&gt;

&lt;p&gt;This is the moment when you need to start making decisions. For instance, you need to decide if you’re implementing the strategy pattern or not. But on top of all that is if in the future you will be able to easily change/ replace the elements you are currently working on. Without deleting half of your code. I focus on coupling the changes with the rest of the code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;I tend to point out the work phases on a sticky note.&lt;/strong&gt; After completing each task I can cross it out. But the real moment of little glory comes when all the tasks are completed and the crushed paper lands in the bin. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5lg5uyaw7ebo2q1364n.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fq5lg5uyaw7ebo2q1364n.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;em&gt;Of course, you can use the virtual sticky notes and have the satisfaction coming from clicking the delete button… but frankly, it’s just not the same ;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The plan isn’t a carbon copy with the changes I’m implementing. It is because you can subdivide them into even smaller steps. &lt;/p&gt;

&lt;p&gt;It is my &lt;strong&gt;high-level work plan and not the plan for the particular changes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;One change at a time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;This is where it gets interesting. After preparing the plan it’s time for a serious fight - decomposing the work into smaller pieces.  &lt;/p&gt;

&lt;p&gt;Examination of borders and drawing a line where I start and finish the work is just a heuristic. In that matter, I rely on two factors.&lt;/p&gt;

&lt;p&gt;A type of change is the first factor. I’ve defined a catalog of 5 different potential changes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Change in the file and directory structure - changing names and moving them&lt;/li&gt;
&lt;li&gt;Refactorization - preparing the ground in the accordance with Uncle &lt;a href="https://www.amazon.com/Clean-Code-Handbook-Software-Craftsmanship/dp/0132350882" rel="noopener noreferrer"&gt;Bob’s 'Clean Code'&lt;/a&gt; principle &lt;/li&gt;
&lt;li&gt;Implementation - the most atomic and independent part of the function you’re working on&lt;/li&gt;
&lt;li&gt;Fixing an error&lt;/li&gt;
&lt;li&gt;Deleting an unnecessary, unused part of the code&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;I always try to make only one change at a time&lt;/strong&gt;. The exception to this rule is when the changes are mutually exclusive, for example - changing the file name that fixes the error. &lt;/p&gt;

&lt;p&gt;Unfortunately, there is a trap here because it’s impossible to describe decomposition in just five easy points. &lt;/p&gt;

&lt;p&gt;Second factor. I verify if the change meets the assumptions below: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To be atomic&lt;/li&gt;
&lt;li&gt;To be as independent of the future changes as possible. What I mean - it doesn’t require something that doesn’t exist yet&lt;/li&gt;
&lt;li&gt;To be dependent on things I added earlier. What I mean - it can use previously added functions&lt;/li&gt;
&lt;li&gt;To change one specific function&lt;/li&gt;
&lt;li&gt;To apply only one specific file (ideal situation)&lt;/li&gt;
&lt;li&gt;To easily describe the changes in just a few words (it makes creating commit messages a lot easier)&lt;/li&gt;
&lt;li&gt;To start from the deepest changes, the ones at the end of the calls chain&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let me show you an example:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I add a function to calculate the X. It’s not used anywhere yet (new MathCalculations function)&lt;/li&gt;
&lt;li&gt;I add a new endpoint that I’ll be taking actions in (only Controller action and route)&lt;/li&gt;
&lt;li&gt;I add the validation of data coming to an endpoint&lt;/li&gt;
&lt;li&gt;I add business logic (e.g. in UseCase)&lt;/li&gt;
&lt;li&gt;I connect triggering logic with the endpoint&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Theoretically and practically I am able to merge my changes with the main development branch. Nothing should happen because various elements are independent of the next steps I plan to take. &lt;/p&gt;

&lt;p&gt;This is, of course, just an example and we may find that to point 4 we would need to add a new entity, repository, or generate a new table in the database. I would think about these as separate changes. &lt;/p&gt;

&lt;p&gt;It’s important to remember that theoretically, &lt;strong&gt;one single change can require dividing it into many smaller pieces and each one of them follows exactly the same process&lt;/strong&gt;. I was thinking about 3 changes… and I ended up making 7 :)&lt;/p&gt;

&lt;p&gt;Decomposition is the key part here. Either you have it or the process itself won’t get you anywhere. &lt;/p&gt;

&lt;p&gt;Earning the ability to do that won’t always mean it is going to be easy (but also no one promised it will be ;) ). You often need to know the system you’re modifying, its architecture, code structure, and the main principles it follows. Without them, working little by little is a lot more difficult. What’s important is that each new task is knowing the code and how the software was built. This is what makes us move around much quicker and with higher confidence.&lt;/p&gt;

&lt;p&gt;In this step, I’m not afraid to use comments // @ TODO. But only to make my work in the next step easier and finally to replace it with an appropriate implementation. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Everything needs to work&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Everything needs to work after the changes you made. Every added, deleted line or modification can’t have any side effects, e.g. damaged automated tests, defective SCA, or malfunctioning software. Everything needs to be compiled correctly.&lt;br&gt;
What’s the next step? To check if everything works. I verify not only the app but also everything needed to implement the next change in the environment. &lt;/p&gt;

&lt;p&gt;I tell more about the changes testing approach in my '&lt;a href="https://emphie.com/insights/programmer-test" rel="noopener noreferrer"&gt;Programmer, Test!&lt;/a&gt;' article. You’ll find a list of points worth remembering in the process of changes verification. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Write it down!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3t6nei1eolaia36tfodw.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3t6nei1eolaia36tfodw.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Preparing the storytelling about changes in the right words is the final step. Remember, you need to explain what you have done and why. &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;I add files to the Staging Area (git add)&lt;/li&gt;
&lt;li&gt;I make the Git Commit and the created history I put into the Commit Message&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is where I can make the next step. Part of the work I consider done has been secured and I can safely take the next step in this case&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Have I achieved?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;First of all, using only one tool (git) I can track/monitor the progress of my work. Even if I had a difficult weekend due to my friend’s bachelor party I could still easily remember what I had done on Friday. And after getting rid of the hangover I am able to quickly get back to work on Monday morning… ;) &lt;/p&gt;

&lt;p&gt;And what’s important - &lt;strong&gt;I can easily undo my experiments&lt;/strong&gt;. All I need to do is to get back to a specific commit.&lt;/p&gt;

&lt;p&gt;In my opinion, it’s important to take care of proper history creation used in Commit Message. You get this feeling of sweet harmony in your work. You know what you changed and most importantly why you had done it. &lt;/p&gt;

&lt;p&gt;But on the other hand, if you don’t care about this you can use Git Squash to simply merge a few commits in one. That way you will describe the final result, not how you achieved it.  &lt;/p&gt;

&lt;p&gt;Obviously, &lt;strong&gt;as always, the right approach depends on the project you’re working on&lt;/strong&gt; or simply your preferences. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Do I push every commit created?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;It depends. Sometimes you co-work with someone on the same branch and your partner is waiting for your changes. The other time you will just upload them from time to time. &lt;/p&gt;

&lt;p&gt;Over time you will get this on your list of habits and you will realize that the work is getting done faster. Next thing you know you have a bunch of tasks marked with the green ‘done’ tick. In the end - practice makes perfect, or rather “practice makes practitioner” ;) &lt;/p&gt;

&lt;p&gt;In the end, I would like to draw your attention to &lt;a href="https://sethrobertson.github.io/GitBestPractices/" rel="noopener noreferrer"&gt;'Commit Often, Perfect Later, Publish Once: Git Best Practices'&lt;/a&gt;. Actually, I think this is where my adventure with the little by little work and Git approach had begun. &lt;/p&gt;

</description>
      <category>programming</category>
      <category>guide</category>
      <category>codenewbie</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Can a man become a starship? Yes, in TypeScript. A guide to structural and nominal typing</title>
      <dc:creator>Dariusz Cichorski</dc:creator>
      <pubDate>Wed, 09 Feb 2022 11:02:45 +0000</pubDate>
      <link>https://dev.to/emphie/can-a-man-become-a-starship-yes-in-typescript-a-guide-to-structural-and-nominal-typing-9ao</link>
      <guid>https://dev.to/emphie/can-a-man-become-a-starship-yes-in-typescript-a-guide-to-structural-and-nominal-typing-9ao</guid>
      <description>&lt;p&gt;&lt;em&gt;*TikTok music playing*&lt;/em&gt; You can do anything you want when you're... a programmer! But for real - programming has become a way of reflecting real-world, often providing a helping hand in various processes by using code. We can create all sorts of things.&lt;/p&gt;

&lt;p&gt;Those things can have different shapes and meanings, serve different purposes and do all sorts of different stuff. Like making a man become a starship. Let's learn how to achieve that using TypeScript and, on the ocassion, gain some knowledge about structural and nominal typing.&lt;/p&gt;

&lt;p&gt;TypeScript can be a good example of our starship-theorem because it's here for you when you need it. Nowadays, it's basically everywhere - both in front-end and back-end worlds, but to be precise and effective you have to remember some important things and use them to provide a valid solution to the problem.&lt;/p&gt;

&lt;p&gt;Our assumption is as follows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"A man cannot become a starship."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Sounds very simple and straightforward, right? Well, it's actually not so simple and I'll prove it to you.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fHEfB8DJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dx93x12hvsjjbudo92lj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fHEfB8DJ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dx93x12hvsjjbudo92lj.png" alt="Image description" width="400" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Shaping the world
&lt;/h2&gt;

&lt;p&gt;Let's play with our assumption in TypeScript. Let's say we have a man and a starship - they all have the same properties: name and id:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&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;Let's prepare some typical real-world situation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Han Solo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&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;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Surprisingly, the code above is absolutely correct and will compile without any errors, but if you think about it, our assumption is broken. Why is that?&lt;/p&gt;

&lt;p&gt;TypeScript (as the name suggests...) is built over types. &lt;strong&gt;If something has the exact same properties, it's the same thing. It doesn't matter that it's technically a different interface&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The difference comes when one of the interfaces is more specific than the other. Let's discuss the scenario as below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;serialNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// newly added field&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time, our real-world situation will behave a little differently:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Han Solo&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&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;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="c1"&gt;// Compiler error:&lt;/span&gt;
&lt;span class="c1"&gt;// Property serialNumber is missing in type 'Person' &lt;/span&gt;
&lt;span class="c1"&gt;// but required in type 'Starship'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Compiler error message pretty much sums that up, but why is that happening? By adding a new field serialNumber to the Starship interface it became a more specific type than the Person, which made it impossible assigning its value to the starship. Let's now change the rules and invert the real-world scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Millenium Falcon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;serialNumber&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;YT 492727ZED&lt;/span&gt;&lt;span class="dl"&gt;'&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;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;starship&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above scenario will compile successfully, because the starship contains all fields required in person type (name, id), so it can in fact become one.&lt;/p&gt;

&lt;p&gt;To sum that up, it's safe to say that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Types are considered the same if they share the same structure (fields).&lt;/p&gt;

&lt;p&gt;More specific type can be assigned to the less specific type (but has to come with all required fields of the less specific type).&lt;/p&gt;

&lt;p&gt;Less specific type cannot be assigned to the more specific type (as it does not come with all required fields).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;What does that mean for our assumption? It means that a man can actually become a starship, but only when they share the same fields. &lt;/p&gt;

&lt;p&gt;In TypeScript, all of that is called structural typing, which is the default type checking mechanism. It works well in most cases, but there are some that require more precision. In those cases, nominal typing comes to the rescue.&lt;/p&gt;

&lt;h2&gt;
  
  
  Being more serious
&lt;/h2&gt;

&lt;p&gt;In situations when type integrity becomes a key aspect of our code, we have to dive a little deeper into what TypeScript is able to provide.&lt;/p&gt;

&lt;p&gt;Nominal typing is a star in this case. Being able to relate objects strictly based on their types, not their members, it stands in contrast with structural typing.&lt;/p&gt;

&lt;p&gt;Currently TypeScript has no native support for nominal types (&lt;a href="https://github.com/Microsoft/TypeScript/issues/202"&gt;see history of the topic&lt;/a&gt;), but there are a few ways we can easily implement it ourselves.&lt;/p&gt;

&lt;h3&gt;
  
  
  Branding
&lt;/h3&gt;

&lt;p&gt;The first technique is called branding. It requires adding a brand field with a string literal as a value. Let's get back to our previous real-world situation, but this time, let's 'brand' our interfaces:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;BrandedPerson&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;person&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;BrandedStarship&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;brand&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;starship&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Boba Fett&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;BrandedPerson&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;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;BrandedStarship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Compiler error:&lt;/span&gt;
&lt;span class="c1"&gt;// Types of property 'brand' are incompatible.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code is pretty much the same that we implemented before using structural typing, but this time the compiler stands strong against letting a man become the starship, as they are in fact a different types.&lt;/p&gt;

&lt;p&gt;As you probably already noticed, this technique comes with the disadvantage of requiring the implementation of additional fake object properties.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enum Intersected Types
&lt;/h3&gt;

&lt;p&gt;Another way of implementing nominal typing is using enums. In TypeScript enums are unique, so any type intersected with an enum becomes unique as well. Let's use that knowledge in our scenario:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;PersonType&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;PersonType&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kr"&gt;enum&lt;/span&gt; &lt;span class="nx"&gt;StarshipType&lt;/span&gt; &lt;span class="p"&gt;{}&lt;/span&gt;
&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;StarshipType&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Boba Fett&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Person&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;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Compiler error:&lt;/span&gt;
&lt;span class="c1"&gt;// Type ... is not assignable to type Starship.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As before, this serves our purpose of not letting a man become a starship, but this time using a type intersection with unique enum.&lt;/p&gt;

&lt;p&gt;This technique comes with the advantage of not adding any fake properties (as in branding), but also with the disadvantage of returning two type declarations for every type.&lt;/p&gt;

&lt;h3&gt;
  
  
  Private Class Members
&lt;/h3&gt;

&lt;p&gt;Yet another way of handling nominal typing is the usage of private class members that denote the types. As previously, let's look at the example below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Boba Fett&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Person&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;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Compiler error:&lt;/span&gt;
&lt;span class="c1"&gt;// Property 'starship' is missing in type 'Person'&lt;/span&gt;
&lt;span class="c1"&gt;// but required in type 'Starship'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Given the compiler error we've got, this method also serves our purpose.&lt;/p&gt;

&lt;p&gt;The concept of this is actually the same as branding, but if you look closely it comes with the advantage of not showing up additional property (brand) on the object, as it is private. Private class members can also be encapsulated.&lt;/p&gt;

&lt;h3&gt;
  
  
  Private Class Members Encapsulation
&lt;/h3&gt;

&lt;p&gt;Let's be like Agent 47 for a moment with elegant and effective technique and play with some encapsulation. Here are our fundamentals:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nx"&gt;Tagged&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; 
  &lt;span class="kr"&gt;private&lt;/span&gt; &lt;span class="na"&gt;_secret_tag&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;T&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Nominal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Type&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;Tag&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Type&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;Tagged&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Tag&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Having that prepared, let's get back to our previous scenario and code it using Nominal type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Nominal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Person&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Nominal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Starship&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&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;person&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Boba Fett&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nx"&gt;Person&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;starship&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Starship&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;person&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="c1"&gt;// Compiler error:&lt;/span&gt;
&lt;span class="c1"&gt;// Type 'Person' is not assignable to type 'Starrship'.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once again, the above implementation prevents a man from becoming a starship, which solves our issue.&lt;/p&gt;

&lt;p&gt;The encapsulation gives us the power of hiding it in a utility file or utility library, which has a positive impact on our code quality. It also comes with the advantage of brand property not appearing on the object (like in previous techniques).&lt;/p&gt;

&lt;h2&gt;
  
  
  Motivation
&lt;/h2&gt;

&lt;p&gt;Okay, we've come a long way since the start - we've learned about two different ways of type handling in TypeScript: structural and nominal typing and how to achieve them. But let's ask ourselves a question: is nominal typing really that important? It actually depends on the case.&lt;/p&gt;

&lt;p&gt;Let's think about some system that requires encapsulation, e.g. encapsulation within modules - a scenario in which no code from the outside should interact with module code, except through explicit predefined channels.&lt;/p&gt;

&lt;p&gt;In that case, &lt;strong&gt;nominal typing can be responsible for making sure that some predefined functions will not be called with simply any object that happens to have the same properties like the one that is required&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Nominal type makes a statement that the code using it is created specifically with this type in mind.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let's go a little bit further with our encapsulation case and create a library that will play relaxing songs to keep us motivated in work for a certain amount of time. Instead of implementing it like that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;play&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;playSongsByBand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Slayer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;time&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;we can use nominal typing:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="nx"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;Minutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;Nominal&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;number&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Minutes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="o"&gt;&amp;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;function&lt;/span&gt; &lt;span class="nx"&gt;play&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;T&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;time&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Minutes&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;playSongsByBand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Slayer&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;time&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;As you can see, the above scenario benefits highly from using nominal typing. Instead of a function that takes an unspecified amount of time as a parameter, we end up with a self-explaining parameter in which you don't have to look to the documentation to understand its unit. And, as the type is nominal, you won't pass your age by mistake!&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;TypeScript mastery comes with understanding it. By knowing how it handles typing we can take our code to new heights.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Is nominal typing better than structural typing? No, the default typing mechanism will still be the one to go for most of the cases, but if you have a real need of being type sensitive, you know what you need to do.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--chQVoYkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x67zmohm09dufue846nj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--chQVoYkq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x67zmohm09dufue846nj.gif" alt="Image description" width="560" height="462"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We started with the starship-theorem. We did it not only because it gave me right to put here a cool transformers gif (or not only why) but also because it’s true. But to be true it must be as follows:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A man cannot become a starship. Unless you're using structural typing. Then in some cases it can...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  A little bonus
&lt;/h2&gt;

&lt;p&gt;Let's say we have a collection of different types that share the same property, e.g. name. We can implement a function that will take anything containing a name field and return its length.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;getNameLength&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;something&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nl"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;string&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="nx"&gt;something&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&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;This way, you can pass any type (e.g. Person, Starship, Company, Band, etc.) containing name field to this function.&lt;/p&gt;

&lt;p&gt;This can be useful, right?&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>webdev</category>
      <category>programming</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
