<?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: PythonIsNotASnake</title>
    <description>The latest articles on DEV Community by PythonIsNotASnake (@pythonisnotasnake).</description>
    <link>https://dev.to/pythonisnotasnake</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%2F1081018%2Ffc221615-e6e9-437a-8295-9e025bc1cc48.jpg</url>
      <title>DEV Community: PythonIsNotASnake</title>
      <link>https://dev.to/pythonisnotasnake</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/pythonisnotasnake"/>
    <language>en</language>
    <item>
      <title>Glam Up My Markup - Camp Form for kids</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Thu, 21 Mar 2024 20:34:27 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/glam-up-my-markup-camp-form-for-kids-1icd</link>
      <guid>https://dev.to/pythonisnotasnake/glam-up-my-markup-camp-form-for-kids-1icd</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for DEV Challenge v24.03.20, Glam Up My Markup: Camp Activities&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built And Why
&lt;/h2&gt;

&lt;p&gt;I built the "Glam Up My Markup" Challenge. I decided to format the form a little bit to make it look like a regular form. Additional I added some colors and bigger fonts so that it is easy to understand for kids and parents. I saw this challenge by the Use-Case parents want to fill out this form for the camp and get supported by their child. So it should look a little bit cute or funny and not like a office document.&lt;br&gt;
The button and the header got a small hover effect so it is more enjoyable in user interaction.&lt;br&gt;
The HTML got the language property with the value "en-us" so a web browser plugin can easily translate the website in any language (tested by Firefox' translator in Beta state).&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en-us"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Camp Activities Inquiry&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- CSS Style Sheet --&amp;gt;&lt;/span&gt;        
        &lt;span class="nt"&gt;&amp;lt;style&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;section&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;margin-left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;margin-right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bec4ae&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;x-large&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;flex-wrap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;wrap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;select&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;x-large&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;textarea&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;x-large&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;margin-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;15px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;button&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;auto&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;x-large&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#787f4b&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;border-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;all&lt;/span&gt; &lt;span class="m"&gt;.5s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;button&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#d76e4f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;cursor&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;pointer&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#cdd3bc&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#313738&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;xx-large&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
                &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
            &lt;span class="nt"&gt;h1&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#d76e4f&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/style&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- HTML Body --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"camp-activities-inquiry"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Camp Activities Inquiry&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;form&lt;/span&gt; &lt;span class="na"&gt;action=&lt;/span&gt;&lt;span class="s"&gt;"/submit-form"&lt;/span&gt; &lt;span class="na"&gt;method=&lt;/span&gt;&lt;span class="s"&gt;"POST"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"activity-select"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Which camp activities are you most looking forward to?&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;select&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"activity-select"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"activity"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;""&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;--Please choose an option--&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"hiking"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Hiking&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"canoeing"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Canoeing&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"fishing"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Fishing&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"crafts"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Crafts&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
                    &lt;span class="nt"&gt;&amp;lt;option&lt;/span&gt; &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"archery"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Archery&lt;span class="nt"&gt;&amp;lt;/option&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;/select&amp;gt;&lt;/span&gt;

                &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"food-allergies"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Food Allergies (if any)&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"food-allergies"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"food_allergies"&lt;/span&gt; &lt;span class="na"&gt;rows=&lt;/span&gt;&lt;span class="s"&gt;"4"&lt;/span&gt; &lt;span class="na"&gt;cols=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;

                &lt;span class="nt"&gt;&amp;lt;label&lt;/span&gt; &lt;span class="na"&gt;for=&lt;/span&gt;&lt;span class="s"&gt;"additional-info"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Additional things the counselor should know&lt;span class="nt"&gt;&amp;lt;/label&amp;gt;&lt;/span&gt;
                &lt;span class="nt"&gt;&amp;lt;textarea&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"additional-info"&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"additional_info"&lt;/span&gt; &lt;span class="na"&gt;rows=&lt;/span&gt;&lt;span class="s"&gt;"4"&lt;/span&gt; &lt;span class="na"&gt;cols=&lt;/span&gt;&lt;span class="s"&gt;"50"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/textarea&amp;gt;&lt;/span&gt;

                &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Submit&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgrjglfc1wdbqlvpgmuc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjgrjglfc1wdbqlvpgmuc.png" alt="Website of the code snippet" width="800" height="271"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4x6spd9zxb4q33ndn5e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fz4x6spd9zxb4q33ndn5e.png" alt="Website of the code snippet with hover effect" width="800" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;I made this in an hour of evening coding session. The code is not special but it consider to the use-case I mentioned above.&lt;br&gt;
PS: Hope to get a badge for this :)&lt;/p&gt;

&lt;p&gt;Keep coding!&lt;/p&gt;

</description>
      <category>frontendchallenge</category>
      <category>devchallenge</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Don't do this with your parameters in functions - functional programming🤢</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Sat, 16 Mar 2024 12:39:42 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/dont-do-this-with-your-parameters-in-functions-functional-programming-18gm</link>
      <guid>https://dev.to/pythonisnotasnake/dont-do-this-with-your-parameters-in-functions-functional-programming-18gm</guid>
      <description>&lt;p&gt;Functional programming is a different concept than object oriented programming. For example Java is object oriented meanwhile JavaScript is functional. Additional there are hybrids like Python which allow to use the language in a functional or object oriented way. In all this cases you have functions (for functional programming) or methods (for object oriented programming) which get parameters as input and return a value as output.&lt;/p&gt;




&lt;p&gt;First I show you an easy example of a function and then we will analyze what we can do better.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;doSomething&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;p1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;p1&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What can we see here? We see a function called &lt;em&gt;doSomething&lt;/em&gt; which doubles the value of &lt;em&gt;p1&lt;/em&gt;. Which problems can we identify when we look at the function? There are three main points.&lt;/p&gt;

&lt;h2&gt;
  
  
  1) Function name doesn't describe anything🧐
&lt;/h2&gt;

&lt;p&gt;The first issue is the name of the function. If you read &lt;em&gt;doSomething&lt;/em&gt; anywhere in a project you will never know what this function is doing. Best practice is to use function names with a describing name of the purpose or of the processing steps the function is doing. In our case a name like &lt;em&gt;multiplyByTwo&lt;/em&gt; or &lt;em&gt;doubleNumber&lt;/em&gt; is a much better choice.&lt;/p&gt;

&lt;h2&gt;
  
  
  2) What means p1?😵‍💫
&lt;/h2&gt;

&lt;p&gt;The next issue is the name of the parameter. If you have only one parameters this is not so dramatically. But if you have three, four or more parameters no one can understand which parameter have which effect on the process or result of the function. In this case &lt;em&gt;multiplier&lt;/em&gt; can be a valid choice or anything else which can be understand very well.&lt;/p&gt;

&lt;h2&gt;
  
  
  3) Never change parameter in function body🤬
&lt;/h2&gt;

&lt;p&gt;You never want to change the input value in a function. It is best practice to create a copy of the input value and then do all the operations on this copy. At last return the copy. So the input value has no changes at all. And if anyone need the changes on the input value then the input value can be changed by the return value of the function.&lt;/p&gt;




&lt;p&gt;Now we have evaluated all the issues and can make it better in a new try:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;multiplyByTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;copyOfMultiplier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;copyOfMultiplier&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;copyOfMultiplier&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;copyOfMultiplier&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;multiplyByTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How you can see the function never changed the value of &lt;em&gt;multiplier&lt;/em&gt;. A copy of the input value is changed instead and returned by the function. Under the function a variable called &lt;em&gt;input&lt;/em&gt; is instantiate and will be changed by the return value of the function. So the programmers can decide by their own if a variable value should be overwritten by a function or not. Not the function take the decision.&lt;/p&gt;




&lt;p&gt;To be honest this code snippet will never look like this in reality. A regular programmer will be shorten the code massively to make it look like this now:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;multiplyByTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;multiplier&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;multiplier&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;multiplyByTwo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No copy of the input value is needed at all and the value is never changed before the function will be called in the last line of the snippet.&lt;/p&gt;

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

&lt;p&gt;Clean code can make a huge different in readability of code and to understand the best practices of your chosen programming language or framework can let you avoid issues like changing parameters in function body.&lt;br&gt;
If you have more tips and best practices for beginners of functional programming share them in the comment section.&lt;br&gt;
Keep coding.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>javascript</category>
      <category>cleancode</category>
    </item>
    <item>
      <title>PONG - The Hello World of Game Development - The 2nd month</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Fri, 01 Mar 2024 06:00:00 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/pong-the-hello-world-of-game-development-the-2nd-month-2i3h</link>
      <guid>https://dev.to/pythonisnotasnake/pong-the-hello-world-of-game-development-the-2nd-month-2i3h</guid>
      <description>&lt;p&gt;In the second month of my game coding journey I had not very much time to invest in the learning process. Nevertheless I implement the first game of &lt;a href="https://20_games_challenge.gitlab.io/"&gt;the 20 games challenge&lt;/a&gt;. Surprise! It was PONG. One of the very first games from the year 1972.&lt;br&gt;
The concept is very simple but contain most of the essential functions you need in game development. There are two players. Each of them can only move up or down. The goal to achieve is to let the ball bounce on your bar and hope that your opponent don't do the same.&lt;br&gt;
The whole project I present in the following lines can be checkout on &lt;a href="https://github.com/PythonIsNotASnake/pong"&gt;github&lt;/a&gt;. For this project I have used Godot in the version &lt;a href="https://godotengine.org/download/archive/4.2.1-stable/"&gt;4.2.1&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Preparation
&lt;/h2&gt;

&lt;p&gt;First of all I started to create some assets. For the whole game I needed two bars as players, one ball, the game field, the goals and walls. To make it a little eye catcher I decided to use same colors. After I had the assets the process of game development started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Building scenes
&lt;/h2&gt;

&lt;p&gt;The structure of the project is apart in different scenes. First of all I have a player_one and a player_two scene. Both of them are identical. The only different is the sprite. In general there are solutions to not duplicate the scene in the way I had done it. But to keep it simple I made it this way. Next there is the ball as a separate scene. Further in a separate directory are the last scenes goal and level.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goal
&lt;/h2&gt;

&lt;p&gt;As goal I used an Area2D as scene. In this scene I put a Sprite2D and a CollisionShape2D. To keep it so simple as possible the Area2D has a signal. This is the body_entered signal to track if the ball enter the collision shape of the goal. If the ball enter this area the game will be reset so the players must remember the result by their self.&lt;/p&gt;

&lt;h2&gt;
  
  
  Player
&lt;/h2&gt;

&lt;p&gt;The player scenes are from type CharacterBody2D and are nearly as simple as the goal is. Each player consists of a Sprite2D and a CollisionShape2D. In the script are functions to enable the movement of the players. For each player are different keys defined to move up and down. Because I use two separate scenes for the players I need a player script which exports essential variables like the speed so no player have an advantage in movement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Ball
&lt;/h2&gt;

&lt;p&gt;The ball is a CharacterBody2D too. It consists like the other scenes a Sprite2D and a CollisionShape2D. To make the ball bounce if it collide with any object in the game world the move_and_collide() function will be needed. This function returns collision info. If the info is true the bounce() function of the velocity will be triggered. So the ball can bounce between the two players and don't stuck in the walls of the court.&lt;/p&gt;

&lt;h2&gt;
  
  
  Level
&lt;/h2&gt;

&lt;p&gt;The level is a Node2D which consists all previous scenes and combine them. To show a background as court for the game a CanvasLayer with a TextureRect is used. This is only for the aesthetic and feeling and have no effect to the game logic nor the physics. Next a TileMap allows to place some squares as the wall. The wall is needed so the ball can bounce on it and don't leave the screen and disappears in the Nirvana. Additional the two players, the ball and the two goals are brought into position. The game can start and two players can enjoy the nostalgic charm of the 70s.&lt;/p&gt;

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

&lt;p&gt;I hope I could help you a bit with my first GODOT game. Probably you stuck at some point and found a solution. If you have code PONG by yourself share your code with the community. My code can be discovered on &lt;a href="https://github.com/PythonIsNotASnake/pong"&gt;github&lt;/a&gt;.&lt;br&gt;
Open to discuss different approaches to solve the challenge to code PONG.&lt;br&gt;
Have fun and keep coding.&lt;/p&gt;

</description>
      <category>godot</category>
      <category>gamedev</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Every beginning is hard or my first steps with GODOT - The 1st month</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Thu, 01 Feb 2024 06:00:00 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/every-beginning-is-hard-or-my-first-steps-with-godot-the-1st-month-4emp</link>
      <guid>https://dev.to/pythonisnotasnake/every-beginning-is-hard-or-my-first-steps-with-godot-the-1st-month-4emp</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/pythonisnotasnake/my-personal-devresolutions2024-2cgg"&gt;DEVResolutions&lt;/a&gt; for this year I mentioned that I'm going to learn the game engine GODOT. An answer on the mentioned post was to document the journey of learning game development. My idea to this is that I will share my progress of every month. Possibly it motivate someone or give an idea how hard or easy is the learning curve of GODOT and game development in general.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prior knowledge
&lt;/h2&gt;

&lt;p&gt;To my person I never before have done game development. The only things I have made was a visual novel game with Ren'Py. But Ren'Py make things very easy. There are no collisions or physics in it. For a simple base game you're not needing any programming skills because you write a storybook. It is more similar to PowerPoint meets LaTeX.&lt;br&gt;
Another part of my skill level is web development. In general I use Java and Angular for my daily work.&lt;/p&gt;




&lt;p&gt;So there comes the knowledge about programming. I not start from scratch at this point. I know how to code so it is not difficult to understand the script language of GODOT. The challenge is to understand the concepts of game development. This mean specific keywords and the structure of a game.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to start?
&lt;/h2&gt;

&lt;p&gt;Last year I started with the &lt;a href="https://docs.godotengine.org/en/stable/getting_started/first_2d_game/index.html"&gt;tutorial&lt;/a&gt; on the GODOT website but never finished it. I recommend to start with this at first. It will give you an overview of the different buttons and other stuff of the GODOT UI. If you have done this you can decide if you want a look into 3D games and do their next tutorial. My personal decision was to stay with 2D games.&lt;br&gt;
In this year I started first to watch a video series on YouTube in my native language about the keywords of GODOT. This helped a lot to get a feeling for the structure of a game. Probably there will be a lot other videos or texts in a language of your choice with a similar content.&lt;/p&gt;

&lt;h2&gt;
  
  
  After basics come more basics
&lt;/h2&gt;

&lt;p&gt;So at this point I have decided to concentrate on 2D games. My idea was &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Why not starting with a complete guided game?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So I found on YouTube a video series in which exactly this was done. The guys from GDQuest have made a video series of programming a &lt;a href="https://www.youtube.com/playlist?list=PLhqJJNjsQ7KH_z21S_XeXD3Ht3WnSqW97"&gt;platform game&lt;/a&gt;. The explanations are very good and each step is described in a deep that you really understand what impact this edit has on the game. Sadly it was made with GODOT major version 3 and not with the latest major version 4. In my case I tried with version 4 and search on the web for objects or methods which not anymore exists or work in another way in the latest version of GODOT.&lt;br&gt;
The first video of the series was the one which contains the most knowledge. After this I get a really good feeling on some points:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;how is the structure of a game&lt;/li&gt;
&lt;li&gt;how to use different kinds of nodes&lt;/li&gt;
&lt;li&gt;how can I make my player to move and interact with the world&lt;/li&gt;
&lt;li&gt;how are collisions working&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;The second part of the series tell you how to make animations and transitions to other scenes (or levels). This can make your game more beautiful and help you to build bigger games than single scene games like pong.&lt;/p&gt;




&lt;p&gt;In the last part of the video series there came menus. But this was a little bit difficult. The comments under the video support my impression. It feels like there was missing some parts in the video as also between video two and video three. So the theoretical use is good explained but it is not simple possible to expand the own project by these.&lt;/p&gt;

&lt;h2&gt;
  
  
  The big goal
&lt;/h2&gt;

&lt;p&gt;It is nearly impossible to learn anything what you never will be use by your own. To give me some motivation I was looking for a game that I will finally code. My intuition tell me that I want to build a 2D fighting game like Street Fighter. After that I make some research for this topic and find out that it is not so difficult to make a rudimentary fighting game. But if you want that the players have fun and enjoy it you need many additional things like a combo system or many sprites of fighters in different positions to make fluent animations and give the player the feeling that the combos feel right and awesome. As I'm not a designer I change my mind. At this point I will try to build a sidescroller shoot'em up like Airwolf or WingWarriors. Possibly my goal can change in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assets and more assets
&lt;/h2&gt;

&lt;p&gt;The most important part of a game are assets. From backgrounds over parts in the scene to items and characters. You will need assets for all of them. To get assets I have tried three different ways.&lt;/p&gt;

&lt;h3&gt;
  
  
  AI generated assets
&lt;/h3&gt;

&lt;p&gt;First of all I let an AI generate me background images for my games. One of them can you see in the cover image of this post. It looks very good and is not much work to do. The problem in this case is if you need an asset in multiple positions like a character who is walking. In most of the tested image generators the character in the next image don't look like the character in the first one. So it is genius for backgrounds, parts in the game world or items but not for animated sprites.&lt;/p&gt;

&lt;h3&gt;
  
  
  Design assets by your own
&lt;/h3&gt;

&lt;p&gt;My next way was to design easily my own characters. So I tried it with pixelart to get simple but not bad looking assets. The result are the samurai and knight in the cover image. If you have the effort to live your creativity this can be a adorable way.&lt;/p&gt;

&lt;h3&gt;
  
  
  Get assets legal from the web
&lt;/h3&gt;

&lt;p&gt;The last way is the easiest way to get assets for your game. On &lt;a href="https://opengameart.org/"&gt;OpenGameArt.org&lt;/a&gt; you find a huge amount of free assets for your projects. It can be filter by the type of license. So you can choose by yourself which type of license is alright for you. There are not only sprites but also textures or sounds and background music. Give it a try and search for your own if you want start quick develop a game without spend to much time in drawing assets.&lt;/p&gt;

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

&lt;p&gt;This was many input for one month. I hope with this in your mind you will have a first idea where to start. If you make your own game don't be shy and share it with the community.&lt;br&gt;
Keep coding.&lt;/p&gt;

</description>
      <category>godot</category>
      <category>gamedev</category>
      <category>learning</category>
      <category>godotengine</category>
    </item>
    <item>
      <title>My personal #DEVResolutions2024</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Wed, 03 Jan 2024 13:29:01 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/my-personal-devresolutions2024-2cgg</link>
      <guid>https://dev.to/pythonisnotasnake/my-personal-devresolutions2024-2cgg</guid>
      <description>&lt;p&gt;I want to use this to share my personal goals. This is stuff which I want to get done in 2024. As background information I am a backend web developer but my goals aim more on private dev goals than on goals for my career.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Personal Goals:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Goal:&lt;/strong&gt; Develop an own game.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action Steps:&lt;/strong&gt; In the last year I have developed a visual novel game by the use of Ren'Py. This year I want to learn Godot to develop bigger games.
The plan is at first to start with the documentation.
The next step will be challenge projects from &lt;a href="https://20_games_challenge.gitlab.io/"&gt;the 20 games challenge&lt;/a&gt;.
After this I should earned the knowledge to start with a own game.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Timeline:&lt;/strong&gt; To reach this goal I will nearly need the complete year 2024 and probably parts of the next year.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Personal Aspirations:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Aspiration:&lt;/strong&gt; To be up to date.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Why it Matters:&lt;/strong&gt; For me it is important to be up to date. This means that I can read and learn new things right then when they appear. So it can support me in my daily job to know about the newest 'shit' like Blockchain or AI.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Support System:&lt;/strong&gt; To reach this I will read more tech news and will be a more active reader on DEV.to.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;DEV Community Contributions:&lt;/strong&gt;
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Contribution Goal:&lt;/strong&gt; Be more part of the DEV.to community.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Collaboration Plans:&lt;/strong&gt; I will publish more posts and use DEV.to as first source to solve my programming issues and to rise my knowledge.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measuring Impact:&lt;/strong&gt; Feedback from the community is very important to see if I could help anyone to solve their issues or problems. One reaction or comment are enough for me to see that someone could benefit from my post.&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>devresolutions2024</category>
    </item>
    <item>
      <title>Take your documentation to the next level with Ren'Py</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Sun, 17 Dec 2023 14:16:25 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/take-your-documentation-to-the-next-level-with-renpy-3m13</link>
      <guid>https://dev.to/pythonisnotasnake/take-your-documentation-to-the-next-level-with-renpy-3m13</guid>
      <description>&lt;p&gt;Do you ever heard of &lt;a href="https://www.renpy.org/"&gt;Ren'Py&lt;/a&gt;? Ren'Py is an engine for visual novel games published in 2004. The engine is open source and run by MIT License. Visual novel games are games which based on visuals and dialogs and live by decisions of the player. Visual novel games are very popular in the Asian region. But there are more use cases than game development. Let me tell you which potential is sleeping in this engine.&lt;br&gt;
&lt;strong&gt;Disclaimer:&lt;/strong&gt; This post will not teach you Ren'Py in any kind and don't explain exactly how you can program your documentation. It will only show you some basics and what you can do and achieve with it.&lt;/p&gt;
&lt;h2&gt;
  
  
  The idea
&lt;/h2&gt;

&lt;p&gt;Which tools do you use to publish documentation for your software to end users? In most of the cases it is a document to read by the end user. Divided into chapters so the user can search for the fitting part of the document.&lt;br&gt;
This proceed is full of information and can give a deep dive into the product. But it can also be overwhelming to read many pages of content.&lt;br&gt;
This is exactly the point on which Ren'Py can make a big different. The plan is to get a interactive documentation which will be a pleasure for users to learn and understand your product. So let's take a look on the details.&lt;/p&gt;
&lt;h2&gt;
  
  
  Gamification
&lt;/h2&gt;

&lt;p&gt;Do you know what gamification is? It is the method to integrate parts of games in software to achieve an enjoyable experience for the user by use of the product. An quick example are success screens at the end of a process. A little symbol of a medal with a short text like 'You have create personal costs successfully' is enough to let the user get a little experience of success in the daily work routine.&lt;br&gt;
In our situation we want to use Ren'Py to let the users enjoy the experience to read the documentation. This goal will be reached by dialogs to see faster the information the user is looking for combined with a visual contact person. The feeling to play a game instead of doing work can motivate a user a lot more to learn something about a product.&lt;/p&gt;
&lt;h2&gt;
  
  
  rpy Files and the Ren'Py Script Language
&lt;/h2&gt;

&lt;p&gt;To write a game with the Ren'Py engine you don't need knowledge in any programming language. Ren'Py is written in Python and the engine use their own format named rpy. It is more like the script for a movie or a theatre play. There are two main sectors in which the language is split.&lt;br&gt;
First the dialogs. The dialogs give the information in text on the screen and enable the user to interact with the program by select an answer. Those are menus which mean the decision by user. Each menu has one or more answers to keep the dialog running. For each option in the menu you can define different actions in your program. This can be completely different conversations.&lt;br&gt;
The second sector are visuals and animations. The animations are similar to power point animations. You can choose between different effects to show or hide objects and switch from one scene to another scene. With this knowledge you can build a presentation completely in Ren'Py. It makes no big different.&lt;br&gt;
With this separation we can look at some code snippets of the &lt;a href="https://www.renpy.org/doc/html/quickstart.html"&gt;Ren'Py documentation&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Peter&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Good day! My name is Peter and I&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;m your contact person for all your questions about our software. How can I help you with our software?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
  &lt;span class="n"&gt;menu&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Installation&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Me&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How can I install the software?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
      &lt;span class="n"&gt;jump&lt;/span&gt; &lt;span class="n"&gt;installation_guide&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Pricing list&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Me&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How is the pricing list for the software?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
      &lt;span class="n"&gt;jump&lt;/span&gt; &lt;span class="n"&gt;pricing_list&lt;/span&gt;
    &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Save progress&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Me&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;How can I save my work progress?&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;
      &lt;span class="n"&gt;jump&lt;/span&gt; &lt;span class="n"&gt;save_files&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This simple example show a conversation. You can see two characters, Peter and Me. Peter ask the user something and the user can response the question with different options. Each answer start a different section of the script. The sections are called 'label'. Behind each of the options the user can find a dialog with the exact information he or she is looking for.&lt;br&gt;
This is one part of Ren'Py. It can go very deep so you can do much more than showed in the example. But let us going forward to the next example. It will show us animations.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="n"&gt;label&lt;/span&gt; &lt;span class="n"&gt;start&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
  &lt;span class="n"&gt;scene&lt;/span&gt; &lt;span class="n"&gt;bg&lt;/span&gt; &lt;span class="n"&gt;office&lt;/span&gt;
  &lt;span class="n"&gt;show&lt;/span&gt; &lt;span class="n"&gt;peter&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="n"&gt;left&lt;/span&gt;
  &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;fade&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How you can see first the script will show a new background named 'bg office'. After this the image of the character 'peter' will be show at the left side of the screen with a fade animation. This are the basic keywords to animate your program. You can find a lot more keywords in the documentation to animate your interactive documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Goal
&lt;/h2&gt;

&lt;p&gt;Now you have a kind of an idea how Ren'Py can work. With this we can take a look at a finished game which shows our goal. If you download the Ren'Py launcher and start the project 'Tutorial' you can see the following view:&lt;br&gt;
&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb7uacfd68l78tot3pt3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnb7uacfd68l78tot3pt3.png" alt="Screenshot of the interactive Ren'Py tutorial of the Ren'Py launcher" width="800" height="472"&gt;&lt;/a&gt;&lt;br&gt;
You can see a kind person who want to help you with your questions. All options in the menu guide you to other sections of the documentation.There are some vibes of a chat bot but without any kind of intelligence.&lt;br&gt;
The launcher give you the ability to jump into the source directory. So you can see the source code of their tutorial and can use this as inspiration. You don't must use Ren'Py to write a deep documentation like it is common for framework or library documentations but can use it for a FAQ.&lt;/p&gt;

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

&lt;p&gt;Now it's your turn. You have a quick overview how Ren'Py work and saw how a documentation made by Ren'Py can look like. For a deep dive the &lt;a href="https://www.renpy.org/doc/html/quickstart.html"&gt;Ren'Py documentation&lt;/a&gt; is the right place to begin. Furthermore there are so many tutorials and forums where people share their knowledge and projects.&lt;br&gt;
Do you think that a user will have more fun with a documentation in this style?&lt;br&gt;
Are you ready to invest time to learn and practice Ren'Py for your next documentation or FAQ?&lt;br&gt;
Can it be a good marketing move to introduce your product with a short game which explain the main features?&lt;/p&gt;

</description>
      <category>python</category>
      <category>design</category>
      <category>documentation</category>
      <category>gamification</category>
    </item>
    <item>
      <title>Choose technologies for your project - A brief report</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Tue, 20 Jun 2023 18:51:37 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/choose-technologies-for-your-project-a-brief-report-14of</link>
      <guid>https://dev.to/pythonisnotasnake/choose-technologies-for-your-project-a-brief-report-14of</guid>
      <description>&lt;p&gt;For your interest this is a post about my own experience with my private project and how the process of development has chosen my used technologies. This shows how important it is to know which technology is the right for your purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conditions
&lt;/h2&gt;

&lt;p&gt;I have chosen much conditions which my software project should meet. First of all I want access from every web device of my home network. Second it should be deploy-able on a raspberry pi. And at last it should start automatically on boot up of the raspberry without any action by my side.&lt;br&gt;
So we can see the three conditions which I had for my software project.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Run on every OS&lt;/li&gt;
&lt;li&gt;Raspberry Pi deployment&lt;/li&gt;
&lt;li&gt;Automatic start on device boot&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Choose of the tech stack
&lt;/h2&gt;

&lt;p&gt;First of all my decision was a web app because of condition one. A web app run on every device which has a internet browser. For the framework I have chosen Vue.js because it looks very interesting and I had play around a little bit with Vue.js version 2 in the past. But I needed a possibility to save the data the users will produce by use of the app. So I have chosen Java Spring Boot because I am a java dev and wanted to see how my code style has changed by the few years of job experience. As database I have chosen MongoDB because of the design as an document oriented database. To fix my condition number 3 I wanted to use docker for deployment. With an argument I can give a docker container the command to restart on every stop of himself.&lt;br&gt;
But for sure this should not be the tech stack of the final project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Euphoria gives way to problems
&lt;/h2&gt;

&lt;p&gt;After my first euphoria for the new project and the detailed tech stack the reality has kicked me. In every project will be conditions by environment which let you overthink your decisions. First of all there were many time since I used Vue.js for the last time. At start of my project version 3 of Vue.js was just released. My Vue.js experience based on version 2 of the framework. What are you doing now? Go with the old version and upgrade later or start learning to use the new version? At this moment all tutorials of Vue.js were written for version 2. After that I have chosen to use Angular instead of Vue.js. This decision was easy because I had much more experience with Angular as web framework than vue.js. After that the first of my planned tech stack components was changed. But it wasn't the last one.&lt;/p&gt;

&lt;h2&gt;
  
  
  ARM is not x86
&lt;/h2&gt;

&lt;p&gt;No much time since the next problem was coming. As database I have chosen MongoDB. For the deployment I needed an docker image of it. But the support for the MongoDB docker image for ARM32 architecture has ended. You will remember. One of my conditions was to run the software on a raspberry pi. To have less problems with this or other database images I have decided to use an h2 database. This database can be run in the same docker container as the java server. As a java developer I know that my software can run on every architecture as long as it has a java runtime environment. But this kind of luxury let me forget that in other cases the architecture of the host system is very important for the whole parts of a project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Apply a web server for the angular web app
&lt;/h2&gt;

&lt;p&gt;After this I had a stable backend based on a docker container containing a java spring boot server and a h2 database. The last I needed was a web server respectively a http server. To archive this goal I have read many tutorials to build a docker image and docker container for the angular app. The web app runs. Fine. But there was a bug on it. If anyone types a specific route in the url bar of the browser there was an error that the path can not be found. This was happening because the web server layer try to find a specific file or directory like the route in the browser. But angular works in another way. Angular has there own scripts to process routes. So I have needed to tell the web server layer to pass on the task to angular. But to configure the docker container required a lot of deep knowledge about docker. Knowledge that I was not ready to learn for this project. Instead I have used the classic apache web server. For the apache web server I could write rules to pass on the routing tasks to angular. This was very easy on the one hand and on the other hand the apache web server started automatically on every system boot.&lt;/p&gt;

&lt;h2&gt;
  
  
  What have I learned?
&lt;/h2&gt;

&lt;p&gt;Through this amount of problems and solutions I have learned to go other ways if your way is blocked. Be flexible in use of technologies. Try something new so you can choose the right technology from your knowledge stock. Have the brave to learn different technologies like different frameworks for web apps, desktop guis, smartphone apps, backend server and so on. So you can make the right choice to solve a specific use case on the most efficient way.&lt;br&gt;
What are your experiences in choosing a tech stack for projects? Let it me know.&lt;/p&gt;

&lt;p&gt;Keep coding.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>codenewbie</category>
      <category>learning</category>
    </item>
    <item>
      <title>Java records und wieso du sie nutzen solltest [German]</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Sat, 27 May 2023 12:31:38 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/java-records-und-wieso-du-sie-nutzen-solltest-german-g9g</link>
      <guid>https://dev.to/pythonisnotasnake/java-records-und-wieso-du-sie-nutzen-solltest-german-g9g</guid>
      <description>&lt;p&gt;Falls du ein Einsteiger bist, welcher aktuell Java lernt, kennst du bereits die Basiselemente wie Klassen, Methoden, Enums und so weiter. Jedoch gibt es seit Java 16 fest im Java Funktionsumfang verankert records. Dieses kurze Tutorial wird dir erklären, was records in Java sind, sowie einige Tipps dazugeben, wie du sie in deinem nächsten Projekt verwenden kannst.&lt;br&gt;
Alle Informationen in diesem Tutorial basieren auf der &lt;a href="https://docs.oracle.com/en/java/javase/16/language/records.html"&gt;Java 16 records Dokumentation&lt;/a&gt;, sowie meinen eigenen Erfahrungen.&lt;/p&gt;
&lt;h2&gt;
  
  
  Was sind record?
&lt;/h2&gt;

&lt;p&gt;Einfach erklärt sind records eine Abstrahierung von Java Beans. Ein record definiert automatisch einen All arguments Konstruktor und gibt public Zugriff zu allen properties des records. Ein record hat von sich aus keine weiteren Methoden. Es ist schlicht ein &lt;em&gt;dummes&lt;/em&gt; Java Objekt ohne weitere Funktionalität.&lt;/p&gt;
&lt;h2&gt;
  
  
  Wie wird ein record implementiert?
&lt;/h2&gt;

&lt;p&gt;Ähnlich zu Enums kann ein record Bestandteil einer Java Klasse sein oder eine eigenständige Datei darstellen.&lt;br&gt;
Als Beispiel möchten wir einen Bruch (engl. fraction) definieren. Ein Bruch besteht aus einem Zähler (engl. numerator) und einem Nenner (engl. denominator). Möchten wir dieses Objekt nun als Java Klasse schreiben sieht es wie folgt aus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setNumerator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;getNumerator&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setDenominator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;getDenominator&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wie du erkennen kannst ist dies ziemlich viel Code um lediglich eine Klasse mit zwei Attributen zu beschreiben. Und nun lass uns dasselbe als record geschrieben betrachten:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Kurz, oder? Und das ist der wichtigste Grund für die Verwendung von records. Diese einzelne Zeile bündelt einen All Arguments Konstruktor und die beiden public Attribute numerator und denominator.&lt;br&gt;
Möchtest du eine neue Instanz dieses records erzeugen, so tust du dies wie für gewöhnliche Klassen auch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="n"&gt;fractionAsRecord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Override von Konstruktoren und Getter/Setter
&lt;/h2&gt;

&lt;p&gt;Falls der vordefinierte Konstruktor und die Getter/Setter Methoden deinen Use Case nicht sinnvoll abdecken, kannst du diese auch überschreiben. Für einen Konstruktor würdest du es wie folgt machen:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"Invalid fraction: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;
      &lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wie du siehst, wird hier nicht wie üblich die Override Annotation benötigt. Dasselbe kann ebenfalls für die Methoden &lt;code&gt;double numerator()&lt;/code&gt; oder &lt;code&gt;void numerator(double numerator)&lt;/code&gt; getan werden.&lt;/p&gt;

&lt;h2&gt;
  
  
  Statische Attribute und Methoden
&lt;/h2&gt;

&lt;p&gt;Nun kommen wir zu einer erweiterten Funktion von records. Records geben dir die Möglichkeit statische Attribute und statische Methoden zu definieren. Für unser Beispiel möchten wir unseren Bruch durch den Wert zwei dividieren. Dafür können wir ein statisches Attribut &lt;code&gt;static double half = 2.0&lt;/code&gt; und eine statische Methode &lt;code&gt;static Fraction divideByTwo(Fraction fr)&lt;/code&gt; implementieren.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="nf"&gt;divideByTwo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Die oben aufgeführte Methode kann mittels &lt;code&gt;Fraction.divideByTwo(fraction)&lt;/code&gt; aufgerufen werden. Wie du sehen kannst, kannst du Records um deine benötigten Methoden erweitern, vorausgesetzt diese sind statisch. Dies gibt dir etwas mehr Flexibilität beim Einsatz von Records.&lt;/p&gt;

&lt;h2&gt;
  
  
  Andere nützliche Funktionen
&lt;/h2&gt;

&lt;p&gt;In der &lt;a href="https://docs.oracle.com/en/java/javase/16/language/records.html"&gt;java 16 Dokumentation&lt;/a&gt; sind eine Anzahl weiterer erweiterter Funktionalitäten, welche ich hiermit kurz erwähne aber nicht detailliert auf alle eingehe. Du kannst diese im eben erwähnten Link im Abschnitt "Features of Record Classes" finden.&lt;br&gt;
Für mich persönlich ist die Option, dass Records Interfaces implementieren können am nützlichsten. Beispielsweise kannst du einige Basis Methoden für eine Gruppe von Records definieren. Ich gebe dir ein kurzes Beispiel mit dem Interface &lt;code&gt;Mathobject&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Mathobject&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Mathobject&lt;/span&gt; &lt;span class="nf"&gt;divideByTwo&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wenn wir unseren Fraction Record dieses Interface implementieren lassen, können wir unsere statische Methode &lt;code&gt;divideByTwo&lt;/code&gt; umschreiben. Dies sieht dann wie folgt aus:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Mathobject&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="nd"&gt;@Override&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="nf"&gt;multiplyByTwo&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Der Record überschreibt die Methode des Interface &lt;code&gt;Mathobject&lt;/code&gt; und lässt uns die beiden Attribute von Fraction innerhalb der Methode nutzen, da diese nicht mehr statisch ist.&lt;/p&gt;

&lt;h2&gt;
  
  
  Abschluss
&lt;/h2&gt;

&lt;p&gt;Was macht Records am Ende so nützlich?&lt;br&gt;
Sie produzieren signifikant weniger Boilerplate Code.&lt;br&gt;
Zudem kennt jeder erfahrene Java Entwickler das Prinzip von Records und kann somit diesen übersichtlichen Code sehr leicht verstehen. Somit wird dein Code verständlicher und orderntlicher.&lt;br&gt;
Und das allerwichtigste ist der Aspekt, dass du weniger Code schreiben musst, was zu einer Zeitersparnis führt.&lt;/p&gt;

&lt;p&gt;Keep coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/pythonisnotasnake/java-records-and-why-you-should-use-them-1bbn"&gt;Here you can find the english version.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
      <category>german</category>
    </item>
    <item>
      <title>Java records and why you should use them</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Mon, 15 May 2023 19:26:42 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/java-records-and-why-you-should-use-them-1bbn</link>
      <guid>https://dev.to/pythonisnotasnake/java-records-and-why-you-should-use-them-1bbn</guid>
      <description>&lt;p&gt;If you are a beginner in learning java you have heard of the basics like classes, methods, enums and so on. But since java 16 records are permanently added to the java feature set. This short tutorial will give you explanation what records in java are and some tips how to use them in your next project.&lt;br&gt;
All informations in this tutorial are from the &lt;a href="https://docs.oracle.com/en/java/javase/16/language/records.html"&gt;java 16 records documentation&lt;/a&gt; and my own experience.&lt;/p&gt;
&lt;h2&gt;
  
  
  What are records?
&lt;/h2&gt;

&lt;p&gt;Easily explained records are an abstraction of java beans. A record defines automatically an all arguments constructor and give public access to all properties of the record. A record does not have any other methods. It is only a &lt;em&gt;stupid&lt;/em&gt; java object without any functionality.&lt;/p&gt;
&lt;h2&gt;
  
  
  How to implement a record
&lt;/h2&gt;

&lt;p&gt;Similar to enums a record can be part of a java class or a file by its own.&lt;br&gt;
As example we want to define a fraction. A fraction consists of a numerator and a denominator. If we want to write it as a classic java class it would look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setNumerator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;getNumerator&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;setDenominator&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;getDenominator&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;As you can see this is many code only to define a class with two attributes. And now let us see how this will be look as a record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Short right? And this is the most important reason to use records. This single line bundles a all arguments constructor and the two public attributes numerator and denominator.&lt;br&gt;
If you want to create a new instance of this record you will do this as you do it for regular classes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="n"&gt;fractionAsRecord&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="mf"&gt;0.0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mf"&gt;1.0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Override constructor and getter/setter
&lt;/h2&gt;

&lt;p&gt;If the default constructor and getter/setter methods do not match your use case you can override them. For a constructor you will do it like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;java&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;lang&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;"Invalid fraction: "&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="s"&gt;"/"&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;
      &lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How you can see it does not need the override annotation as usual. The same can be done with the methods &lt;code&gt;double numerator()&lt;/code&gt; or &lt;code&gt;void numerator(double numerator)&lt;/code&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Static attributes and methods
&lt;/h2&gt;

&lt;p&gt;Now we came to a advanced function of records. Records give you the ability to define static attributes and static methods.&lt;br&gt;
For our example we want to divide our fraction with the number two. So we can declare a static attribute &lt;code&gt;static double half = 2.0&lt;/code&gt; and a static method &lt;code&gt;static Fraction divideByTwo(Fraction fr)&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="nf"&gt;divideByTwo&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;(),&lt;/span&gt; &lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The method above can be called by &lt;code&gt;Fraction.divideByTwo(fraction)&lt;/code&gt;. As you can see you can expand records with your needed methods as long as they are static. This will give you a little more flexibility in use of records.&lt;/p&gt;

&lt;h2&gt;
  
  
  Other useful features
&lt;/h2&gt;

&lt;p&gt;In the &lt;a href="https://docs.oracle.com/en/java/javase/16/language/records.html"&gt;java 16 documentation&lt;/a&gt; are a number of advanced features that I will mention but not explain in all details. You can find them in the link above under the section "Features of Record Classes".&lt;br&gt;
Personally the aspect to let a record implement some interfaces is the most useful for me. For example you can define some basic methods for a group of records. I give you an easy example with the interface &lt;code&gt;Mathobject&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;Mathobject&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Mathobject&lt;/span&gt; &lt;span class="nf"&gt;divideByTwo&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we let implement our fraction this interface we can rewrite our static method &lt;code&gt;divideByTwo&lt;/code&gt;. This looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="n"&gt;record&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;Mathobject&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

  &lt;span class="nd"&gt;@Override&lt;/span&gt;
  &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="nc"&gt;Fraction&lt;/span&gt; &lt;span class="nf"&gt;multiplyByTwo&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Fraction&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;numerator&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;denominator&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;half&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
  &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The record override the method of the interface &lt;code&gt;Mathobject&lt;/code&gt; and let us use the two attributes from fraction directly inside of the method because this is a non-static method.&lt;/p&gt;

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

&lt;p&gt;What makes records so useful at the end?&lt;br&gt;
They produce significantly less boilerplate code.&lt;br&gt;
Every experience java developer knows records and can understand the short code very easily. So it makes your code more understandable and cleaner.&lt;br&gt;
And the much important aspect of all is the significantly less code to write which save you time.&lt;/p&gt;

&lt;p&gt;Keep coding.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/pythonisnotasnake/java-records-und-wieso-du-sie-nutzen-solltest-german-g9g"&gt;Hier gelangst du zur deutschen Fassung.&lt;/a&gt;&lt;/p&gt;

</description>
      <category>java</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Dockerize your Spring Boot Server</title>
      <dc:creator>PythonIsNotASnake</dc:creator>
      <pubDate>Sat, 13 May 2023 11:57:08 +0000</pubDate>
      <link>https://dev.to/pythonisnotasnake/dockerize-your-spring-boot-server-38e1</link>
      <guid>https://dev.to/pythonisnotasnake/dockerize-your-spring-boot-server-38e1</guid>
      <description>&lt;p&gt;There are many reasons why you want to run your spring boot server in a docker container. For example a capsuled environment, the comfort to delete and rebuild your application or a easy way to autostart your service on every reboot. I hope I have wake up some motivation in you to dockerize your spring boot server so we can start.&lt;br&gt;
But before let me tell there exists many different ways to structure the dockerfile and my way must not be the best way in your specific case.&lt;/p&gt;
&lt;h2&gt;
  
  
  Docker vs VMs
&lt;/h2&gt;

&lt;p&gt;When you search for a way to dockerize your application you have been hear something about VMs by sure. If not a VM, short for virtual machine, is a virtual operating system on your real operating system. You can give them some resources like process units from your processor, some ram and storage. Further you can install a operating system of your choice. This call like a lot of configuration by your own. Docker is easier in that way. If you have written a dockerfile (a blueprint of your docker container) you can easily build your whole docker container on any machine with a few CLI commands. That's all. Now let us learn something about the basic component of a dockerized app.&lt;/p&gt;
&lt;h2&gt;
  
  
  Docker components
&lt;/h2&gt;

&lt;p&gt;First we have the &lt;strong&gt;dockerfile&lt;/strong&gt;. A dockerfile is the blueprint to tell docker how your app should be build and which third-party services your application will be need.&lt;br&gt;
Secondly there is the &lt;strong&gt;docker image&lt;/strong&gt;. The docker image is the builded package of your application. Similar to an .jar, .exe or .deb file but you can capsule other images in your image like a java runtime environment. The best way to find docker images is to take a look on &lt;a href="https://hub.docker.com/search?q="&gt;docker hub&lt;/a&gt;.&lt;br&gt;
The third and last component is the &lt;strong&gt;docker container&lt;/strong&gt;.  The docker container is like a vm but needs lower resources to run. In the docker container runs your application. You can start and stop the container. On every start of it the applications in it are restarting too.&lt;br&gt;
So after we know the core components of docker we can start to write the dockerfile for our spring boot server.&lt;/p&gt;
&lt;h2&gt;
  
  
  Writing a dockerfile
&lt;/h2&gt;

&lt;p&gt;Create a new file called 'Dockerfile'. Then open the file with a text editor.&lt;br&gt;
We started with the first line &lt;code&gt;FROM eclipse-temurin:latest&lt;/code&gt;. The statement &lt;code&gt;FROM&lt;/code&gt; means that a docker image will be used. In our case we are using the image of a java runtime environment. &lt;code&gt;latest&lt;/code&gt; in this case means that we will use the latest release of the image at every time we are executing the dockerfile to build an image. The official wording for the release version is tag. If you want to use a specific tag for example '17.0.7_7-jdk' write &lt;code&gt;FROM  eclipse-temurin:17.0.7_7-jdk&lt;/code&gt;.&lt;br&gt;
The next line is the &lt;code&gt;EXPOSE&lt;/code&gt; statement to define a port your application want to use. Also write &lt;code&gt;EXPOSE 8080&lt;/code&gt; if your spring boot application is using the default port 8080. Otherwise replace 8080 with the correct port of your application.&lt;br&gt;
The next step is a little more complex than the steps before. For this tutorial you will need your spring boot server as compiled .jar file. If you have a gradle project you can do it with the CLI command &lt;code&gt;./gradlew build&lt;/code&gt;.&lt;br&gt;
After you have your jar file we can continue to add your jar to the image. For this we need to expand our dockerfile by two new lines. With the line &lt;code&gt;ARG JAR_FILE=target/*.jar&lt;/code&gt; we define an argument that we call 'JAR_FILE'. If now argument is provided in the build command docker will use the provided default value &lt;code&gt;target/*.jar&lt;/code&gt;. But this line is only one half. Further we need the next line &lt;code&gt;ADD ${JAR_FILE} app.jar&lt;/code&gt;. This add your provided jar file to the builded docker image with the new name 'app.jar'.&lt;br&gt;
Coming to the last line we only need the &lt;code&gt;ENTRYPOINT&lt;/code&gt; statement to start the spring boot application inside of the container. Also we add the line &lt;code&gt;ENTRYPOINT ["java", "-jar","app.jar"]&lt;/code&gt;. Translated this means simply use java to run the jar with name app.jar.&lt;br&gt;
And this is it. You have written your first dockerfile. Your dockerfile should look like this now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; eclipse-temurin:latest&lt;/span&gt;
&lt;span class="k"&gt;EXPOSE&lt;/span&gt;&lt;span class="s"&gt; 8080&lt;/span&gt;
&lt;span class="k"&gt;ARG&lt;/span&gt;&lt;span class="s"&gt; JAR_FILE=target/*.jar&lt;/span&gt;
&lt;span class="k"&gt;ADD&lt;/span&gt;&lt;span class="s"&gt; ${JAR_FILE} app.jar&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; ["java", "-jar","app.jar"]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Build the docker image
&lt;/h2&gt;

&lt;p&gt;After you have your dockerfile ready we can start to build the docker image. For this open a terminal and check if docker is running. For example use the command &lt;code&gt;docker ps -a&lt;/code&gt; to list all docker containers. If docker is running you can start to build your image with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;--build-arg&lt;/span&gt; &lt;span class="nv"&gt;JAR_FILE&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;build/libs/example.jar &lt;span class="nt"&gt;-t&lt;/span&gt; springboot:latest &lt;span class="nb"&gt;.&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Replace the jar path after &lt;code&gt;JAR_FILE=&lt;/code&gt; with the path to your own jar file, springboot with the name of your new docker image and latest with tag of your choice but you can also leave it as latest.&lt;br&gt;
&lt;em&gt;Important! Don't forget the dot at the end of the command.&lt;/em&gt;&lt;br&gt;
Now docker will build your image. At this process some third party docker images like the jre will be downloaded by docker.&lt;/p&gt;
&lt;h2&gt;
  
  
  Run the docker container
&lt;/h2&gt;

&lt;p&gt;Finally you can run your docker image in a docker container. Use the following command to do that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--name&lt;/span&gt; springbootcontainer &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8080:8080 springboot:latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Like in the steps before replace &lt;code&gt;springbootcontainer&lt;/code&gt; by the name of your new container and &lt;code&gt;springboot:latest&lt;/code&gt; by the name of your image and your tag. With the &lt;code&gt;-p&lt;/code&gt; parameter you can define which port from inside of the container should forwarded to which port of your local machine. In common situations you forwarded the application port to the identical port of your local machine.&lt;br&gt;
Hint: If you want automatically restarts of your docker container use the additional parameter &lt;code&gt;--restart always&lt;/code&gt; in the docker run command.&lt;/p&gt;

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

&lt;p&gt;Congratulation! You have build your first docker container of an java spring boot application. Now you can start to experiment with the dockerfile elements and try other ways to deploy your docker container to match your case perfectly.&lt;br&gt;
If you need more input try the &lt;a href="https://docs.docker.com/"&gt;documentation of docker&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>java</category>
      <category>springboot</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
