Wednesday, August 30, 2017

How do i become a good Java Programmer?

1. Have strong foundation and understanding on OOP Principles
 For a Java developer, having strong understanding on Object Oriented Programming is a must. Without having a strong foundation on OOPS, one can't realize the beauty of an Object Oriented Programming language like Java. If you don't have good idea on what OOPS is, even though you are using OOP language you may be still coding in procedural way. Just studying OO principle definitions won't help much. We should know how to apply those OO principles in designing a solution in OO way. So one should have a strong knowledge on Object modeling, Inheritance, Polymorphism, Design Patterns.
2. Master the core APIs
 It doesn't matter how strong you are in terms of theoretical knowledge if you don't know the language constructs and core APIs. In case of Java, one should have very strong hands-on experience with core APIs like java.lang.*, I/O, Exceptions, Collections, Generics, Threads, JDBC etc. When it comes to Web application development, no matter which framework you are using having strong knowledge on Servlets, JSPs is a must.
3. Keep coding
 Things look simpler when talking about them theoretically. We can give a solution to a problem very easily in theory. But we can realize the depth of the problem when we start implementing our approach. You will come to know the language limitations, or design best practices while coding. So keep coding.
4. Subscribe to forums 
 We are not alone. There are lots of people working on the same technologies that we are working on. While doing a simple proof of concept on a framework may not give you real challenges, when you start using it on real projects you will face weird issues and you won't find any solution in their official documentation. When starting to work on a new technology the best and first thing to do is subscribe to the relevant technology forums. Whatever the issue you are facing, someone else in the world might have already faced it earlier and might have found the solution. And it would be really really great if you can answer the questions asked by other forum users.
5. Follow blogs and respond
 As I already told you are not alone. There are thousands of enthusiastic technology freaks around the world blogging their insights on technology. You can see different perspectives of same technology on blogs. Someone can find great features in a technology and someone else feels its a stupid framework giving his own reasons of why he felt like that. So you can see both good and bad of a technology on blogs. Follow the good blogs and respond/comment on posts with your opinion on that.
6. Read open source frameworks source code
 A good developer will learn how to use a framework. But if you want to be an outstanding developer you should study the source code of various successful, popular frameworks where you can see the internal working mechanism of the framework and lot of best practices. It will help a lot in using the frameworks in very effective way.
7. Know the technology trends
 In the open source software development technology trends keep on changing. By the time you get good idea on a framework that might become obsolete and some brand new framework came into picture with super-set of features. The problem which you are trying to solve with your current framework may be already solved by the new framework with a single line of configuration. So keep an eye on whats coming in and whats going out.
8. Keep commonly used code snippets/utilities handy
 Overtime you may need to write/copy-paste same piece of code/configuration again and again. Keeping those kind of configuration snippets like log4.properties, jdbc configuration etc and utilities like StringUtils, ReflectionUtils, DBUtils will be more helpful. I know it itself won't make you outstanding developer. But just imagine some co-developer asks you to help in fetching the list of values of a property from a collection of objects and then you just used your ReflectionUtil and gave the solution in few minutes. That will make you outstanding.
9. Know different development methodologies
 Be familiar with various kinds of methodologies like Agile, SCRUM, XP, Waterfall etc. Nowadays choosing the development methodology depends on the client. Some clients prefer Agile and some clients are happy with waterfall model. So having an idea on various methodologies would be great.
10. Document/blog your thoughts on technology
 In day to day job you may learn new things, new and better way of doing things, best practices, architectural ideas. Keep documenting those thoughts or blog it and share across the community. Imagine you solved a weird problem occurred while doing a simple POC and you blogged about it. May be some developer elsewhere in the world is facing the same issue on a production deployed application. Think how important that solution for that developer. So blog your thoughts, they might be helpful for others or to yourself.


NOTE:- Don't focus on a particular language especially when you are yet to get a steady job or any core area of specialization.


Monday, August 21, 2017

Simple linear regression analysis "Java Code Snippet"

Simple linear regression analysis calculator : - the code below shows the modeling of the relationship between a response variable and an explanatory variable (dependent and independent variable respectively) in one of the most widely use of statistical techniques referred to as “Regression Analysis”. 
This regression model allows “you” to explore what happens to the response variable for specified changes in explanatory variable.
It aims at aims finding the line of best fit through a 2 - dimensional plane of paired x and y variables, finding the error of estimation, Pearsons’ coefficient of correlation and also, finding the (a) regression line using y = a + bx with it corresponding scatter plot.
 A regression (linear) has two parameters which are the slope and the intercept. Once the estimates of both parameters are known using the program, current application, the predicted value (y) will be generated.

----------------------------------------------------------------------

Copy, Save on your preferred storage device... Note, the class name is LRegression, so all you have to do is "change to your current directory" then Run...

If you saved on "c:\users\document"--- all you have to do is change ur current directory in your cmd prompt to "c:\users\document" then "java LRegression Values of x each separated by a space FOLLOWED by Vales of y.


Example---- if your x values are 12, 23, 45, 6 and your y values are 23, 32.41,12----- all you have to do after changing to your current directory is ~> java LRegression 12 23 45 6 23 32 41 12. 


In case of any error (Exception), fear not, its taken care of.... you would get an\ user friendly error message.

-------------------------------------------------------------------------------------------------
/*
Simple Linear Regression calculator
Program written by Doubra Clement Ebijuoworih
*/
     import java.util.Scanner;
     import static java.lang.System.out;
     import javax.swing.JOptionPane;

                  class LRegression

                  {
                        // n counts for entry values (x and y)
                        static int n = 0;

                         // initialization and declaration of the summatioon of x and y values..

                            static double sumOfx = 0.0;
                            static double sumOfy = 0.0;

                          ///000  UserInput.. i.e.trying to get the sum of x and sum of y...


                           public static void main(String [] args)

                           {            
                                        double[] x = new double[args.length];
   double[] y = new double[args.length];

  // checking for NaN

for (int i = 0; i <args.length; i++)
{
try
                                  {   
                                  double change = Double.parseDouble(args[i]);
               if (change == Double.NaN)
                   {}
  }
                catch (Exception e) 
                  {System.out.println("\n\nVALUES OTHER THAN INTEGER OR  DOUBLE HAVE BEEN ENTERED");
                                                           System.exit(1);
 }};
                                       // making sure more than 1 value is input into the system

                                           if (args.length < 3)

                                           {
                       System.out.println("\n\n        REQUIRED INPUT SHOULD BE MORE THAN 1 FOR BOTH X & Y");
                                                         System.exit(1);
                                  }

                                //  checking if x input == y input

                          if ((args.length % 2) != 0)
                          {
                               out.println("\n  **ERROR** Corresponding 'y' values not found  for every                          x' values or     vice versa.....");
                               out.println("\n  **Enter Your 'X' and 'Y' values again; Using the previous                                format.........");
                          }
                            else
                                 {
                                   n = args.length / 2 ;

                                         for (int count = 0; count <= args.length - 1; count++)

                                           {
                                if (count >= n)
                                                        {
                                    // y input and functions...
                                                  y[count] = Double.parseDouble(args[count]);
                                                   sumOfy += y[count];   // getting the summation of y

                                                                  continue;

                                                        } 
                                                       else {;}
                                          x[count] = Double.parseDouble(args[count]);
                                                   sumOfx += x[count];
                                              }
                                 //000
                                         // 111
                                          // Getting the summation of xy i.e. (Exy)

                                double [] x_ = new double[args.length];

                                double [] y_ = new double[args.length];
                                double SumOfXY = 0.0;
                                double SumOfxSquare = 0.0;
                                double SumOfySquare = 0.0;
                                double slope = 0.0;
                                double xMean = 0.0;
                                double yMean = 0.0;
                                double intercept = 0.0;
                                double leastSquare = 0.0 ;
                                double pearsonsCofC = 0.0;

                                for (int xycounter =0; xycounter <=args.length -1; xycounter++)

                                          {     //opening 44
                                                if (xycounter == n)
                                                   break;
                                    x_ [xycounter] = Double.parseDouble(args[xycounter]);
                                          SumOfxSquare += (x_[xycounter] * x_[xycounter]);
                                    y_ [xycounter] = Double.parseDouble(args[xycounter+n]);
                                          SumOfySquare += (y_[xycounter] * y_[xycounter]);
                                SumOfXY += (x_[xycounter] * y_[xycounter]);

                              }    // closing 44 

                                                 // 111
                                            /// 222  Calculating "b" = SLOPE of the line...

             slope =  ((n * SumOfXY)  - (sumOfx * sumOfy)) / ((n * SumOfxSquare) -(sumOfx *                  sumOfx));


                                                /// Calculating "a" = intercept...

                                           xMean = sumOfx / n ;
                                           yMean = sumOfy / n ;
                                           intercept = yMean - (slope * xMean);

                                            /////// Calculating the least Square...

       leastSquare = Math.sqrt(((intercept * SumOfySquare) - (slope * SumOfXY) - (n * (yMean * yMean))) / ( SumOfySquare - (n * (yMean * yMean))));

                                               // if (leastSquare == (double)NaN)

                                               // { leastSquare = 0.00; }
                                            /////// Calculating the pearsons CofC

       pearsonsCofC = (SumOfXY - (n * (xMean * yMean))) / Math.sqrt((SumOfySquare - (n * (yMean * yMean))) * (SumOfxSquare - (n * (xMean * xMean))));


                           ///// *****************working with JFrames & console***************


                          out.println("\n    For the given values of x and y,\n");


                                                   //** Drawing the table**//

                               out.println("       ---------------------------"); 
                    out.printf("       %s %15s", "Values of x" ," Values of y\n");
                               out.println("       ---------------------------");

                           for (int draw = 0; draw < n; draw++)

                               {
                                double xdouble = 0.0;
                                double ydouble = 0.0;

                                xdouble = Double.parseDouble(args[draw]);

                                ydouble = Double.parseDouble(args[draw+n]);

                              out.printf("      %9s %s %7s" , xdouble ,"    |" , ydouble);

                                                     out.println();

                                  }

                                  out.println("       ---------------------------");
                                  out.printf("      %9s%14s" , sumOfx, sumOfy);
                                  out.println();
                                  out.println("       ---------------------------");
            out.printf("\n  %s%.2f %10s%.2f" , "mean of x = " , xMean ,";  mean of y = ", yMean);
                                  out.println();

                                                  //** end of table...**//

                                     //  out.printf("\n  %s " , " ::

      out.printf("\n  %s%.2f%s%.2f%s\n" , "The regression line :: y = ", intercept, " + ",  slope, "(x)");

       out.printf("\n  %s %.2f\n" , "The LeastSquare :: r = ", leastSquare);
       out.printf("\n  %s %.2f \n" , "The Pearsons Coefficient of Correlation :: r = ", pearsonsCofC);

      // JOptionPane.showMessageDialog(null, "The regression line :-  Y = " + (int)intercept +" + "+ //(int)slope +"(x)"+ "\n\nThe LeastSquare :-  r = " +(int)leastSquare + "\n\nThe Pearsons //Coefficient of Correlation :-  r = " + (int)pearsonsCofC);

                                            ///222
                          }}}

Wednesday, November 30, 2016

Learn Git

There 're many platforms online via which you can learn how to use Git.
First, what is Git?

Git is a version control system (VCS) that is used for software development and other version control tasks. As a distributed revision control system it is aimed at speed, data integrity, and support for distributed, non-linear workflows.



Git is a free an open source distributed version control system designed to handle everything from small to very large projects with speed and accuracy.


Click here to download Git. 


Platforms via which you can easily get started with "Learning Git"


  • Code Academy learn Git easily with it friendly interactive user interface
  • Code School learn Git basics in 15 minutes also with  friendly interactive user interface
  • tutorilazine learn Git in 30 minutes

Saturday, January 24, 2015

java.nio.file.FileAlreadyExistsException | java.nio.file.NoSuchFileException

Trying to create multiple directories using the createDirectory() method will throw a NoSuchFileException. Instead use the createDirectories() method. 

Trying to create a directory that already exists will throw a FileAlreadyExistsException. i.e running the same code used to create a single directory more than once on the same path/filename.
See Code Snippet below.

import java.nio.file.Path;
import java.nio.file.Paths;
import java.nio.file.FileSystems;       
import java.nio.file.Files;
import java.io.IOException;
import static java.lang.System.err;

public class OcpPrepare {
    public static void main(String[] args) {
    
     //-----------First Part-----------//
    //trying to create multiple direcotries One, Two and Three
        Path newDir = FileSystems.getDefault().getPath("C:\\Users\\", "One\\Two\\Three");      
        try{
        Files.createDirectory(newDir);
        }
        catch(IOException e){
            err.println(e); //NoSuchFileException Thrown ;; 
        }
//-----------Second Part-----------//
//trying to create a directory that already exist
        Path newDir = FileSystems.getDefault().getPath("C:\\Users\\One");      
        try{
        Files.createDirectory(newDir);
        }
        catch(IOException e){
            err.println(e); //FileAlreadyExistsException Thrown ;; 
        }
    }
}

Comapring 2 Paths Using java.nio.file Class

Using Java.nio.file.Path and Paths class

when comparing 2 paths using the equals() method in java "nio.2", one thing to know 4Sure is that, it does not affect the file System, so, therefore, the compared paths are not required to exist. #Very Funny right? See the below sample code snippet
--------------------------------------
import java.nio.file.Path;
import java.nio.file.Paths;
import static java.lang.System.out;

public class OcpPrepare {


    public static void main(String[] args) {

        
      Path firstPath = Paths.get("c:\\users\\Book1.txt");
      Path secondPath = Paths.get("c:\\users\\Book2.txt");
      
      if (firstPath.equals(secondPath))
      {
          out.println("Same Path");
      }
       else
          {
          out.println("Not Same Path");
          }
    }
}

Monday, October 27, 2014

Visual Basic (VB) is lost in the crowd.

These days 95%, if not 99, of software/web, mobile development job vacancies requires you, a job seeker (ENTRY LEVEL), to know @ least 3 of the below listed packages. Two from software/web development and one from database management.

Software/Web Development Lang(s)
C/C++ 
C#
Asp.net
Java
Php
Python
Ruby
HTML, CSS & JavaScript

Database Management
Ms SQL
My SQL
Oracle

I am just curious as to what is happening to the once popular Visual Basic a.k.a (vb)…. Is it lost in the crowd? Is it outdated? like i said, just curious:::

Thursday, October 23, 2014

An Application Package on Library Management System (LMS) ~~ VisualBasic Code Snippet + GUI Design

Librarian & Member Login

                                                      
                                              Member Management

Source Code Snippet

Wednesday, August 20, 2014

An Application Package on, 3DES, Data Encryption & Decryption ~~ VisualBasic Code Snippet + GUI Design

                                  File Menu { --New  --Open  --Save  --Exit  

                                                                        
 Operation Menu--Encrypt file/Data --Decrypt file/Data


Encrypting Data/File (plain text) Using Encryption Key (9090)
** You 're to use your own key **


            Encrypted Data/File


Decrypting Data/File (cipher text) Using  Key (9090)


Decrypted Data/File


                           Format Menu { --Font  --Fore-Color --BackGround-Color
             

**SOURCE CODE "Snippet" ** 


Imports System.Security.Cryptography

Public Class Index   ' Class Begins

    Sub Encryption()

   Dim plainText As String = txtPlain_Cipher_Text.Text    'InputBox("Enter the plain text:")
   Dim EncryptionKey As String = InputBox("Enter Encryption Key")

        Dim container As New Main(EncryptionKey)
        Dim cipherText As String = container.EncryptData(plainText) 
        txtPlain_Cipher_Text.Text = cipherText 
    End Sub
'==================================================
    Sub Decryption()

        If txtPlain_Cipher_Text.Text = String.Empty Then

            Try

                OpenFileDialog.ShowDialog()
                txtPlain_Cipher_Text.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog.FileName)

            Catch Ooops As IO.FileNotFoundException
                'Do nothing
            End Try

        Else

            Dim DecryptionKey As String = InputBox("Enter Decryption Key:")
            Dim container As New Main(DecryptionKey)

            Try
                Dim plainText As String = container.DecryptData(txtPlain_Cipher_Text.Text)
                txtPlain_Cipher_Text.Text = plainText

            Catch ex As System.Security.Cryptography.CryptographicException
                MsgBox("Invalid Key.", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
            End Try

        End If
    End Sub
 '==================================================
    Private Sub EncryptToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EncryptToolStripMenuItem.Click

        Encryption()

    End Sub
 '==================================================
    Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NewToolStripMenuItem.Click

        txtPlain_Cipher_Text.Text = String.Empty

    End Sub
 '==================================================
    Private Sub SaveToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveToolStripMenuItem.Click

        If txtPlain_Cipher_Text.Text = String.Empty Then
            MsgBox("No text found", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
        Else
            SaveFileDialog.ShowDialog()
            Dim path As String = SaveFileDialog.FileName
            Try
                System.IO.File.WriteAllText(path, txtPlain_Cipher_Text.Text)
            Catch ae As ArgumentException
                MsgBox("File not saved; No file name selected", MsgBoxStyle.Information + MsgBoxStyle.OkOnly)
            End Try
        End If
    End Sub
 '==================================================
    Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenToolStripMenuItem.Click

        Try
            OpenFileDialog.ShowDialog()
            txtPlain_Cipher_Text.Text = My.Computer.FileSystem.ReadAllText(OpenFileDialog.FileName)
        Catch ex As IO.FileNotFoundException ' Exception caught when closing the Dialog box without making any selection
            'do nothing
        End Try
    End Sub
 '==================================================
    Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FontToolStripMenuItem.Click
        FontDialog.ShowDialog()

        txtPlain_Cipher_Text.Font = FontDialog.Font

    End Sub
 '==================================================
    Private Sub ForeColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ForeColorToolStripMenuItem.Click

        ColorDialog.ShowDialog()
        txtPlain_Cipher_Text.ForeColor = ColorDialog.Color

    End Sub
 '==================================================
    Private Sub BackGroundColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackGroundColorToolStripMenuItem.Click

        ColorDialog.ShowDialog()
        txtPlain_Cipher_Text.BackColor = ColorDialog.Color

    End Sub
 '==================================================
   
    Private Sub ExitToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ExitToolStripMenuItem.Click

        Me.Close()

    End Sub
 '==================================================
    Private Sub DecryptToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DecryptToolStripMenuItem.Click

        Decryption()

    End Sub 

End Class  ' Class Ends Here
 '==================================================