<?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: Jean Roger Nigoumi Guiala</title>
    <description>The latest articles on DEV Community by Jean Roger Nigoumi Guiala (@jrking365).</description>
    <link>https://dev.to/jrking365</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%2F35255%2Fb3eaba5c-fccf-4352-95a0-e97d51568151.jpg</url>
      <title>DEV Community: Jean Roger Nigoumi Guiala</title>
      <link>https://dev.to/jrking365</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jrking365"/>
    <language>en</language>
    <item>
      <title>Change Management In Software Engineering</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Wed, 05 Jul 2023 19:04:00 +0000</pubDate>
      <link>https://dev.to/jrking365/change-management-in-software-engineering-313c</link>
      <guid>https://dev.to/jrking365/change-management-in-software-engineering-313c</guid>
      <description>&lt;p&gt;Software engineering has an optimal goal : &lt;em&gt;To solve problems&lt;/em&gt;, and that is usually done by providing a technical solution. But Software engineering is also about having the best process that can enable a team to find optimal solution to a problem. &lt;br&gt;
When you grow in seniority, it becomes less about solving a specific task , but rather enabling the team and the system (process) so that the optimal solution can be found.&lt;br&gt;
basically if we take the analogy of a factory, it's making sure that the production line keeps working efficiently.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lBNuOuuz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0lyjb76rwc11f6sb3vt.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lBNuOuuz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a0lyjb76rwc11f6sb3vt.jpg" alt="Problem solving" width="640" height="682"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To do that sometimes we need to change the way that we are doing things, the way we are coding , the technology we are using , our deployment process or even our whole architecture.&lt;br&gt;
Being in charge of change as a subject expert sometimes means not only finding the right solution, but also support its adoption and implementation. &lt;br&gt;
To be able to do that efficiently there are some stuff that needs to be done, some of them are : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Understanding the system and the tradeoff&lt;/li&gt;
&lt;li&gt;Explaining the Why (the Vision)&lt;/li&gt;
&lt;li&gt;Supporting the change. &lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Understanding the System.
&lt;/h2&gt;

&lt;p&gt;This is one of the most important step. Usually as Senior or subject matter expert, we have our set of technologies or ways of doing things that we are used to and usually when tasking of finding new solution to a problem , we tend to go directly to the way we are used to doing things and that worked for us. It's not a bad thing as wisdom and knowledge are built through experience. But we need to be careful of the ecosystem we are in, the team , where the company is right now and other parameters. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PKva5oEX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92dlycrg4ry7n1pnr6cu.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PKva5oEX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92dlycrg4ry7n1pnr6cu.jpg" alt="Deep dive" width="640" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So taking that into consideration, I think it's important to &lt;em&gt;understand why this or that was done&lt;/em&gt;. &lt;em&gt;why did they decide to use a VM and not containerized?&lt;/em&gt; (maybe time? maybe expertise ? or the infrastructure doesn't allow it ) . The most important thing here is not to come with some preconceived things in mind, but rather understand and ask questions because this will define how we implement things. &lt;br&gt;
Understanding the system is not about knowing all the code or database , but rather &lt;em&gt;finding the thought process&lt;/em&gt; behind the implementation: how things are tied together.&lt;/p&gt;

&lt;h2&gt;
  
  
  Explain the WHY? : &lt;strong&gt;Communication is key&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uJ3MDyZZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cjwdnae3lh9e8f1pqs8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uJ3MDyZZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6cjwdnae3lh9e8f1pqs8.jpg" alt="communication is key" width="640" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The thing to understand here is : To be able to have a team rallied behind a vision, it's important for them to feel included and to know why the change is necessary. &lt;br&gt;
Let's say you have a javascript codebase and because you have more and more people working on it , the need to have a certain structure becomes necessary thus you think about &lt;strong&gt;Typescript&lt;/strong&gt;&lt;br&gt;
If you just come to the team with "&lt;em&gt;we are going to switch to typescript because it's better&lt;/em&gt;". You are going to create more confusion and also the team might be frustrated and feel like a change is imposed. &lt;/p&gt;

&lt;p&gt;What needs to be done is understand the needs take time with the team to explain why  the switch to typescript is important. Explain the Pro(s) , the con(s), the current process , how it will be with the implemented change , the goal behind that etc.&lt;br&gt;
In my experience I have found this approach to rally the team. the team gets more excited if they subscribe to the vision and it makes the change smooth. &lt;br&gt;
Ultimately this all comes down to : &lt;em&gt;Communication and trust&lt;/em&gt; and these are the most important things. &lt;/p&gt;

&lt;h2&gt;
  
  
  Support the change
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--lNdJS97u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccgru1g5dny6xthmhnce.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lNdJS97u--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ccgru1g5dny6xthmhnce.jpg" alt="Teach and support the team" width="640" height="427"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Last but not the least , and one of the most important step is to support the change and help the team. &lt;br&gt;
This usually translate into : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Documenting what needs to be done and how ?&lt;/li&gt;
&lt;li&gt;Implementing a &lt;code&gt;template&lt;/code&gt; if needed on how to do it. &lt;/li&gt;
&lt;li&gt;Follow up and make sure every question/concern finds an answer. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Basically this means : &lt;strong&gt;Lead the troop&lt;/strong&gt;. As the domain expert it is your task to make sure they are equipped to do it and also to establish the guidelines. &lt;/p&gt;

&lt;p&gt;If for example it is about moving the codebase to typescript, some of the tasks involve writing some &lt;em&gt;Development principles&lt;/em&gt; that will define the way the code is written , tests are written, what to allow and not , best practices and design pattern. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--RqQjUmj6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xz5nb8lbwswfuzr44td.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--RqQjUmj6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2xz5nb8lbwswfuzr44td.jpg" alt="Step by steps" width="640" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Lastly one of the most important thing to note is that &lt;em&gt;Change is done gradually&lt;/em&gt;. Do not try to change everything at first, start with the core or the smallest possible change that could lead the way. &lt;br&gt;
This gives you time also to make sure that your system keeps working and also give time to the team to digest and understand what is being done gradually , rather than having one big change that will cause more confusion. &lt;/p&gt;




&lt;h2&gt;
  
  
  About me
&lt;/h2&gt;

&lt;p&gt;I'm a Senior software Developer based in Canada, I love software architecture and building stuff. &lt;br&gt;
Feel free to reach out to me on : &lt;br&gt;
twitter : &lt;a href="https://twitter.com/Guialajr"&gt;https://twitter.com/Guialajr&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/jrking365"&gt;https://github.com/jrking365&lt;/a&gt;&lt;br&gt;
linkedIn: &lt;a href="https://www.linkedin.com/in/jean-roger-nigoumi/"&gt;https://www.linkedin.com/in/jean-roger-nigoumi/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>management</category>
      <category>development</category>
      <category>architecture</category>
    </item>
    <item>
      <title>DRY: Don't Repeat Yourself</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Fri, 10 Mar 2023 18:02:50 +0000</pubDate>
      <link>https://dev.to/jrking365/dry-dont-repeat-yourself-531c</link>
      <guid>https://dev.to/jrking365/dry-dont-repeat-yourself-531c</guid>
      <description>&lt;p&gt;A software engineering principle. &lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;As a software developer , it's all about &lt;strong&gt;finding solutions to problems&lt;/strong&gt;. Being able to build something that will solve a specific task. &lt;br&gt;
When you are just starting your journey, it will often be around just finding a way to solve a problem, making something work by using a specific language/technology. &lt;/p&gt;

&lt;p&gt;But at some point in your journey, it's not only about making it work , it's making sure you can be able to build on top of it; iterate and also allow people to contribute without impeding the work. There is that meme of coming back to the code you wrote a years ago and not understanding anything, I think it speaks to most of us in the software industry.&lt;/p&gt;

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

&lt;p&gt;So it's not only about coding , but building something that can last using tools and principles; just like building a car , a house. And that is called &lt;strong&gt;Software engineering&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;On Wikipedia a software engineer is define as &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;a person who applies the principles of software engineering to design, develop, maintain, test, and evaluate computer software. The term programmer is sometimes used as a synonym, but may also lack connotations of engineering education or skills.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One of those principles is called &lt;strong&gt;DRY&lt;/strong&gt;(&lt;strong&gt;D&lt;/strong&gt;on't &lt;strong&gt;R&lt;/strong&gt;epeat &lt;strong&gt;Y&lt;/strong&gt;ourself) &lt;/p&gt;
&lt;h2&gt;
  
  
  What is DRY ?
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F57l2m9h8gbccs4euitrh.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%2F57l2m9h8gbccs4euitrh.png" alt="do not repeat yourself javascript class"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The &lt;strong&gt;Dry&lt;/strong&gt; Principle that was popularized by the book &lt;em&gt;The Pragmatic Programmer&lt;/em&gt; by Andy Hunt and Dave Thomas (That I encourage you to read of course), in that book they state that :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“every piece of knowledge must have a single, unambiguous, authoritative representation within a system.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Basically , write only once. A rule of thumb is , if you find yourself writing something twice (a knowledge), it should be refactored(a single function, module, Abstract etc) and reused everywhere.&lt;/p&gt;

&lt;p&gt;take a look at this example :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// not DRY&lt;/span&gt;

&lt;span class="c1"&gt;//file 1 &lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;infoOfRectange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectange&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;area&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rectangle&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;*&lt;/span&gt; &lt;span class="nx"&gt;rectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 

&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="nx"&gt;area&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; 
&lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;rectangle&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="c1"&gt;//file 2 use the area to compare two rectangle&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;compare_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rectangle2&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;area_rectangle1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rectangle1&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;*&lt;/span&gt; &lt;span class="nx"&gt;rectangle1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&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;area_rectangle2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;rectangle2&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;*&lt;/span&gt; &lt;span class="nx"&gt;rectangle2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&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;area_rectangle2&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;area_rectangle2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;rectangle2&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="s2"&gt; has a greater area than &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;rectangle1&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="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;Here we have two different function that uses the &lt;strong&gt;area&lt;/strong&gt; of the rectangle, according to the definition, the area here is a &lt;strong&gt;knowledge&lt;/strong&gt; so that knowledge needs to have a single representation. &lt;br&gt;
So in our context , applying the DRY principle means having a single source of truth for that.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;//dry&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;rectangle_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;width&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;length&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nx"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;//calling that function in `compare_area`&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;compare_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rectangle2&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;area_rectangle1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;rectangle_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rectangle1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&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;area_rectangle2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;rectangle_area&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;rectangle2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;rectangle2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;width&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;
  
  
  Do not over engineer
&lt;/h2&gt;

&lt;p&gt;Now that we have learned about Dry , One common mistake is over engineering , meaning refactoring when we don't need to. Because in software development every second cost something and also it's not necessary to bring complexity in our system when it's not needed meaning when we don't have duplicate, when a &lt;code&gt;knowledge&lt;/code&gt; is only necessary in one place, it's already DRY and thus we don't need to separate everything.&lt;br&gt;
&lt;em&gt;I will refractor this because it could be useful later&lt;/em&gt; This statement should be a red flag and as we said above can cause many issue : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;introducing more complexity&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;introducting more coupling between our features&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Cost (is it necessary ?, can this time be spent on something else)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This introduce another principle known as &lt;strong&gt;KISS&lt;/strong&gt; (Keep it Simple Stupid). it translates simply to &lt;code&gt;Do not over engineer&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If you have some other example or tips , feel free to share them in the comment section, as well as questions :). &lt;/p&gt;

&lt;p&gt;You can follow me on twitter : &lt;a href="https://twitter.com/Guialajr" rel="noopener noreferrer"&gt;@Guialajr&lt;/a&gt;&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>architecture</category>
      <category>software</category>
      <category>codequality</category>
    </item>
    <item>
      <title>TIL: ruby factory bot and models association : `after(:build)`</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Wed, 25 Jan 2023 17:21:28 +0000</pubDate>
      <link>https://dev.to/jrking365/til-ruby-factory-bot-and-models-association-afterbuild-3i71</link>
      <guid>https://dev.to/jrking365/til-ruby-factory-bot-and-models-association-afterbuild-3i71</guid>
      <description>&lt;p&gt;so I had an issue today , I have a model (we will call it StatusMain) that embeds another model(we will call it HistoricalStatus), an example below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ruby '3'&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;StatusMain&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;Mongoid&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Document&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;Mongoid&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Timestamps&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;AASM&lt;/span&gt;


  &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ss"&gt;:status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;default: &lt;/span&gt;&lt;span class="s1"&gt;'initiated'&lt;/span&gt;

  &lt;span class="n"&gt;embeds_many&lt;/span&gt; &lt;span class="ss"&gt;:historical_statuses&lt;/span&gt;

  &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="ss"&gt;:initiated&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="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;status: &lt;/span&gt;&lt;span class="s1"&gt;'initiated'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="n"&gt;scope&lt;/span&gt; &lt;span class="ss"&gt;:rejected&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="n"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;status: &lt;/span&gt;&lt;span class="s1"&gt;'rejected'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="n"&gt;aasm&lt;/span&gt; &lt;span class="ss"&gt;column: :status&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;after_all_transitions&lt;/span&gt; &lt;span class="ss"&gt;:create_history&lt;/span&gt;

    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="ss"&gt;:initiated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;initial: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
    &lt;span class="n"&gt;state&lt;/span&gt; &lt;span class="ss"&gt;:rejected&lt;/span&gt;

    &lt;span class="n"&gt;event&lt;/span&gt; &lt;span class="ss"&gt;:reject&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;transitions&lt;/span&gt; &lt;span class="ss"&gt;from: :initiated&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;to: :rejected&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;to_p&lt;/span&gt;
    &lt;span class="no"&gt;Protos&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt; &lt;span class="no"&gt;StatusInitial&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="ss"&gt;id: &lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'$oid'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="ss"&gt;status: &lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;historical_statuses: &lt;/span&gt;&lt;span class="n"&gt;historical_statuses&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;collect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="ss"&gt;:to_p&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;

  &lt;span class="kp"&gt;private&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;create_history&lt;/span&gt;
    &lt;span class="n"&gt;historical_statuses&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="ss"&gt;status_main_id: &lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;status: &lt;/span&gt;&lt;span class="n"&gt;aasm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;to_state&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;created_at: &lt;/span&gt;&lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;updated_at: &lt;/span&gt;&lt;span class="no"&gt;Time&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and the historical_status model looks something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ruby '3'&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;HistoricalStatus&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;Mongoid&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Document&lt;/span&gt;
  &lt;span class="kp"&gt;include&lt;/span&gt; &lt;span class="no"&gt;Mongoid&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;Timestamps&lt;/span&gt;

  &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ss"&gt;:status_main_id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;BSON&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;ObjectId&lt;/span&gt;
  &lt;span class="n"&gt;field&lt;/span&gt; &lt;span class="ss"&gt;:status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;type: &lt;/span&gt;&lt;span class="no"&gt;String&lt;/span&gt;

  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:status_main&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;
  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;presence: &lt;/span&gt;&lt;span class="kp"&gt;true&lt;/span&gt;

  &lt;span class="n"&gt;embedded_in&lt;/span&gt; &lt;span class="ss"&gt;:status_main&lt;/span&gt;

  &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;to_p&lt;/span&gt;
    &lt;span class="no"&gt;Protos&lt;/span&gt;&lt;span class="o"&gt;::&lt;/span&gt;&lt;span class="no"&gt;HistoricalStatus&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="ss"&gt;id: &lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'$oid'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="ss"&gt;status_main_id: &lt;/span&gt;&lt;span class="n"&gt;status_main_id&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;as_json&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="s1"&gt;'$oid'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="ss"&gt;status: &lt;/span&gt;&lt;span class="n"&gt;status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;created_at: &lt;/span&gt;&lt;span class="n"&gt;created_at&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iso8601&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="ss"&gt;updated_at: &lt;/span&gt;&lt;span class="n"&gt;updated_at&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;iso8601&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;so as you can see, the goal is to have the historical_status store every status transitions, and be embedded in my StatusMain &lt;/p&gt;

&lt;p&gt;so as I was working on my spec , I designed my factories like this &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;status_main factory
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ruby '3'&lt;/span&gt;

&lt;span class="no"&gt;FactoryBot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:status_main&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'initiated'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;historical_statuses&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="p"&gt;[&lt;/span&gt;
        &lt;span class="n"&gt;create&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:historical_status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="ss"&gt;status_main: &lt;/span&gt;&lt;span class="n"&gt;instance&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
      &lt;span class="p"&gt;]&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;*historical_status factory&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ruby '3'&lt;/span&gt;

&lt;span class="no"&gt;FactoryBot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:historical_status&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;status_main&lt;/span&gt;

    &lt;span class="n"&gt;status_main_id&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;status_main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'initiated'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;trait&lt;/span&gt; &lt;span class="ss"&gt;:initiated&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'initiated'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;trait&lt;/span&gt; &lt;span class="ss"&gt;:rejected&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'rejected'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;So as you can see , in my factories, historical_status receives the status_main, that way , in status_main factory, I can create the historical_status with the correct status_main id. &lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;so the issues I had is that , my status_main_id was always nil in my historical_status , that caused my test to fail because as you can guess &lt;code&gt;.as_json['$oid'],&lt;/code&gt; does not exist on nil object.&lt;/p&gt;

&lt;p&gt;Tried multiple things and I was surprised that my status_main_id is nil... How can it be nil when I'm passing it and doing it correctly. &lt;br&gt;
Turns out my status_main object that I'm passing to historical_status was nil... now it's interesting, I continued investigating and found out , that my &lt;code&gt;status_main&lt;/code&gt; object was set &lt;strong&gt;AFTER&lt;/strong&gt; my &lt;code&gt;historical_status&lt;/code&gt; was created, thus &lt;code&gt;status_main_id&lt;/code&gt; was nil in historical_status.&lt;/p&gt;
&lt;h2&gt;
  
  
  The solution
&lt;/h2&gt;

&lt;p&gt;let me first paste the updated factory and then I will explain.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight ruby"&gt;&lt;code&gt;&lt;span class="c1"&gt;# ruby '3'&lt;/span&gt;

&lt;span class="no"&gt;FactoryBot&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;define&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
  &lt;span class="n"&gt;factory&lt;/span&gt; &lt;span class="ss"&gt;:historical_status&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
    &lt;span class="n"&gt;status_main&lt;/span&gt;

    &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'initiated'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="n"&gt;after&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="ss"&gt;:build&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt;&lt;span class="n"&gt;historical_status&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;evaluator&lt;/span&gt;&lt;span class="o"&gt;|&lt;/span&gt;
      &lt;span class="n"&gt;historical_status&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status_main_id&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;evaluator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;status_main&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;id&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;trait&lt;/span&gt; &lt;span class="ss"&gt;:initiated&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'initiated'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;

    &lt;span class="n"&gt;trait&lt;/span&gt; &lt;span class="ss"&gt;:rejected&lt;/span&gt; &lt;span class="k"&gt;do&lt;/span&gt;
      &lt;span class="n"&gt;status&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="s1"&gt;'rejected'&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;end&lt;/span&gt;
  &lt;span class="k"&gt;end&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;so as you can notice , we now have an &lt;code&gt;after(:build)&lt;/code&gt;&lt;br&gt;
In the new factory, I'm using the after(:build) callback to set the status_main_id after the historical_status object has been built, and before it's saved, this way you can use the evaluator to get the id of the &lt;code&gt;status_main&lt;/code&gt; and set it to the &lt;code&gt;status_main_id&lt;/code&gt; field. This is important because the factory is trying to use the id of the &lt;code&gt;status_main&lt;/code&gt; object that is associated with the historical_status and if the id is not set yet it will raise an error.&lt;/p&gt;

&lt;p&gt;The evaluator is an instance of FactoryBot::Evaluator that is passed to the block, which is used to access the attributes of the factory and the objects that are being built/created by the factory.&lt;/p&gt;

&lt;p&gt;By setting the &lt;code&gt;status_main_id&lt;/code&gt; in the after(:build) callback, you ensure that the &lt;code&gt;status_main_id&lt;/code&gt; field is set before the historical_status object is saved, and the id will be the same as the original &lt;code&gt;status_main&lt;/code&gt; &lt;code&gt;id&lt;/code&gt; field as wanted.&lt;/p&gt;

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

&lt;p&gt;So here is what I learned today , feel free to comment a better way to achieve that if you have some, or if you can explain in a different way what is happening.&lt;/p&gt;

</description>
      <category>watercooler</category>
      <category>offers</category>
    </item>
    <item>
      <title>How do you discipline yourself? Idea and tools</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Mon, 19 Aug 2019 10:08:56 +0000</pubDate>
      <link>https://dev.to/jrking365/how-do-you-discipline-yourself-idea-and-tools-48gm</link>
      <guid>https://dev.to/jrking365/how-do-you-discipline-yourself-idea-and-tools-48gm</guid>
      <description>&lt;p&gt;So lately I'm trying to be more organized and I'm trying to work more on personal projects (app, blogging, learning ...). But sometimes I just can't get my planning right And end up spending time doing the wrong stuff.&lt;br&gt;
I will like to know how you keep motivated and focused on the right thing? what are the tools you use? What helped you in being more organized and focused.&lt;/p&gt;

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

</description>
      <category>discuss</category>
      <category>productivity</category>
      <category>planning</category>
    </item>
    <item>
      <title>Tips on improving Web accessibility</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Wed, 27 Feb 2019 12:49:28 +0000</pubDate>
      <link>https://dev.to/jrking365/tips-on-improving-web-accessibility--32jc</link>
      <guid>https://dev.to/jrking365/tips-on-improving-web-accessibility--32jc</guid>
      <description>&lt;p&gt;When creating a website, what are your tips and tricks for managing accessibility?&lt;br&gt;
For example, suppose you build a website, how do you imagine the whole process to make it as accessible as possible? what tools do you use to test? Also, how do you manage colors for color-blind readers?&lt;br&gt;
I am really interested in knowing how you are doing to make the Web as accessible as possible.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>a11y</category>
      <category>wcag</category>
    </item>
    <item>
      <title>How to keep calm while dealing with bugs?</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Mon, 13 Aug 2018 15:00:32 +0000</pubDate>
      <link>https://dev.to/jrking365/how-to-keep-calm-while-dealing-with-bugs-2o6h</link>
      <guid>https://dev.to/jrking365/how-to-keep-calm-while-dealing-with-bugs-2o6h</guid>
      <description>&lt;p&gt;So i want us to discuss on a subject: How do you handle stress, how to keep cool while dealing with bugs? what is your tips, what do you do when you are coding and you spend hours on a bug and start getting angry or nervous?&lt;/p&gt;

&lt;p&gt;Personally i just leave my computer for 15Min and try to do something else not computer related. What about you?&lt;/p&gt;

</description>
      <category>discuss</category>
    </item>
    <item>
      <title>Imposter syndrome</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Sat, 11 Aug 2018 23:51:20 +0000</pubDate>
      <link>https://dev.to/jrking365/imposter-syndrome-5ck4</link>
      <guid>https://dev.to/jrking365/imposter-syndrome-5ck4</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bJRr6rnT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6oby64hf6dk928xm76pg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bJRr6rnT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/6oby64hf6dk928xm76pg.png"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.chanty.com/blog/stop-feeling-like-imposter-work/"&gt;image source&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;S&lt;/strong&gt;o, i have been studying software engineering for almost 5 years, and i always had a problem, i always thought (and still now sometimes) that i don't know how to code, that I'm not even average, or that they are many genius programmers and I'm just one guy that struggle to write code.&lt;br&gt;
But, two weeks ago, a friend of mine told me something that turned me upside down :&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"you are a role model and i am working day and night to reach the coding skills that you have,i want to be just like you".&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;When she said that, i was shocked, so many things came to my mind : &lt;br&gt;
&lt;em&gt;how can she want to be just like me when i spend my time on stack-overflow, when i can't remember some basics CSS rules?&lt;/em&gt;&lt;br&gt;
But i realized something, coding is a journey, you will never be the best but you always have to work to be the best.&lt;br&gt;
Sometimes you may feel like you know nothing, but remember that those who answer your questions on Stack-overflow were one day just like you.&lt;br&gt;
Remember that there is someone out there who is working and hoping someday to be like you, to reach the level where you are now.&lt;br&gt;
So whenever the imposter syndrome hits you , just remember what you have already done and say to yourself that you are just starting your journey. Always say to yourself that you are the best, that you are going to be the best, self confidence is the key.&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>career</category>
      <category>beginners</category>
      <category>productivity</category>
    </item>
    <item>
      <title>How to build a successful developer community</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Wed, 13 Dec 2017 13:47:58 +0000</pubDate>
      <link>https://dev.to/jrking365/how-to-build-a-successful-developer-community-cb</link>
      <guid>https://dev.to/jrking365/how-to-build-a-successful-developer-community-cb</guid>
      <description>&lt;h5&gt;
  
  
  So i'm planning to start a developer community here in cameroon (africa). It will be basically about sharing experience, learning and making some events... also i'm planning to create free hackathon, trainings.
&lt;/h5&gt;

&lt;p&gt;I will like to have some of your tips on how to build a great dev community, what to do, how to organize etc. ;)&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>community</category>
      <category>dev</category>
      <category>hackathon</category>
    </item>
    <item>
      <title>What are the Best Tips in implement TDD in a web application project</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Fri, 17 Nov 2017 14:41:28 +0000</pubDate>
      <link>https://dev.to/jrking365/what-are-the-best-tips-in-implement-tdd-in-a-web-application-project-76b</link>
      <guid>https://dev.to/jrking365/what-are-the-best-tips-in-implement-tdd-in-a-web-application-project-76b</guid>
      <description>&lt;h5&gt;
  
  
  I don't really understand the TDD (test Driven Development) i will like to have somme informations on the best way to implement it... some tools you use? how do you code?
&lt;/h5&gt;

</description>
      <category>discuss</category>
      <category>tdd</category>
      <category>beginners</category>
      <category>testing</category>
    </item>
    <item>
      <title>What does it take to be a senior developer?</title>
      <dc:creator>Jean Roger Nigoumi Guiala</dc:creator>
      <pubDate>Mon, 02 Oct 2017 03:20:41 +0000</pubDate>
      <link>https://dev.to/jrking365/what-does-it-mean-to-be-a-senior-developer-55</link>
      <guid>https://dev.to/jrking365/what-does-it-mean-to-be-a-senior-developer-55</guid>
      <description></description>
      <category>discuss</category>
      <category>question</category>
    </item>
  </channel>
</rss>
