<?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: Lucas Fernandes</title>
    <description>The latest articles on DEV Community by Lucas Fernandes (@lsfernandes92).</description>
    <link>https://dev.to/lsfernandes92</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%2F237450%2F49a050db-ebd4-4c22-b21c-17557f4b7eee.png</url>
      <title>DEV Community: Lucas Fernandes</title>
      <link>https://dev.to/lsfernandes92</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lsfernandes92"/>
    <language>en</language>
    <item>
      <title>How do I practice vocabulary</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Wed, 30 Jul 2025 17:37:14 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/how-do-i-practice-vocabulary-53h8</link>
      <guid>https://dev.to/lsfernandes92/how-do-i-practice-vocabulary-53h8</guid>
      <description>&lt;h2&gt;
  
  
  TLDR
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;1. Read and note unknown words (&lt;strong&gt;max. 5 per day&lt;/strong&gt;)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;2. Create flashcards:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Front: word + original sentence&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Back: word meaning + sentences examples&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;3. Before each day of reading:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Set a study time frame&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;For each word, try to remember the meanings and the
sentences examples &lt;strong&gt;mentally&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Then consult the meaning &lt;strong&gt;thoroughly&lt;/strong&gt;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Then &lt;strong&gt;write and speak out&lt;/strong&gt; loud what you just consulted to reinforce memory&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;&lt;strong&gt;Use &lt;a href="https://apps.ankiweb.net/" rel="noopener noreferrer"&gt;Anki&lt;/a&gt;&lt;/strong&gt; to create flashcards and automate reviews.&lt;/em&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;To improve my vocabulary, I read. &lt;em&gt;&lt;strong&gt;Ta-dah!&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;No seriously, I generally take the opportunity when I'm reading a book in English to do this, but it works with any type of media, for example, a foreign article or news.&lt;/p&gt;

&lt;p&gt;The advantage of books is that you'll possibly notice that the word you want to learn repeats later in the reading. This will help you remember and reinforce your understanding of the word.&lt;/p&gt;

&lt;p&gt;Personally, I like it because when you encounter the word later in the book you'll feel that reading will flow better, and thus, a sense of progress. &lt;/p&gt;

&lt;p&gt;Keep in mind that it's a &lt;strong&gt;process that takes time&lt;/strong&gt; and that at the beginning, reading will be less fluid. It takes time because you have to stop, research the word, read the meaning, read a couple of examples of its application in sentences, take notes and dedicate time to remember their meanings regularly.&lt;/p&gt;

&lt;p&gt;On the other hand, this way you'll &lt;strong&gt;retain more information&lt;/strong&gt;, &lt;strong&gt;strengthen your brain connections&lt;/strong&gt; and have a &lt;strong&gt;higher quality of reading.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Anki, your flashcard brain wizard
&lt;/h2&gt;

&lt;p&gt;I'll quote how the &lt;a href="https://apps.ankiweb.net/" rel="noopener noreferrer"&gt;Anki site&lt;/a&gt; describes it.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Anki is a flashcard program that helps you spend more time on challenging material, and less on what you already know.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And that's sufficient for describing most of what Anki does. However, what the site doesn't mention is its powerful ability to do &lt;strong&gt;spaced repetition&lt;/strong&gt; for you.&lt;/p&gt;

&lt;h3&gt;
  
  
  So what's spaced repetition?
&lt;/h3&gt;

&lt;p&gt;The idea of spaced repetition is nothing more than you reinforcing the memories of these words &lt;strong&gt;before they are forgotten&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of reviewing all words at once, this method tells us to space this &lt;strong&gt;review over time.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The great thing about using Anki is that you don't need to worry about manually controlling the spacing of reviews over time. The program does it for you!&lt;/p&gt;

&lt;h2&gt;
  
  
  The core concept
&lt;/h2&gt;

&lt;p&gt;Take your reading material and &lt;strong&gt;start reading.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When you encounter a &lt;strong&gt;word you don't know, stop, note it down in Anki, and research its meaning.&lt;/strong&gt; I like to use &lt;a href="https://dictionary.cambridge.org/" rel="noopener noreferrer"&gt;Cambridge Dictionary&lt;/a&gt; to research meanings.&lt;/p&gt;

&lt;p&gt;My annotation style for each word follows the flashcard idea, where on the front of the card I put the &lt;strong&gt;word and the sentence&lt;/strong&gt; where it appeared. On the back of the card I write the &lt;strong&gt;meaning and more examples&lt;/strong&gt; of the word's application in sentences.&lt;/p&gt;

&lt;p&gt;Using the word &lt;strong&gt;"ad-hoc"&lt;/strong&gt; as an example. In the front I write:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;ad-hoc&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;"We held an &lt;em&gt;&lt;strong&gt;ad hoc&lt;/strong&gt;&lt;/em&gt; meeting to address the server crash"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;and on the back I write:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Describes something create or done &lt;strong&gt;spontaneously&lt;/strong&gt;, &lt;strong&gt;impromptu&lt;/strong&gt;, or &lt;strong&gt;as needed.&lt;/strong&gt; It's a fancy way to say &lt;strong&gt;"on the fly".&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;"We held an &lt;em&gt;&lt;strong&gt;ad hoc&lt;/strong&gt;&lt;/em&gt; meeting to address the server crash"&lt;/p&gt;

&lt;p&gt;"The team formed an &lt;em&gt;&lt;strong&gt;ad hoc&lt;/strong&gt;&lt;/em&gt; committee to handle the merger"&lt;/p&gt;

&lt;p&gt;In tech context, it means that something &lt;strong&gt;unexpected/unplanned came up that disrupt the regular workflow.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;p&gt;"My spring backlog grew due to the &lt;em&gt;&lt;strong&gt;ad hoc&lt;/strong&gt;&lt;/em&gt; bug fixes"&lt;/p&gt;

&lt;p&gt;"The &lt;em&gt;&lt;strong&gt;ad hoc&lt;/strong&gt;&lt;/em&gt; standup lasted 20 minutes to align on the hotfix"&lt;/p&gt;

&lt;p&gt;"Yesterday I spent my time in &lt;em&gt;&lt;strong&gt;ad hoc&lt;/strong&gt;&lt;/em&gt; debugging, instead of my planned assigned ticket"&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The important thing here is that on the front, you just put the minimum to try remember the meaning. The back of the card should be consulted only after trying to remember the word's meaning.&lt;/p&gt;

&lt;p&gt;Continue reading and repeat the process when you encounter another unknown word, but do this for a &lt;strong&gt;maximum of 5 words per day.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Doing this you'll create an arsenal of words to practice in a regular time space.&lt;/p&gt;

&lt;h2&gt;
  
  
  The importance of writing
&lt;/h2&gt;

&lt;p&gt;There's something very powerful about writing that makes my brain really &lt;strong&gt;strive to remember&lt;/strong&gt; something. Writing it's also helpful in spell the word, the &lt;strong&gt;spelling&lt;/strong&gt;. Writing combined with the practice of speaking out loud will make it &lt;strong&gt;easier to retain meanings.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For each day, I like to set aside some time to review the words before resuming reading. My way of studying has been the following for each word that Anki tells me I need to review on that day:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;I set aside some time, like 1 minute&lt;/li&gt;
&lt;li&gt;I try to remember its meaning and its application in sentences &lt;strong&gt;mentally&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;I then &lt;strong&gt;consult the meaning&lt;/strong&gt; and its application in sentences thoroughly&lt;/li&gt;
&lt;li&gt;Now, again without looking at the consultation, I &lt;strong&gt;write and speak out loud&lt;/strong&gt; the meaning and application in sentences. Remembering what I just read from the consultation itself&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And that's it! I now get a small frisson of excitement when I suddenly recall what some random word means, proving that this steps helps me retain information for longer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Thank you for reading!&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Want to help me? If these steps ever helped you out or wanna keep me excited on sharing learning techniques like this? Consider &lt;a href="https://buymeacoffee.com/jaggiesweekly" rel="noopener noreferrer"&gt;&lt;strong&gt;buying me a coffee&lt;/strong&gt;&lt;/a&gt; or supporting me on &lt;a href="https://ko-fi.com%20jaggiesweekly" rel="noopener noreferrer"&gt;&lt;strong&gt;Ko-fi&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>learning</category>
    </item>
    <item>
      <title>MVC: The Linchpin Architecture of Ruby on Rails</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Thu, 11 Apr 2024 16:58:09 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/mvc-the-linchpin-architecture-of-ruby-on-rails-3hi3</link>
      <guid>https://dev.to/lsfernandes92/mvc-the-linchpin-architecture-of-ruby-on-rails-3hi3</guid>
      <description>&lt;p&gt;When it comes to web development, knowing your architectural patterns is key to building solid and easy-to-maintain apps. And one of the stars in the Ruby on Rails world is MVC—which stands for Model-View-Controller. So, let's cover some key points on what MVC is and how it plays a big role in Rails development.&lt;/p&gt;




&lt;h2&gt;
  
  
  Explaining MVC in Ruby on Rails
&lt;/h2&gt;

&lt;p&gt;In Rails, you get the MVC model right out of the box, embodying the &lt;a href="https://rubyonrails.org/doctrine#convention-over-configuration" rel="noopener noreferrer"&gt;convention over configuration principle&lt;/a&gt; that Rails is known for. It's like having a roadmap that tells you where to go without sweating the small stuff. This setup helps devs concentrate on the fun stuff—like cooking up new features—instead of struggling with naming and organizing files within the project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Web Request Flow in Rails MVC
&lt;/h2&gt;

&lt;p&gt;For knowledge purposes, understanding how a simple web request moves through the MVC can make things clearer. Here's a simple breakdown of how it works:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A user sends a request to the web server&lt;/li&gt;
&lt;li&gt;The web server gets the request and passes it to the controller&lt;/li&gt;
&lt;li&gt;The request is then directed to its specific route, like &lt;code&gt;/grocery&lt;/code&gt;. The route connects with the controller method that handles this request&lt;/li&gt;
&lt;li&gt;The controller talks to the model to get the needed data from the database. It then processes this data based on the app's logic&lt;/li&gt;
&lt;li&gt;Once the data is validated, it's prepared to be shown in the view&lt;/li&gt;
&lt;li&gt;The data is sent to the view for display, usually in an HTML file like &lt;code&gt;index.html&lt;/code&gt; or &lt;code&gt;index.html.erb&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The view processes the data and creates a response to send back to the webserver&lt;/li&gt;
&lt;li&gt;This response, along with any JSON data, is then sent back to the user's browser&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  The Model
&lt;/h2&gt;

&lt;p&gt;The Model in MVC is like the brain of the operation. It's where your business logic resides and where all the smarts and data magic happen in your app. In a nutshell, here's what you need to know about the Model:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It encapsulates data-related business logic&lt;/li&gt;
&lt;li&gt;Each Model corresponds to a table in the database&lt;/li&gt;
&lt;li&gt;While the Model class name is by convention in singular, its equivalent table name in the database is plural&lt;/li&gt;
&lt;li&gt;It inherits from &lt;code&gt;ActiveRecord::Base&lt;/code&gt; which brings some facilities, such as:

&lt;ul&gt;
&lt;li&gt;Establish and maintain a connection with the database&lt;/li&gt;
&lt;li&gt;Enable data retrieval from the database&lt;/li&gt;
&lt;li&gt;Facilitate data writing to the database&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;
&lt;code&gt;ActiveRecord::Base&lt;/code&gt; provides abstractions of database adapters to connect with a wide range of popular databases&lt;/li&gt;

&lt;li&gt;It also makes it easy to define relationships or associations between models&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  The View
&lt;/h2&gt;

&lt;p&gt;The View part handles how users interact with the app and how things look on the screen. Here's what you need to know about it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It deals with how things look and how you interact with the browser&lt;/li&gt;
&lt;li&gt;It's not for handling business stuff or talking to databases&lt;/li&gt;
&lt;li&gt;It's purpose is only for object representation&lt;/li&gt;
&lt;li&gt;It mixes HTML and Ruby code using special tags like &lt;code&gt;&amp;lt;%= %&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;% %&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The instantiation of this class is done under the hood by the &lt;code&gt;ActionView&lt;/code&gt; module&lt;/li&gt;
&lt;li&gt;The Rails developer only needs to modify the templates that resides on &lt;code&gt;app/views&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The folder that stores the template file is named after the controller action name. For eg., &lt;code&gt;index.html.erb&lt;/code&gt;, or &lt;code&gt;show.html.erb&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;The template has a one-to-one mapping to the controller action&lt;/li&gt;
&lt;li&gt;The extension of the template can be:

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;html.erb&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;xml.builder&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;json.builder&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;It comes with special templates such as layouts and partials

&lt;ul&gt;
&lt;li&gt;Layouts: are templates that control the global layout of the application and are things that might not change, such as the nav bar&lt;/li&gt;
&lt;li&gt;Partials: are special subtemplates that can be reused multiple times within the application&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Communication between controllers and views is made via instance variables&lt;/li&gt;

&lt;li&gt;All of this is done as part of the &lt;code&gt;ActionPack&lt;/code&gt; lib&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Controller
&lt;/h2&gt;

&lt;p&gt;The Controller acts as the intermediary between the Model and the View, handling requests and coordinating data flow. Key aspects of the Controller&lt;br&gt;
include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It's the interface that glues the logic that resides in the Model classes and display them into pages that the final user can view. This is done with:

&lt;ul&gt;
&lt;li&gt;Figuring out what to do when a user makes a request&lt;/li&gt;
&lt;li&gt;Getting data from the Model and sending it to the View to show to the user&lt;/li&gt;
&lt;li&gt;Gathering info from a browser request and use to create or update a model&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;It's inherits from &lt;code&gt;application_controller.rb&lt;/code&gt; that inherits from &lt;code&gt;ActionController::Base&lt;/code&gt;
&lt;/li&gt;

&lt;li&gt;Controller class names use CamelCase&lt;/li&gt;

&lt;li&gt;File names are lowercase with underscores, ending in &lt;code&gt;_controller.rb&lt;/code&gt;
&lt;/li&gt;

&lt;li&gt;Each controller handles a specific part of the app&lt;/li&gt;

&lt;li&gt;Controllers have instance methods that match up with create, read, update, and delete (CRUD) actions&lt;/li&gt;

&lt;/ul&gt;




&lt;h2&gt;
  
  
  Pros and Cons of MVC in Rails
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Pros
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Scalability&lt;/strong&gt;: MVC promotes a structured approach that scales well with growing applications&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Maintainability&lt;/strong&gt;: Separation of concerns makes code easier to maintain and update&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reusability&lt;/strong&gt;: Components like views and partials can be reused across the application&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Cons
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Complexity&lt;/strong&gt;: There are some magic things that happen behind the scenes that, at first sight, might be confusing, especially for new developers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partial Knowledge&lt;/strong&gt;: While MVC is essential, it's part of a larger application architecture, and understanding other design patterns is beneficial&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;MVC in Ruby on Rails is a common approach used in many projects, and understanding it is crucial if you want to work on Rails projects. This architecture follows certain conventions that help developers focus on important tasks and take advantage of built-in methods and tools provided by the framework. While Rails apps aren't solely based on MVC, from my experience point of view, knowing other design patterns also helps in building software effectively with MVC.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;As you can see, this post doesn't cover all the details of this design pattern. The goal here is to provide some guidance and key points to focus on. Hopefully, this gives you a starting point to learn more about the subject, just like it did for me.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For further reading and references, check out the following links:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.sitepoint.com/model-view-controller-mvc-architecture-rails/" rel="noopener noreferrer"&gt;Sitepoint's MVC Architecture in Rails&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://rubyonrails.org/" rel="noopener noreferrer"&gt;Ruby on Rails Official Documentation&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>beginners</category>
      <category>learning</category>
      <category>rails</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Admin processes</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Thu, 11 Jan 2024 16:32:27 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-admin-processes-3c0h</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-admin-processes-3c0h</guid>
      <description>&lt;h3&gt;
  
  
  Run admin/management tasks as one-off processes
&lt;/h3&gt;




&lt;p&gt;Besides the app's regular business processes, developers frequently need to perform one-off administrative or maintenance tasks for the app, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Running database migrations;&lt;/li&gt;
&lt;li&gt;Running a console to run arbitrary code or inspect the app's model against the live database;&lt;/li&gt;
&lt;li&gt;Running one-time scripts committed into the app's repo(e.g. &lt;code&gt;php scripts/fix_bad_records.php&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Those tasks should operate within the same environment as the regular long-running processes of the app. They execute against a release, utilizing the identical codebase and configuration. Moreover, to prevent synchronization issues, the code must be shipped alongside the application code.&lt;/p&gt;

&lt;p&gt;All process types should employ the same dependency isolation techniques. For instance, if the Ruby web process utilizes the command &lt;code&gt;bundle exec thin start&lt;/code&gt;, the database migration should also use &lt;code&gt;bundle exec rails db:migrate&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The Twelve-Factor app strongly advocates for languages that offer a built-in REPL shell, simplifying the execution of one-off administrative scripts. During development, developers can run these scripts by accessing a local console within the app's container. In a production deployment, developers can access the app's console via &lt;code&gt;SSH&lt;/code&gt; or another mechanism provided by the execution environment, and then execute the script.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to&lt;br&gt;
consolidate the knowledge I've gained while studying these&lt;br&gt;
rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Twelve-Factor App: Logs</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Wed, 10 Jan 2024 22:53:20 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-logs-h91</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-logs-h91</guid>
      <description>&lt;h3&gt;
  
  
  Treat logs as event streams
&lt;/h3&gt;




&lt;p&gt;Logs offer insights into the behavior of a running app, typically stored in log files on the disk containing the app's outputs.&lt;/p&gt;

&lt;p&gt;They represent an aggregated, time-ordered stream of events occurring across running processes and backing services, registering each event on a single line. Logs flow continuously without a fixed start or end as long as the app operates.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A twelve-factor app doesn't concern itself with routing or storing its output stream.&lt;/strong&gt; Rather than managing log files, the focus is on directing processes and backing services to output logs to &lt;code&gt;stdout&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;During local development, developers can observe logs in their terminal's foreground to monitor the app's behavior. In other environments like &lt;code&gt;test&lt;/code&gt;, &lt;code&gt;staging&lt;/code&gt;, or &lt;code&gt;production&lt;/code&gt;, this is captured by the execution environment. All streams from the app, its processes, and backing services are directed to one or more final destinations for viewing and long-term storage, entirely managed by the execution environment.&lt;/p&gt;

&lt;p&gt;The app's event stream can be directed to a file or monitored in real-time using terminal-based tail commands. Importantly, it can also be sent to a log indexing and analysis system or a general-purpose data warehousing system like &lt;code&gt;Hadoop&lt;/code&gt; or &lt;code&gt;Hive&lt;/code&gt;. These systems offer significant power and flexibility for examining an app's behavior over time, including:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Find specific time events in the past;&lt;/li&gt;
&lt;li&gt;Large-scale graphing of trends(such as the requests per minute);&lt;/li&gt;
&lt;li&gt;Active alerting according to user-defined heuristics(such as an alert when the quantity of errors per minute exceeds a certain threshold)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to&lt;br&gt;
consolidate the knowledge I've gained while studying these&lt;br&gt;
rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
      <category>learning</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Dev/prod parity</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Thu, 04 Jan 2024 15:18:00 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-devprod-parity-460l</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-devprod-parity-460l</guid>
      <description>&lt;h3&gt;
  
  
  Keep development, staging, and production as similar as possible
&lt;/h3&gt;




&lt;p&gt;Historically, significant disparities have existed between development and production environments, manifesting in several ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The Time Gap: Code often takes days, weeks, or even months to reach production, whereas it should ideally be deployed within hours or minutes.&lt;/li&gt;
&lt;li&gt;The Personnel Gap: Developers create code while DevOps engineers handle deployment. Ideally, developers would be closely engaged in deploying and observing its behavior in the production environment.&lt;/li&gt;
&lt;li&gt;The Tools Gap: Local development setups might utilize stacks like &lt;code&gt;Nginx&lt;/code&gt;, &lt;code&gt;SQLite&lt;/code&gt;, and OS X, while production environments employ &lt;code&gt;Apache&lt;/code&gt;, &lt;code&gt;MySQL&lt;/code&gt;, and Linux. Let's keep development and production as similar as possible.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Twelve-Factor app is engineered for continuous deployment, aiming to narrow the gap between these environments.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers adhering to &lt;strong&gt;the twelve-factor principles resist the temptation to use different backing services in development versus production.&lt;/strong&gt; This stems from the appeal developers find in using lightweight services locally versus more robust ones in production. Discrepancies between these services often lead to minor incompatibilities, causing code that passed testing in dev or staging to fail in production. This discourages continuous deployment and results in considerable friction that incurs significant costs throughout an application's lifecycle. Additionally, modern packaging systems like &lt;code&gt;Homebrew&lt;/code&gt; and &lt;code&gt;apt-get&lt;/code&gt; have made installing and running modern backing services less challenging.&lt;/p&gt;

&lt;p&gt;Many programming languages offer libraries that streamline access to backing services, providing adapters for various service types. For instance, &lt;code&gt;ActiveRecord&lt;/code&gt; for &lt;code&gt;Ruby/Rails&lt;/code&gt; includes database adapters such as &lt;code&gt;MySQL&lt;/code&gt;, &lt;code&gt;PostgreSQL&lt;/code&gt;, and &lt;code&gt;SQLite&lt;/code&gt;. While adapters to different backing services simplify porting to new services, it's essential for all deployments (developer environments, staging, production) to use the same type and version of each backing service.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to&lt;br&gt;
consolidate the knowledge I've gained while studying these&lt;br&gt;
rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Disposability</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Wed, 03 Jan 2024 15:25:08 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-disposability-1g0</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-disposability-1g0</guid>
      <description>&lt;h3&gt;
  
  
  Maximize robustness with fast startup and graceful shutdown
&lt;/h3&gt;




&lt;p&gt;&lt;strong&gt;The Twelve-Factor app's processes are designed to be disposable, allowing them to be started or stopped at any moment.&lt;/strong&gt; This flexibility accelerates elastic scaling, rapid deployment of code or configuration changes, and ensures the resilience of production deployments.&lt;/p&gt;

&lt;p&gt;Efforts should be made to &lt;strong&gt;minimize the startup time of processes.&lt;/strong&gt; Swift startups provide greater agility for the release process and scaling up, contributing to robustness as the process manager can easily transfer processes to new physical machines when needed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Processes shut down gracefully when they receive a &lt;code&gt;SIGTERM&lt;/code&gt;&lt;/strong&gt; signal from the process manager. In the case of a web process, this entails ceasing to listen on the service port (rejecting new requests), allowing ongoing requests to be completed, and then exiting. For instance, in the case of a worker process, graceful shutdown involves returning the current job to the work queue. In &lt;code&gt;RabbitMQ&lt;/code&gt;, a worker can send a NACK to accomplish this.&lt;/p&gt;

&lt;p&gt;Processes should also be resilient against abrupt termination, which could result from hardware failures. Although less common than graceful shutdowns with SIGTERM, such incidents can occur. An advisable strategy involves utilizing a robust queueing backend like Beanstalkd, which returns jobs to the queue upon client disconnection or timeouts. In any scenario, a twelve-factor app is structured to handle unexpected, non graceful terminations. The crash-only design embodies this principle to its logical conclusion.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Concurrency</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Tue, 02 Jan 2024 18:36:48 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-concurrency-5d3l</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-concurrency-5d3l</guid>
      <description>&lt;h3&gt;
  
  
  Scale out via the process model
&lt;/h3&gt;




&lt;p&gt;Web applications have various process execution forms. PHP, for example, processes function as child processes of Apache, starting based on request volume, while Java processes operate within a massive JVM uberprocess, managing concurrency internally through threads. These running processes are minimally visible to app developers. &lt;strong&gt;In the context of the twelve-factor app, processes are crucial and they are a first-class citizen&lt;/strong&gt;, drawing inspiration from the unix process model for service daemons. This model allows developers to allocate different workloads to specific process types, such as handling HTTP requests through web processes and long running tasks through worker processes.&lt;/p&gt;

&lt;p&gt;Moreover, while individual processes can handle internal multiplexing via threads or asynchronous/event-driven models, vertical scaling of an individual VM has limitations. The process model excels in scaling out, as the share-nothing, horizontally partitionable nature of twelve-factor app processes facilitates simple and reliable addition of concurrency.&lt;/p&gt;

&lt;p&gt;Furthermore, the text emphasizes that twelve-factor app processes should refrain from daemonizing or writing PID files. Instead, reliance on the operating system’s process manager (like &lt;code&gt;systemd&lt;/code&gt; or cloud platform-based distributed process managers) or tools such as &lt;code&gt;Foreman&lt;/code&gt; during development is encouraged. These tools effectively manage output streams, handle crashed processes and address user-initiated restarts and shutdowns.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Port binding</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Fri, 29 Dec 2023 17:26:49 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-port-binding-44o9</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-port-binding-44o9</guid>
      <description>&lt;h3&gt;
  
  
  Export services via port binding
&lt;/h3&gt;




&lt;p&gt;At times, the server functions as a web server container where the web app operates as a module within the container. For instance, a PHP app might run as a module inside Apache HTTPD, or Java apps might function within Tomcat.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The twelve-factor app is entirely self-contained&lt;/strong&gt; and doesn't depend on the runtime injection of a web server into the execution environment to establish a web-facing server. Instead, &lt;strong&gt;the web app exports HTTP as a service by binding to a port&lt;/strong&gt;, which serves as a listening port for incoming requests. In a local environment, developers access the app by visiting &lt;code&gt;http://localhost:3000&lt;/code&gt;. In a deployment environment, a routing layer manages the routing of requests from a public-facing hostname to the port-bound web processes.&lt;/p&gt;

&lt;p&gt;This is commonly achieved by using dependency declarations to incorporate the web server library into the app, such as using &lt;code&gt;Thin&lt;/code&gt; for &lt;code&gt;Ruby&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Furthermore, this approach signifies that any service can be exported by port binding, awaiting incoming requests. It's important to note that by doing so, one app can serve as the backing service for another app.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Processes</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Thu, 28 Dec 2023 17:07:25 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-processes-58b2</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-processes-58b2</guid>
      <description>&lt;h3&gt;
  
  
  Execute the app as one or more stateless processes
&lt;/h3&gt;




&lt;p&gt;The app operates within the execution environment as one or more processes.&lt;/p&gt;

&lt;p&gt;Consider the code as a stand-alone script, the execution environment as the developer's local machine with the installed language runtime, and the process launched via the command line, for example, &lt;code&gt;$ ruby my_file.rb&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Twelve-factor app dictates that processes should be stateless and share nothing.&lt;/strong&gt; Any additional data requiring persistence must be stored in a backing service, typically a database.&lt;/p&gt;

&lt;p&gt;However, the memory space or filesystem of the process can be utilized as a brief, single-transaction cache. For instance, downloading a large file, performing operations on it, and then storing the results of the operation in the database. Nonetheless, the Twelve-Factor app never assumes that anything cached in memory or on disk will be available for future requests or jobs, as future requests might be served by different processes.&lt;/p&gt;

&lt;p&gt;Moreover, any language-specific packaging that utilizes the filesystem as a cache for compiled assets violates the Twelve-Factor App. It is preferred to handle this during compilation in the build stage. &lt;em&gt;Tip: The Rails asset pipeline can be configured to package assets during the build stage.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Certain web systems rely on "sticky sessions" where user session data is cached in the memory of the app’s process, expecting subsequent requests from the same visitor to be routed to the same process. This practice also violates the Twelve-Factor app. Session state data is better suited for a datastore offering time expiration, such as Memcached or Redis.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Build, release, run</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Wed, 27 Dec 2023 20:20:57 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-build-release-run-1294</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-build-release-run-1294</guid>
      <description>&lt;h3&gt;
  
  
  Strictly separate build and run stages
&lt;/h3&gt;




&lt;p&gt;A codebase goes through several stages before transforming into an execution environment:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;build stage&lt;/strong&gt; involves a process that converts the code repository into an executable bundle, known as the build. This stage, utilizing a root commit specified by the deployment process, retrieves vendor dependencies and compiles binaries and assets.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;release stage&lt;/strong&gt; takes the output produced by the build stage and combines it with the deployment's configurations. The result of this combination creates a package ready for immediate execution within the execution environment.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The &lt;strong&gt;run stage&lt;/strong&gt; (also referred to as "runtime") executes the app within the execution environment by launching a set of the app’s processes against a chosen release.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;The Twelve-Factor app strictly emphasizes the separation between the build, release, and run stages.&lt;/strong&gt; For instance, making changes to the code at runtime is impossible, as there's no mechanism to propagate those changes back to the build stage.&lt;/p&gt;

&lt;p&gt;Every release should have its unique identification associated, such as a timestamp, and each release is an increment of the previous version. This implies that any modification must generate a new release.&lt;/p&gt;

&lt;p&gt;The build process is initiated by developers when the code is pushed to an environment. In contrast, runtime execution can occur automatically, such as during a server reboot. Consequently, it's crucial to keep the run stage with as few moving parts as possible, as issues at this stage might prevent the app from running, especially during off-hours when support might not be readily available. The build stage can be more complex, as developers actively manage the deployment, keeping errors in the foreground.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Backing services</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Tue, 26 Dec 2023 14:02:30 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-backing-services-2e94</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-backing-services-2e94</guid>
      <description>&lt;h3&gt;
  
  
  Treat backing services as attached resources
&lt;/h3&gt;




&lt;p&gt;Backing services are classified as any resources required by the app to fulfill its functionalities. Typically accessed via a network or other locations stored within the configuration. These services include databases, SMTP clients, third-party integrations such as &lt;code&gt;Amazon S3&lt;/code&gt;, &lt;code&gt;Twitter&lt;/code&gt;, or &lt;code&gt;Last.fm&lt;/code&gt; APIs, and caching systems. These backing services are usually managed by the individual responsible for deploying the app and its resources.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Twelve-factor app doesn't differentiate between local and third-party services.&lt;/strong&gt; For the app, both types of resources are accessed via URLs. Thus, swapping out a local resource, like a database, for one managed by a third party requires no code changes.&lt;/p&gt;

&lt;p&gt;Resources can be attached to or detached from deployments at will. For instance, if a database malfunctions, the app's administrator might spin up a new database backup, detach the current database, and then restore the new database instance by requiring no code alterations.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
    <item>
      <title>The Twelve-Factor App: Config</title>
      <dc:creator>Lucas Fernandes</dc:creator>
      <pubDate>Sat, 23 Dec 2023 15:41:29 +0000</pubDate>
      <link>https://dev.to/lsfernandes92/the-twelve-factor-app-config-18c5</link>
      <guid>https://dev.to/lsfernandes92/the-twelve-factor-app-config-18c5</guid>
      <description>&lt;h3&gt;
  
  
  Keep your configs for each environment
&lt;/h3&gt;




&lt;p&gt;The app's configuration is everything that may vary between environments. This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System resources like databases, Memcached, and backing services;&lt;/li&gt;
&lt;li&gt;Credentials for external services such as Amazon S3 or Twitter;&lt;/li&gt;
&lt;li&gt;Environment-specific values such as the hostname.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Twelve-Factor methodology strongly advocates for&lt;br&gt;
separating configuration from the code. This is primarily&lt;br&gt;
because configuration values may differ between environments&lt;br&gt;
while the code remains constant. A useful way to determine if&lt;br&gt;
configurations are properly extracted from the code is by&lt;br&gt;
considering the scenario of making the codebase open source.&lt;br&gt;
If the credentials need to be managed, the configurations&lt;br&gt;
might be compromised.&lt;/p&gt;

&lt;p&gt;Another approach involves using configuration files not&lt;br&gt;
included in the version control system, such as&lt;br&gt;
'config/database.yml' in Rails. While this is a significant&lt;br&gt;
improvement, it is not recommended because there's a risk of&lt;br&gt;
accidentally pushing these files. Additionally, configuration&lt;br&gt;
files often scatter across different locations, making&lt;br&gt;
maintenance challenging. Moreover, these config files tend to&lt;br&gt;
be specific to a particular language or framework.&lt;/p&gt;

&lt;p&gt;Another practice to avoid is grouping configurations into&lt;br&gt;
environment-specific sets. Apps tend to categorize&lt;br&gt;
configurations into named groups for different environments.&lt;br&gt;
However, this method doesn't scale well. As the project&lt;br&gt;
expands, developers might introduce their own custom&lt;br&gt;
environments, leading to an explosion of configurations that&lt;br&gt;
complicate deployment management.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Twelve-Factor methodology suggests storing&lt;br&gt;
configurations in environment variables.&lt;/strong&gt; Environment&lt;br&gt;
variables are easy to modify between deployments without&lt;br&gt;
requiring changes to the code. They compel setting up&lt;br&gt;
independent configurations for each deployment environment,&lt;br&gt;
minimizing the chance of accidental check in the codebase&lt;br&gt;
repository. They don't aggregate into 'environments' groups,&lt;br&gt;
they are language- and OS-agnostic standards and provide a&lt;br&gt;
scalable model as the app naturally expands to more&lt;br&gt;
deployments.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This Twelve-Factor App post series is a means for me to consolidate the knowledge I've gained while studying these rules. Please feel free to visit [the site (&lt;a href="https://12factor.net/" rel="noopener noreferrer"&gt;https://12factor.net/&lt;/a&gt;) for more detailed explanations. That's all folks!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>learning</category>
      <category>writing</category>
      <category>architecture</category>
      <category>devjournal</category>
    </item>
  </channel>
</rss>
