Thursday, December 30, 2010
Tuesday, December 7, 2010
Tuesday, October 19, 2010
Monday, October 11, 2010
Monday, September 27, 2010
Monday, September 6, 2010
The Tao of Polymorphism
"In object-oriented programming (OOP), Inheritance is a way to compartmentalize and reuse code by creating collections of attributes and behaviors called objects which can be based on previously created objects." - Wikipedia
I dont know why everyone tend to use most difficult and hardest terms even for simple concepts. As for example above definition refers to Inheritance. We are not here to discuss Inheritance, but the advantages of Inheritance.
Labels:
Java,
Something More
Wednesday, September 1, 2010
BlogDay 2010
I am pretty sure that the above title is unfamiliar to you. Even I came to know about it today - actually a day late.
I can explain this but someone out there has done that in very simple manner.
Below paras are copy from the same.
So get your hands rubbing, Here are my recommendations,
OMG! Ubuntu!
The blog is purely dedicated to Ubuntu. So if you are into Ubuntu there is no blog better than this.
Strength: Total coverage. Nothing in Ubuntu-sphere is left out. Awesome language.
Weakness: Many posts a day. Time demanding
Lolland - The Indian Humour Site
Magnetic Infinity
The blog is about personal experiences of a student .. rather different and special one. What keeps me attached is the language used. It seems blog is dormant for quite sometime but hoping for author to keep up.
http://magneticinfinity.blogspot.com/
Vandit's Blog
Author is experienced computer engineering student and has shared his experiences.
http://www.iamvandit.co.cc/
ART of Friendship
Its the most active blog than above two. Blog is all about experiences of Electrical student.
http://koolrups-thosedays.blogspot.com/
SIDD Speaks
The most awesome blog I have ever seen. Author is well knowledgeable and knows how to explain with bit of humour. The blog is even most active blog.
http://www.sagarsiddhpura.blogspot.com/
Now thats called an ending.
I can explain this but someone out there has done that in very simple manner.
Below paras are copy from the same.
What is BlogDay?
BlogDay was created with the belief that bloggers should have one day dedicated to getting to know other bloggers from other countries and areas of interest. On that day Bloggers will recommend other blogs to their blog visitors.
With the goal in mind, on this day every blogger will post a recommendation of 5 new blogs. This way, all blog readers will find themselves leaping around and discovering new, previously unknown blogs.
With the goal in mind, on this day every blogger will post a recommendation of 5 new blogs. This way, all blog readers will find themselves leaping around and discovering new, previously unknown blogs.
What will happen on BlogDay?
one long moment on August 31st, bloggers from all over the world will post recommendations of 5 new Blogs, preferably Blogs that are different from their own culture, point of view and attitude. On this day, blog readers will find themselves leaping around and discovering new, unknown Blogs, celebrating the discovery of new people and new bloggers.
So get your hands rubbing, Here are my recommendations,
OMG! Ubuntu!
The blog is purely dedicated to Ubuntu. So if you are into Ubuntu there is no blog better than this.
Strength: Total coverage. Nothing in Ubuntu-sphere is left out. Awesome language.
Weakness: Many posts a day. Time demanding
Lolland - The Indian Humour Site
Its the most hilarious site i have seen. The author really has the skill of picking out Local anecdotes and deliver it in most amusive and refreshing way.
Amitbhavani's blog
The blog is an normal technical blog but FAQ's and How-To's posts out-stands this blog.
This blog is work of Harshal Pushkarna - Excellent professional writer. Author is also the writer for famous magazine "Safari". Blog is in gujarati language and very impressive.
As on this special post, I cannot end without my colleagues blogs.
The blog is about personal experiences of a student .. rather different and special one. What keeps me attached is the language used. It seems blog is dormant for quite sometime but hoping for author to keep up.
http://magneticinfinity.blogspot.com/
Vandit's Blog
Author is experienced computer engineering student and has shared his experiences.
http://www.iamvandit.co.cc/
ART of Friendship
Its the most active blog than above two. Blog is all about experiences of Electrical student.
http://koolrups-thosedays.blogspot.com/
SIDD Speaks
The most awesome blog I have ever seen. Author is well knowledgeable and knows how to explain with bit of humour. The blog is even most active blog.
http://www.sagarsiddhpura.blogspot.com/
Now thats called an ending.
Labels:
Something More
Saturday, August 28, 2010
Inheritance implementation in Java
"Understanding a concept does not mean merely remembering the definition, it includes knowing the working or application of that concept." - Come closer to the screen, look at above sentence and try to understand (its the definition of understand) it. I know its recursive but I will clarify it with the example of Inheritance:
Assume your instructor has chosen you for questioning, and he demands: "Explain Inheritance?". You somehow manage to utter some words "reuse", "code", "hierarchical relationship" and get the clean cheat. You get seated and wipe-off the perspiration.
If this scenario is common then you are a victim. You merely know the definition or have faint idea but do you know at what stage is inheritance comes in to the picture? Apart from by-hearting the definition, it is equally important to know how a concept is implemented. Lets have a look @ how Inheritance is implemented in Java. Beginning with process of compilation,
Assume class "Child" is child of class "Parent". We define both classes as follows:
class Parent class Child extends Parent
{ {
int a; int b;
} }
Now going by definition, we know that sub class inherits all the members of parent class, hence "Child" class should have two members conceptually:
int a;
int b;
And to verify it we create an object and try to access member a, and it works.
child ob = new Child();
ob.a = 10;
Weighing both sides,
This gap is filled at compilation level and Java handles Inheritance at compile time. Thus,
Compilation includes defining structure of each class. The moment javac senses one class to be child of another, it adds all members of super class to structure of child. Thus the class layout after compilation would be...
class Parent class Child
{ {
int a; int a;
} int b;
}
Getting This? YES or NO??? Ok, Repeating once more,
Inheritance (sub-class has all the members of super-class) is detected at compile time. If any class is found to be "child" of super-class, all members of super-class is added to structure of child-class. Finally all layouts is written to .class file and thus saved.
Now that's called Understanding Inheritance. I know you will let me know what have you inherited from this post via comments.
Assume your instructor has chosen you for questioning, and he demands: "Explain Inheritance?". You somehow manage to utter some words "reuse", "code", "hierarchical relationship" and get the clean cheat. You get seated and wipe-off the perspiration.
If this scenario is common then you are a victim. You merely know the definition or have faint idea but do you know at what stage is inheritance comes in to the picture? Apart from by-hearting the definition, it is equally important to know how a concept is implemented. Lets have a look @ how Inheritance is implemented in Java. Beginning with process of compilation,
Assume class "Child" is child of class "Parent". We define both classes as follows:
class Parent class Child extends Parent
{ {
int a; int b;
} }
Now going by definition, we know that sub class inherits all the members of parent class, hence "Child" class should have two members conceptually:
int a;
int b;
And to verify it we create an object and try to access member a, and it works.
child ob = new Child();
ob.a = 10;
Weighing both sides,
- At code level there is no member 'int b' in child class
- At execution level Child class has the member 'int b'.
This gap is filled at compilation level and Java handles Inheritance at compile time. Thus,
Compilation includes defining structure of each class. The moment javac senses one class to be child of another, it adds all members of super class to structure of child. Thus the class layout after compilation would be...
class Parent class Child
{ {
int a; int a;
} int b;
}
Getting This? YES or NO??? Ok, Repeating once more,
Inheritance (sub-class has all the members of super-class) is detected at compile time. If any class is found to be "child" of super-class, all members of super-class is added to structure of child-class. Finally all layouts is written to .class file and thus saved.
Now that's called Understanding Inheritance. I know you will let me know what have you inherited from this post via comments.
Labels:
Java,
Something More
Thursday, August 19, 2010
Sign Extension in Java
Sign extension is a rule in Java by which widening conversion is carried out. While we are on the mood to know something, Let us see the whole process by an Example.
Labels:
Java,
sign extend,
sign extension,
Something More,
widening conversion
Wednesday, August 18, 2010
Combating one of the most common Programming Mistake
Lets begin with question.
Do you know the most common programming mistake? Try to recollect the times when you used to compile your baby size programs and print Hello World.
Didn't get it? Its omittance of semicolon at the end;
The Solution:
What I am about to share is solution to just another big common mistake, staking programmers scared sleeps.
The scenario:
After hapless efforts, tonnes of Page Dn and Page Up, when your eyes swell of digging screen and at last you encounter the villain: "if(x=0)". You take a deep breath and after adding the required '=' the program finally complies.
The Solution:
In order to avoid this just use a simple rule: always put conditions with constants on left: "if(0==x)". It might look bit odd but has the 'miracle' thing. It will always generate error if you put single '='. Here's how,
Lets assume you forget to put the second '=' (No way if you have read this post) and you try to compile, it would throw an error because "if(0=x)" is illegal in language - you cannot assign variable to constant.
Hence always keep these practices:
- Use (0==x) in conditions
- Read this blog everyday before brushing
That said will save you real time.
Labels:
Programming,
Something More
Monday, August 9, 2010
How to create 'Special' folder.
Want to create a folder that can never be
- Created(By others)
- deleted(By others)
- Renamed
- Moved
- Copied
Read on…….
Labels:
Something More,
Tricks
"Tab Candy" - New feature in Firefox 4
Without a doubt “Web browser” is most speedy developing software ever. New features are being added everyday and one such feature is “Tab Candy” introduced in upcoming version of popular browser Firefox 4. Before exploring the subject let us know what scenario lead to its necessity.
We often find ourselves reading articles, Checking emails, Social Networking, Downloading etc. all in several tabs open in one browser window. Its fine up-to 8 to 10 tabs but when it gets more, the problem arises. To tackle this situation “Tab Candy” was proposed.
Tab Candy is basically tab grouping. You put Email tabs into one bunch, Facebook-Orkut-what-not into second, News–Reader into third and so on. Make them as you wish.
To see it in action is even more fascinating, just press Tab candy button and you zoom out with thumbnails of all tabs. Pick similar tabs and drag them outside boundary to form another group.
Click on any tab to zoom in and viola! Only tabs from that group are shown. Feel like someone is buzzing you, zoom out and select Social-Networking group, only tabs in that group will be shown.
Thus it is very much similar to Desktop-switching concept used in Linux where many windows are open at a time but they can grouped and one group shown at a time. This certainly keeps us on track without irrelevant things.
Whats more, you can setup a layout with groups at predefined position and thus resulting into something like this
The future?
Tab Candy project is further developed to enable tab-group sharing, so that I Click-Click-Click at home, reach the office, Click-Click-Click and session is restored. Search feature is also being added to interface.
See it in motion @ http://bit.ly/9d3xFi
Working with 100+ tabs easily-effectively-efficiently(read that again) is the “Whats next” of browser.
Tab Candy is basically tab grouping. You put Email tabs into one bunch, Facebook-Orkut-what-not into second, News–Reader into third and so on. Make them as you wish.
To see it in action is even more fascinating, just press Tab candy button and you zoom out with thumbnails of all tabs. Pick similar tabs and drag them outside boundary to form another group.
Click on any tab to zoom in and viola! Only tabs from that group are shown. Feel like someone is buzzing you, zoom out and select Social-Networking group, only tabs in that group will be shown.
Thus it is very much similar to Desktop-switching concept used in Linux where many windows are open at a time but they can grouped and one group shown at a time. This certainly keeps us on track without irrelevant things.
Whats more, you can setup a layout with groups at predefined position and thus resulting into something like this
The future?
Tab Candy project is further developed to enable tab-group sharing, so that I Click-Click-Click at home, reach the office, Click-Click-Click and session is restored. Search feature is also being added to interface.
See it in motion @ http://bit.ly/9d3xFi
Working with 100+ tabs easily-effectively-efficiently(read that again) is the “Whats next” of browser.
Thursday, July 22, 2010
Batch scripts in action - Java LAB
As I mentioned in earlier blog the batch scripts are very helpful. Below is another incident when Command-prompt-programming comes to rescue.
Java newbies know the usual procedure to compile and run Java program
- Open Notepad
- Write program(Optional) and save it as something.java
- Open CMD
- Run following command "set path=c:\program Files\Java\jdk1.6.0\bin"
- Navigate to your folder having something.java
- Run command "javac something.java"
- Run command "java something"
Thats a lot of procedure. Lets put Batch to help.
One more thing. I got to make folder "Lab_DATE" every lab and do respective practicals in them. Hence I created "start.bat" with following obvious commands.
mkdir Lab_
cd Lab_
cmd notepad
set path=C:\Program Files\Java\jdk1.6.0\bin
But it had a problem. The CMD window closed after executing last command. I needed it live after changing the path. Try it and you will know.
Help was the first thing that came to this computer engineers mind. Running "cmd /?" yields help. Thankfully there is /K switch that keeps terminal live after executing command. Finally tweaking start.bat to
mkdir Lab_
cd Lab_
cmd /C notepad
cmd /K set path=C:\Program Files\Java\jdk1.6.0\bin
did the trick... "Cut the crap" in my words.
I am still searching for some script that would write my Java program ;-)
Labels:
Batch Scripts,
Java,
Something More
Batch scripts in action - Algorithms LAB
Lets have a look @ batch scripts aka batch programming.
I have algorithm lab - C programming.
On very first day new instructions were given - You must create new folder every time named "Lab_DATE" and do respective programs in them. First assignment was to write a C program that performed Quick sort.
As soon as task was fixed, my lab-mates pounced on traditional C editor - Blue-screen and rectangular cursor. I rather prefer to write my program in notepad and then later debug and run in C environment. Notepad is quick, easy copy and paste ;-) , clean interface and much more.
So my actions were prefixed to be performed in every lab,
- Create new folder every time
- Open notepad and write program
- Open that program in C
I thought of making a batch script that would do all these for me.
Quickly, I opened notepad and typed these commands.
mkdir Lab_
cd Lab_
notepad test.c
C:\tc\bin\tc.exe test.c
Next thing to do is save it as "start.bat". Job's done.
Just two lazy clicks on start.bat
- Creates "Lab_" folder
- Goes into folder
- Starts notepad with test.c file
- Once program is written and notepad is closed, the program opens in C editor ready for CTRL+F9.
Jobs well done but I am still finding script that would write a Quick sort program Quickly ;-)
Labels:
Batch Scripts,
Something More
Wednesday, July 21, 2010
Evolution Of Languages
I read the first chapter of Java-The complete Refernce.
C was dominant for many following years. But environment was changing. Lets see evolution of C++ the first OOP language.
Apart facts, this topic was most interesting.
Long ago, Before computers were invented . . . Just joking, Not so long ago lets us see evolution of first language Fortran
Scenario: Computers were limited to big companies.Average people still did not have the smell of computers. Small softwares were needed. Assembly language prevailed at that time and there was dire need of another programming language which was easy to debug.
Hence evolved Fortan.
Years passed. Now computers were becoming public. But yet no language was able to tackle new problems. Moreover Fortan was using GOTO - the most dark word in world of programming. So code had many GOTO's and jumps made larger programs intractable. It was called Spaghetti code. Lets see birth of revolution "C".
Scenario: There were several languages, Each for different purposes but none robust. Hence there was a need of ONE-FOR-ALL language that had definite structure.
Hence evolved C.
It was a total revolution. It was structured, It was robust, It was efficient and it was one-for-all. But one factor that C had and none language possessed was the feeling of "Programmers Language".
C was dominant for many following years. But environment was changing. Lets see evolution of C++ the first OOP language.
Scenario: Hardware was out in public. Programs were becoming gigantic and difficult to handle. Procedure orientation could not handle the growing complexity. At the same time new concept of OOP was introduced to handle prevailing complexity.
Finally something struck Stroustroup's mind and C++ evolved.
Everybody was happy with C++. Once again the same thing - Environment was changing.
Computers were common now. Internet was about to bloom. But now C++ was lagging the upcoming need, Portablity.
Scenario: Machines were out and so was variety among them. Variety of processors, variety of OS were bothering software vendors. Every new architecture or OS would require new COMPILER - difficult piece of software. At the same time internet was blooming. This opened a new dimension to software world. Web apps were failing to satisfy large diverse internet audience in multiple factors like security, ability to run on all OS and all architecture, Compactness and ability to run quickly.
Thus some brains @ Sun started to work and finally announced Java.
Java had it all. Portability to run on any PC, Structured, Ability to handle complexity, Robustness and blah blah blah....
Lets see what do current scenario demands. I am ready for it ;-)
Labels:
Academics,
Java,
Something More
Saturday, July 17, 2010
Environment Variables in Windows
Being a computer engineering student, I had to face Java language this year.
On the first lab some instructions were given to run commands prior compiling (Setting path.)
set path=c:\program files\java\jdk1.6.0\bin
Surprisingly (for me) just running javac command then worked. I knew there was no command called "javac" and the current directory in cmd did not have any "javac" file.
Curiosity bubbled and I asked the instructor of this, and he explained:
The command "set path" alters the default-set system path "C:\windows" and "C:\windows\system32".
It can be verified by My Computer > Properties > Advanced tab > Environment Variables Button.
Hence First lesson: System path (Under Environment Variables) is like virtual current directory. You can execute exe's lying in these folders, just like you execute them as if they are in your current directory.
Lemme explain,
Suppose there is an executable "temp.exe" in directory D:\temp. When you start command prompt, you are at c:\Documents and settings\
Now try to run "temp.exe".
Failed ? Eh ?
Reason is, there is no file called "temp.exe" in your current folder.
Navigate to D:\temp\ and then run "temp.exe". That goes well.
So to run any executable just by name (as we did by just typing "javac") we need to be in that directory.(My perception before lab)
But windows provides a mechanism through which you can setup another directories virtually as your current directories and execute files in them as if they were in your current directory.
Best example could be "notepad". Running this command opens up notepad editor. The executable for notepad is located @ C:\windows\system32 folder. Hence this directory being set as path by default we can run files in this folder just by names.
When I altered the path by "Set path" command, I could no longer run "notepad". It had the error.
Hence the confusion waded away and I carried on with Java.
Labels:
Java,
Programming,
Something More
Subscribe to:
Posts (Atom)