Friday, 27 July 2012

Generate Auto Id


Logic to generate unique id -

Create a table in the database named tbl_id and set the fields (the number of unique id’s to be generated. For Example – In Computer rental system, there is a need to generate id for both the customer and the Computer. So, two fields one for the customer and second for the computer must be set / defined. One thing to make sure is that the data type of fields must be Number)

Set the default value to 1000. (Depending on the requirement if the user wants that the id must start from 1 set the default values to 1)

On the form or the web page where unique need to be generated a select query need to be written in which the field value from the table tbl_id need to be selected. For Example – In case of customer id, select the customer_id field value from the table tbl_id by writing a query like this – SELECT customer_id from tbl_id.

Store the result obtained from this query in a variable of type integer. Now if the user wants that the id must be in a suitable format such as CS – 1000, or CUS – 1000 or whatever the format is just concatenating the prefix required with this variable. (make sure that concatenation does not change the value of the variable.

On the click of the save button or key depending on the programming language or the way the action is being performed update the value of the variable by adding 1 to it and update this variable value again in the tbl_id customer_id field.

Wednesday, 25 July 2012

Computer Rental System in Visual Basic.NET



Introduction to Java

This post has been created to present a quick overview of Java, what exactly are the features Java and writing your first Hello World Program in Java (compiling it and executing it).

Genesis of Java Language


C and C++ are the programming languages that provides a basis for Java. Java derives its syntax from C and object oriented features from C++. Later in this chapter we will discuss the reasons and the section of events that lead to the creation of Java. 

Programming Language innovation occurs to solve a fundamental problem that the preceding languages were not able to solve and java is no different.  

C Programming Evolution -


In early 1970's there was a need of a structured programming language that could replace the assembly code when creating system programs.This lead to the creation of C that shocked the programming world. Even today its power cannot be underestimated. Operating Systems like LINUX, UNIX are coded in C. Various factors need to be considered before using a programming language such as -
  • Ease of Use vs. Power
  • Safety vs. Efficiency
  • Rigidity vs. Extensibility
Before C Language, options available to programmers were FORTRAN, BASIC, COBOL, ASSEMBLY LANGUAGE. While one was easy to make scientific applications but not system programs, other was easy to learn but not powerful. They were not even structured to. GOTO was the primary means of program control (resulting in a lot of spaghetti code). While language like PASCAL was structured they were not designed for efficiency, PASCAL was not considered for systems-level code.



Sunday, 22 July 2012

Constructor/Method outside the class

Defining a constructor/method outside the class - 

      For defining a constructor or method outside the class four things should be kept in mind - 
    1. Return Type
    2. Class Name
    3. Scope Resolution Operator
    4. Constructor/Method name

Note - Constructors/Destructors don't have a return type, so while defining constructors/destructors outside the class return type is not specified.

Syntax - (return type) (class name)(scope resolution operator)(constructor/method name)

For Example - Consider the definition of class student that a constructor, method and destructor.

class student
{
    private : 
              int id ;
    public :
              student ( );
              void add_student ( );
              ~student ( );
}


Implementing constructor student ( ) outside the class -
student : : student ( )
{
}


Implementing method add_student ( ) outside the class - 
void student : : student ( )
{
}


Implementing destructor student ( ) outside the class - 
student : : ~student ( )
{
}