<?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 Stoller</title>
    <description>The latest articles on DEV Community by Lucas Stoller (@lucasstoller).</description>
    <link>https://dev.to/lucasstoller</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%2F468205%2F20f59c2c-e228-47a8-beb1-2d84f932c59d.jpeg</url>
      <title>DEV Community: Lucas Stoller</title>
      <link>https://dev.to/lucasstoller</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lucasstoller"/>
    <language>en</language>
    <item>
      <title>Getting Started with Ruby: A Beginner's Guide to Installation and Basic Programs</title>
      <dc:creator>Lucas Stoller</dc:creator>
      <pubDate>Mon, 26 Feb 2024 11:47:57 +0000</pubDate>
      <link>https://dev.to/lucasstoller/getting-started-with-ruby-a-beginners-guide-to-installation-and-basic-programs-2cfo</link>
      <guid>https://dev.to/lucasstoller/getting-started-with-ruby-a-beginners-guide-to-installation-and-basic-programs-2cfo</guid>
      <description>&lt;p&gt;Welcome to my ruby course. After a long time, I decided to teach Ruby here on my blog! I divided the course between weekly chapters. At the end of each chapter, I will let the last and next one link (if they exist at the moment).&lt;/p&gt;

&lt;p&gt;Just to mention that Im not a Ruby guru (not yet 🤔) Im just a dev trying to help the community the way I know so, Experienced Ruby Devs reading these articles, if you find something that needs a fix or complementation, let comment bellow or DM me on Linkedin/Twitter. Hope you enjoy it! Let's go!&lt;/p&gt;

&lt;h2&gt;
  
  
  Ruby overview
&lt;/h2&gt;

&lt;p&gt;First of all, Ruby is not Ruby on Rails. Ruby is a whole language and Rails is a famous Framework built on top of that. Here in this course, we are gonna learn the Ruby Language.&lt;/p&gt;

&lt;p&gt;Another thing you need to learn to know about ruby is that it is very very object-oriented. Everything in ruby is an object. You dont know what an is object? Dont worry. Im gonna explain to you further. All you need to know now is that.&lt;/p&gt;

&lt;p&gt;Last but not least, if you have programmed in other languages before youre gonna see that ruby is a very fun language to program. That is at most because Ruby has an elegant syntax designed to be intuitive and readable by humans. Its design philosophy emphasizes simplicity and productivity, which means you can accomplish more with fewer lines of code compared to many other languages.&lt;/p&gt;

&lt;p&gt;Now that youre contextualized about Ruby, let's jump into the Ruby Dev Env setup!&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting up the Ruby dev environment
&lt;/h2&gt;

&lt;p&gt;To set up the Ruby development environment in your machine were gonna use asdf, my favorite tool to manage programming languages. Instead of using each language version manager (rbenv for Ruby, nvm for node.js, etc) the ASDF tool enables you to manage all (or almost all) language versions using only one tool. To set your ruby env using asdf do the following:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;1. Install&lt;/strong&gt; &lt;code&gt;asdf&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;First, you'll need to install &lt;code&gt;asdf&lt;/code&gt;. The method varies depending on your operating system.&lt;/p&gt;

&lt;h3&gt;
  
  
  For macOS:
&lt;/h3&gt;

&lt;p&gt;You can use Homebrew by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew install asdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, add &lt;code&gt;asdf&lt;/code&gt; to your shell by adding the following lines to your &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.zshrc&lt;/code&gt;, or equivalent configuration file:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;. $(brew --prefix asdf)/asdf.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  For Ubuntu/Linux:
&lt;/h3&gt;

&lt;p&gt;First, clone the &lt;code&gt;asdf&lt;/code&gt; repository from GitHub and check out the latest version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;https://github.com/asdf-vm/asdf.git&amp;gt; ~/.asdf --branch v0.10.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then, add the following lines to your &lt;code&gt;.bashrc&lt;/code&gt;, &lt;code&gt;.zshrc&lt;/code&gt;, or equivalent configuration file to initialize &lt;code&gt;asdf&lt;/code&gt; with your shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;. $HOME/.asdf/asdf.sh. $HOME/.asdf/completions/asdf.bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After adding the lines, either restart your terminal or source your profile file (e.g., &lt;code&gt;source ~/.bashrc&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Install Dependencies&lt;/strong&gt; : Depending on your system and the Ruby version you're installing, you might need to install some dependencies. For example, on Ubuntu, you might need to install build-essentials and other libraries:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo apt-get updatesudo apt-get install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm6 libgdbm-dev libdb-dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;2. Install the Ruby Plugin&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;With &lt;code&gt;asdf&lt;/code&gt; installed, you can now add the Ruby plugin:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asdf plugin add ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;3. Install Ruby&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;To install Ruby, first, list all the available versions with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asdf list-all ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Choose a version to install (for example, 3.0.2), and then install it by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asdf install ruby 3.0.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;4. Set a Global Ruby Version&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;After the installation, you can set a global Ruby version with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asdf global ruby 3.0.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This sets the Ruby version for all your projects. You can also set a Ruby version on a per-project basis by using &lt;code&gt;asdf local ruby 3.0.2&lt;/code&gt; the project directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;5. Verify Installation&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Finally, verify that the correct version of Ruby is installed by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ruby -v
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And verify &lt;code&gt;asdf&lt;/code&gt; is correctly managing the Ruby version:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;asdf current ruby
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Your first program in Ruby
&lt;/h2&gt;

&lt;p&gt;Know that youre with your ruby dev env set, let's play a little bit. Let's create your first code in ruby: The classic Hello Word for sure.&lt;/p&gt;

&lt;p&gt;Open your terminal and create a file named &lt;code&gt;hello_world.rb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;touch hello_world.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, open this file in your favorite code editor (mine is vscode) and edit it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;puts "What is your name?"name = gets.chompputs "Hello World, #{name}!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now run the code in your terminal&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    ruby hello_world.rb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code will ask you for your name and right after will respond to you with Hello World, !&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fectf5feffes590u6bdl6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fectf5feffes590u6bdl6.png" width="295" height="99"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Explaining the code
&lt;/h3&gt;

&lt;p&gt;line 1: &lt;code&gt;puts "What is your name?&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Print the "What is your name? on the screen&lt;/p&gt;

&lt;p&gt;line 2: &lt;code&gt;name = gets.chomp&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Make the terminal wait for your answer and when you press Enter, it gets what you typed (&lt;code&gt;gets&lt;/code&gt;), removes any trailing newline (&lt;code&gt;.chomp&lt;/code&gt;) and saves it into the computer memory for use later (&lt;code&gt;name =&lt;/code&gt;)&lt;/p&gt;

&lt;p&gt;line 4: &lt;code&gt;puts "Hello World, #{name}!&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Use the value saved in memory to print the "Hello World, ! on the screen&lt;/p&gt;

&lt;p&gt;It is just a little bit of the power of the Ruby. If you dont understand all I said dont whory, more details are coming in the next chapter. Here is just for you to play a little bit with the language and test the environment you set.&lt;/p&gt;

&lt;h3&gt;
  
  
  IRB
&lt;/h3&gt;

&lt;p&gt;Before we finish this chapter you must know about the IRB existence. Its a very helpful tool for beginner and even advanced ruby programmers.&lt;/p&gt;

&lt;p&gt;IRB stands for Interactive Ruby, it is a tool that came in the ruby package and enables you to execute ruby code, as its name says, in an interactive way. You enter a line of ruby code, ruby interprets it, and returns the response right after.&lt;/p&gt;

&lt;p&gt;To test irb you can do the following:&lt;/p&gt;

&lt;p&gt;Open your terminal and type &lt;code&gt;irb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;irb
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It will open the ruby in interactive mode. Now you can ask for Ruby to print some hello world messages for you for example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;puts "Hello world from IRB!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ruby will interpret your command and return the message &lt;code&gt;Hello world from IRB!&lt;/code&gt; right next.&lt;/p&gt;

&lt;p&gt;That is it. Know you have learned the overview about ruby language, how to set up a dev env in your local machine, how to write your first program in ruby and how to use IRB. Hope you have enjoyed it and see you in the next chapter.&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>asdf</category>
    </item>
    <item>
      <title>How to improve the documentation of your Ruby on Rails app</title>
      <dc:creator>Lucas Stoller</dc:creator>
      <pubDate>Sun, 25 Feb 2024 18:55:43 +0000</pubDate>
      <link>https://dev.to/lucasstoller/how-to-improve-the-documentation-of-your-ruby-on-rails-app-348j</link>
      <guid>https://dev.to/lucasstoller/how-to-improve-the-documentation-of-your-ruby-on-rails-app-348j</guid>
      <description>&lt;p&gt;When creating a Rails application is very easy, due to the Rails conventions, the application gets big and with messy contexts. Today I’m going to bring two gems to avoid this happening, at least in the documentation aspect: &lt;code&gt;rails-erd&lt;/code&gt; and &lt;code&gt;annotations&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Rails Erd
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Creating Entity Relationship Diagram of the app
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;rails-erd&lt;/code&gt; gem is a gem that enables you to generate an ERD (Entity Relation Diagram) of or Rails app using your application &lt;code&gt;schema.rb&lt;/code&gt; and the &lt;code&gt;ActiveRecord&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;For those who don’t know what an ERD is, in simple words, an ERD is a diagram that picks every entity of your application (in Rails: the models) and creates a diagram showing each one’s attributes and how they interact with each other. It’s a very common tool to understand how the application works behind the scenes. Here is an example of an ERD generated by the &lt;code&gt;rails-erd&lt;/code&gt;:&lt;/p&gt;

&lt;p&gt;To install and use the &lt;code&gt;rails-erd&lt;/code&gt; just follow the instructions here:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;add gem &lt;code&gt;rails-erd&lt;/code&gt; inside the &lt;code&gt;:development&lt;/code&gt; section of your &lt;code&gt;Gemfile.rb&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;exec &lt;code&gt;bundle install&lt;/code&gt; on your terminal&lt;/li&gt;
&lt;li&gt;exec &lt;code&gt;bundle exec erd&lt;/code&gt; on your terminal to generate the erd&lt;/li&gt;
&lt;li&gt;(optional) exec &lt;code&gt;bundle exec rails g erd:install&lt;/code&gt; on your terminal, this way every time you make a migration it will update the ERD.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Annotations
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Enhancing code readability with inline documentation
&lt;/h3&gt;

&lt;p&gt;The &lt;code&gt;annotations&lt;/code&gt; gem is a powerful tool for Ruby on Rails developers aiming to improve the readability and maintainability of their codebase. This gem allows you to add descriptive annotations directly in your models, tests, fixtures, and factories, essentially anywhere in your code where clarification might be beneficial for future reference or for other developers working on the project.&lt;/p&gt;

&lt;p&gt;Here is an example of how a example Post model is annotated using this gem:&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;# == Schema Information&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;# Table name: posts&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#  id         :integer          not null, primary key&lt;/span&gt;
&lt;span class="c1"&gt;#  title      :string&lt;/span&gt;
&lt;span class="c1"&gt;#  body       :text&lt;/span&gt;
&lt;span class="c1"&gt;#  user_id    :integer&lt;/span&gt;
&lt;span class="c1"&gt;#  created_at :datetime         not null&lt;/span&gt;
&lt;span class="c1"&gt;#  updated_at :datetime         not null&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;# Indexes&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#  index_posts_on_user_id  (user_id)&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;# Foreign Keys&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#  user_id  (user_id =&amp;gt; users.id)&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;# Annotations:&lt;/span&gt;
&lt;span class="c1"&gt;#  This model represents a blog post in the application. Each post belongs to a user.&lt;/span&gt;
&lt;span class="c1"&gt;#  - title: the title of the post&lt;/span&gt;
&lt;span class="c1"&gt;#  - body: the body/content of the post&lt;/span&gt;
&lt;span class="c1"&gt;#  - user_id: reference to the user that created the post&lt;/span&gt;
&lt;span class="c1"&gt;#&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Post&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="no"&gt;ApplicationRecord&lt;/span&gt;
  &lt;span class="c1"&gt;# Associations&lt;/span&gt;
  &lt;span class="n"&gt;belongs_to&lt;/span&gt; &lt;span class="ss"&gt;:user&lt;/span&gt;

  &lt;span class="c1"&gt;# Validations&lt;/span&gt;
  &lt;span class="n"&gt;validates&lt;/span&gt; &lt;span class="ss"&gt;:title&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;:body&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="c1"&gt;# Additional logic, such as custom methods or scopes, can be added below.&lt;/span&gt;
&lt;span class="k"&gt;end&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Annotations can serve as a quick reminder of the purpose of a specific piece of code, explain why a particular decision was made, or provide a brief overview of how a complex function works. This practice encourages writing self-documenting code, reducing the need for external documentation and making the codebase much more approachable for new developers or when revisiting old code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Getting Started with Annotations in Your Rails App
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Add gem &lt;code&gt;annotate&lt;/code&gt; to your Gemfile.&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;bundle install&lt;/code&gt; to install the gem.&lt;/li&gt;
&lt;li&gt;Use the command &lt;code&gt;bundle exec annotate&lt;/code&gt; to automatically generate annotations for your models and tests based on the current schema and existing test cases.&lt;/li&gt;
&lt;li&gt;Optionally, you can customize the behavior of the annotate gem by modifying its configuration file. This allows you to control which files are annotated and how the annotations are formatted.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That’s it, hope this helps you keep your Rails app better documented. See you next time!&lt;/p&gt;

</description>
      <category>ruby</category>
      <category>documentation</category>
      <category>gems</category>
    </item>
    <item>
      <title>What is Java Stream and why does it exist?</title>
      <dc:creator>Lucas Stoller</dc:creator>
      <pubDate>Sat, 04 Feb 2023 21:37:02 +0000</pubDate>
      <link>https://dev.to/lucasstoller/what-is-java-stream-and-why-does-it-exist-mfd</link>
      <guid>https://dev.to/lucasstoller/what-is-java-stream-and-why-does-it-exist-mfd</guid>
      <description>&lt;p&gt;A Stream is a sequence of values. The &lt;a href="http://java.util.stream" rel="noopener noreferrer"&gt;java.util.stream&lt;/a&gt; package defines types for streams of reference values (Stream) and some primitive values (IntStream, LongStream, and DoubleStream).&lt;/p&gt;

&lt;p&gt;Streams are like iterators in the way they supply their elements as needed for processing.&lt;/p&gt;

&lt;p&gt;Streams were introduced in Java 8 as a way to add manageability to existing data structures. With them, we can use some very interesting methods for our structures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Map&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Reduce&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Filter&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Find&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Foreach&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Among others.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this, it is important to create a &lt;strong&gt;stream pipeline&lt;/strong&gt;. A stream pipeline is used to manage actions on a stream. It is composed of iterators and finalizers, where iterators are methods that return stream and finalizers do not return streams and still close it. Example:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Fm0eklp6sm2bvktp25dpm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Fm0eklp6sm2bvktp25dpm.png" width="265" height="182"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;To use Java streams we need to convert the data structure we are working on to a Stream, assemble and run our pipeline. Finally, we can convert the stream pipeline output back to the source structure if necessary.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.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%2Ft19lmd9aga0mypmuk4xa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.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%2Ft19lmd9aga0mypmuk4xa.png" width="800" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You might be wondering: "Why weren't such methods declared directly in the data structures?"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F8-Dj522xUIgILbaL-GSXu5Vht8qG_LBEtviWFDFpScIlxTf5Dq2JmgcSwSXGOHWETY9zhvhttkPDGBwXmcLdTQeAlYHJAkBjh6YynmG4uNjv9i74ihGTQYwdgZ1EdxF1xy7XVCdOyO2lMNF5sJfJsME" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Flh3.googleusercontent.com%2F8-Dj522xUIgILbaL-GSXu5Vht8qG_LBEtviWFDFpScIlxTf5Dq2JmgcSwSXGOHWETY9zhvhttkPDGBwXmcLdTQeAlYHJAkBjh6YynmG4uNjv9i74ihGTQYwdgZ1EdxF1xy7XVCdOyO2lMNF5sJfJsME" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see, we need to convert the structure we are working on to a stream before using the utility methods because they are not present in the Collections API but have been externalized in their own Streams API. And these are some of the reasons why Java Architects proposed this solution:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;The Collections API is more concerned with storing the data than with the actions and work that we are going to do on the data itself;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Manipulation X Management of the Data Structure&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Eager Loading X Lazy Loading&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Even though those methods we declared in Collections API we would still need to do a conversion to work with asynchronous processing, see:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The risk of collision in method names increases every time we insert a new method in an API with hierarchically ordered classes.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>java</category>
      <category>streams</category>
    </item>
  </channel>
</rss>
