Saturday, December 10, 2016

Road to Disruption

Road to Disruption
Someone has rightly said, time changes faster than it seems. Same concept is evident in how businesses, industries has been changing. Decade after decade the speed of change in businesses is increasing at an amazing rate. You remember how traditional businesses shifted from pen & paper based business management in 1970’s to SAP era of business management now. How computer gave birth to information technology which resulted in reduced effort, lower cost, lesser time to market for products/ services.

Disruption is shining anyway. Can’t say if it’s dawn of disruption but for sure it is not the end. New age thinker are changing the way industry runs, business are done, services are delivered. Take a look at some of disruptors. Uber has changed the way people book taxies. You need not to be a radio taxi company to provide taxi service, a mobile app based technology company also can. Now booking taxi is just a click away & in 5 minute one can avail sedan ride at lowest price. Paytm has shown, not only banks but an IT company can also do banking. How easily one can pay for any item they buy be it home grocery, food, jewelry anywhere with just one image scan. These companies are today valued at multibillion USD in a short span of 2-5 years. Traditional companies takes ages to become a billion dollar company.

What is Disruption?
A question keep striking in peoples mind who these disruptors are & how to become one of them. To answer this question first we need to understand the “Disruption”.  Disruption is something which changes the way existing market, technology, product, service, system works. It finds simple way of doing the same thing with minimal cost, effort, and infrastructure & altogether a new experience to customers like Uber, Paytm, Airbnb did.

Who is a Disruptor?
One who finds simple approach to solve existing problem, process or identifies hidden opportunity & successfully implements it.
To simplify disruption, it is a customer focused idea implemented successfully which has changed the way existing system works.

How to become one of the Disruptor?
Becoming disruptor is not a one day story nor it is impossible to become. Disruptor thinking is an approach which comes with practice in day to day routine. I am sharing some of common traits of disruptors, rest experience is the best teacher.
First they decide what they want to disrupt, a product/ service/ industry or what?
They study a lot on existing industry, trends about what they want to disrupt.
They think with end user in mind like current days design thinking.
They do experiment with ideas & learn from them either they succeed or fail.
They build on ideas which has least dependency on infrastructure/ capital
Lastly, they lead the idea implementation

Practicing disruptor’s traits in day to day routine will develop disruptor like thinking approach. Don’t forget having a good idea is not disruption. It is Ideas successful execution which will lead to disruption. 

Note: This is not my own article but shared and written by Parshant Tanwar (my friend, a wikipedia of thoughts). Thanks to him for sharing his thoughts with me also given me privilege to publish this to open world.

Friday, December 9, 2016

Create bulk data in database table using SQL

I had a requirement to create a very heavy size database to test some sampling technique. I have created a table in database called "NewEmployee" and written set of Insert statement with dummy data using SQL script. The script is given here:

declare @id int
select @id = 1
while @id >=1 and @id <= 100000
begin
Insert Into NewEmployee Values (17, '18'+ convert(varchar(5), @id), NULL, 14, 'Don' + convert(varchar(5), @id), 'Boscow'+ convert(varchar(5), @id), '2000-07-31', '1976-05-15', 'adventure-works\don'+ convert(varchar(5), @id), 'don'+ convert(varchar(5), @id)+'@dummydata.com', '320-555-0195', 'M', 'Don Boscow'+ convert(varchar(5), @id), '320-555-0195', 0, 'M', 1, 'Production', '2000-07-31', NULL, 'Current');

    select @id = @id + 1
end

Thursday, December 8, 2016

Create new database table from existing one

Create new database table from existing one

For example you want to create a duplicate table called "NewEmployees" of an existing table called "Employees". Use the following script:

--syntax--
CREATE TABLE newTable
AS 
(SELECT * FROM oldTable);
 
example script:
CREATE TABLE NewEmployees
AS
(SELECT * FROM Employees)
 
Note: you may specify exact fields names instead of *. Here * denotes to all fields.

There are chances to get an error in SELECT statement if you have any primary key 
auto incremental field in the existing table. In such situation you may go for
another script (given here under)

--syntax--
SELECT * INTO newTable
FROM oldTable 
 
example script: 
SELECT * INTO NewEmployees
FROM Employees



Sunday, October 9, 2016

Java Packages

Java Packages
An article by Prof. Seema Maitrey



Java – Package
Introduction

A package is a collection of related classes. It helps to organize our classes into a folder structure and make it easy to locate and use them. More importantly, it helps improve re-usability.
Each package in Java has its unique name and organizes its classes and interfaces into a separate namespace, or name group.
Although interfaces and classes with the same name cannot appear in the same package, they can appear in different packages.
·         A Java package is a mechanism for organizing Java classes.
·         Package are used in Java, in-order to avoid name conflicts and to control access of class, interface and enumeration etc.
·         It can be defined as a group of similar types of classes, interface, enumeration and sub-packages.
·         Using package it becomes easier to locate the related classes.
·         We can define package using keyword- package.
Creating a Package:-
i.                    include a package command follow by name of package as a first statement of java source file.
ii.                  There can be only one package statement in each source file.
 If package statement not used in source file than it takes default package for all classes, interfaces and enumeration.
 Example:

package MyPackage;
public class Test{
    public static void main(String args[]){
      System.out.println(“Testing package”);
    }
}

 To run this program:
 - Create MyPackage folder in your currently development working directory.
- Compile the source file.
- Put the class file into the directory you have created.
- Execute the program from development directory.

 

Uses of java package

·         Package is a way to organize files in Java.
·         It is used when project consist multiple modules.
·         Package’s access level allows to protect data from being used by the non-authorized classes.
 import keyword:
·         import keyword is used to import built-in and user defined packages into the java source files.  
·         If a class wants to use another class in the same package, the package name does not need to be used.
·         Classes in to the same package use without any import statement.
·         Import statement is kept after package statement.
package MyPackage;
import  java.util.Date;

There are three ways to refer that is present in different package.
1) Using fully qualified name
Example :  class Test extends java.util.Date
 {
   <>  
}
 2) import the class you want to use :
Example:  import java.util.Date;

               class Test extends Date
               {
                <>
               }
 3) import all the classes from the particular package:
Example:
import java.util.*;

class Test extends Date{
  <>
}
Classification of package

Package are categorized into two forms

1.       Built-in Package:-Existing Java package for example java.lang, java.util etc.
  1. User-defined-package:- Java package created by user to categorized classes and interface

Let's see this with an example. We define a class and object and later compile this it in our package p1. After compilation, we execute the code as a java package.
Step 1) Consider the following code,
package p1;         1)
class c1() {          2)
public void m1() 3)
{
System.out.println(“ m1 of c1”);
}
public static void main(String args[])    4)
{ c1 obj=new c1();                                 5)
obj.m1();                                                 6)
}
Here,
1.       To put a class into a package, at the first line of code define package p1
2.       Create a class c1
3.       Defining a method m1 which prints a line.
4.       Defining main method
5.       Creating an object of class c1
6.       Calling method m1
Step 2) In next step, save this file as demo.java

Step 3) In this step, we compile the file.





The compilation is completed. A class file c1 is created. However, no package is created? Let's do that in next step


Step 4) Now we have to create a package, use the command
javac –d . demo.java
This command forces the compiler to create a package.
The "." operator represents the current working directory.
When you execute the code, it creates a package p1. When you open the java package p1 inside you will see c1.class file.
Step 7) Compile the same file using the following code
javac –d .. demo.java
·         Here ".." indicates the parent directory. In our case file will be saved in parent directory which is C Drive(java_prac).

File saved in parent directory when above code is executed.

Step 8) Now let's say you want to create a sub package p2 within our existing java package p1. Then we will modify our code as
package p1.p2
class c1 {
public void m1() {
System.out.println(“m1 of c1”);
}
public static void main(String args[])   
{
c1 obj=new c1();                                  
obj.m1();                                               
}


Step 9) Compile the file
As seen in below screenshot, it creates a sub-package p2 having class c1 inside the package.

Step 10) To execute the code mention the fully qualified name of the class i.e. the package name followed by the sub-package name followed by the class name -
java p1.p2.c1

This is how the package is executed and gives the output as "m1 of c1" from the code file.
Using packages created in earlier assignment (To import package)
Step 1) Copy the code into an editor.
// Using packages created in earlier assignment
package p3;
import p1.*; //imports classes only in package p1 and NOT  in the sub-package p2
class c3{
  public   void m3(){
     System.out.println("Method m3 of Class c3");
  }
  public static void main(String args[]){
    c1 obj1 = new c1();
    obj1.m1();
    p1.p2.c2 obj2 = new p1.p2.c2();
    obj2.m2();
  }
}
 
Step 2) Save the file as Demo2.java . Compile the file using the command javac –d .Demo2.java
Step3) Execute the code using the command java p3.c3
Order of Package Statement
Program coding wise is very simple but is important to know the steps of package creation. While creating User Defined Packages in Java, the order of statements is very important. The order must be like this, else, compilation error.
1.      Package statement
2.      Import statement
3.      Class declaration
If exists, the package statement must be first one in the program. If exists, the import statement must be the second one. Our class declaration is the third. Any order changes, it is a compilation error.

Happy coding!!