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.

Posted by: ahmedashfaque | February 17, 2015

Why Java is so popular? part 3

In the part 1 and then part 2 of this series we discussed some reasons for popularity of Java programming language. In this part we will discuss about fault tolerance aspect of Java.

All programming languages have variable data types. Each data type is used for doing a different kind of computation. For example, an integer type variable is used to hold integer values for computations. Similarly a character type is used for doing computations where strings and characters are involved in any computation. E.g. if we want to hold user names in a textbox at a user interface then string data type will be used.

Java is a strongly typed programming language. What it means is that when you program using Java then the compiler will not allow you to assign a value to a variable if it is not defined. The compiler will also not allow you to hold a data in a variable of a different data type.

For a new comer it may pose some problems. For example, a new comer may not know subtle differences between different data types  and thus may find it difficult to compile his/her code because of some minor error in his/her program. But this apparent shortcoming is a disguise in blessing.

What happens is that if your programming language is strongly typed then your source code is immune to faulty performance when it runs. Since all errors are already restricted through data type checking of variables in programming language itself, your code will be highly fault tolerant. For example if you have defined a text field on your user screen as an integer but the user enters some values different than an integer (character or date or float for example) then the system will raise an error and will not accept the entered data. This will save you a lot of heartache. Your program will allow only the right values to be accepted and saved to the database. On the other hand if typing checking is not handled then even garbage values will be accepted and saved in the database.

You can see the immense value of fault tolerance in a programming language. Java definitely scores very highly in this area.

Posted by: ahmedashfaque | February 16, 2015

Most popular book on Java Programming

Yesterday my book “Learn Java Programming the easy way” was a free download in Kindle. Some 2000 people downloaded my book and thus created a record. It became the most popular book on Kindle store. I thank everybody for making my book a success.

It is the most satisfying moment for an author to know that his books are so popular.

Posted by: ahmedashfaque | February 14, 2015

Why Java is so popular? Part 2

In the first part of this series we have seen it is the “develop once and run everywhere” concept that catapulted Java into the mainstream of software development paradigm. Let us see how Java infrastructure helps in developing software applications in this post.

Java was always a free for use software language as against proprietary nature of other languages like those from Microsoft. Even though it was developed by Sun Microsystems Inc. but they always kept its core and its associated functionality open. Thus a large number of developers contributed in developing many facets of Java. This has resulted in huge Java libraries built for developing different kinds of software products. For networking these developers built sockets libraries so that applications developed in Java could get networking support so that the application can be easily integrated with software applications developed using other technologies. Similarly an an existing software application built using Java can be networked with any software application being developed using any other technology. For web based application development, libraries have been built into Java language so that developers can handle HTTP requests and responses without any problems. The built in Java libraries are also good for building controller and listener components so that Model View Controller concepts can be implemented easily.

On the development environment side organizations like Net Beans and Eclipse developed Integrated Development Environments (IDE) for Java. These IDEs are very rich and support developing even very large software applications.

The movement around Java has been tremendous. You get everything for free to develop sophisticated software applications using Java. Such kind of infrastructure is simply not available for any other programming language.

Posted by: ahmedashfaque | February 13, 2015

Download a chapter from my book on Java Programming

Today my book “Learn Java Programming the easy way” has been published. You can download a chapter from this book here.

Currently I am writing a book on Software Engineering for University students. I have done lot of research in writing this book. I got feedback from hundreds of professors from USA and Indian universities. I have taken all this input in writing my book.

The same research has gone into writing my Java programming book. It is extremely valuable because of incorporation of all the research.

Posted by: ahmedashfaque | February 13, 2015

Do you need a 600 page book to learn Java?

Today my book “Learn Java Programming the easy way” has been published (Kindle edition). This book is sized 99 pages. If people can learn Java programming in 99 pages?

Java is a rich programming language. Extensive libraries have been written in Java which take care of all infrastructure requirements to create software products with ease. Programmers do not have to worry about the operating system, memory management etc. Programmers can also develop software products using databases, networking etc. without thinking about how to manage them. It is because the libraries available with Java takes care of these management tasks. Programmers only have to import these libraries within their source code.

Large programming books describe and document how these features can be used in Java for programming. But if you want to learn Java then you do not need to think about these large documentation and their explanation (you can always learn about them after you have good grasp of the Java language). Because of these explanations, a programming books becomes large. Otherwise the main concepts of programming including variables, methods, classes, objects etc. do not need to be explained in more than 100 pages.

What i have done is that I explained the concepts of programming in detail with examples. You can learn these concepts in my book. Once your basic concepts are clear then you can do any kind of programming. The most important aspect is that your concepts should be clear.

This book provides not only programming concepts but also covers software design aspects. For example, if you want to design a web based software product then what kind of classes you need to create. Both database programming and web based programming are covered in my book. But still the most important point about this book is that it covers conceptual concepts which are not covered by any book on Java programming. For example I have explained about objects which is not covered by any other book. (In most books on Java programming, objects are wrongly explained).

Smaller size of the book will help you to grasp concepts clearly and quickly. You do not have to spend a lot of time going through some 600 pages to grasp programming concepts.

I am sure this book will be extremely useful to you. Enjoy reading my book!

Posted by: ahmedashfaque | February 13, 2015

Why Java is so popular? part 1

Way back in 2001 when I visited India, I was surprised to see most software service vendors were developing software products for their customers using Java. At that point in time, most USA software developers were using Microsoft Visual Basic or Visual Plus. I wondered why Java is being used in India and how it has become so popular?

At that point of time Java indeed was being discussed as the hot new thing in town. But emergence of a new technology is one thing and adoption of the technology is something different. It takes time before any new technology is adopted. In 2001 I thought Java is a new emerging technology. No doubt it was hot. But never thought it could be adopted so quickly.

So what is so special about Java? Well, Java is the leading object oriented programming language. Way back in 2001, it was still in its infancy though it provided some magical solutions to software developers. One benefit at that time in 2001 was that people were talking about was develop once and run everywhere. What it means is that most programming languages use operating system infrastructure on which to build software products. So you end up writing many versions of your software product which run on different operating systems. This is a big disadvantage as it translates to excessive extra time and money required to build all those different versions of your software product for different platforms.

Java was the first language which promised platform independence. You write just one version of your software product and it will run on all platforms.

I will continue this discussion in my next post.

Here is another book review for my book “Software Project Management: A Process Driven Approach”

Dear Ashfaque Ahmed

Your book is excellent for students and programmers for doing projects.

This book I have gone through every page . I feel it is a fine and good book for software project management.

With regards

RAMESH BABU G.V,

ASSISTANT PROFESSOR & PLACEMENT OFFICER,

Dept. of Computer Science,

SVU COLLEGE OF CM&CS,

SRI VENKATESWARA UNIVERSITY, India

Posted by: ahmedashfaque | February 10, 2015

Object relational databases – what are they?

Relational databases have been around for last 50 years. They are the backbone on which all applications including websites run. They can hold enormous data and still work fine. They have been time tested and proven. This is why everybody rely on them.

Now what are object relational databases? Well they the new breed which extend the relational databases. Off course the relational part still exists. They way data is written and manipulated and stored is the same old technology of all relational databases. Then what is the new addition?

It is from the programming side. It has been a long cherished dream of software developers to create structure in their software program which will be the same as that residing on the database. Suppose you have a database with 2 tables sales and customer. In sales table you have columns sales ID, sales date, amount, customer ID. In customer table you have customer ID, and other customer information.

When you write source code to insert, delete or update or view data in the database table then you create objects in object oriented programming. Each object can have its own structure. Suppose you have created a class sales. This class has fields as sales ID, sates date, amount, customer ID. Similarly you have created a class customer with fields similar to what you have in table customer.

Now when you create objects from these classes then they will have same structure as database tables. You can now write data processing logic using these objects. It will be much easier for you to write your code because your objects have the same structure as database structure. This is the idea.

In object relational databases, programming side is linked to database. When you create your database design then you can use this design to create your classes automatically. Or you can create your classes and then from there you can create your database automatically. This means you do not have to create 2 designs: one for database and another for programming. this is the whole idea.

Microsoft, Oracle and other vendors are working on this technology. Currently this technology is immature but will mature in next few years for sure.

Posted by: ahmedashfaque | February 3, 2015

Solution for the programming puzzle

I had provided a programming puzzle and asked you the solution for the same. Today let me give you the solution as well as explanation.

The computer program will print 10 on your computer screen. Many of you people may have expected 9 as the solution but this is wrong.

What we did was to assign e1 to e2. If you do not know then let me state that assigning an object is different from that for variables in computer programming.

Suppose we had 2 variables a and b. Let us do some assignments for them.

a = 4;

b = a;

Now the values will be a= 4 as well as b = 4.

Now if I do

b = b + 1

And add a + b then we will get 9 (a  =4, b = 5)

But when I do this operation with objects then things are different. When I did e2 = e1 then effectively I told the compiler that even though e1 and e2 are 2 entities but they point to same memory. When I did e2 = e2 + 1 then I made e = 5. But since e1 is also now pointing to this same memory so e1 = 5. Thus e1+e2 = 10.

this is funny but objects behave this way.

I hope you now understand difference between assignment of objects and that for variables.

Older Posts »

Categories

Follow

Get every new post delivered to your Inbox.

Join 89,268 other followers