<?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: Khalil Stemmler</title>
    <description>The latest articles on DEV Community by Khalil Stemmler (@stemmlerjs).</description>
    <link>https://dev.to/stemmlerjs</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F133775%2F760d187b-90eb-4304-a867-4303e50ca90a.jpeg</url>
      <title>DEV Community: Khalil Stemmler</title>
      <link>https://dev.to/stemmlerjs</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/stemmlerjs"/>
    <language>en</language>
    <item>
      <title>⚡ Add a GraphQL Server to a RESTful Express.js API in 2 Minutes</title>
      <dc:creator>Khalil Stemmler</dc:creator>
      <pubDate>Thu, 09 Jan 2020 18:47:04 +0000</pubDate>
      <link>https://dev.to/apollographql/add-a-graphql-server-to-a-restful-express-js-api-in-2-minutes-4gdb</link>
      <guid>https://dev.to/apollographql/add-a-graphql-server-to-a-restful-express-js-api-in-2-minutes-4gdb</guid>
      <description>&lt;h3&gt;
  
  
  ⚡ Add a GraphQL Server to a RESTful Express.js API in 2 Minutes
&lt;/h3&gt;

&lt;p&gt;You can get a lot done in 2 minutes, like microwaving popcorn, sending a text message, eating a cupcake, and &lt;strong&gt;hooking up a GraphQL server&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Yup. If you have an old Express.js RESTful API lying around or you're interested in incrementally adopting GraphQL, we only need 2 minutes to hook it up with a fresh new GraphQL Server.&lt;/p&gt;

&lt;p&gt;Ready? Set. Go!&lt;/p&gt;

&lt;p&gt;Let's say that your server looked something like the following.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;apiRouter&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./router&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;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&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;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;5000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Existing routes for our Express.js app&lt;/span&gt;
&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/v1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;apiRouter&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;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="s2"&gt;`[App]: Listening on port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At the root of your project, &lt;code&gt;npm install&lt;/code&gt; &lt;a href="https://github.com/apollographql/apollo-server/tree/master/packages/apollo-server-express" rel="noopener noreferrer"&gt;apollo-server-express&lt;/a&gt; as a dependency.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install apollo-server-express --save
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Go to where your Express app is defined and import &lt;code&gt;ApolloServer&lt;/code&gt; and &lt;code&gt;gql&lt;/code&gt; from &lt;code&gt;apollo-server-express&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;apollo-server-express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, create an instance of an &lt;code&gt;ApolloServer&lt;/code&gt; with the &lt;em&gt;simplest possible&lt;/em&gt; GraphQL &lt;strong&gt;type definitions&lt;/strong&gt; and &lt;strong&gt;resolvers&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;server&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;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
    type Query {
      hello: String
    }
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;resolvers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello world!&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;Lastly, use &lt;code&gt;ApolloServer&lt;/code&gt;'s &lt;a href="https://www.apollographql.com/docs/apollo-server/api/apollo-server/?utm_source=devto&amp;amp;utm_medium=blog_post&amp;amp;utm_campaign=add_graphl_server_express_2_mins#apolloserverapplymiddleware" rel="noopener noreferrer"&gt;applyMiddleware&lt;/a&gt; method to pass in our Express.js server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;applyMiddleware&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Boom. That's it!&lt;/p&gt;

&lt;p&gt;Your code should look something like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;express&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;v1Router&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;./api/v1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;apollo-server-express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;express&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;port&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PORT&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mi"&gt;5000&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;server&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;ApolloServer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;typeDefs&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;gql&lt;/span&gt;&lt;span class="s2"&gt;`
    type Query {
      hello: String
    }
  `&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;resolvers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Query&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;hello&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hello world!&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;span class="nx"&gt;server&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;applyMiddleware&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;/api/v1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;v1Router&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;listen&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;port&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&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;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="s2"&gt;`[App]: Listening on port &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;port&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;If you navigate to &lt;code&gt;localhost:5000/graphql&lt;/code&gt;, you should be able to see your GraphQL schema in the GraphQL playground.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwd4tiobfydytzdtamlef.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fwd4tiobfydytzdtamlef.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If you want to change the URL that the GraphQL endpoint sits at from &lt;code&gt;/graphql&lt;/code&gt; to something else, you can pass in a &lt;code&gt;path&lt;/code&gt; option to &lt;code&gt;server.applyMiddleware()&lt;/code&gt; with the URL you want, like &lt;code&gt;path: '/specialUrl'&lt;/code&gt;. Check out the &lt;a href="https://www.apollographql.com/docs/apollo-server/api/apollo-server/?utm_source=devto&amp;amp;utm_medium=blog_post&amp;amp;utm_campaign=add_graphl_server_express_2_mins#apolloserverapplymiddleware" rel="noopener noreferrer"&gt;docs&lt;/a&gt; for full API usage.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;How simple was that? Is your popcorn finished? 😉&lt;/p&gt;

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

&lt;p&gt;Here's what we did.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install &lt;code&gt;apollo-server-express&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Create a &lt;code&gt;new ApolloServer&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Connect your GraphQL Server with &lt;code&gt;server.applyMiddleware&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I personally really love the fact that Apollo Server is non-intrusive and can be tacked on any project as an alternative way to communicate between services and applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to go from here
&lt;/h2&gt;

&lt;p&gt;If you're new to Apollo and GraphQL, a great way to learn is to actually build something in real life. For that reason, I highly recommend checking out the &lt;a href="https://www.apollographql.com/docs/tutorial/introduction?utm_source=devto&amp;amp;utm_medium=blog_post&amp;amp;utm_campaign=add_graphl_server_express_2_mins" rel="noopener noreferrer"&gt;Apollo Fullstack Tutorial (you can also learn in TypeScript now 🔥)&lt;/a&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;I'm &lt;a href="https://twitter.com/stemmlerjs" rel="noopener noreferrer"&gt;Khalil Stemmler&lt;/a&gt;, a Developer Advocate at Apollo GraphQL. I teach advanced TypeScript, GraphQL, and Node.js best practices for large-scale applications. Feel free to ping me on &lt;a href="https://twitter.com/stemmlerjs" rel="noopener noreferrer"&gt;Twitter&lt;/a&gt; if you need help with anything Apollo, TypeScript, or architecture-related. Cheers 🤠&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>graphql</category>
      <category>expressjs</category>
      <category>node</category>
      <category>restfulapi</category>
    </item>
    <item>
      <title>How to Learn Software Design and Architecture [Roadmap]</title>
      <dc:creator>Khalil Stemmler</dc:creator>
      <pubDate>Sun, 29 Sep 2019 18:08:51 +0000</pubDate>
      <link>https://dev.to/stemmlerjs/how-to-learn-software-design-and-architecture-ago</link>
      <guid>https://dev.to/stemmlerjs/how-to-learn-software-design-and-architecture-ago</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;This article is a summary of what I'm writing about in my newest project, &lt;a href="https://solidbook.io"&gt;solidbook.io - The Handbook to Software Design and Architecture with TypeScript&lt;/a&gt;. Check it out it you like this post.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It's crazy to me to consider the fact that Facebook was once an empty text file on someone's computer.&lt;/p&gt;

&lt;p&gt;Lol.&lt;/p&gt;

&lt;p&gt;This past year, I've been going hard in software design and architecture, &lt;a href="https://khalilstemmler.com/articles/domain-driven-design-intro/"&gt;Domain-Driven Design&lt;/a&gt;, and &lt;a href="https://solidbook.io"&gt;writing a book&lt;/a&gt; on it, and I wanted to take a moment to try to piece it together into something useful I could share with the community.&lt;/p&gt;

&lt;p&gt;Here's my roadmap for how to learn software design and architecture.&lt;/p&gt;

&lt;p&gt;I've broken it down into two artifacts: the &lt;strong&gt;stack&lt;/strong&gt; and the &lt;strong&gt;map&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Stack
&lt;/h2&gt;

&lt;p&gt;Similar to the &lt;a href="https://en.wikipedia.org/wiki/OSI_model"&gt;OSI Model&lt;/a&gt; in networking, each layer builds on top of the foundation of the previous one.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ntjWTm94--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/e727h5b9nozcuo4za2yw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ntjWTm94--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/e727h5b9nozcuo4za2yw.png" alt="The stack"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Map
&lt;/h2&gt;

&lt;p&gt;While I think the stack is good to see the bigger picture of how everything works together, the map is a little bit more detailed (and inspired by the &lt;a href="https://github.com/kamranahmedse/developer-roadmap"&gt;web developer roadmap&lt;/a&gt;) and as a result, I think it's more useful.&lt;/p&gt;

&lt;p&gt;It's pretty huge, and Dev.to won't let me upload the entire thing, so &lt;a href="https://khalilstemmler.com/articles/software-design-architecture/full-stack-software-design/"&gt;click here to fork the repo, read my detailed write-up and see the entire image&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_VVi-SDM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7f7bqt2vg9pelqp1cbss.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_VVi-SDM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/7f7bqt2vg9pelqp1cbss.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I hope it's useful.&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

</description>
      <category>softwaredesign</category>
      <category>architecture</category>
      <category>cleancode</category>
    </item>
    <item>
      <title>The Moment I Fell In Love With Coding</title>
      <dc:creator>Khalil Stemmler</dc:creator>
      <pubDate>Tue, 07 May 2019 15:46:10 +0000</pubDate>
      <link>https://dev.to/stemmlerjs/the-moment-i-fell-in-love-with-coding-2j2m</link>
      <guid>https://dev.to/stemmlerjs/the-moment-i-fell-in-love-with-coding-2j2m</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ziW1fyl---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/wx3swcw23jk620aosene.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ziW1fyl---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://thepracticaldev.s3.amazonaws.com/i/wx3swcw23jk620aosene.png" alt="" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;My moment was in 2013, the second year of university. I had recently gotten into &lt;strong&gt;glitch art&lt;/strong&gt; and I was determined to figure out how to create my own tool. &lt;br&gt;
It wasn't until I learned about abstract data structures and how to implement a queue and a stack that it clicked in as how to build my tool.&lt;/p&gt;

&lt;p&gt;During an all-nighter at &lt;a href="https://www.instagram.com/kirk_danuco/"&gt;@kirk_danuco&lt;/a&gt;'s apartment, I finally figured it out.&lt;/p&gt;

&lt;p&gt;I was so high on excitement that my body wasn't convinced I had just spent an entire 24 hours awake.&lt;/p&gt;

&lt;p&gt;It was at that moment that I truly fell in love with coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--EERtI6fM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cloud.githubusercontent.com/assets/6892666/13548037/f228d03c-e2b3-11e5-962c-be4a2074a9bd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--EERtI6fM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_800/https://cloud.githubusercontent.com/assets/6892666/13548037/f228d03c-e2b3-11e5-962c-be4a2074a9bd.gif" alt="blurbchat" width="603" height="703"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I still use this tool to this day! You can download it from my &lt;a href="https://github.com/stemmlerjs/glitchie"&gt;GitHub&lt;/a&gt; and try it out yourself.&lt;/p&gt;

</description>
      <category>personal</category>
      <category>java</category>
      <category>glitch</category>
      <category>art</category>
    </item>
    <item>
      <title>Value Objects - DDD w/ TypeScript</title>
      <dc:creator>Khalil Stemmler</dc:creator>
      <pubDate>Sun, 07 Apr 2019 17:59:19 +0000</pubDate>
      <link>https://dev.to/stemmlerjs/value-objects-ddd-w-typescript-1g6e</link>
      <guid>https://dev.to/stemmlerjs/value-objects-ddd-w-typescript-1g6e</guid>
      <description>&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%2Fzo2lx6p4p6ib8yd09qz7.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%2Fzo2lx6p4p6ib8yd09qz7.png" alt="Domain Driven Design"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://khalilstemmler.com/articles/typescript-value-object/" rel="noopener noreferrer"&gt;Originally posted @ khalilstemmler.com&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In Domain-Driven Design, Value Objects are one of the two primitive concepts that help us to create rich and encapsulated domain models. &lt;/p&gt;

&lt;p&gt;The two concepts are &lt;strong&gt;Entities&lt;/strong&gt; and &lt;strong&gt;Value Objects&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Value Objects&lt;/em&gt; are best understood by understanding how it's different from an Entity. Their main difference is in how we determine &lt;strong&gt;identity&lt;/strong&gt; between two Value Objects and how we determine &lt;strong&gt;identity&lt;/strong&gt; between two Entities.&lt;/p&gt;

&lt;h3&gt;
  
  
  Entity Identity
&lt;/h3&gt;

&lt;p&gt;We use an Entity to model a domain concept when we care about the model's &lt;strong&gt;identity&lt;/strong&gt; and being able to distinguish that identity from other instances of the model. &lt;/p&gt;

&lt;p&gt;The &lt;em&gt;way that we determine that identity&lt;/em&gt; helps us determine whether it's an Entity or a Value Object.&lt;/p&gt;

&lt;p&gt;A common example is modeling a user. &lt;/p&gt;

&lt;p&gt;In this example, we'd say that a &lt;code&gt;User&lt;/code&gt; is an Entity because the way that we determine the difference between two different instances of a &lt;code&gt;User&lt;/code&gt; is through it's &lt;strong&gt;Unique Identifier&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Unique Identifier&lt;/strong&gt; we use here is either a randomly-generated UUID or an auto-incremented SQL id that becomes a Primary Key that we can use for lookup from some persistence technology.&lt;/p&gt;




&lt;h3&gt;
  
  
  Value Objects
&lt;/h3&gt;

&lt;p&gt;With Value Objects, we establish identity through the &lt;strong&gt;structural equality&lt;/strong&gt; of two instances.&lt;/p&gt;

&lt;h4&gt;
  
  
  Structural Equality
&lt;/h4&gt;

&lt;p&gt;Structural equality means that two objects have the same content. This is different from &lt;strong&gt;referential equality / identity&lt;/strong&gt; which means that the two objects &lt;em&gt;are the same&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;To identify two Value Objects from each other, we look at the actual contents of the objects and compare based on that.&lt;/p&gt;

&lt;p&gt;For example, there might be a &lt;code&gt;Name&lt;/code&gt; property on the &lt;code&gt;User&lt;/code&gt; Entity.&lt;/p&gt;

&lt;p&gt;How can we tell if two &lt;code&gt;Name&lt;/code&gt;s are the same?&lt;/p&gt;

&lt;p&gt;It's pretty much like comparing two strings, right?&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="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nick Cave&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nick Cave&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;// true&lt;/span&gt;

&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Kim Gordon&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Nick Cave&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt; &lt;span class="c1"&gt;// false&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is easy. &lt;/p&gt;

&lt;p&gt;Our &lt;code&gt;User&lt;/code&gt; could look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IUser&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Entity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IUser&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;public&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IUser&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="nx"&gt;props&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;props&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="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 is OK, but it could be better. Lemme ask a question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;What if we wanted to limit the length of a user's name. Let's say that it can be no longer than 100 characters, and it must be at least 2 characters.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;A naive approach would be to write some validation logic before we create an instance of this User, maybe in a service.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CreateUserService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;createUser &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="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&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;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;2&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User must be greater than 2 chars and less than 100.&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="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&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="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;This isn't ideal. What if we wanted to handle Editing a user's name?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EditUserService&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;editUserName &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;User&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="kr"&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;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="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;2&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User must be greater than 2 chars and less than 100.&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="nx"&gt;user&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="c1"&gt;// save&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;ol&gt;
&lt;li&gt;This isn't really the right place to be doing this.&lt;/li&gt;
&lt;li&gt;We've just repeated the same validation logic.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This is actually how a lot of projects start to spin out of scope. We end up putting too much domain logic and validation into the services, and the models themselves don't accurately encapsulate the domain logic.&lt;/p&gt;

&lt;p&gt;We call this an &lt;strong&gt;Anemic Domain Model&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We introduce value object classes to encapsulate where validation should occur and to satisfy the &lt;strong&gt;invariants&lt;/strong&gt; (validation &amp;amp; domain rules) of our models.&lt;/p&gt;

&lt;h3&gt;
  
  
  Value Objects
&lt;/h3&gt;

&lt;p&gt;We had this before, a basic class for our &lt;code&gt;User&lt;/code&gt; entity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IUser&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Entity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IUser&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;public&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IUser&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="nx"&gt;props&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;props&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="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;If we were to create a class for the &lt;code&gt;name&lt;/code&gt; property, we could co-locate all of the validation logic for a &lt;code&gt;name&lt;/code&gt; in that class itself. &lt;/p&gt;

&lt;p&gt;We will also make the &lt;code&gt;constuctor&lt;/code&gt; private, and using a &lt;code&gt;static factory method&lt;/code&gt; to execute the preconditions that must be satisfied in order to create a valid &lt;code&gt;name&lt;/code&gt; using the &lt;code&gt;constructor&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IName&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Name&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;ValueObject&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IName&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;private&lt;/span&gt; &lt;span class="nf"&gt;constuctor &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IName&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="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;create &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="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;)&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="k"&gt;if &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="kc"&gt;undefined&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;name&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;2&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="nx"&gt;length&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;)&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User must be greater than 2 chars and less than 100.&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="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&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="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;And then change the &lt;code&gt;User&lt;/code&gt; class to require a &lt;code&gt;IName&lt;/code&gt; instead of a string. &lt;/p&gt;

&lt;p&gt;We'll also utilize a &lt;code&gt;static factory method&lt;/code&gt; here as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;IUser&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;readonly&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;Name&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;User&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;Entity&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IUser&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;public&lt;/span&gt; &lt;span class="k"&gt;readonly&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;Name&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;constructor &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IUser&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="nx"&gt;props&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;props&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="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;create &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;IUser&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;props&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="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;props&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="kc"&gt;undefined&lt;/span&gt;&lt;span class="p"&gt;)&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Must provide a name for the user&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="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;User&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&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;h2&gt;
  
  
  Value Object class
&lt;/h2&gt;

&lt;p&gt;Here's an example of a Value Object class.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;shallowEqual&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;shallow-equal-object&lt;/span&gt;&lt;span class="dl"&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;ValueObjectProps&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;index&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;]:&lt;/span&gt; &lt;span class="kr"&gt;any&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="cm"&gt;/**
 * @desc ValueObjects are objects that we determine their
 * equality through their structrual property.
 */&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ValueObject&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="kd"&gt;extends&lt;/span&gt; &lt;span class="nx"&gt;ValueObjectProps&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;public&lt;/span&gt; &lt;span class="k"&gt;readonly&lt;/span&gt; &lt;span class="na"&gt;props&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="nf"&gt;constructor &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="na"&gt;props&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="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;props&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Object&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;freeze&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;equals &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;vo&lt;/span&gt;&lt;span class="p"&gt;?:&lt;/span&gt; &lt;span class="nx"&gt;ValueObject&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="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&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;vo&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="nx"&gt;vo&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&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;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;vo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="kc"&gt;undefined&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;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;shallowEqual&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;props&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;vo&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;props&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;Check out the &lt;code&gt;equals&lt;/code&gt; method. Notice that we use &lt;code&gt;shallowEquals&lt;/code&gt; in order to determine equality. This is one way to accomplish &lt;code&gt;structural equality&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;When it makes sense, subclasses of this &lt;strong&gt;Value Object&lt;/strong&gt; base class can also be extended to include convenience methods like &lt;code&gt;greaterThan(vo?: ValueObject&amp;lt;T&amp;gt;)&lt;/code&gt; or &lt;code&gt;lessThan(vo?: ValueObject&amp;lt;T&amp;gt;)&lt;/code&gt;. It wouldn't make sense in this example, but it might if we were talking about something like &lt;code&gt;LoggingLevel&lt;/code&gt;s or &lt;code&gt;BusinessRating&lt;/code&gt;s.&lt;/p&gt;




&lt;p&gt;In future articles, we'll talk about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;entity design&lt;/li&gt;
&lt;li&gt;better error handling technique for object creation&lt;/li&gt;
&lt;li&gt;moving anemic code out of services and into domain models&lt;/li&gt;
&lt;li&gt;writing DTOs to create data contracts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is part of the Domain-Driven Design with TypeScript series. If this was useful to you, let me know in the comments &amp;amp; subscribe to the newletter to get notified when new articles come out. Cheers!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://khalilstemmler.com/learn" rel="noopener noreferrer"&gt;Learn Enterprise TypeScript - Newsletter&lt;/a&gt;&lt;/p&gt;

</description>
      <category>ddd</category>
      <category>typescript</category>
      <category>softwaredesign</category>
      <category>valueobject</category>
    </item>
    <item>
      <title>When To Use TypeScript - A Detailed Guide Through Common Scenarios</title>
      <dc:creator>Khalil Stemmler</dc:creator>
      <pubDate>Sat, 06 Apr 2019 20:11:16 +0000</pubDate>
      <link>https://dev.to/stemmlerjs/when-to-use-typescript-a-detailed-guide-through-common-scenarios-4def</link>
      <guid>https://dev.to/stemmlerjs/when-to-use-typescript-a-detailed-guide-through-common-scenarios-4def</guid>
      <description>&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffmnev5boz88ht0woqcip.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Ffmnev5boz88ht0woqcip.jpg" title="When To Use TypeScript" alt="alt text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have you heard of that little programming language called &lt;strong&gt;TypeScript&lt;/strong&gt;? You know, the one that Microsoft made? The one that's kinda &lt;a href="https://redmonk.com/sogrady/2019/03/20/language-rankings-1-19/?utm_campaign=digest&amp;amp;utm_medium=email&amp;amp;utm_source=nuzzel" rel="noopener noreferrer"&gt;blowing up&lt;/a&gt;? &lt;/p&gt;

&lt;p&gt;Maybe you were like me, a true JavaScript purist. Why do I need TypeScript? I was doing &lt;em&gt;just fine&lt;/em&gt; coding away with React and Node without types. Prop types and Joi validation have been treating me just nicely, thank you.&lt;/p&gt;

&lt;p&gt;Maybe you caved and gave it a shot. Started playing with it. Maybe you hated it because it reminded you of Java. Maybe you got annoyed with how you couldn't be super productive right away. &lt;/p&gt;

&lt;p&gt;These were some of &lt;strong&gt;my own initial sentiments&lt;/strong&gt; when I first started with TypeScript. &lt;/p&gt;

&lt;p&gt;I certainly didn't see the benefit... up until I started experiencing some really annoying stuff. Things like builds not failing when they should, buggy code and typos finding their way into production code somehow in addition to finding it increasingly challenging to express my designs in a really clean object-oriented way.&lt;/p&gt;

&lt;p&gt;9 months later into using TypeScript, I've built new features in Angular apps for clients, I began compiling &lt;a href="https://univjobs.ca" rel="noopener noreferrer"&gt;Univjobs&lt;/a&gt;'s React / Redux front-end with TypeScript and ported all Univjobs' backend services to TypeScript from vanilla Node.js, refactoring mass amounts of code along the way.&lt;/p&gt;

&lt;p&gt;In this article, we'll take a look at some of the most common scenarios and identify when it might be vital to use TypeScript, and when we could probably just do without it and stick to vanilla JS.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why this discussion matters more than ever today
&lt;/h2&gt;

&lt;p&gt;I've come to the very important conclusion that depending on your situation, context, project, skill level and other factors, that it's actually &lt;strong&gt;dangerous&lt;/strong&gt; for your project to &lt;strong&gt;NOT&lt;/strong&gt; be written using TypeScript today.&lt;/p&gt;

&lt;p&gt;The front-end space, for one- is getting more and more complex. Certain features that were once considered bleeding-edge, are now very-much standard user exprience assumptions. &lt;/p&gt;

&lt;p&gt;For example, it's almost always expected that your app is going to still work offline in some capacity; and when users ARE online, it's also usually expected that they're going to get real-time notifications without having to refresh the page.&lt;/p&gt;

&lt;p&gt;These are some pretty steep (but definitely not unrealstic in 2019) demands.&lt;/p&gt;

&lt;p&gt;Before we dive into different scenarios, we should actually talk about the three categories of really hard software problems to be solved.&lt;/p&gt;

&lt;h2&gt;
  
  
  3 Categories of Hard Software Problems
&lt;/h2&gt;

&lt;p&gt;Generally speaking, there are 3. The first being building Performant System Problem, the second, the Embedded System Problem, and the third being the with Complex Domain Problem.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. The Performant System Problem
&lt;/h3&gt;

&lt;p&gt;Let's talk about Twitter. &lt;/p&gt;

&lt;p&gt;Twitter is actually a really simple concept. &lt;/p&gt;

&lt;p&gt;You sign up, you make tweets, you like other people's tweets and that's pretty much it.&lt;/p&gt;

&lt;p&gt;If Twitter is that simple, why couldn't someone else do it?&lt;/p&gt;

&lt;p&gt;It's apparent that the real challenge for Twitter is not actually so much as "what it does", but it's "how it's able to do what it does". &lt;/p&gt;

&lt;p&gt;Twitter has the unique challenge of serving requests from approximately 500 million users every single day. &lt;/p&gt;

&lt;p&gt;The hard problem that Twitter solves is actually a &lt;strong&gt;perfomance problem&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When the challenge is performance, whether we use a strictly typed language or not is less important.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. The Embedded System Problem
&lt;/h3&gt;

&lt;p&gt;An embedded system is a combination of computer hardware and software, with the purpose of enabling control over the mechanical or electrical aspects of a system.&lt;/p&gt;

&lt;p&gt;Most systems we use today are built on a very complex layer of code that, if not initially written in, compiles down to C or C++ usually. &lt;/p&gt;

&lt;p&gt;Coding in these languages is not for the faint of heart. &lt;/p&gt;

&lt;p&gt;In C, there is no such thing as objects; and we as humans like objects because we can easily understand them. C is procedural and this makes the code that we have to write in this language more challenging to keep clean. These problems also require knowledge of the lower-level details.&lt;/p&gt;

&lt;p&gt;C++ does make life a whole lot better because it has object orientation, but the challenge is still fundementally interacting with lower-level hardware details.&lt;/p&gt;

&lt;p&gt;Because we don't really have that much of a choice on the languages we use for these problems, it's irrelevant to discuss TypeScript here.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. The Complex Domain Problem
&lt;/h3&gt;

&lt;p&gt;For some problems, that challenge is less about scaling in terms of handling more requests, but scaling in terms of &lt;strong&gt;the codebase's size&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Enterprise companies have &lt;strong&gt;complex real-life problems&lt;/strong&gt; to be solved. In these companies, the biggest engineering challenges are usually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Being able to &lt;strong&gt;logically&lt;/strong&gt; (domains) separate parts of that monolith into smaller apps. And then, &lt;strong&gt;physically&lt;/strong&gt; (microservices for bounded contexts) splitting them up so that teams can be assigned to maintain them&lt;/li&gt;
&lt;li&gt;Handling integration and synchronization between these apps&lt;/li&gt;
&lt;li&gt;Modeling the domain concepts and actually solving the problems of the domain&lt;/li&gt;
&lt;li&gt;Creating a ubiquitous (all encompassing) language to be shared by developers and domain experts&lt;/li&gt;
&lt;li&gt;Not getting lost in the mass amounts of code written and slowing down to the point where it becomes impossible to add new features without breaking existing ones&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I've essentially described the types of problems that &lt;a href="https://dev.to/blank?todo=domain-driven-design"&gt;Domain Driven Design&lt;/a&gt; solves. For these types of projects, you wouldn't even think about not using a strictly-typed language like TypeScript. &lt;/p&gt;

&lt;h4&gt;
  
  
  Object-oriented JavaScript
&lt;/h4&gt;

&lt;p&gt;For &lt;strong&gt;Complex Domain&lt;/strong&gt; problems, if you don't choose TypeScript and instead, choose JavaScript, it will require some extra effort to be successful. Not only will you have to be &lt;strong&gt;extra comfortable&lt;/strong&gt; with your object modeling abilities in vanilla JavaScript, but you'll also have to know how to utilize the 4 principles of object-oriented programming (encapsulation, abstraction, inheritance, and polymorphism).&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This can be hard to do. JavaScript doesn't naturally come with concepts of interfaces and abstract classes. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;"Interface Segregation" from the SOLID design principles isn't easily achievable with vanilla JavaScript&lt;/p&gt;

&lt;p&gt;Using JavaScript alone would also require a certain level of discipline as a developer in order to keep the code clean, and this is vital once the codebase is sufficiently large. You're also left to ensure that your team shares the same discipline, experience and knowledge level on how to implement common design patterns in JavaScript. If not, you'll need to guide them.&lt;/p&gt;

&lt;p&gt;In Domain-Driven projects like this, the strong benefit from using a strictly typed language is &lt;em&gt;less&lt;/em&gt; about expressing what &lt;strong&gt;can be done&lt;/strong&gt;, but more about using encapsulation and information hiding to &lt;u&gt;reduce the surface area of bugs&lt;/u&gt; by limiting what domain objects are &lt;strong&gt;actually allowed to do&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;We can live without this on the front-end, but it's a &lt;strong&gt;hard language requirement for the backend&lt;/strong&gt; in my books. It's also the reason why I moved my Node.js backend services to TypeScript. &lt;/p&gt;

&lt;p&gt;There's a reason why TypeScript is called "&lt;strong&gt;JavaScript that scales&lt;/strong&gt;".&lt;/p&gt;

&lt;p&gt;Out of all three categories of hard software problems, only the Complex Domain Problem is the one where TypeScript is an absolute necessity.&lt;/p&gt;

&lt;p&gt;Besides this, there are other factors that might determine when it's best to use TypeScript for your JavaScript project. &lt;/p&gt;




&lt;h2&gt;
  
  
  Code size
&lt;/h2&gt;

&lt;p&gt;Code size &lt;em&gt;usually&lt;/em&gt; ties back to the &lt;strong&gt;Complex Domain Problem&lt;/strong&gt;, where a large codebase means a complex domain, but that's not always the case. &lt;/p&gt;

&lt;p&gt;When the amount of code a project has gets to a certain size, it becomes &lt;strong&gt;harder&lt;/strong&gt; to keep track of everything that exists, and becomes &lt;strong&gt;easier&lt;/strong&gt; to end up re-implementing something already coded. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Duplication is the enemy to well-designed and stable software.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is especially heightened when new developers start coding on an already large codebase.&lt;/p&gt;

&lt;p&gt;Visual Studio Code's autocompletion and Intellisense helps to navigate through huge projects. It works really well with TypeScript, but it's somewhat limited with JavaScript.&lt;/p&gt;

&lt;p&gt;For projects that I know will stay simple and small, or if I know that it will be thrown away eventually, I would be less pressed to recommend TypeScript as a necessity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Production software vs. pet projects
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Production software&lt;/strong&gt; is code that you care about, or code that you'll get in trouble for if it doesn't work. It's also code that you've written tests for. The general rule of thumb is that if you care about the code, you need to have unit tests for it. &lt;/p&gt;

&lt;p&gt;If you don't care, don't have tests. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pet projects&lt;/strong&gt; are self-explanatory. Do whatever you like. You have no professional commitment to uphold any standards of craftsmanship whatsoever. &lt;/p&gt;

&lt;p&gt;Go on and make things! Make small things, make big things.&lt;/p&gt;

&lt;p&gt;Maybe someday you'll experience the pain when your pet project turns into your main project which turns into production software, which is buggy because it didn't have tests or types 🙃 not like I've been there or anything...&lt;/p&gt;

&lt;h3&gt;
  
  
  Lack of Unit Tests
&lt;/h3&gt;

&lt;p&gt;It's not always possible to have tests for everything, because, well- &lt;strong&gt;life&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In that case, I'd say that if you don't have Unit Tests, the next best thing you could have is compile-time checking with TypeScript. After that, if you're using React, the next best is thing is to use runtime checking with Prop types.&lt;/p&gt;

&lt;p&gt;However, compile time checking is &lt;strong&gt;not a subsitute&lt;/strong&gt; for having unit tests. The good thing is that unit tests can be written in any language- so the argument for TypeScript here is irrelevant. What's important is that tests are written and we are confident about our code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Startups
&lt;/h2&gt;

&lt;p&gt;Definitely use whatever helps you be most productive. &lt;/p&gt;

&lt;p&gt;At this time, the language you choose matters a lot less.&lt;/p&gt;

&lt;p&gt;The most important thing for you to do is to validate your product. &lt;/p&gt;

&lt;p&gt;Choosing a language (Java, for example) or a tool (like Kubernetes) that you heard would help you scale in the future, while being totally unfamiliar with it and needing to spend time learning, may or may not be the best option in the case of a startup.&lt;/p&gt;

&lt;p&gt;Depending on how early you are, the most important thing for you to do is to be productive. &lt;/p&gt;

&lt;p&gt;In Paul Graham's famous article, &lt;a href="http://www.paulgraham.com/pypar.html" rel="noopener noreferrer"&gt;The Python Paradox&lt;/a&gt;, his main point is that startup engineers should just use the technology that maximizes their productivity.&lt;/p&gt;

&lt;p&gt;Overall, in this case, use whatever you're most comfortable with: types or no types. You can always refactor towards a better design once you know you've built something people actually want.&lt;/p&gt;

&lt;h2&gt;
  
  
  Working on Teams
&lt;/h2&gt;

&lt;p&gt;Depending on the size of your team and the frameworks you're using, using TypeScript might be a make or break kind-of thing.&lt;/p&gt;

&lt;h3&gt;
  
  
  Large teams
&lt;/h3&gt;

&lt;p&gt;When teams are sufficiently large (because the problems are sufficiently large), it's a good reason to use an opinionated framework, like Angular for the front-end, and TypeScript for the backend.&lt;/p&gt;

&lt;p&gt;The reason why using an opinionated framework is benefitial is because you limit the number of possible ways for people to accomplish something. In Angular, there's pretty much one main way to add a Route Guard, use Dependency Injection, hook up Routing, Lazy-Loading and Reactive Forms.&lt;/p&gt;

&lt;p&gt;The huge benefit here is that the API is well specified.&lt;/p&gt;

&lt;p&gt;With TypeScript, we save massive amounts of time and make communication efficient. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;The ability to quickly determine the required arguments and it's return type for any method, or the ability to explicitly describe program intent through public, private, and protected variables alone is incredibly useful.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yes, some of this is possible with JavaScript, but it's hacky.&lt;/p&gt;

&lt;h4&gt;
  
  
  Communicating patterns &amp;amp; implementing design principles
&lt;/h4&gt;

&lt;p&gt;Not only that, but &lt;strong&gt;design patterns&lt;/strong&gt;, the solutions to commonly occuring problems in software, are more easily communicated through explicit strictly-typed languages.&lt;/p&gt;

&lt;p&gt;Here's a JavaScript example of a common pattern. See if you can identify what it is.&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;AudioDevice&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;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;isPlaying&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&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;currentTrack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;play &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;track&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;currentTrack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;track&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;isPlaying&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&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;handlePlayCurrentAudioTrack&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;handlePlayCurrentAudioTrack &lt;/span&gt;&lt;span class="p"&gt;()&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;`Subclasss responsibility error`&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;Boombox&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AudioDevice&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="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;handlePlayCurrentAudioTrack &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Play through the boombox speakers&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;IPod&lt;/span&gt; &lt;span class="kd"&gt;extends&lt;/span&gt; &lt;span class="nc"&gt;AudioDevice&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="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;handlePlayCurrentAudioTrack &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Ensure headphones are plugged in&lt;/span&gt;
    &lt;span class="c1"&gt;// Play through the ipod&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;AudioDeviceType&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;Boombox&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Boombox&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;IPod&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Ipod&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;AudioDeviceFactory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;create&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deviceType&lt;/span&gt;&lt;span class="p"&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;switch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;deviceType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;AudioDeviceType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;Boombox&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;new&lt;/span&gt; &lt;span class="nc"&gt;Boombox&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="k"&gt;case&lt;/span&gt; &lt;span class="nx"&gt;AudioDeviceType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="na"&gt;IPod&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;new&lt;/span&gt; &lt;span class="nc"&gt;IPod&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nl"&gt;default&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;null&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;boombox&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;AudioDeviceFactory&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AudioDeviceType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Boombox&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;ipod&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;AudioDeviceFactory&lt;/span&gt;
  &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;AudioDeviceType&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;IPod&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you guessed &lt;strong&gt;Abstract Factory Pattern&lt;/strong&gt;, you're right. Depending on your familiarity with the pattern, it might not have been that obvious to you.&lt;/p&gt;

&lt;p&gt;Let's look at it in TypeScript now. Look at how much more intent we can signify about &lt;code&gt;AudioDevice&lt;/code&gt; in TypeScript.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AudioDevice&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nx"&gt;isPlaying&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;boolean&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;protected&lt;/span&gt; &lt;span class="nx"&gt;currentTrack&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ITrack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;null&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="p"&gt;}&lt;/span&gt;

  &lt;span class="nf"&gt;play &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;track&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;ITrack&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="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;currentTrack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;track&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;isPlaying&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&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;handlePlayCurrentAudioTrack&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;abstract&lt;/span&gt; &lt;span class="nf"&gt;handlePlayCurrentAudioTrack &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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Immediate improvements&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We know the class is abstract &lt;strong&gt;right away&lt;/strong&gt;. We needed to sniff around in the JavaScript example.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;AudioDevice&lt;/strong&gt; can be instantiated in the JavaScript example. This is bad, we intended &lt;strong&gt;AudioDevice&lt;/strong&gt; to be an abstract class. And abstract classes shouldn't be able to be instantiated, they're only meant to be subclassed and implemented by &lt;a href="https://khalilstemmler.com/wiki/concrete-class/" rel="noopener noreferrer"&gt;concrete classes&lt;/a&gt;. This limitation is set in place correctly in the TypeScript example.&lt;/li&gt;
&lt;li&gt;We've signaled the scope of the variables.&lt;/li&gt;
&lt;li&gt;In this example, &lt;strong&gt;currentTrack&lt;/strong&gt; refers to an interface. As per the &lt;a href="https://khalilstemmler.com/wiki/dependency-inversion" rel="noopener noreferrer"&gt;Dependency Inversion&lt;/a&gt; design principle, we should always depend on abstractions, not concretions. This isn't possible in the JavaScript implementation.&lt;/li&gt;
&lt;li&gt;We've also signaled that any subclasses of &lt;strong&gt;AudioDevice&lt;/strong&gt; will need to implement the &lt;strong&gt;handlePlayCurrentAudioTrack&lt;/strong&gt; themselves. In the JavaScript example, we exposed the possibility for someone to introduce runtime errors trying to execute the method from either the illegal abstract class or the non-complete concrete class implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Takeaway: If you work on a large team and you need to minimize the potential ways someone could misuse your code, TypeScript is a good way to help fix that.&lt;/p&gt;

&lt;h3&gt;
  
  
  Smaller teams &amp;amp; coding styles
&lt;/h3&gt;

&lt;p&gt;Smaller teams are a lot easier to manage coding styles and communication. Paired with linting tools, frequent discussions about how things will get done and pre-commit hooks, I think small teams can be really successful without TypeScript.&lt;/p&gt;

&lt;p&gt;I think that success is an equation involving the size of the codebase and the size of the team.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As the codebase grows&lt;/strong&gt;, the team might find that they need to rely on some help from the language itself to remember where things are and how they should be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;As the team grows&lt;/strong&gt;, they might find they need more rules and restrictions to keep the style consistent and prevent duplicate code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frameworks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  React &amp;amp; Angular
&lt;/h3&gt;

&lt;p&gt;Much of what draws me and other developers to React is the ability to write code however you want and in an elegant/clever way. &lt;/p&gt;

&lt;p&gt;It's true that React makes you a better JavaScript developer because it forces you to approach problems differently, it forces you to be aware of how &lt;strong&gt;this binding&lt;/strong&gt; in JavaScript works and enables you to compose large components out of small ones.&lt;/p&gt;

&lt;p&gt;React also allows you to have a bit of your own style. And because of the number of ways I can implement any given task, I will most often write vanilla React.js apps when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;the codebase is small&lt;/li&gt;
&lt;li&gt;it's just me coding it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And I will compile it with TypeScript when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;more than 3 people are coding it, or&lt;/li&gt;
&lt;li&gt;the codebase is expected to be very large&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I will also optionally use Angular for the same reason I will compile React with TypeScript.&lt;/p&gt;

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

&lt;p&gt;In conclusion, these are my personal opinions on when TypeScript is absolutely necessary and I welcome you to disagree with any of it. &lt;/p&gt;

&lt;p&gt;This is what has worked for me in the past when deciding whether to use TypeScript. However, today- since I've seen the light, it's not much more effort for me to use TypeScript over vanilla JavaScript as I'm equally comfortable with both and would prefer the type safety.&lt;/p&gt;

&lt;p&gt;My final points here are:&lt;/p&gt;

&lt;h2&gt;
  
  
  You can always gradually start using TypeScript
&lt;/h2&gt;

&lt;p&gt;Start gradually by adding TypeScript and ts-node to your &lt;code&gt;package.json&lt;/code&gt; and utilizing the &lt;code&gt;allowjs: true&lt;/code&gt;, option in your &lt;code&gt;tsconfig&lt;/code&gt; file.&lt;/p&gt;

&lt;p&gt;This is how I migrated all of my Node.js apps over time to TypeScript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Compile time errors are better than runtime ones
&lt;/h2&gt;

&lt;p&gt;You can't argue with that. If catching bugs in production code is especially important to you, TypeScript will help you minimize a lot of these.&lt;/p&gt;

&lt;h2&gt;
  
  
  If you are in a position to learn it, learn it. It does wonders for your software design skills
&lt;/h2&gt;

&lt;p&gt;Depending on where you are in your life and your career, you might not have the time to learn it. If you do have the time, I'd recommend you start learning it and start learning about &lt;strong&gt;SOLID design principles&lt;/strong&gt; and software design patterns. This is the &lt;strong&gt;fastest way to level up as a Junior Developer&lt;/strong&gt; in my honest opinion.&lt;/p&gt;




&lt;p&gt;I hope this article was useful to you! Are you considering using TypeScript on your next project? Let me know if you agree/disagree in the comments.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://khalilstemmler.com/" rel="noopener noreferrer"&gt;Learn Advanced Node.js &amp;amp; TypeScript with Khalil&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Essential software development patterns, principles, and tutorials with modern JavaScript and TypeScript.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>9 Books For Junior Developers In 2019</title>
      <dc:creator>Khalil Stemmler</dc:creator>
      <pubDate>Wed, 13 Mar 2019 12:54:39 +0000</pubDate>
      <link>https://dev.to/stemmlerjs/9-books-for-junior-developers-in-2019-2d2</link>
      <guid>https://dev.to/stemmlerjs/9-books-for-junior-developers-in-2019-2d2</guid>
      <description>&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fm58xm52gajbb27sbd7qx.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fm58xm52gajbb27sbd7qx.jpg" alt="There's always so much more to learn"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Whether you’re a new developer or you’re fairly experienced as a programmer, you’ll come to realize that the amount of time you’ve worked at a job isn’t the best way to determine your skill and knowledge as a programmer (I know, tell that to the recruiters 🤫). &lt;/p&gt;

&lt;p&gt;What you do in your spare time and how you choose to take learning into your own hands is what’s going to ultimately determine your success in this industry. That’s why it’s so important for us as developers to adopt a growth mindset.&lt;/p&gt;

&lt;p&gt;There are some excellent ways to learn and improve as a developer. Some of those ways are pair-programming, online courses, meetups, work experience, building projects and finding a mentor. &lt;/p&gt;

&lt;p&gt;One of my personal favourite ways to learn is to crack open a well-written book and try to absorb something from those who have distilled years of knowledge and insight into a permanent artifact.&lt;/p&gt;

&lt;p&gt;Here are my personal recommendations that I think all developers (especially junior ones) should read at some point. These books are all highly regarded by professionals in our industry and have the potential to leave a profound impact on the quality of your work and your speed of development &amp;amp; learning. Some of them stray from the technical details and focus more on giving you practical rules about what it means to be a good developer; on the interpersonal and professional level.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0132350882/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0132350882&amp;amp;linkId=63a7fb47960db0590eabb58edf25aee5" rel="noopener noreferrer"&gt;1. Clean Code&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Robert C. Martin (Uncle Bob)
&lt;/h3&gt;

&lt;p&gt;After you overcome the basic challenges of development and get comfortable figuring out how to write code to solve problems, it’d be a good idea to take a read of this book. It turns out that making the code work the first time is actually the easy part. The hard part is making your code read well so that others are able to understand it and change it in the future. &lt;/p&gt;

&lt;p&gt;Remember the last time you had to read 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;function&lt;/span&gt; &lt;span class="nf"&gt;calculateIt&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;a&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;b&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;a&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;delta&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&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;x&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;delta&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;x&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;var&lt;/span&gt; &lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;next&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;h&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;element&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;y&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&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;y&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;h&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;Who knows what it really does. Code like this might work… but the moment we need to change it, we have to hope the author of the code is still in the company- and pray that he’s somehow able to decipher what he wrote potentially years ago.&lt;/p&gt;

&lt;p&gt;When careful attention isn’t taken to write code that’s readable and maintainable, we end up with pockets of code like this that everyone is afraid to touch, and if it ever breaks- we’re in trouble.&lt;/p&gt;

&lt;p&gt;Uncle Bob’s “Clean Code” teaches you how to identify what clean code looks like compared to bad code, and it teaches you how to transform it into good code. A task like this sounds trivial to most, but you’d be surprised at how turning a just a few clean software design principles into habits can help you write much more professional and scalable code. &lt;/p&gt;

&lt;p&gt;We’re software craftsmen, you know. Building a house is not much different than building an application in principle. We need to pay attention to the details or else it can all become very expensive to fix in the future if not done right first time.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0137081073/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0137081073&amp;amp;linkId=c172b446308df330b348e0db03e30168" rel="noopener noreferrer"&gt;2. The Clean Coder&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Robert C. Martin (Uncle Bob)
&lt;/h3&gt;

&lt;p&gt;This book is not necessarily a technical book as it is a book for teaching you how to be a professional in this industry. Professionals are those who: when faced with challenges, uncertainty and pressure, will continue to treat creating software as a craft and will be unswerved to adhering to their professional values.&lt;/p&gt;

&lt;p&gt;The Clean Coder is full of practical advice on estimation, refactoring, testing, dealing with conflict, schedules, avoiding burnout, and much more. Trusted advice from someone who has spent decades doing this stuff.&lt;/p&gt;

&lt;p&gt;One of the best things it teaches is how to have integrity as a developer, when to say “No” and how to say it.&lt;/p&gt;

&lt;p&gt;A book about professionalism.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0134757599/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0134757599&amp;amp;linkId=cd665cc1a6483955a2d51dd2d1a576d1" rel="noopener noreferrer"&gt;3. Refactoring&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Martin Fowler
&lt;/h3&gt;

&lt;p&gt;Martin Fowler is one of my favourite authors. The first reason is that he’s hilarious. His approach to writing software books is unmistakably “Fowler”. The other reason is that he's incredibly good at explaining complex topics, and doing so very simply- in a way that doesn’t fatigue you as a reader.&lt;/p&gt;

&lt;p&gt;Refactoring is a book that the creator of Ruby on Rails once said that you should “read before you write another line of code”. Fowler guides you through refactoring a simple application, introducing you to a number of techniques that he’s accumulated and cataloged over his years of consulting.&lt;/p&gt;

&lt;p&gt;Fowler shows you how to flip between coding and refactoring, how often you should be committing your code and when you should be writing your tests. Highly recommended. The latest version of this book was updated to present the examples in JavaScript, which was an added plus for me since it's my favourite language.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0134757599/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0134757599&amp;amp;linkId=cd665cc1a6483955a2d51dd2d1a576d1" rel="noopener noreferrer"&gt;4. Design Patterns: Elements of Reusable Object-Oriented Software&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Erich Gamma, Richard Helm, Ralph Johnson, &amp;amp; John Vlissides
&lt;/h3&gt;

&lt;p&gt;This is the seminal book on Design Patterns (and also the name of a damn good post-punk band). What are design patterns, you ask? Design Patterns are well-known solutions to commonly occurring problems in software development. If you’re familiar with the patterns, you’ll find that you’ll be able to greatly reduce the amount of time it takes you to put forth the solutions to those problems. &lt;br&gt;
Having good awareness of design patterns also allows you to communicate your solutions effectively with other developers.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Yeah, I just used a Facade overtop of whichever database Adapter gets loaded from the Strategy.”&lt;/p&gt;

&lt;p&gt;“Ahh! Gotcha.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yeah, it’s an older book. But it’s still one of the best for reference. If you’d like something on this topic that’s a bit more recent and friendly, I’d also recommend the good “Head First Design Patterns: A Brain-Friendly Guide” by Eric Freeman.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0321125215/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0321125215&amp;amp;linkId=c16807ab5ed838159eb3a89a339459a6" rel="noopener noreferrer"&gt;5. Domain-Driven Design: Tackling Complexity in the Heart of Software&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Eric Evans
&lt;/h3&gt;

&lt;p&gt;In order for large codebases to continue to scale, we need to logically split up code into different parts. The idea is to partition your code in a way such that it would be possible for separate teams to work on those parts of your system without affecting anyone else. &lt;/p&gt;

&lt;p&gt;The underlying concept that enables moving your codebase in this direction is Domain-Driven Design. It’s an approach to software development where we model the problems that exist in the “problem domain” (the real world) to a number of solution domains. &lt;/p&gt;

&lt;p&gt;DDD is incredibly important when a codebase gets sufficiently large. Large enterprise companies employ DDD in order to assign teams to parts of the company’s codebase.&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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpcolcxbah1afo2k38c9u.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%2Fthepracticaldev.s3.amazonaws.com%2Fi%2Fpcolcxbah1afo2k38c9u.png" alt="Anemic Domain Models vs Rich Ones"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;b&gt;&lt;br&gt;
  Taken from Vladimir Khorikov's course on "Refactoring an Anemic Domain Model to a Rich One"&lt;br&gt;
&lt;/b&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Eric Evan’s coined the term “Ubiquitous Language”, which is the term for building a common, all-encompassing language between the developers, the domain experts and any other users or actors in the domain. By using this Ubiquitous Language, it ensures that the most important domain concepts are well understood and get modeled in the software.&lt;/p&gt;

&lt;p&gt;The book is a little more technical and challenging than the others, but if you get familiar with these concepts, you’ll be very well off in understanding how today’s largest companies keep their codebases manageable and scalable.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/1617292397/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=1617292397&amp;amp;linkId=d1e4c3b453d124d01e886aab876c8ff9" rel="noopener noreferrer"&gt;6. Soft Skills: The Software Developer's Life Manual&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by John Sonmez
&lt;/h3&gt;

&lt;p&gt;We should strive to stay well-balanced as a software developer. Unfortunately, being well-balanced is not a trait that most people affiliate with software developers. The truth is, it’s incredibly important to invest in your learning, health and overall well-being as a developer.&lt;/p&gt;

&lt;p&gt;Soft skills is about the important stuff that matters outside of actually coding, like productivity, career goals and personal finance. Sonmez also goes into investing, how he retired at 33, fitness hacking tips and maintaining relationships- things rarely addressed in the programming community.&lt;/p&gt;

&lt;p&gt;It’s written in such a way that you can jump into the book at whichever chapter you think is most relevant to you today. &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0134494164/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0134494164&amp;amp;linkId=32995f69d0747d8723d42ffdda296878" rel="noopener noreferrer"&gt;7. Clean Architecture&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Robert C. Martin (Uncle Bob)
&lt;/h3&gt;

&lt;p&gt;What? Uncle Bob writes good books, ok?&lt;/p&gt;

&lt;p&gt;In school, there’s a lot of focus on algorithms and less focus on software design principles. I think it’s kind of unfortunate because in reality, you don’t encounter that many algorithm challenges too often. Instead, it’s more common that you’ll be faced with the challenge of structuring your code in a way that’s modular, flexible, readable and will allow you to add new features quickly when requirements change. &lt;/p&gt;

&lt;p&gt;Clean Architecture is about the essential software design principles and patterns that you’ll be able to use in order to face these challenges.&lt;/p&gt;

&lt;p&gt;Some of the best takeaways from this book are the cost of dependencies, stable vs. non-stable code and the SOLID principles: a way to write code so that it’s more understandable, flexible and maintainable.&lt;/p&gt;

&lt;p&gt;Other aspects of this book that were incredibly useful were concepts of “screaming architecture” and “packaging by component” which are opinions on how to organize your modules so that it practically &lt;strong&gt;&lt;strong&gt;screams&lt;/strong&gt;&lt;/strong&gt; to the reader exactly what the project is all about.&lt;/p&gt;

&lt;p&gt;This book goes well hand-in-hand with Domain-Driven Design, which is enabled through the use of a “Layered Architecture” or as Uncle Bob calls it, “The Clean Architecture” (also known as Ports and Adapters). A great book for anyone who wants to up their architecture chops and learn how to effectively design a system at a high level, and do the dance of dependencies at the detail level.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/0996128107/ref=as_li_tl?ie=UTF8&amp;amp;tag=stemmlerjs09-20&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;linkCode=as2&amp;amp;creativeASIN=0996128107&amp;amp;linkId=c26139ec47911c60569dc5851da21d06" rel="noopener noreferrer"&gt;8. The Effective Engineer&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Edmond Lau
&lt;/h3&gt;

&lt;p&gt;Time is our single most valuable asset in life, and we should aim to be more efficient with it. It’s easy to get bogged down and spend a lot of time fixing bugs and wasting effort. Doing repeated work. Bleh. The Effective Engineer is all about getting more done in less time and removing repeated work.&lt;/p&gt;

&lt;p&gt;We can mitigate wasted time and effort on repetitive tasks through a framework called “leverage”.&lt;/p&gt;

&lt;p&gt;Leverage helps you identify the activities that you can do that produce the most disproportionate results- per unit of time invested. It’s a framework that can apply to anything, whether that be how you learn, how you code, how you debug... anything!&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;a href="https://www.amazon.ca/gp/product/020161622X/ref=as_li_tl?ie=UTF8&amp;amp;camp=15121&amp;amp;creative=330641&amp;amp;creativeASIN=020161622X&amp;amp;linkCode=as2&amp;amp;tag=stemmlerjs09-20&amp;amp;linkId=005803be38be1c9a5d5b8c01afb049f3" rel="noopener noreferrer"&gt;9. The Pragmatic Programmer&lt;/a&gt;
&lt;/h1&gt;

&lt;h3&gt;
  
  
  by Andrew Hunt &amp;amp; David Thomas
&lt;/h3&gt;

&lt;p&gt;Praised for being easy to follow and understand, The Pragmatic Programmer is a book that should be on the desktop of developers of all levels. Andrew and David are programmers that not only spent many years doing what they do, but paying attention to what they were doing &lt;strong&gt;as they were doing it&lt;/strong&gt;- and then &lt;strong&gt;trying to determine if they could do that better&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;What came out of their years of introspection was this book, which introduces a number of essential programmer philosophies to follow throughout your career, like “programmers should have a "do it once, or automate" philosophy”.&lt;/p&gt;

&lt;p&gt;It includes simple yet detailed advice that you should carry with you in the back of your mind before you write another line of code or start a new project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final words
&lt;/h2&gt;

&lt;p&gt;Books really are some of the best tools to improve your knowledge and skills as a new programmer or Junior Developer. Books tend to have a really high return on investment; did you know you can make a lot of money programming? 😉&lt;/p&gt;

&lt;p&gt;These are just a few of the best books out there right now in 2019! None of them are really new, but that’s because programming has maintained the same general philosophies and best practices for years. As a prof I once had used to say, &lt;strong&gt;“you can make a lot of money in this industry, you just have to read the damn manual”&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Have you read any of these books? What did you think? Any books not on this list that you think newer developers would really benefit from reading? Let us know in the comments!&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;p&gt;Here’s a list of some really excellent articles that cover some of the topics from these books. If you don’t quite have the time to invest in fully blown books right now, familiarizing yourself with these concepts might assist you in your journey to become a better developer!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://refactoring.guru/" rel="noopener noreferrer"&gt;Refactoring.guru&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://stackify.com/solid-design-principles/" rel="noopener noreferrer"&gt;SOLID Design Principles&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself" rel="noopener noreferrer"&gt;DRY (Don’t Repeat Yourself)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.codeminer42.com/nodejs-and-good-practices-354e7d763626" rel="noopener noreferrer"&gt;NodeJS and Good Practices&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/remojansen/implementing-the-onion-architecture-in-nodejs-with-typescript-and-inversifyjs-10ad"&gt;Implementing the SOLID and the onion architecture in Node.js&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://fullstackmark.com/post/11/better-software-design-with-clean-architecture" rel="noopener noreferrer"&gt;Better Software Design with Clean Architecture&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html" rel="noopener noreferrer"&gt;The Clean Architecture&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Keep growing, and have fun while you’re at it!&lt;/p&gt;




&lt;p&gt;If you’re a Canadian student or recent-grad looking for entry-level developer opportunities or co-ops/internships, you should check out our platform, &lt;a href="https://univjobs.ca" rel="noopener noreferrer"&gt;Univjobs&lt;/a&gt;. We only post jobs specifically for students and recent grads.&lt;/p&gt;

</description>
      <category>books</category>
      <category>career</category>
      <category>learning</category>
      <category>cleancode</category>
    </item>
  </channel>
</rss>
