Posted by: ahmedashfaque | April 13, 2015

Hiring Java developers

I am hiring 2 Java developers for a USA based outsourced project. Salary will be commensurate with experience and required skills.

Location: India

Position: Permanent

Job description:

  • Must have at least 3 years of experience on J2EE
  • Ability to design applications as well as to write code
  • Understanding of MVC
  • Understanding of complete software development lifecycle
  • Good command of English language

Interested candidates please send your CV at ashfaque.a@gmail.com.

Posted by: ahmedashfaque | April 7, 2015

software design fundamentals 1

Designing a software product is the most challenging aspect about software development activities. When a software product needs to be developed then the first thing to be done is to find out the requirements of users of the software product. Even though requirement management activities are themselves challenging; nevertheless the next step to be done is to find out as to how to create a design which will fulfill all the user requirements. The requirements indicate what a software product will be doing so that needs of end users is fulfilled. However how the needs of end users can be fulfilled is the domain of software design. It is not easy to find out the best way to design a software product.

There are 2 methods which are deployed in designing a software product. The first one is known as mental method.

In mental method, a requirement is analysed to find out the nouns and verbs which are present in the requirement statement. For example, a requirement can state that the system should compare prices of 2 commodities and find out the commodity with the lower price. Here the nouns are ‘system’ and ‘commodities’ and the verbs are ‘compare’ and ‘find out’. We can create classes for the nouns and verbs will form the operations involving these nouns. Since system will be the top level entity in the software design (everything will belong to the system in the software design), we can create a class for commodity.

The next level of designing involves thinking about relationship among classes. For this ‘has a’ and ‘is a’ relationship type is determined. For example a commodity is a member of a commodity group. Similarly a commodity has a price band attached to it. All classes which have ‘is a’ relationship with the other class is a child class of this class. All classes which have ‘has a’ relationship with the other class is parallel to this class. In this step all child classes can be extended from the super classes and all parallel classes can be implemented from a common interface class.

Mental models are good for designing user interfaces. But they are good enough to build business logic which need to be implemented. It is because the business logic can not be implemented using simple hierarchy of classes. Component model is a better choice for implementing business logic.

Posted by: ahmedashfaque | March 23, 2015

Software design principles – abstraction

Software design is all about thinking in terms of software components. If you can build these components then you can build the software product.

When we speak of components, we also think in terms of abstraction. Abstraction is the most powerful tool in building software products. Abstraction is about generalising about many similar things and then making a general design for a master component which after tweaking will result in building all these similar components with least effort. At the same time, code once and reuse everywhere principle ensures minimum software defects entering into the software product.

Let us consider an example. Suppose you need to build a component for purchase orders. Your customer tells you that their purchase order contains many variations. Some purchase orders are meant to be used for purchasing goods from regular vendor. Some other type of purchase orders are used for purchase from irregular vendors. Some other type of purchase orders are used for internal purchases e.g. getting semi finished goods from one plant to another plant. Due to these variations, fields contained on a purchase order are different depending on the type of purchase order.

If you will create diferen components for different types of purchase orders? Most likely you will create a common component which may represent a general purchaase order. Later you can create specific components for each type of purchase order.

the generalization used in creating a general purchase order is an example of abstraction. Using abstraction you can reuse your design and your code. In our example when classes are designed for purchase orders then you can create a super class for the general purchase order and extend it to create sub classes for each type of purchase order.

Posted by: ahmedashfaque | March 11, 2015

Why Java is so popular? Part 10

So far in part 1, part 2, part 3, part 4, part 5, part 6, part 7, part 8 and part 9 we have covered many topics on Java. In this post we will see nested if statement.

If you have a requirement to check 2 conditions for a statement to verify then you can use a nested if statement. Let us see an example:

public class doubleCheck{

public static void main(String args[]){
int x = 40;
int y = 30;

if( x == 40 ){
if( y == 30 ){
System.out.print(“X = 40 and Y = 30″);
}
}
}
}

The system will print “X = 40 and Y = 30″.

Explanation

The system will first check value of x. If value is true then it will proceed to check value of y. If value of y is also true then the system will go to statement to print the values of X and Y. if any of the conditions is false then the system will terminate the program without reaching the print statement. In that case, the print statement can not be reached and so there will be no printing of values.

Nested if statements are complex in nature and so should be avoided.

Posted by: ahmedashfaque | March 10, 2015

Why Java is so popular? Part 9

So far in part 1, part 2, part 3, part 4, part 5, part 6, part 7 and part 8 we have covered many topics on Java. In this post we will see loop control.

Loops are used to continuously check a condition and do some processing in each looping through the code while the condition is true. Once the condition returns false then the control flow of the program code exits the loop and terminates.

Loops are very useful in many business transactions. For example if a customer needs to be given some discount for each purchase of higher value than a cut off value then the customer can be given some cumulative discount. Similar business logic can be executed using loops.

Let us see one example:

public class myLoop{

public static void main(String args[]) {
int x = 20;

while( x < 25 ) {
System.out.print(“value of x : ” + x );
x++;
System.out.print(“\n”);
}
}
}

The system will print out following values:

value of x : 20

value of x : 21

value of x : 22

value of x : 23

value of x : 24

Explanation: When The program is run, the execution will move into the loop for the first time and will print “value of x : 20″ because the current value of x is 20. During processing, the value of x is increased by 1 and so when next time it prints, it will be “value of x : 21″.

 

Posted by: ahmedashfaque | March 8, 2015

Why Java is so popular? Part 8

So far in part 1, part 2, part 3, part 4, part 5, part 6 and part 7 we have covered many topics on Java. In this post we will see arrays.

Arrays are a special variable to hold a list of values. For example if you want to hold price list of goods which are selling at the local grocery shop then you can put the price list in an array. The benefit is that if you want to do a central processing of these values then you can do it without defining further variables for computation. Like if you want to know how many items are there in the list or what is the total value of all items in the list or what is the minimum value in the list then you can simply count the number of items in the list.

Let us see one piece of code.

public class myArray {

public static void main(String[] args) {
double[] groceryList = {1.9, 2.9, 3.4, 3.5};

// Print all the array elements
for (int i = 0; i < groceryList.length; i++) {
System.out.println(groceryList[i] + ” “);
}
// Summing all elements
double total = 0;
for (int i = 0; i < groceryList.length; i++) {
total += groceryList[i];
}
System.out.println(“Total is ” + total);
// Finding the largest element
double max = groceryList[0];
for (int i = 1; i < groceryList.length; i++) {
if (groceryList[i] > max) max = groceryList[i];
}
System.out.println(“Max is ” + max);
}
}

 

Let us analyze the code. We have declared an array groceryArray of length 4. So there are 4 item values stored in the Array 1.9, 2.9, 3.4, 3.5. Using a loop we print all values in the list by iterating each element in the array and printing the element value. In the next operation, we added all values of array elements using a loop and adding each element in each iteration of the loop. The final operation we did was to find out which array element has the highest value. Again we used a loop and iterating through the loop to find out if any element has higher value than value of previous element.

Posted by: ahmedashfaque | March 7, 2015

Why Java is so popular? Part 7

So far in part 1, part 2, part 3, part 4, part 5 and part 6 we have covered many topics on Java. In this post we will see modifiers.

Modifiers are keywords that you add to those definitions to change their meanings. The Java language has a wide variety of modifiers, including the following:

  •     Java Access Modifiers
  •     Non Access Modifiers

To use a modifier, you include its keyword in the definition of a class, method, or variable. The modifier precedes the rest of the statement, as in the following examples:

Modifier for a class:

public class className {
// …
}

If a class is declared as public then this class can be accessed from anywhere in your source code. Suppose the class className is in package my_package then it can be accessed from another package as my_package.className.

Access Control Modifiers:

Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are:

Visible to the package, the default. No modifiers are needed.
Visible to the class only (private).
Visible to the world (public).
Visible to the package and all subclasses (protected).

Non Access Modifiers:
Java provides a number of non-access modifiers to achieve many other functionality.
The static modifier for creating class methods and variables
The final modifier for finalizing the implementations of classes, methods, and variables.
The abstract modifier for creating abstract classes and methods.
The synchronized and volatile modifiers, which are used for threads.

The modifiers make Java a strong programming language. You can set the access level for all entities including classes, methods and variables. This functionality ensures that you have flexibility as well as total control over what programming elements have access at what level.

Posted by: ahmedashfaque | March 5, 2015

why Java is so popular? part 6

Suppose you have a requirement to compare 2 numbers and find out which one of them is the smaller number. How you can do it in Java?

For doing it, we will create a class and create a function which will do the comparison of the 2 numbers.

public class CompareNumber{
   
   public static void main(String[] args) {
      int a = 112;
      int b = 434;
      int c = compareFunction(a, b);
      System.out.println("The smaller number is = " + c);
   }

   /** compare and return the smaller number */
   public static int compareFunction(int x, int y) {
      int min;
      if (x > y)
         min = y;
      else
         min = x;

      return min; 
   }
}

When you run this program, system will compare and find out which number is smaller 
and will print it.

Explanation:
We have created a method compareFunction. This function takes 2 parameters (x and y) 
and compares them and finds out smaller of the 2 numbers.
Next we call this method inside our main method. this method provides values for x and y 
and our compareFunction calculates and finds out the result. This result we print out
in the print statement.

Posted by: ahmedashfaque | March 3, 2015

why java is so popular? part 5

So far we have seen many features of Java programming language in part 1, part 2, part 3, and part 4. Let us continue the discussion in this part.

As we know any computer program is large. Due to large size, complexity of the computer program increases and it becomes difficult to understand the program. To make a computer program simpler, we divide the program into many small methods and link them by calling one method to the other. Since Java is an object oriented language, we use a class as a wrapper to include all variables and methods inside classes. Classes are also a template for creating objects.

Why you need to create objects? Well, objects provide data structure so that you can use them to build all your logic. Once you have objects then you can then define their relationships.

Let us understand as to what classes (and corresponding objects) you need to create for your computer program. Suppose you have to create a website application for managing inventory in your warehouse. You will need to think about structure of the warehouse, kinds of inventory to be handled, kinds of inventory management to be deployed etc. Typical transactions in a warehouse include facility to receive inventory, moving inventory inside the warehouse (put away transactions), storing inventory in the warehouse, moving inventory outside the warehouse for dispatch (against sales orders or transfer orders) etc.

The master data in a warehouse include warehouse number, bin number, storage type, material number, customer etc. The transaction data may include material quantity, purchase order number, transfer order number, sales order number, date, time etc.

Once you figure out data and entities then you can model your application. The entities will be our classes (which will be objects in runtime) and our data will be contained inside these classes. In our warehouse management system, we can create classes for warehouse, bins, inventory, purchase order, sales order etc. We can then find out relationship between objects which will be interacting with each other in runtime.

 

Posted by: ahmedashfaque | February 18, 2015

Why Java is so popular? part 4

We have been discussing about reasons for popularity of Java programming language over part 1, part 2 and part 3. We will continue this discussion today.

Let us see a small piece of Java code.

private void cal_salary () {

int sal = 2500;

int month = 2;

int total_sal = sal*month;

system.out.println(“total salary for 2 months is:” + total_sal)

}

If you run this piece of code then you will get output as “total salary for 2 months is 5000″. Now let us see some declarations and constructions of the source code.

When we declared private void method name (); we are stating that this method is a private method and it is not returning any value. The word “private” is a modifier and it denotes accessibility of a method. A method can be accessible from within a class or from outside from another class.

A modifier for a method or a variable is very important for Java programming. This in fact goes into designing your program. If you want a method to be used for a calculation and this type of calculation is not used anywhere in your program then you will declare it as private.

However it is possible that this kind of computation is needed at many other places. In that case you will declare it as “public”. In that case it can be accessed from anywhere in your code. For example suppose you have put this method inside a class named “my_class” and you have declared your method as public then you can access this method from within another class.

public void cal_salary (){

}

So our method is public now. Now if I am in class “any_class” and want to access this method then I will use my_class.cal_salary().

The referencing mechanism of pieces of code in Java is so good that you can reuse your code, over and over. Code reuse is a powerful concept. There are 2 benefits of code reuse. First, you do not need to write pieces of code many times if they are supposed to do same kind of computation. The second benefit is that chances of error in code is minimized as the more code you write, the more chances of error in code. So less is better.

There are some more benefits of code reuse. Your debugging time will be lot less as you will be debugging your code only once instead of doing it many times for all the duplicated code at many places. Maintaining your code will be easier because if any change has to be done then it will be done in just one place instead of making changes all over the many pieces of code scattered over your entire code base.

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.

Join 99,634 other followers