<?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: Dev From Legacy</title>
    <description>The latest articles on DEV Community by Dev From Legacy (@devfromlegacy).</description>
    <link>https://dev.to/devfromlegacy</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%2F469607%2F5c0471cf-8f49-417c-b12d-f43a05f9d7e3.jpg</url>
      <title>DEV Community: Dev From Legacy</title>
      <link>https://dev.to/devfromlegacy</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devfromlegacy"/>
    <language>en</language>
    <item>
      <title>Git and Github: a fast sequence</title>
      <dc:creator>Dev From Legacy</dc:creator>
      <pubDate>Thu, 17 Sep 2020 03:37:06 +0000</pubDate>
      <link>https://dev.to/devfromlegacy/git-and-github-a-fast-sequence-3dam</link>
      <guid>https://dev.to/devfromlegacy/git-and-github-a-fast-sequence-3dam</guid>
      <description>&lt;p&gt;You can practice the steps in sequence:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Starting:&lt;/strong&gt; download and install &lt;a href="https://git-scm.com/"&gt;Git&lt;/a&gt;, then you can open Git Bash.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Creating a repository:&lt;/strong&gt; access a diretory with some source code (example: &lt;em&gt;test.html&lt;/em&gt;) and type &lt;code&gt;git init&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adding files:&lt;/strong&gt; at same directory, you can type: &lt;code&gt;git add .&lt;/code&gt; . Then all files in that directory will be added.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Checking status:&lt;/strong&gt; type &lt;code&gt;git status&lt;/code&gt; and you will see the message: &lt;em&gt;Changes to be committed&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Configure your user:&lt;/strong&gt; execute the commands bellow changing data between quotation marks.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git config --global user.email "you@example.com"
git config --global user.name "Your Name"
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Committing:&lt;/strong&gt; execute the commands bellow changing message between quotation marks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "Your message."
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Visualizing logs:&lt;/strong&gt; type &lt;code&gt;git log&lt;/code&gt; .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Ignoring files:&lt;/strong&gt; you can create a empty file and it adds filename in a file called &lt;code&gt;.gitigonore&lt;/code&gt; at same directory.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Starting with Github:&lt;/strong&gt; Create a account in &lt;a href="https://github.com/"&gt;Github&lt;/a&gt; and create a new repository.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adding remote repository:&lt;/strong&gt; type code bellow changing your repository link.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git remote add origin https://github.com/YOURNAME/NAMEREPOSITORY.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pushing your code:&lt;/strong&gt; type &lt;code&gt;git push origin master&lt;/code&gt; and enter your login and password.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cloning from Github:&lt;/strong&gt; you can access a different directory in your computer and execute the command bellow.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone https://github.com/YOURNAME/NAMEREPOSITORY.git
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Pulling from Github:&lt;/strong&gt; you can change a file on Github page, then execute the command bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git pull https://github.com/YOURNAME/NAMEREPOSITORY.git master
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Creating new branch:&lt;/strong&gt; &lt;code&gt;git branch NAMEBRANCH&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Switching branch:&lt;/strong&gt; &lt;code&gt;git checkout NAMEBRANCH&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Committing on branch:&lt;/strong&gt; change any file and execute commands bellow.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add NOMEFILE
git commit -m "Changing file for commit branch test."
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Merging:&lt;/strong&gt; execute commands bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout master
git merge NAMEBRANCH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Rebase:&lt;/strong&gt; change any file and execute steps bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add NOMEFILE
git commit -m "Changing file for commit master for rebase test."
git checkout NAMEBRANCH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Change any file again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add NOMEFILE
git commit -m "Changing file for commit branch for rebase test."
git checkout master
git rebase NAMEBRANCH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reseting and restoring:&lt;/strong&gt; change any file and execute steps bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add NOMEFILE
git reset HEAD NOMEFILE
git checkout -- NOMEFILE
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reverting:&lt;/strong&gt; change any file and execute steps bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add NOMEFILE
git commit -m "Changing file for revert test."
git log
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should get the hash related the last commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git revert HASHLASTCOMMIT
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Stash:&lt;/strong&gt; change any file and execute steps bellow, the command &lt;code&gt;git stath pop&lt;/code&gt; will remove from stash list and apply, then you can commit.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git stash
git stash pop
git add NOMEFILE
git commit -m "Changing file for stash test."
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Switching to a different commit and creating a branch:&lt;/strong&gt; execute steps bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Get a hash any past commit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout HASHPASTCOMMIT
git checkout -b NOMENEWBRANCH
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Difference between commits:&lt;/strong&gt; return to master &lt;code&gt;git checkout master&lt;/code&gt; and execute steps bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git log --oneline
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Get two hash from any commits.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git diff HASH1..HASH2
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Creating tag:&lt;/strong&gt; execute steps bellow.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git tag -a VERSIONNAME -m "Creating a tag."
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can push commits and tag to Github.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push origin master
git push origin VERSIONNAME 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Any feedback is welcome!&lt;/p&gt;

</description>
      <category>github</category>
      <category>git</category>
    </item>
    <item>
      <title>Java first steps: 20 things I'd forgotten</title>
      <dc:creator>Dev From Legacy</dc:creator>
      <pubDate>Wed, 16 Sep 2020 02:01:35 +0000</pubDate>
      <link>https://dev.to/devfromlegacy/java-first-steps-20-things-i-d-forgotten-3gof</link>
      <guid>https://dev.to/devfromlegacy/java-first-steps-20-things-i-d-forgotten-3gof</guid>
      <description>&lt;p&gt;If you don't work with Java or you're relearning it (like me!), I'm sharing some things:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Java Major features:&lt;/strong&gt; Object Oriented, Platform independent, it has many libraries and it's similar to C++.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Java Virtual Machine(JVM):&lt;/strong&gt; Java source code [&lt;em&gt;.java&lt;/em&gt;] is compiled into Java bytecode [&lt;em&gt;.class&lt;/em&gt;], which is  executed by a Java virtual machine (JVM).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Important Versions:&lt;/strong&gt; 1 [1995], 5 [2004] and 8 [2014]. Current version in 2020-09: 9.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Java Kit Development:&lt;/strong&gt; it includes the Java Runtime Environment (JRE), an interpreter/loader (Java), a compiler (javac), an archiver (jar), a documentation generator (Javadoc) and other tools needed in Java development.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Environment Variables:&lt;/strong&gt; unless on Windows, you will need to set environment variable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Compiling/Executing Java on Command Prompt:&lt;/strong&gt; you can compile your .java program using &lt;code&gt;javac MyProgram.java&lt;/code&gt; and you can run using &lt;code&gt;java MyProgram&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;7. Best options IDE for Java:&lt;/strong&gt; currently Eclipse, Netbeans and IntelliJ IDEA.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;8. Java Hello World:&lt;/strong&gt; in the Java programming language, every application must contain a main method whose signature is: &lt;code&gt;public static void main(String[] args)&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class HelloWorldProgram {
    public static void main(String[] args) {
        System.out.println("Hello World!"); // Display the string.
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;9. Java Comments:&lt;/strong&gt; Single-line comments start with two forward slashes &lt;code&gt;//&lt;/code&gt; and multi-line comments start with &lt;code&gt;/*&lt;/code&gt; and ends with &lt;code&gt;*/&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;10. Java naming convention - CamelCase:&lt;/strong&gt; Java follows camel-case syntax for naming the class, interface, method and variable. Method and variable should start with lowercase letter (example: &lt;code&gt;ImageSprite&lt;/code&gt; ). Class and interface should start with uppercase letter (example: &lt;code&gt;getBackground&lt;/code&gt; ).&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;11. Java Operators: *&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arithmetic [+, -, *, /, %, ++, --]&lt;/li&gt;
&lt;li&gt;Logical [&amp;amp;&amp;amp;, ||, !]&lt;/li&gt;
&lt;li&gt;Comparison [==, !=, &amp;gt;, &amp;lt;, &amp;gt;=, &amp;lt;=, &amp;gt;&amp;gt;=, &amp;lt;&amp;lt;=]&lt;/li&gt;
&lt;li&gt;Assignment [=, +=, -=, *=, /=, %=, &amp;amp;=, |=, ^=]&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;12. Concatenation by +:&lt;/strong&gt; using operator + is one way to build a string in Java.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestVariables {

    public static void main(String args[]) {

        int age = 30;
        System.out.println("Age: " + age);
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;13. Floating-Point Data Types:&lt;/strong&gt; Java has some peculiarities about floating-point, like the outputs below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestFloatingPoint {

    public static void main(String args[]) {

        double salary = 1250.70;
        System.out.println("S: " + salary); //Output: S: 1250.7
        double division = 3.14 / 2;
        System.out.println(division); //Output: 1.57
        int otherDivision = 5 / 2;
        System.out.println(otherDivision); //Output: 2
        double newDivision = 5 / 2;
        System.out.println(newDivision); //Output: 2.0
        double lastDivision = 5.0 / 2;
        System.out.println(lastDivision); //Output: 2.5
        double number1 = 0.2;
        double number2 = 0.1;
        System.out.println(number1 +number2);
        //Output: 0.30000000000000004
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;14. Java Type Casting/Conversion:&lt;/strong&gt; Java Type Casting is classified into two types: Explicit and Implicit.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestConversion {

    public static void main(String[] args) {

        //Implicit casting
        byte a = 40;
        short b = a;
        int c = b;
        long d = c;
        float e = d;
        double f = e;
        System.out.println("byte : "+a); //Output: 40 
        System.out.println("short : "+b); //Output: 40
        System.out.println("int: "+c); //Output: 40
        System.out.println("long: "+d); //Output: 40
        System.out.println("float: "+e); //Output: 40.0
        System.out.println("double: "+f); //Output: 40.0

        //Explicit casting
        double g = 30.0;
        float h = (float) g;
        long i = (long) h;
        int j = (int) i;
        short k = (short) j;
        byte l = (byte) k;
        System.out.println("double: "+g); //Output: 30.0
        System.out.println("float: "+h); //Output: 30.0
        System.out.println("long: "+i); //Output: 30
        System.out.println("int: "+j); //Output: 30
        System.out.println("short: "+k); //Output: 30
        System.out.println("byte: "+l); //Output: 30
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;15. Characters and Strings in Java:&lt;/strong&gt; you can see some examples bellow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestCharacters {

    public static void main(String args[]) {
        char letter = 'a';
        System.out.println(letter); //Output: a
        char letterValue = 65;
        System.out.println(letterValue); //Output: A
        char nextLetterValue = (char) (letterValue + 1);
        System.out.println(nextLetterValue); //Output: B
        String sentence = "String test";
        System.out.println(sentence); //Output: String test
        String newSentence = "String test" + 1;
        System.out.println(newSentence); //Output: String test1
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;16. Conditionals in Java:&lt;/strong&gt; you can see some examples bellow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestConditional {

    public static void main(String[] args) {

        int age = 22;
        int numberPeople = 1;
        boolean accompanied = (numberPeople &amp;gt; 1);
        if ((age &amp;gt;= 21 || accompanied) &amp;amp;&amp;amp; numberPeople &amp;lt; 20) {
            System.out.println("You are allowed!");
            switch (numberPeople) {
                case 1:
                    System.out.println("Table for 1 on the right!");
                    break;
                case 2:
                    System.out.println("Table for 2 on the left!");
                    break;
                default:
                    System.out.println("Table for group on the patio!");
            }
        } else {
            System.out.println("You arent't allowed!");
        }
        // Output: You are allowed!
        // Table for 1 on the right!
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;17. Scope:&lt;/strong&gt; A block of code refers to all of the code between curly braces {}.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestScope {
    public static void main(String[] args) {

        { // This is a block
            int x = 100;
            // Code here CAN use x
            System.out.println(x);

        } // The block ends here
        // Code here CANNOT use x
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;18. Loops in Java:&lt;/strong&gt;  you can see some examples bellow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestLoop {

    public static void main(String[] args) {
        int counter = 0;
        while(counter &amp;lt;= 1) {
            System.out.println(counter);
            counter++;
        }
        System.out.println(counter);

        for(int newCounter = 0; newCounter &amp;lt;= 1; newCounter++) {
            System.out.println(newCounter);
        }
        //Output: 0 1 2 0 1
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;19. Break/continue:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestBreakContinue {

    public static void main(String[] args) {
        for (int i = 0; i &amp;lt; 4; i++) {
            if (i == 2) {
                break;
            }
            System.out.println(i);
        }
        // Output: 0 1

        for (int i = 0; i &amp;lt; 4; i++) {
            if (i == 2) {
                continue;
            }
            System.out.println(i);
        }
        // Output: 0 1 3
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;20. Arrays in Java:&lt;/strong&gt;  you can see some examples bellow.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class TestArrays {

    public static void main(String[] args) {

        String[] cars = {"Volvo", "BMW", "Ford", "Mazda"};
        System.out.println(cars[0]);
        // Outputs Volvo        
    }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



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