Wednesday, January 14, 2015

Getting started with Java

Java syntax and API is a simple to learn and use.
Java is object-oriented where each object can perform one or more discrete tasks and contains all the data needed to perform the task.
Java is distributed, you can send data across the net easily.
Java is robust, so programs run correctly and do not break when the unexpected happens.
Java is secure by limiting access of programs to your resources and files on your computer.
Java is architecture-neutral and portable by writing the code in one computer and running the code on another machine with another hardware configuration.
Java byte code is interpreted by a virtual machine not directly by the operating system.
Java is multithreaded as the programs share data and instructions.
Java is dynamic by calling upon resources as needed.

In order to learn this language, I recommend this path of action:


  1. Know how computers work 
    1.  - CPU, ALU, RAM, Thread, Process, Memory Address, and Interrupts
  2. Know how CPU instructions carried out
    1. - Assembly language instructions ( mov, jmp, cmp, add, ... )
  3. Know how file systems store data and how to manage your files in folders
  4. Know basic command line utilities ( dir, mkdir, rmdir, copy, set, echo, ... )
  5. Know how to get help from the local system or utilities and how to read the help documentation
  6. Know about path and other environmental variables
  7. Understand basic automation commands in the terminal
    1.  - i.e. for %i in ( 1 2 3 4 ) do echo Hello World %i
  8. Understand basic script execution and syntax
    1. - i.e. hello.bat -> for %%i in ( 1 2 3 4 ) do echo Hello World %%i
  9. Understand difference between JRE and JDK 
  10. Install and run ( javac, java ) simple Java program written in notepad.exe  ( see below )
  11. Learn C++ function and structure concepts 
  12. Understand the importance of documentation ( javadoc )
  13. Understand the importance of flowcharts, pseudo code, UML
  14. Create simple algorithms based on what you know 
    1. i.e. Calculate the are of a circle 
      1. create a table with columns radius, diameter, PI, area
      2. enter values into radius column
      3. calculate diameter and keep in mind the function ( d= 2 * r )
      4. write PI for each row ( this will need to be accessed by each row, so it is static )
      5. calculate the are ( a = r * r * PI )
      6. analyze the results
        1. each column with changing values without formula will be variable 
        2. each formula columns will be function/method 
        3. each entry that does not change will be final and static for all to access 
        4. value on the left side of the equation will be the return value for the method
        5. think about the documentation hat would help another person learn about your code
      7. write the code and look for syntax errors
        1. determine proper data types for identifiers
      8. identify unneeded code 
        1. diameter should be removed or changed to hold r*r as a sub-calculation since it can help with troubleshooting, but you can ignore 
      9. think about input validation to ensure positive radius values
        1. you can create another method to return an absolute value of radius before calculation of area
      10. enter the values from your table and test if you get the same results from your code
  15. Use Raptor to create code from flowchart
  16. Always generate javadoc of your own code and understand how to read it
  17. Use BlueJ to visualize objects and inheritance
  18. Use Greenfoot to understand GUI concepts and create simple games
  19. Move to a full featured Integrated Development Environment ( IDE ) like Eclipse
  20. Understand how to use the debugger to monitor values in your code at different stages of processing
  21. Make mistakes and learn from the error messages
  22. Add features to code you wrote and understand as you learn more about a language 
  23. Don't be afraid to experiment 


 /** Student Class establishes the student id, name and grade
  *  @author Richland Teacher
  *  @version 2015
 */
 public class hello
 {
     private final String studentName;
     int value;
     public static int year;
     /**
      * This is a method that will take two parameters and will set a single field in the object
      * @param parameterOne imaginary first name as a String
      * @param parameterTwo imaginary last name as a String
      */
//Constructor for the hello class
public hello( String parameterOne, String parameterTwo ){
          studentName=parameterOne+parameterTwo;
          value=100;
          year=1900;
}
    // Main method
     public static void main(String[] args)
     {
         String name="My name is: ";
         System.out.println("Hello, "+name + args[0]);
         hello testing = new hello("firstname","lastname");
         System.out.println("Hello "+testing.value+"  "+year);
     }
  }// End of  class

No comments:

Post a Comment