Sunday, December 24, 2006

Java 5 Feature: An intro to foreach

Looping is a control structure that has been around ever since we started programming. The good old syntax for looping that you would have used most often is:

String[] messages = {"Hello", "Greetings", "Thanks"};
var length = messages.length;
var int i = 0;
for(i = 0; i < length; i++){
System.out.println(messages[i]);
}

What if you want to iterate over a collection, like ArrayList? We will do something like:

Iterator iter = lst.iterator();
for(;iter.hasNext();) {
System.out.println(iter.next());
}


The foreach was introduced to avoid introduction of any new keywords. The foreach introduced in Java 5 simplifies looping further. Let’s take a look at an example of how we can use the new way to loop:

for (String msg : messages) {
System.out.println(msg);
}

You would read
for (String msg : messages)

as "foreach String msg in messages". Within the loop of foreach, msg represents a String element within the array String[].
Instead of inventing another keyword "foreach", Sun decided to use the good old "for". Also, "in" may be used in existing code forfields, variables, or methods. In order to avoid stepping over your toes, they decided to use the ":" instead.

Using foreach with a List
ArrayList lst = new ArrayList();
lst.add(1);
lst.add(4.1);
lst.add("test");

for (Iterator iter = lst.iterator(); iter.hasNext();) {
System.out.println(iter.next());
}
for (Object o : lst) {
System.out.println(o);
}


ArrayList values = new ArrayList();
values.add(1);
values.add(2);
int total = 0;
for (int val : values) {
total += val;
}
System.out.println("Total : " + total);


Can you use foreach on your own class?

You can do that, provided your class implements the Iterable interface. It is pretty simple. For foreach to work, you must return an Iterator. Of course, you know that Collection provides the iterator. However, for you to use foreach on your own class, the use of Collection would have made your class quite bulkier; the Iterable interface has just one method interate().


Pros and Cons:
  • Foreach looks simpler, elegant, and is easier to use
  • You can’t use it all the time, however. If you need access to the index in a collection (for setting or changing values) or you want access to the iterator (for removing an element, for instance), then you can’t use the foreach.
  • Users of your class will not be able to use foreach on your object if you don’t implement the Iterable interface.


Refer to Sun's Java Tutorial for more info.

Java 5 Feature: An intro to Autoboxing

With Java 5 (or Java 1.5 or JSE 5.0 or Java J2SE 5.0 or JDK 1.5), a new feature called Autoboxing has been introduced to the language. it is the automatic conversion of the primitives and wrapper objects.
Boxing is to place a primitive data-type within an object so that the primitive can be used like an object. For example, a List, prior to JDK 1.5, can't store primitive data types. So, to store int type data in a List, a manual boxing was required (i.e from int to integer). Similarly, to retrieve the data back, an unboxing process was required to convert Integer back to int.

Autoboxing is the term for treating a primitive type as an object type. The compiler automatically supplies the extra code needed to perform the type conversion. For example, in JDK 1.5, it now allows the programmer to create an ArrayList of ints. This does not contradict what was said above for List: the ArrayList still only lists objects, and it cannot list primitive types. But now, when Java expects an object but receives a primitive type, it immediately converts that primitive type to an object.

This action is called Autoboxing, because it is boxing that is done automatically and implicitly instead of requiring the programmer to do so manually.

Unboxing is the term for treating an object type as a primitive type without any extra code.

For example, in versions of Java prior to 1.5, the following code did not compile:

Integer i = new Integer(9);
Integer j = new Integer(13);
Integer k = i + j; // error prior to JDK 1.5
Originally, the compiler would not accept the last line. As Integers are objects, mathematical operators such as + were not meaningfully defined for them. But the following code would of course be accepted without complaint:
int i = 9;
int j = 13;
int k = i + j;

int x = 4;
int y = 5;
// Integer qBox = new Integer(x + y);
Integer qBox = x + y;//would have been error,but okay now-equi to prev line
The Integer is unboxed into an int, the two are added, and then the sum is autoboxed into a new Integer.

Pros and Cons:
  • Autoboxing unclutters your code, but comes with important considerations in terms of performance and sometimes unexpected behavior.
  • Understand what == means. For objects, you are comparing identity, for primitive types, you are comparing value. In the case of auto-unboxing, the value based comparison happens.
  • If the Integer object is null, assigning in to int will result in a runtime exception – NullPointerException – being thrown.
Refer to Sun's Java Tutorial for more info.

Tuesday, December 19, 2006

Google Browser Sync

Google Browser Sync for Firefox is an extension that continuously synchronizes your browser settings - including bookmarks, history, persistent cookies, and saved passwords - across your computers. It also allows you to restore open tabs and windows across different machines and browser sessions.
Please note: Google Browser Sync must update your browser settings whenever you start Firefox. This will increase the start-up time of Firefox (the time between clicking on the Firefox icon and loading your start page) - please bear with us as we work to decrease this delay.

How to Use
To use Google Browser Sync, simply install and configure the extension on all computers for which you'd like your browser settings automatically kept in sync. Even if you only install Browser Sync on a single computer, you can use it to backup your browser settings and to restore your open tabs and windows across browser sessions.

Configuring your computers
After successfully downloading and installing the extension, then restarting your browser, you'll see a setup wizard. (Please note that you'll need a Google Account to complete the setup process; if you don't already have a Google Account, you can create one now.) The setup wizard will take you through a series of quick and easy steps. You'll need to choose which browser components you'd like to keep synchronized with your other computers (the standard install includes all possible components), and choose a PIN to protect your sensitive information.
Configuring your second computer is even easier. You only need to install the extension, log in with your Google Account username and password, and provide your PIN.

Day-to-day use
Google Browser Sync is completely automated. The settings you select at startup are automatically synchronized across each of the computers on which you install Browser Sync. You won't even need to log in every time you start the browser. You can change which browser components are being synced - or even stop the syncing process entirely - using the settings panel in the upper-right corner of the page. The settings panel also gives you access to your PIN. How to Uninstall In the Firefox browser, click "Tools" and select "Extensions". The Extensions window should appear. Click "Google Browser Sync", then click the "Uninstall" button. Click the "OK" button in the confirmation window. The Extensions window should confirm that Google Browser Sync has been uninstalled. Close the Extensions window, then close all Firefox windows and restart the browser.

link:
http://www.google.com/tools/firefox/browsersync/index.html

Thursday, December 7, 2006

To Ruby From Java - Similarities and Differences

Came through this interesting post comparing Java with Ruby.

Java is mature. It's tested. And it's fast (contrary to what the anti-Java crowd may still claim). It's also quite verbose. Going from Java to Ruby, expect your code size to shrink down considerably. You can also expect it to take less time to knock together quick prototypes.

Similarities

As with Java, in Ruby...

  • Memory is managed for you via a garbage collector.
  • Objects are strongly typed.
  • There are public, private, and protected methods.
  • There are embedded doc tools (Ruby's is called RDoc). The docs enerated by RDoc look very similar to those generated by javadoc.

Differences

Ulike Java, in Ruby...

  • You don't need to compile your code. You just run it directly.
  • There are different GUI toolkits. Ruby users can try WxRuby, FXRuby, Ruby-GNOME2, or the bundled-in Ruby Tk for example.
  • You use the end keyword after defining things like classes, instead of having to put braces around blocks of code.
  • You have require instead of import.
  • All member variables are private. From the outside, you access everything via methods.
  • Parentheses in method calls are usually optional and often omitted.
  • Everything is an object, including numbers like 2 and 3.14159.
  • There's no static type checking.
  • Variable names are just labels. They don't have a type associated with them.
  • There are no type declarations. You just assign to new variable names as-needed and they just "spring up" (i.e. a = [1,2,3] ratherthan int[] a = {1,2,3};).
  • There's no casting. Just call the methods. Your unit tests should tell you before you even run the code if you're going to see an exception.
  • It's foo = Foo.new( "hi") instead of foo = new Foo( "hi" ).
  • The constructor is always named "initialize" instead of thename of the class.
  • You have mixin's instead of interfaces.
  • YAML tends to be favored over XML.
  • It's nil instead of null.

http://www.ruby-lang.org/en/documentation/ruby-from-other-languages/to-ruby-from-java/

Wednesday, December 6, 2006

HtmlUnit - unit testing framework for web applications

HtmlUnit is a java unit testing framework for testing web based applications. It is similar in concept to httpunit but is very different in implementation. Which one is better for you depends on how you like to write your tests.
HttpUnit models the http protocol so you deal with request and response objects. HtmlUnit on the other hand, models the returned document so that you deal with pages and forms and tables.

HtmlUnit is not a generic unit testing framework. It is specifically a way to simulate a browser for testing purposes and is intended to be used within another testing framework such as JUnit.

Features
Support for the HTTP and HTTPS protocols. ( JSSE must be in your classpath in order to use HTTPS support)
Support for cookies
Ability to specify whether failing responses from the server should throw exceptions or should be returned as pages of the appropriate type (based on content type)
Support for submit methods POST and GET
Ability to customize the request headers being sent to the server
Support for html responses
o Wrapper for html pages that provides easy access to all information contained inside them
o Support for submitting forms
o Support for clicking links
o Support for walking the DOM model of the html document
Proxy server support
Support for basic authentication
Partial support for javascript (see javascript section below)

JavaScript support
Starting with the 1.1 release, HtmlUnit is supporting javascript. The core javascript language is already fully supported by the Rhino javascript engine.

http://htmlunit.sourceforge.net/


Digg This Article Bookmark The Article On Delicious Bookmark at YahooMyWeb Bookmark at reddit.com Bookmark at NewsVine Fark this

Helipad - The flexible web notepad

Helipad is a web-based tool, which means you can use it wherever you can get online.

Since Helipad is a hosted application, we do all the boring stuff: backup documents, maintain security, upgrade software, while you're left to do the most important thing: write.
  • Write notes and organize them with tags
  • Create and maintain to-do lists
  • Draft documents on any computer or phone with Internet access
  • Share your work with others

Features
  • Unobtrusive auto-save: set a timer to save automatically so you
  • don't lose your work
  • Organize your documents with tags
  • Quickly find documents with a live-search on every page
  • Customize your Helipad with themes and plugins
  • Share your documents with friends
  • Prepare documents for print by changing fonts

Get more out of Helipad
  • Helipad works with popular phone web browsers.
  • Your notes look great printed from Helipad.
  • Developers can get more out of Helipad by using the API, or by writing add-ons.


Digg This Article
Bookmark The Article On Delicious
Bookmark at YahooMyWeb
Bookmark at reddit.com
Bookmark at NewsVine
Fark this

Friday, December 1, 2006

DropBoks

DropBoks is a little website that allows you to securely upload and download your files as you please. No bells, no whistles, just an easy and quick way to store your files online.

Each account has 1 GB of storage space available. You can upload and download files (any format) as large as 50 MB.

How are we able to keep DropBoks free? We have found that when you offer a
valuable service that is extremely simple to use, folks have no problem making a
small donation. This has covered our costs since day one!



Monday, November 27, 2006

meebo - Browser based IM

meebo.com is a website for instant messaging from absolutely anywhere. Whether you're at home, on campus, at work, or traveling foreign lands, hop over to meebo.com on any computer to access all of your buddies (on AIM, Yahoo!, MSN, Google Talk, ICQ and Jabber) and chat with them, no downloads or installs required, for free!

http://www.meebo.com

Sunday, October 8, 2006

Common J2EE Design Patterns

There are a common set of design patterns for the J2EE platform.
  • Intercepting filter--This pattern applies to request pre- and post-processing of request. It applies additional services needed to process a request. For example, an intercepting filter such as a servlet filter may handle all incoming requests to the Web site and provide a central mechanism for authorization.
  • View helper--A view helper encapsulates the presentation and data access logic portions of a view, thus refining the view and keeping it simpler. Presentation logic concerns formatting data for display on a page, while data access logic involves retrieving data.
    View helpers are often JSP tags for rendering or representing data and JavaBeans for retrieving data.
  • Composite view--This pattern makes view presentation more manageable by creating a template to handle common page elements for a view. Often, Web pages contain a combination of dynamic content and static elements, such as a header, footer, logo, background, and so forth. The dynamic portion is particular to a page, but the static elements are the same on every page. The composite view template captures the common features.
  • Front controller--This pattern provides a centralized controller for managing requests. A front controller receives all incoming client requests, forwards each request to an appropriate request handler, and presents an appropriate response to the client.
  • Value object--This pattern facilitates data exchange between tiers (usually the Web and EJB tiers) by reducing the cost of distributed communication. In one remote call, a single value object can be used to retrieve a set of related data, which then is available locally to the client.
  • Session facade--This pattern coordinates operations between cooperating business objects, unifying application functions into a single, simplified interface for presentation to the calling code. It encapsulates and hides the complexity of classes that must cooperate in specific, possibly complex ways, and isolates its callers from business object implementation changes. A session facade, usually implemented as a session bean, hides the interactions of underlying enterprise beans.
  • Business delegate--This pattern intervenes between a remote business object and its client, adapting the business object's interface to a friendlier interface for the client. It decouples the Web tier presentation logic from the EJB tier by providing a facade or proxy to the EJB tier services. The delegate takes care of lower-level details, such as looking up remote objects and handling remote exceptions, and may perform performance optimizations, such as caching data retrieved from remote objects to reduce the number of remote calls.
  • Data access object--This pattern abstracts data access logic to specific resources. It separates the interfaces to a systems resource from the underlying strategy used to access that resource. By encapsulating data access calls, data access objects facilitate adapting data access to different schemas or database types.
When deciding on a pattern to use, keep in mind that certain patterns are more applicable to a particular application tier. For example, patterns related to views and presentation are applied in the Web tier. Good examples of Web tier patterns are composite view and view helper. Other patterns are more concerned with controlling business logic, and they are more useful in the EJB tier. Session facade is a good example of an EJB tier pattern. Other patterns focus on retrieving data or delegating operations, and they are best applied between tiers. The value object and business delegate patterns fall into this category.

Friday, September 1, 2006

Software Development Philosophies

This is an incomplete list of approaches, styles, or philosophies in software development.
  • Agile software development
  • Agile Unified Process (AUP)
  • Open Unified Process
  • Best practice
  • Cathedral and the Bazaar
  • Constructionist design methodology (CDM)
  • Design-driven development (D3)
  • Dynamic Systems Development Method (DSDM)
  • Extreme Programming (XP)
  • Iterative and incremental development
  • KISS principle (Keep It Simple, Stupid)
  • MIT approach, see Worse is better
  • Open Unified Process
  • Quick-and-dirty
  • Rational Unified Process (RUP)
  • Scrum (management)
  • Spiral model
  • Test-driven development (TDD)
  • Unified Process
  • Waterfall model
  • Worse is better (New Jersey style)
  • You Ain't Gonna Need It (YAGNI)

From Wikipedia

Wednesday, August 30, 2006

Developing applications with Facelets, JSF, and JSP

Dr. Xinyu Lu has published an article on java.net giving an overview of the differences between developing webapps using JSP and JSTL tags, and JSF. This article introduces a rich list of useful tips to help developers smoothly transition from the old-fashioned JSP/servlet programming to the new JSF-style programming. It clarifies the issues and confusion developers may encounter, and promotes best practices and methodologies to simplify web development, improve code reuse, and make source code more designer-friendly, as well as easy-to-maintain.

JavaServer Faces (JSF) is a server-side user interface component framework for Java-based web applications. As a standard web development technology, JSF 1.2 is encapsulated as part of the latest Java EE 5 specification. JSF promotes a component-based, event-driven UI development methodology, independent from any mark-up language, protocol, or client device. Inspired by MVC frameworks like Struts, the JSF API has built-in support for internationalization, localization, data type conversion, and validation. Developing scriptlet-free web pages becomes possible in collaboration with JSTL tags. Recently, AJAX-JSF UI components have gained a lot of attention in Java communities, because they deliver a rich user experience similar to desktop applications and can be used off-the-shelf without requiring deep knowledge of remote scripting in JavaScript. As a view-tier MVC solution, JSF with dependency injection and pluggable APIs can be easily integrated with business-tier technologies like Spring, JBoss Seam, and EJB 3.0. Evidently, the JSF community endeavors to interface JSF with a variety of exciting new technologies. To benefit fully from the great features that JSF and JSP 2.0+ offer, developers must give up their stale JSP/servlet programming style and migrate to the new world of JSF.
http://today.java.net/pub/a/today/2006/08/29/developing-with-facelets-jsf-jsp.html

Tuesday, July 4, 2006

Simultaneous posting on Blogger and MSN Spaces

Now you can easily post your Blogger post on MSN Spaces without doing any cut-copy-paste. The trick is very simple and anybody can use it in no time.

STEPS
  • Sign into your MSN Spaces and access Settings > EMail Settings.
  • Turn on e-mail publishing.
  • Specify up-to-three email addresses you want to use to publish blog entries. Enter your Blogger Mail-to-Blogger Address here (BloggerDashboard > Settings > EMail) in one of them.
  • Choose a secret word. (Let us say it is 'agent007'). This secret word is combined with your space name (Lets say it is mymsnspace) to form a special e-mail address (mymsnspace.agent007@spaces.msn.com) that only you can use to publish entries to your space.
  • Access Settings tabs in you Blogger Dashboard in another window. There is a textfield named BlogSend Address. Here provide an email address to have your blog mailed to whenever you publish it. Enter your special e-mail address that MSN Spaces has created for you (mymsnspace.code007@spaces.msn.com)
Now, as you publish your blog entry on Blogger, it is published on MSN Spaces simultaneously!

Thursday, June 29, 2006

How can i prevent Browser from Caching the Page content?

Before sending the data to the browser, use the following code:

response.setHeader("Cache-Control","no-store");
response.setHeader ("Pragma","no-cache");
response.setDateHeader ("Expires", 0);

This also helps in case, when user should not be able to see previous pages by clicking the Back button in the browser.

Can an icon be published on the left side of the URL in the address bar?

Create an icon called favicon.ico and place that in the root of the website.
You can also link to it using this:
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
Source: JGuru.com

Friday, June 23, 2006

JBoss - The Basics

This is not for the experienced JBoss application server user. It is meant to give the JBoss beginner the basics to running and deploying applications to JBoss 4.0.3 SP1.

JBoss Layout

JBoss is easy to understand if you know the way the directories are setup and how to work with them. First everything you will do to JBoss is in the install directory.

bin directory

The most important one here is the run.bat or run.sh. This will run the application server and display debug and information messages to the user in the session it is started in. To start JBoss simply use the run command from this directory. To stop the server do a CTRL-C in the session it was started in. There are also some other files there but this is the basics only so I will not discuss them.

lib directory

This is the "root" server lib directory. You don't usually have to nor want to do anything with these libs.

server directory

This is where the directories for the server instances are. This is where you will do most of your work.

default directory

The default directory is the directory for the default instance. This is the instance which is started if you do not specify an instance. If you are in need of multiple instances then you will need to duplicate this directory. So if you think that you will need more instances do yourself a favor and make a backup of this directory before doing anything else.

I will go through this directory and tell you a little about it and give you a little information which may come in handy in the future.

conf

This is where all the configuration files for the paticular instance reside. These are more or less needed but you don't need to do much with them to work with the server. The only one I have changed in this directory is the log4j.xml because I wanted to add some different appenders to keep more concise logs.

data

This directory I have never done anything in and never even navigated to tell I decided to write this. The only think I could see of any interest is the wsdl directory which will hold a sub directory for each archive which holds a web service which holds the wsdl and wsdd files for each service.

deploy

This is the most important directory. It contains all the deployed applications archive files and the jbossweb-tomcat55.sar directory. The most important thing in the jbossweb-tomcat55.sar directory is the server.xml. This is the file which will need to be modified if you are going to have multiple instances running. If you do run multiple instances make sure you change the listening ports in the server.xml, refeer to the JBoss site for information on changing ports. To run a server with a different name use this command run -c instance_name. The next important directory is lib. It is where the archive files need to be put for the instance to find them. For instance if you are going to be using databases the database lib goes here. The log directory is next, it is where the logs for the instance get put. The temp and work are where the applications get expanded to and run from.

others

There are other directories but these are all you really need to worry about when getting started.

JBoss Deployment

Since JBoss hot deploys new applications it works very will for me. I simply build the project and then use a script to deploy it from a command prompt.


Source: Dru Devore's Blog

Thursday, June 1, 2006

[Humor] Compensation

How are you compensated in the Organization for the good work? Is it one of these forms ;)



Tuesday, May 30, 2006

Javascript plugin for Eclipse

I waas looking for a Javascript editor and came across JSEclipse plugin from Interakt. Its a beautiful plugin and even has a all-features-enabled free version :).

The best things I like about JSEclipse are:
  • Code completion for JavaScript function and classes.
  • Code completion for JavaDoc.
  • Function and class names are displayed in the Outline panel for the currently open file.
  • Open declaration i.e. the famous F3 functionality
  • Error reporting
  • Warning reporting
  • Code wrap
  • Support for major JavaScript libraries
  • Code completion uses Rhino for better accuracy
  • Use of JSDoc and inline parameter comments to detect parameter type
  • Suggest parameters to be filled
  • Project dependent code completion
  • Reads all classes in current project
  • Reads classes in currently opened files
  • Scan current file for words
  • Reads XML files for class definitions
  • Add your own XML with class definitions
However, it works on Eclipse 3.1.x versions only. I have multiple Eclipse installations. It didnt work on Eclipse 3.0 ("Editor could not be initialized."). However with Eclipse 3.1.2, it was a breeze to work with it. Either create an Eclipse project, or add JS files to your existing project, and you are ready to go!

It appears to work based on usage - it remembers how an object is used and completes based on that.

Have u guys (and gals) used any other editor for Javascript? Do share your experiences here.

Wednesday, May 17, 2006

Google Web Toolkit for building AJAX apps in Java

Google has introduced a toolkit for building AJAX applications in Java, though its in beta. It has also supplied some sample applications with the kit.

Google Web Toolkit (GWT) is a Java software development framework that makes writing AJAX applications like Google Maps and Gmail easy for developers who don't speak browser quirks as a second language. Writing dynamic web applications today is a tedious and error-prone process; you spend 90% of your time working around subtle incompatabilities between web browsers and platforms, and JavaScript's lack of modularity makes sharing, testing, and reusing AJAX components difficult and fragile.

GWT lets you avoid many of these headaches while offering your users the same dynamic, standards-compliant experience. You write your front end in the Java programming language, and the GWT compiler converts your Java classes to browser-compliant JavaScript and HTML.

I plan to explore GWT for the next couple of days and then would be writing on that. Would appreciate your experience on GWT.

Sunday, February 12, 2006

[Humor] Progressive HR Policies

Dear Staff,

Please be advised that there are NEW rules and regulations implemented to raise the efficiency of our firm.

Transportation
It is advised that you come to work driving a car according to your salary. If we see you driving a Honda, we assume you are doing well financially and therefore you do not need a raise.

If you drive a 10 year old car or taking public transportation, we assume you must have lots of savings therefore you do not need a raise.

If you drive a Pickup, you are right where you need to be and therefore you do not need a raise.

Annual Leave
Each employee will receive 52 Annual Leave days a year (Wooow!).
They are called Sunday.

LUNCH BREAK
Skinny people get 30 minutes for lunch as they need to eat more so that they can look healthy.
Normal size people get 15 minutes for lunch to get a balanced meal to maintain their average figure.
Fat people get 5 minutes for lunch, because that's all the time needed to drink a Slim Fast and take a diet pill.

SICK DAYS
We will no longer accept a doctor Medical Cert as proof of sickness. If you are able to go to the doctor, you are able to come to work.

TOILET USE
Entirely too much time is being spent in the toilets.

There is now a strict 3-minute time limit in the cubicles. At the end of three minutes, an alarm will sound, the toilet paper roll will retract, the door will open and a picture will be taken. After your second offence, your picture will be posted on the company bulletin board under the "Chronic Offenders" category. Subsequent pictures will be sold at public auctions to raise money to pay your salary.

SURGERY
As long as you are an employee here, you need all your organs. You should not consider removing anything. We hired you intact. To have something removed constitutes a breach of employment.

Internet Usage
All personal internet usage will be recorded and charges will be deducted from your bonus (if any) and if we decide not to give you any,charges will be deducted from your salary. (note: Rs.20 per minute as we have leased line connection).
Just for the record. 73% of the staff will not be entitled to any salary for the next 3 months as their internet charges have exceeded their 3 months salary.


Thank you for your loyalty to our company. We are here to provide a positive employment experience.

Therefore, all questions, comments, concerns, complaints, frustrations, irritations, aggravations, insinuations, allegations, accusations, contemplation, consternation and input should be directed elsewhere.

Have a nice day.


Thanks & Regards,
Manager, HR

Friday, February 3, 2006

Female Software Professionals

Received this 'source code' from a friend. Found quite interesting. Just reproducing here in good humor. No offences. No gender biases. Just a positively humorous entry.


class Indian_Bachelor_female_professional
{
double styles;
short skirts;
long time_to_understand_problems;
float mind;
void knowledge();
char non_co_operative;
};

class Married_female_Software_Professional {
double weight;
short tempered;
long gossips;
float hopes;
void work();
char unstable;
};

class Female_Engaged_software_professional {
double time_on_phone;
short attention_on_work;
long boast;
float on_cloud_nine;
void understanding();
char edgy;
};

class Newly_Married_software_professional {
double dinner_invitations;
short time_at_work;
long lunch_breaks;
float talks;
void bank_balance();
char hen_pecked;
};

class husband_wife_software_professional {
double income;
short temper;
long time_no_see;
float new_software_company;
void love_life();
char money_minded;
};

Working too long in the same Company

What type r u ;)
[Received in an email]

[Humor]Acronyms and Abbreviations

New meaning to the names of a few IT companies:

No hard feelings. Just a positively humorous attempt!
  • AT&T : All Troubles & Terrible
  • BAAN : Beggars Association and Nerds
  • BFL : Brainwash First and Let them go
  • C-DOT : Coffee During Office Timings
  • CMC : Coffee, Meals and Comfort
  • DEC : Drifting & Exhausted Computers
  • DELL : Deplorable Equipment & lackluster
  • HCL : Hidden Costs & Losses
  • HUGHES : Highly Useless Graduates Hired for Eating and Sleeping
  • IBM : Implicitly Boring Machines
  • INFOSYS :Inferior Offline Systems
  • NIIT : Not Interested in IT
  • ORACLE : On-line Romance And Chatting with Lady Employees
  • PARAM : Puzzled And Ridiculous Array of Microprocessors
  • PATNI: Pathetic Appraisal Techniques, No Increments
  • PSI : Peculiar Symptoms of India
  • SATYAM : Sad And Tired Yelling Away Madly
  • TCS : Totally Confusing Solutions
  • TISL : Totally Inconsistent Systems Ltd
  • WIPRO : Weak Input, Poor & Rubbish Output

Can you create folders with these names?

Can you create folders in your Windows environment with these names:
  • Aux
  • Con
  • Nul

Do you why? May be 'reserved words'?!!!

Wednesday, February 1, 2006

Looking for info for Web Hosting

I am planning to have a domain for my blog. However, I have no experience of having a separate domain and getting it hosted. So, I would like to know how to proceed on that. I am in India, and would prefer a Company that accepts payment in Indian Rupees. Also, while selecting a company for hosting the sites, which facilities/features I should see e.g. sub-domains, email ids, storage etc. Also, what are the popular blog softwares required? Plz share your experiences.

Sunday, January 15, 2006

Has form data changed?

I recently came across a situation where it was required that form should be submitted only if there was any change of data in the form-fields, and there were some 90 fields in the form! So, what to do? Checking 90 fields manually was simply out of question for me, as for this, I had to take care of their initial value (when page was rendered). So, I decided to dig a deep into Javascript and look for some sort of solution there. And it was their already!!!
For every HTML control, we know there is an ID, name, type and value attached to it. What is not known to all is that there is a 'defaultValue' as well for each control. So, using this 'default' behavior, we can check if there is a change in form-data.



/**
* Checks if the form data is changed
* @ param - none
* @returns boolean
*/
function isFormChanged() {
var formNo=document.forms.length;
var flag = true;
for (j=0;j var max = document.forms[j].elements.length;
for(var i=0; i< max; i++) {
if (document.forms[j].elements[i].type =="textarea" || document.forms[j].elements[i].type =="text") {
if(document.forms[j].elements[i].value != document.forms[j].elements[i].defaultValue) {
return true;
}
}
if (document.forms[j].elements[i].type =="select-one") {
if(document.forms[j].elements[i].options[document.forms[j].elements[i].selectedIndex].selected != document.forms[j].elements[i].options[document.forms[j].elements[i].selectedIndex].defaultSelected) {
return true;
}
}
if (document.forms[j].elements[i].type =="select-multiple") {
if(document.forms[j].elements[i].options[document.forms[j].elements[i].selectedIndex].selected != document.forms[j].elements[i].options[document.forms[j].elements[i].selectedIndex].defaultSelected ) {
return true;
}
}
if (document.forms[j].elements[i].type =="checkbox" || document.forms[j].elements[i].type =="radio") {
if(document.forms[j].elements[i].checked != document.forms[j].elements[i].defaultChecked) {
return true;
}
}
}
}
return false;
}



So, as u can see the default behavior of textfield, textarea, radio button and checkbox has been used to arrive at this simple solution! You can even exclude certain controls from the check where the value has been assigned using javascript (i.e. once the page has already been rendered).

A

Popular Posts (Last 30 days)

This is a personal blog and I do not speak for my employer.