Monthly Archives: September 2009

20 Top jQuery tips & tricks for jQuery programmers

Following are few very useful jQuery Tips and Tricks for all jQuery developers.

1. Optimize performance of complex selectors

Query a subset of the DOM when using complex selectors drastically improves performance:

1.var subset = $("");

2.$("input[value^='']", subset);

2. Set Context and improve the performance

On the core jQuery function, specify the context parameter when. Specifying the context parameter allows jQuery to start from a deeper branch in the DOM, rather than from the DOM root. Given a large enough DOM, specifying the context parameter should translate to performance gains.

1.$("input:radio", document.forms[0]);

3. Live Event Handlers

Set an event handler for any element that matches a selector, even if it gets added to the DOM after the initial page load:

1.$('button.someClass').live('click', someFunction);

This allows you to load content via ajax, or add them via javascript and have the event handlers get set up properly for those elements automatically.

Likewise, to stop the live event handling:

1.$('button.someClass').die('click', someFunction);

These live event handlers have a few limitations compared to regular events, but they work great for the majority of cases. Live event will work starting from jQuery 1.3

4. Checking the Index

jQuery has .index but it is a pain to use as you need the list of elements and pass in the element you want the index of

1.var index = e.g $('#ul>li').index( liDomObject );

The following is easier:

if you want to know the index of an element within a set, e.g. list items within a unordered list:

1.$("ul > li").click(function ()

3. var index = $(this).prevAll().length;

5. Use jQuery data method

jQuery’s data() method is useful and not well known. It allows you to bind data to DOM elements without modifying the DOM.

6. Fadeout Slideup effect to remove an element
Combine more than one effects in jQuery to animate and remove an element from DOM.

1.$("#myButton").click(function() {

2. $("#myDiv").fadeTo("slow", 0.01, function(){ //fade
3. $(this).slideUp("slow", function() { //slide up
4. $(this).remove(); //then remove from the DOM
5. });
6. });

7. Checking if an element exists

Use following snippet to check whether an element exists or not.

1.if ($("#someDiv").length) {

2. //hooray!!! it exists...

8. Add dynamically created elements into the DOM

Use following code snippet to create a DIV dynamically and add it into the DOM.

1.var newDiv = $('<div></div>');


9. Line breaks and chainability

Instead of doing:


You can increase readability like so:


2. .hide()
3. .addClass()
4. .fadeIn()
5. .hide();

10. Creating custom selectors

01.$.extend($.expr[':'], {

02. over100pixels: function(a) {
03. return $(a).height() > 100;
04. }
07.$('.box:over100pixels').click(function() {
08. alert('The element you clicked is over 100 pixels high');

11. Cloning an object in jQuery

Use .clone() method of jQuery to clone any DOM object in JavaScript.

1.// Clone the DIV

2.var cloned = $('#somediv').clone();

jQuery’s clone() method does not clone a JavaScript object. To clone JavaScript object, use following code.

1.// Shallow copy

2.var newObject = jQuery.extend({}, oldObject);
4.// Deep copy
5.var newObject = jQuery.extend(true, {}, oldObject);

12. Test if something is hidden using jQuery

We use .hide(), .show() methods in jquery to change the visibility of an element. Use following code to check the whether an element is visible or not.

1.if($(element).is(":visible") == "true") {

2. //The element is Visible

13. Alternate way of Document Ready

1.//Instead of

2.$(document).ready(function() {
3. //document ready
7. //document ready

14. Selecting an element with . (period) in its ID

Use backslash in the selector to select the element having period in its ID.

1.$("#Address\\.Street").text("Enter this field");

15. Counting immediate child elements

If you want to count all the DIVs present in the element #foo

01.<div id="foo">

02. <div id="bar"></div>
03. <div id="baz">
04. <div id="biz">
05. </div>
06. <span><span>
09.//jQuery code to count child elements
10.$("#foo > div").size()

16. Make an element to “FLASH”

1.jQuery.fn.flash = function( color, duration )

3. var current = this.css( 'color' );
4. this.animate( { color: 'rgb(' + color + ')' }, duration / 2 );
5. this.animate( { color: current }, duration / 2 );
7.//Then use the above function as:
8.$( '#importantElement' ).flash( '255,0,0', 1000 );

17. Center an element on the Screen = function () {

02. this.css("position","absolute");
03. this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
04. this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
05. return this;
08.//Use the above function as:

18. Getting Parent DIV using closest

If you want to find the wrapping DIV element (regardless of the ID on that DIV) then you’ll want this jQuery selector:


19. Disable right-click contextual menu

There’s many Javascript snippets available to disable right-click contextual menu, but JQuery makes things a lot easier:


2. $(document).bind("contextmenu",function(e){
3. return false;
4. });

20. Get mouse cursor x and y axis

This script will display the x and y value – the coordinate of the mouse pointer.


2. //display the x and y axis values inside the P element
3. $('p').html("X Axis : " + e.pageX + " | Y Axis " + e.pageY);

Windows Authentication vs. SQL Server Authentication

Windows Authentication is for the environment that all of your users are part of a Windows domain (have a Windows NT/2000 user account or is a member of a group). Your access to SQL Server is controlled by your Windows NT/2000 account or group, which is authenticated when you log on to the Windows operating system on the client.

If you have a mixed environment (e.g. Windows and Novell), then you have to use SQL Server Authentication where you will have to create a Login ID and Password in SQL Server.

Don’t be confused with “Authentication” and “Authorization.” The “Authentication” is dealing with user’s connection to SQL Server and the “Authorization” is dealing with what data privilege a user has once he is connected to the SQL Server.

Secondly, don’t be confused with “Authentication,”(think of it as a “method”), and “Authentication Mode.” There are two kinds of authentication – Windows authentication and SQL Server authentication. And there are two kinds of authentication mode – Windows authentication mode and mixed authentication

The Windows authentication mode only allows you to login/connect to SQL Server with Windows authentication. The mixed authentication mode allows you to login/connect to SQL Server with either Windows authentication or SQL Server authentication.

Again, if your environment is pure Windows, then you should use Windows authentication mode, which uses Windows authentication to login/connect to SQL Server. If your environment is not pure Windows, like Novell and Windows, then you have to use mixed authentication mode, which will prompt you, during connection, to choose either Windows authentication or SQL Server authentication to connect to SQL Server.

If you are a member of Windows’ administrator group then, it doesn’t matter if you are using Windows authentication mode or mixed authentication mode, you should be able to use Windows Authentication to connect to SQL Server. However, what you can do after the connection depends on what you have been authorized.

Disadvantages of SQL Server Authentication

  • If a user is a Windows domain user who has a login and password for Windows, he must still provide another (SQL Server) login and password to connect. Keeping track of multiple names and passwords is difficult for many users. Having to provide SQL Server credentials every time that one connects to the database can be annoying.
  • SQL Server Authentication cannot use Kerberos security protocol.
  • Windows offers additional password policies that are not available for SQL Server logins.

Advantages of SQL Server Authentication

  • Allows SQL Server to support older applications and applications provided by third parties that require SQL Server Authentication.
  • Allows SQL Server to support environments with mixed operating systems, where all users are not authenticated by a Windows domain.
  • Allows users to connect from unknown or untrusted domains. For instance, an application where established customers connect with assigned SQL Server logins to receive the status of their orders.
  • Allows SQL Server to support Web-based applications where users create their own identities.
  • Allows software developers to distribute their applications by using a complex permission hierarchy based on known, preset SQL Server logins.

10 Stupid Mistakes Made by the Newly Self-Employed

We have seen many of them make similar mistakes. This advice is geared towards small business owners, particularly people who are just starting (or about to start) their own business.

1. Selling to the wrong people.

While sales are important to the survival of any business, you don’t need to push your business on everyone you meet, including friends and family. Furthermore, it’s a waste of time to try selling to people who simply don’t need what you’re offering.

Selling to the wrong people includes trying to sell to everyone. Some customers are much easier to sell to than others. For example, a person who does web consulting for small businesses, and he’s learned that some clients are much harder to work with than others. If a potential customer is broke and obsessively worried about every nickel they spend, if they want a web site but don’t know why, or if they simply don’t understand the Internet well enough, they won’t be a good client in the long run. Feel free to say no to customers that are more trouble than they’re worth. Let your competitors sell to them instead. You’ll save yourself many headaches, and you’ll free up more time to focus on serving the best customers.

Just because someone is interested in doing business with you doesn’t mean you should accept. If an offer doesn’t excite me right away, we usually decline or ignore it. Most relationships simply aren’t worth pursuing. Learn to say no to the weak opportunities so you have the capacity to say yes to the golden opportunities.

2. Spending too much money.

Until you have a steady cashflow coming in, don’t spend your precious start-up cash unless it’s absolutely necessary. Your business should put cash into your pocket, so before you “invest” money into it, be clear on how you’re going to pull that cash back out again.

Obviously some businesses require lots of cash to start, but in the age of the Internet business, you can very easily start a lucrative business for pocket change.

3. Spending too little money.

It’s also a mistake to be too stingy with your cash. Don’t let frugality get in the way of efficiency. Take advantage of skilled contractors who can do certain tasks more efficiently than you can. Buy decent equipment when it’s clear you’ll get your money’s worth. You don’t have to overspend on fancy furniture, but get functional furniture that helps you be more productive. Don’t use an antiquated computer with outdated software that slows you down if you can afford something better.

It takes time to develop the wisdom to know when you’re being too tight or too loose with your cash, so if you’re just starting out, get a second opinion. Often the very thought of getting a second opinion makes the correct choice clear. If you can’t justify the expenditure to someone you respect, it’s probably a mistake. On the other hand, there are situations where it’s hard to justify not spending the cash.

4. Putting on a fake front.

Many one-person businesses refer to themselves as “we.” That’s something a lot of new entrepreneurs do, but it isn’t necessary. There’s nothing wrong with a one-person business, especially today. It’s perfectly OK to refer to your business as an I when you’re the only one working in it. Pretending that you’re a we when you’re really an I is a bit silly. It’s not going to gain you any respect in a way that matters. Promoting yourself as an I may even be an advantage today, since people will know the buck stops with you, and if you make a promise, you’re the one who will carry it out. Promises from a we sometimes aren’t worth very much.

If you’re a newly self-employed person, don’t pretend you’re anything else. Price your products and services fairly for your level of skills and talents. Some newly self-employed people think they must become actors. The business they promote to the world is pure fantasy. Trying to fool your customers in this manner will only backfire. If you’re so desperate for business that you need to lie, you shouldn’t be starting your own business. If you can’t provide real value and charge fairly for it, don’t play the game of business. Develop your skills a bit more first.

5. Assuming a signed contract will be honored.

A signed contract is just a piece of paper. What’s behind a signed contract is a relationship. If the relationship goes sour, the contract won’t save you. The purpose of a contract is to clearly define everyone’s roles and commitments. But it’s the relationship, not the paper, that ultimately enforces those commitments.  Once you start falling back on the paper, the deal is already in trouble. Creative (and lucrative) business deals almost always stray from the paper contracts that represent them. Business relationships are similar to other personal relationships — they twist and turn all over the place.

Written contracts are still necessary, especially when dealing with larger corporations where people come and go, but they’re secondary to relationships. Just don’t make the mistake of assuming that the contract is the deal. The contract is only the deal’s shadow. The real deal is the relationship. Keep your business relationships in good order, and you won’t have to worry so much about what’s on paper.

It’s sad but true that there are loads of scoundrels in business. Many of them hold titles like CEO, President, and CFO. There are indeed people out there who seem to care about nothing but money, and they will lie, cheat, and steal to get it. In recent years some of the more despicable ones have gotten themselves indicted (or are already behind bars). But there are plenty of others to whom the word honor has no meaning. For example, in the computer gaming industry, it isn’t unusual for large publishers to feign interest in certain games and string the developers along. They give the developer every indication that a deal is pending, but all the developer sees are delays and false verbal promises. In reality the publisher only wants to keep the game off the market to keep it from competing with one of their own titles; they hope to cause the developer to miss the next Christmas season or to run out of cash and cancel the title altogether. It happens. Business, especially the entertainment industry, is not for the timid.

6. Going against your intuition.

Intuition is just as important in business as it is in other settings. You’d be amazed at how many gigantic corporate deals are green-lighted or red-lighted because of some CEO’s gut feeling. While you might think that logic is the language of business, that’s far from reality. If you base all your business deals on hard logic and ignore your intuition, most likely you’ll be in for a world of hurt.

We humans aren’t very logical to begin with. We simply don’t have enough data to make truly logical decisions because business deals depend on human beings, and we don’t have a logical system for accurately predicting human behavior. Not being able to predict how other humans will behave is a pretty big gap in our logic. And intuition has to fill that gap. The real performance of human beings is what makes or breaks business deals. But to assume everyone will perform as expected is unrealistic in the extreme. No deal ever goes perfectly.

It’s hard to say no to a deal that seems juicy by the numbers when my gut is saying, “You’ll regret it,” but more often than not, I later see evidence my intuition was right all along. Sometimes I just get a bad read on someone, and then years later, several people I know are complaining about being ripped off by that person.

Intuition is a critical part of the decision-making process in business. Since business deals depend on relationships, you need to get a read on the other people involved in any deal you consider. If you get a bad read, walk away. If you get a good read, proceed with caution.

7. Being too formal.

Business is built on relationships. In some settings a certain degree of formality is appropriate, but in most business situations being too formal only gets in the way. Business relationships work best when there’s a decent human-to-human connection behind them.

It’s a mistake to be too formal even when looking to establish new business relationships. Human beings don’t want to build relationships with faceless corporations. They only want relationships with other human beings… sometimes animals too.

Treat your business relationships like friendships (or potential friendships). Formality puts up walls, and walls don’t foster good business relationships. No one is loyal to a wall… except the one in China.

Formality is boring and tedious. People want to enjoy their work. But if someone demonstrates they have a real personality and a good sense of humor, a connection is far more likely.

8. Sacrificing your personality quirks.

Being self-employed was a weighty responsibility, and other people were counting on me. Sink or swim, right?

It’s perfectly OK to be your own weird self and to inject your own unique spirit into your business, especially if you’re in your teens or 20s.  Ultimately you’ll enjoy your work much more if you attract the kinds of customers and partners that want to work with you for who you are — warts and all. Send the people who only want to work with androids to your corporate competitors. They deserve each other.

If other people can’t handle your weirdness, too bad for them. Focus your energy on the people who can.

9. Failing to focus on value creation.

It’s easy to fall into the trap of thinking that the purpose of a business is to make money. But the real purpose of a business is to create value. While it’s possible to make money in the short run without creating much value, in the long run it’s unsustainable. Even criminal organizations have to create value for someone. When you know your business is just sucking value away from others without providing anything in return, it will erode your self-esteem, and the business won’t be much fun to run.

Why does your business exist? It exists to provide some sort of value, both for you and your customers. The better you understand what value you’re trying to provide, the better you’ll be able to focus. Too often business owners aren’t clear on what value they’re trying to provide. They just sell stuff and hope for the best. That’s a lousy business model. The world doesn’t need more selling or more stuff. But it always needs and wants genuine value creation, and that’s where you should direct your efforts.

10. Failing to optimize.

Although value creation is essential to a sustainable business, it’s equally naive to assume you can simply focus on creating value, and the rest will take care of itself. You may build a business that provides good value but loses money. As a business owner, you need to find a way to deliver your value in a cost effective manner. Most likely your first attempt will be very suboptimal. You’ll waste too much time, money, and resources trying to produce and deliver your value. That’s OK though. Many businesses start out that way. Just don’t let yours stay that way.

Once you have a particular business process in place, pull it apart and re-optimize it from time to time. Look for ways to make it more efficient. Can you get it done in less time? At less cost? Can you do it less frequently? Can you outsource it? Can you dump the process altogether?

Don’t fall into the trap of using archaic methods for doing routine tasks that could be automated, including inventory management, billing, accounting, order processing, communications, and marketing. If you find yourself doing the same repetitive tasks month after month, make sure you put some effort into optimizing them. Not optimizing is like throwing time and money down the drain. It’s often much easier to save time and money than it is to create them.

It takes significant effort to build a successful business, but it’s also a tremendous growth experience. We know many people who have quit their jobs to run their own businesses. Many of them didn’t do as well as they’d hoped, but we don’t know any that regretted taking the plunge. There’s simply no substitute for holding the reins of your own destiny.

10 Ways to Improve Your Technical Skills

Strong technical skills can save you time, increase your income, and enable you to extract the most bang-per-buck from your technology purchases. Here are 10 things you can do to improve your technical skills, regardless of your current skill level:

1. Read technical books

One of the best ways to improve your technical skills is by reading books. As a teenager I used to buy computer books at the local bookstore. Today it’s far better to shop online because you can more easily find the true gems and avoid the lemons. Visit, search for a book on a particular topic you wish to learn, and check the reviews and ratings. Look for books with at least 4 out of 5 stars (I usually don’t buy any with less than 4.5 stars). Take advantage of Amazon’s browsing features to quickly find the best books in any field.

Even when you opt to buy technical books locally (such as for an easy return if it doesn’t suit you), you can still check the online reviews to rule out the bad ones. Take your time previewing books in the bookstore or online, especially if cost is a concern. If you can’t understand the first chapter, don’t waste your money.

Although technical books can be expensive and are often padded with lengthy code listings and other fluff, the good ones make up for it with clearly organized, well-edited, well-indexed content. Books in their second edition or later are a great choice because they’ve already been through at least one round of testing in the marketplace.

2. Read online tutorials

The advantage of online tutorials over books is that they’re accessible, timely, and of course free. The disadvantage is that they usually aren’t professionally edited, which can leave them lacking in completeness and/or clarity. However, they often sport other features like abundant interlinking, user comments, and interactive demos. Sometimes the comments are better than the original information, since they can contain lots of additional tips and suggestions. I find this is particularly true of reference sites like (a reference site for PHP).

My favorite way of finding online tutorials is to use Google. If I need a CSS tutorial, I’ll search on CSS tutorial. I usually find something halfway decent in the top 5 results this way. Other variations that work well include how to XXX, XXX reference, and simply XXX, where XXX is whatever you wish to learn.

3. Hang out with geeks

If you spend enough time with technical people, some of their knowledge will rub off on you. Even geeks learn from other geeks, but if you aren’t much of a geek yourself, a great way to accelerate the development of your technical skills is to join a local computer club or users group. Use APCUG (Association of Personal Computer User Groups) and/or WUGNET (Windows Users Group Network) to find a group near you. Such groups usually welcome new members of any skill level. Contact one of them and attend a meeting as a guest to see if you like it.

Once you join a computer club or other geek-ridden association, volunteering is a great way to make fast friends. These nonprofit associations are frequently in need of volunteers for committee and project work; even if your technical skills are weak, they often just need raw manpower. When I decided to become active in the Association of Shareware Professionals during the late 90s, I put a lot of energy into volunteering. I wrote articles for their newsletter and served a year each as vice-president and president of the association. It was a lot of work to be sure, but I learned a great deal from working closely with the other volunteers. Many of those lessons have proven invaluable in running this personal development web site. In fact, writing those articles, which gradually became less technical and more motivational, contributed to my 2004 career switch from software development to personal development.

4. Subscribe to technical magazines

Technical magazines used to be one of my favorite outlets for learning, but I cancelled all my magazine subscriptions years ago. During the early 80s, I spent many long hours typing in BASIC programs from Family Computing and similar magazines (it took me a long time because I hadn’t yet learned to type). While I think print magazines are less useful today — the same info can often be found online for free – they’re an inexpensive way to improve your general technical skills, especially if you’re unlikely to push yourself in other ways. The professional editing and experienced writers are a big plus.

5. Take classes

If group learning is your thing, look for college extension courses and other classroom and workshop offerings in your area. Periodically I get catalogs in the mail from UNLV, and while I lived in Los Angeles, I received them from UCLA, Learning Tree University, Pierce College, Santa Monica College, and others.

A key advantage of classroom learning is the opportunity to interact with an experienced educator. Teachers with decades of experience know plenty of educational distinctions you won’t find in books or online tutorials. And unlike many technical writers, they know how to teach.

If you really want the degree, consider going to college and majoring in a technical subject. I earned Bachelor of Science degrees in Computer Science and Mathematics. But given my path after college, these degrees were unnecessary busywork rather than practical skill building. I started learning to program when I was 10 years old, and while I did pick up some additional distinctions in college, it would have been a better use of my time to skip college altogether and learn the info on my own. In the long run, I found my math and physics classes far more useful than my computer science ones — my knowledge of the former didn’t become obsolete so rapidly.

6. Create your own web site

Long-term readers of this site know I’m a big fan of experiential learning. Setting a goal to create a basic web site is a great way to learn practical skills like HTML and CSS. When you have a compelling reason to learn, your goals will accelerate your learning, and you’ll learn with a focus on practical application.

I learned HTML in 1995 when I wanted to make my first web site. I created the site as I learned the HTML language, gradually evolving it from the basic “Hello, world” example. Later I learned CSS, PHP, MySQL, and RSS, so I could do more interesting things than plain vanilla HTML would allow.

Erin learned web programming in the same manner. She wasn’t a technically adept person when we first met, but attempting to create her first web site got her in motion. Eventually she started a web consulting practice, creating dozens of small business web sites. She also built her own sites including and and generates most of her income from them. So the simple decision to make some basic web sites eventually led to generating abundant sustainable income from online businesses. We learned by doing.

7. Build your own PC

If you want to develop better hardware skills, a great project is to build your own PC from scratch. I did this in 2004 and found it very rewarding. You’ll save money, learn a lot about how your computer works, and end up with a nicely customized machine that you can easily upgrade. After all the components arrived, it took me about a day to assemble everything and install the necessary software. This may or may not be a good use of your time, but I found it worthwhile for the experience. I still use this same PC today, and it’s plenty fast enough for my needs.

A detailed, novice-friendly, step-by-step tutorial I used can be found at My Super PC. I used to find the best online prices for all the components, which beat local retail prices by about 30% on average. I remember buying several components from

If this project makes you nervous, I wouldn’t recommend it. But if you feel comfortable researching and selecting components and carefully following assembly directions, it’s a rewarding way to spend a day.

8. Embrace a variety of software

General software productivity improves with breadth of experience, so use many different software programs (online or offline) to improve your overall ability to get things done through software. I started using software in 1981, and such broad experience makes it easy for me to learn new applications quickly. I usually dive in and start using them without going through the tutorials or reading the manual. This saves me a lot of time and makes it easier for me to justify the effort of installing new software and upgrading old software.

When Erin has trouble figuring out how to do something in one of her applications, I’m often able to solve her problem in seconds even if I’m not familiar with the program. After using hundreds of different software programs, you eventually learn to think like an interface programmer, so you intuit how certain features are likely to be implemented. Think of it as technical intuition.

Branch out from software myopia, and experience the full richness of using many different interfaces. You’ll learn a lot about interface design from image editing programs, programming tools, and of course computer games. The greater the variety of interfaces you experience, the faster you’ll be able to learn and master each new program you use.

9. Learn to program

Programming is the art of instructing a computer to perform a task. The key to accomplishing this feat is learning to think like a computer. Programming is one of the most mentally challenging tasks a human being can perform, but nothing compares to the satisfaction of engineering a piece of code to solve a specific problem. Ask any programmer. 🙂

I learned to program in BASIC at age 10 and later went on to learn over a dozen programming languages. The challenge of developing my logic and analytical skills at such a young age has served me well my entire life, even in seemingly non-technical pursuits.

For example, I tackle many personal development problems with a programmer’s mindset. How do we define the problem? What are the possible solutions? Which solution best meets our constraints? What are the instruction steps to implement the solution? Does the solution produce the desired output? Can we make this solution more elegant or optimal? I’ve taken the common programming process of requirements gathering, architecture, design, coding, debugging, and optimization and applied it to personal development.

While humans certainly aren’t as precise or predictable as machines — we have major compatibility issues, sometimes even with ourselves — a programmer’s mindset can generate effective solutions to very human problems. Intuition is a big factor in both personal development and programming, but I like that there’s a structured fallback process that works in both fields. It’s much harder to use this process in personal development though because we know how a computer thinks, but we’re still figuring out how humans think.

10. Marry a geek

Your final salvation on the road to geekdom is to – gasp – marry a geek. I shudder to think of the technical purgatory Erin would be wallowing in right now if we’d never met. I almost cried when I first saw her slogging away on a 10″ monochrome Mac in 1994, and I soon gave her a pity upgrade to a PC with a 14″ SVGA monitor. I told her that if I die first, she’ll need to marry another geek right away – an easy task for someone with her social skills.

If you aren’t a geek yourself, then do what you can to recruit one into your family. If that’s too much to ask, at least find a geek you can befriend. They can really save you in a jam, and they’ll keep you from falling too far behind the rest of the world.

Be kind to your geek friends, and offer them fair value in exchange for their help. Creative trades are often welcome. For example, Erin and I are both inept when it comes to fashion and home decorating (my colorblindness certainly doesn’t help), so someone who can teach us how to dress and buy furniture that matches would be a welcome ally. Right now the best we’ve got is our six-year old daughter. She’s very sure of herself, but I’m not sure her advice can be trusted.

Technical skills are of major importance these days, and the technical have-nots are more estranged than ever.

10 Reasons to Develop Your Technical Skills

Solid technical skills are becoming increasingly important, and I don’t see that changing any time soon. While computers have become easier to use in many ways, the leading edge is more complicated than ever. This complexity scares many people away from developing their technical skills, but let’s consider some of the reasons you may want to go beyond the basics.

Here are some of the advantages strong technical skills can offer you:

1. Enjoy significantly higher paying work.

Whether you’re employed or self-employed, strong technical skills allow you to leverage technology to the hilt, and that leverage pays. The better you understand the technology you use, the more value you can efficiently extract from it. People gladly open their wallets to pay those with in-demand technical skills.

2. Save money.

You’ll save money every time you can solve a technical problem on your own instead of having to hire someone at a high hourly rate. This can add up to substantial savings over time.

3. Save time.

You’ll save time by solving technical problems quickly instead of scratching your head in confusion. There are many technical problems that baffle novices but which require only a quick fix from someone with adequate technical skills.

4. Prevent problems.

You’ll prevent problems before they occur by intelligently maintaining and upgrading your technology. Even a simple skill like keeping your video and sound drivers up-to-date can prevent compatibility problems down the road, especially if you play computer games.

5. Reduce frustration.

Technology isn’t particularly frustrating if you understand how it works. A lack of understanding is frustrating. If something breaks, and you know how and why it broke, then it’s just a fact to be dealt with rather than an act of divine cruelty.

6. Make intelligent technology purchases.

I don’t know many geeks who buy their computers at retail stores. It’s a lot smarter to buy online if you know what to look for. You’ll get better value, higher quality components, and more control over the final product.

Decent technical knowledge can help you target those sweet spots with all your technology purchases, so you get the best bang per buck.

7. Empower yourself.

Today it’s almost ridiculous how much technology can do. You can use your computer to manage your whole life now, including your finances, your calendar, and your entertainment. Knowing how to use technology can add tremendous richness to your life. But if you lack the technical skills, you’ll probably find it way too complicated to extract this value in a reasonable amount of time.

8. Access information efficiently.

Whenever you want to know something now, you can go online and get the information in seconds. Sites like Google, Wikipedia, and WikiHow truly place information at your fingertips, but it still takes a bit of technical skill to craft intelligent queries when you’re searching for something obscure.

Need to buy a new suit? Want to see what movies are playing near you? Want to become an early riser? If someone has figured it out, it’s probably online. With an internet connection at hand, we all become walking Wikipedias.

9. Earn money online.

This is one of the coolest benefits of technical know-how. With the right technical skills, you can build your own income-generating web site. Your computer (or some online server) will work tirelessly to make you money 24/7.

10. Feel more confident and comfortable with technology.

Competence builds confidence. As you develop your technical skills, you’ll feel more comfortable with all forms of technology. This will encourage you to branch out and leverage technology even more. You can listen to audio books on your portable MP3 player, take pictures with your digital camera, and so on. You’ll feel in control of technology instead of intimidated by it.

The more technical experience you gain, the faster you’ll adapt to new technology. You may fall behind the curve at some point, but you’ll quickly catch up with a few days’ research.

Like it or not, strong technical skills are of major importance today. Don’t let yourself be caught on the wrong side of the technology fence.

Top Ten Errors Java Programmers do

Here’s my top ten list of errors that we all seem to make at one time or another, how to spot them, and how to fix them.

10. Accessing non-static member variables from static methods (such as main)

Many programmers, particularly when first introduced to Java, have problems with accessing member variables from their main method. The method signature for main is marked static – meaning that we don’t need to create an instance of the class to invoke the main method. For example, a Java Virtual Machine (JVM) could call the class MyApplication like this :-

MyApplication.main ( command_line_args );

This means, however, that there isn’t an instance of MyApplication – it doesn’t have any member variables to access! Take for example the following application, which will generate a compiler error message.

public class StaticDemo
public String my_member_variable = “somedata”;

public static void main (String args[])
// Access a non-static member from static method
System.out.println (”This generates a compiler error” +
my_member_variable );


If you want to access its member variables from a non-static method (like main), you must create an instance of the object. Here’s a simple example of how to correctly write code to access non-static member variables, by first creating an instance of the object.

public class NonStaticDemo
public String my_member_variable = “somedata”;

public static void main (String args[])
NonStaticDemo demo = new NonStaticDemo();

// Access member variable of demo
System.out.println (”This WON’T generate an error” +
demo.my_member_variable );

9. Mistyping the name of a method when overriding

Overriding allows programmers to replace a method’s implementation with new code. Overriding is a handy feature, and most OO programmers make heavy use of it. If you use the AWT 1.1 event handling model, you’ll often override listener implementations to provide custom functionality. One easy trap to fall into with overriding, is to mistype the method name. If you mistype the name, you’re no longer overriding a method – you’re creating an entirely new method, but with the same parameter and return type.

public class MyWindowListener extends WindowAdapter {
// This should be WindowClosed
public void WindowClose(WindowEvent e) {
// Exit when user closes window


Compilers won’t pick up on this one, and the problem can be quite frustrating to detect. In the past, I’ve looked at a method, believed that it was being called, and taken ages to spot the problem. The symptom of this error will be that your code isn’t being called, or you think the method has skipped over its code. The only way to ever be certain is to add a println statement, to record a message in a log file, or to use good trace debugger (like Visual J++ or Borland JBuilder) and step through line by line. If your method still isn’t being called, then it’s likely you’ve mistyped the name.

8. Comparison assignment ( = rather than == )

This is an easy error to make. If you’re used other languages before, such as Pascal, you’ll realize just how poor a choice this was by the language’s designers. In Pascal, for example, we use the := operator for assignment, and leave = for comparison. This looks like a throwback to C/C++, from which Java draws its roots.

Fortunately, even if you don’t spot this one by looking at code on the screen, your compiler will. Most commonly, it will report an error message like this : “Can’t convert xxx to boolean”, where xxx is a Java type that you’re assigning instead of comparing.

7. Comparing two objects ( == instead of .equals)

When we use the == operator, we are actually comparing two object references, to see if they point to the same object. We cannot compare, for example, two strings for equality, using the == operator. We must instead use the .equals method, which is a method inherited by all classes from java.lang.Object.

Here’s the correct way to compare two strings.

String abc = “abc”; String def = “def”;

// Bad way
if ( (abc + def) == “abcdef” )

// Good way
if ( (abc + def).equals(”abcdef”) )

6. Confusion over passing by value, and passing by reference

This can be a frustrating problem to diagnose, because when you look at the code, you might be sure that its passing by reference, but find that its actually being passed by value. Java uses both, so you need to understand when you’re passing by value, and when you’re passing by reference.

When you pass a primitive data type, such as a char, int, float, or double, to a function then you are passing by value. That means that a copy of the data type is duplicated, and passed to the function. If the function chooses to modify that value, it will be modifying the copy only. Once the function finishes, and control is returned to the returning function, the “real” variable will be untouched, and no changes will have been saved. If you need to modify a primitive data type, make it a return value for a function, or wrap it inside an object.

When you pass a Java object, such as an array, a vector, or a string, to a function then you are passing by reference. Yes – a String is actually an object, not a primitive data type. So that means that if you pass an object to a function, you are passing a reference to it, not a duplicate. Any changes you make to the object’s member variables will be permanent – which can be either good or bad, depending on whether this was what you intended.

On a side note, since String contains no methods to modify its contents, you might as well be passing by value.

5. Writing blank exception handlers

I know it’s very tempting to write blank exception handlers, and to just ignore errors. But if you run into problems, and haven’t written any error messages, it becomes almost impossible to find out the cause of the error. Even the simplest exception handler can be of benefit. For example, put a try { .. } catch Exception around your code, to catch ANY type of exception, and print out the message. You don’t need to write a custom handler for every exception (though this is still good programming practice). Don’t ever leave it blank, or you won’t know what’s happening.

For example

public static void main(String args[])
try {
// Your code goes here..
catch (Exception e)
System.out.println (”Err – ” + e );

4. Forgetting that Java is zero-indexed

If you’ve come from a C/C++ background, you may not find this quite as much a problem as those who have used other languages. In Java, arrays are zero-indexed, meaning that the first element’s index is actually 0. Confused? Let’s look at a quick example.

// Create an array of three strings
String[] strArray = new String[3];

// First element’s index is actually 0
strArray[0] = “First string”;

// Second element’s index is actually 1

strArray[1] = “Second string”;

// Final element’s index is actually 2
strArray[2] = “Third and final string”;

In this example, we have an array of three strings, but to access elements of the array we actually subtract one. Now, if we were to try and access strArray[3], we’d be accessing the fourth element. This will case an ArrayOutOfBoundsException to be thrown – the most obvious sign of forgetting the zero-indexing rule.

Other areas where zero-indexing can get you into trouble is with strings. Suppose you wanted to get a character at a particular offset within a string. Using the String.charAt(int) function you can look this information up – but under Java, the String class is also zero-indexed. That means than the first character is at offset 0, and second at offset 1. You can run into some very frustrating problems unless you are aware of this – particularly if you write applications with heavy string processing. You can be working on the wrong character, and also throw exceptions at run-time. Just like the ArrayOutOfBoundsException, there is a string equivalent. Accessing beyond the bounds of a String will cause a StringIndexOutOfBoundsException to be thrown, as demonstrated by this example.

public class StrDemo
public static void main (String args[])
String abc = “abc”;

System.out.println (”Char at offset 0 : ” + abc.charAt(0) );

System.out.println (”Char at offset 1 : ” + abc.charAt(1) );
System.out.println (”Char at offset 2 : ” + abc.charAt(2) );

// This line should throw a StringIndexOutOfBoundsException

System.out.println (”Char at offset 3 : ” + abc.charAt(3) );

Note too, that zero-indexing doesn’t just apply to arrays, or to Strings. Other parts of Java are also indexed, but not always consistently. The java.util.Date, and java.util.Calendar classes start their months with 0, but days start normally with 1. This problem is demonstrated by the following application.

import java.util.Date;
import java.util.Calendar;

public class ZeroIndexedDate
public static void main (String args[])
// Get today’s date

Date today = new Date();

// Print return value of getMonth
System.out.println (”Date.getMonth() returns : ” +

// Get today’s date using a Calendar

Calendar rightNow = Calendar.getInstance();

// Print return value of get ( Calendar.MONTH )
System.out.println (”Calendar.get (month) returns : ” +
rightNow.get ( Calendar.MONTH ));


Zero-indexing is only a problem if you don’t realize that its occurring. If you think you’re running into a problem, always consult your API documentation.

3. Preventing concurrent access to shared variables by threads

When writing multi-threaded applications, many programmers (myself included) often cut corners, and leave their applications and applets vulnerable to thread conflicts. When two or more threads access the same data concurrently, there exists the possibility (and Murphy’s law holding, the probability) that two threads will access or modify the same data at the same time. Don’t be fooled into thinking that such problems won’t occur on single-threaded processors. While accessing some data (performing a read), your thread may be suspended, and another thread scheduled. It writes its data, which is then overwritten when the first thread makes its changes.

Such problems are not just limited to multi-threaded applications or applets. If you write Java APIs, or JavaBeans, then your code may not be thread-safe. Even if you never write a single application that uses threads, people that use your code WILL. For the sanity of others, if not yourself, you should always take precautions to prevent concurrent access to shared data.

How can this problem be solved? The simplest method is to make your variables private (but you do that already, right?) and to use synchronized accessor methods. Accessor methods allow access to private member variables, but in a controlled manner. Take the following accessor methods, which provide a safe way to change the value of a counter.

public class MyCounter
private int count = 0; // count starts at zero

public synchronized void setCount(int amount)
count = amount;

public synchronized int getCount()

return count;

2. Capitalization errors

This is one of the most frequent errors that we all make. It’s so simple to do, and sometimes one can look at an uncapitalized variable or method and still not spot the problem. I myself have often been puzzled by these errors, because I recognize that the method or variable does exist, but don’t spot the lack of capitalization.

While there’s no silver bullet for detecting this error, you can easily train yourself to make less of them. There’s a very simple trick you can learn :-

* all methods and member variables in the Java API begin with lowercase letters
* all methods and member variables use capitalization where a new word begins e.g – getDoubleValue()

If you use this pattern for all of your member variables and classes, and then make a conscious effort to get it right, you can gradually reduce the number of mistakes you’ll make. It may take a while, but it can save some serious head scratching in the future.
(drum roll)
And the number one error that Java programmers make !!!!!

1. Null pointers!

Null pointers are one of the most common errors that Java programmers make. Compilers can’t check this one for you – it will only surface at runtime, and if you don’t discover it, your users certainly will.

When an attempt to access an object is made, and the reference to that object is null, a NullPointerException will be thrown. The cause of null pointers can be varied, but generally it means that either you haven’t initialized an object, or you haven’t checked the return value of a function.

Many functions return null to indicate an error condition – but unless you check your return values, you’ll never know what’s happening. Since the cause is an error condition, normal testing may not pick it up – which means that your users will end up discovering the problem for you. If the API function indicates that null may be returned, be sure to check this before using the object reference!

Another cause is where your initialization has been sloppy, or where it is conditional. For example, examine the following code, and see if you can spot the problem.

public static void main(String args[])
// Accept up to 3 parameters
String[] list = new String[3];

int index = 0;

while ( (index < args.length) && ( index < 3 ) )

list[index++] = args[index];

// Check all the parameters
for (int i = 0; i < list.length; i++)
if (list[i].equals “-help”)
// ………
if (list[i].equals “-cp”)

// ………
// else …..

This code (while a contrived example), shows a common mistake. Under some circumstances, where the user enters three or more parameters, the code will run fine. If no parameters are entered, you’ll get a NullPointerException at runtime. Sometimes your variables (the array of strings) will be initialized, and other times they won’t. One easy solution is to check BEFORE you attempt to access a variable in an array that it is not equal to null.

Which Shopping Cart Should I use?

Which Shopping Cart Should I use? This is a common question that we get when clients call. There are so many shopping carts out there it is hard to know which one to use for your web site.

It is important to know when selecting your shopping cart what features you need. All the shopping carts below feature the following:

* Customer management
* Product management
* Variety of payment and shipping modules
* Order receipt emails
* Ability to use SSL secure layers for ordering process

However the shopping carts vary when it comes to:

* Time it takes to modify the cart to look like a current web design
* WYSIWYG ability to modify product descriptions using different fonts, colors, etc.
* Ability to import/export from Excel spreadsheet
* Wholesale/Reseller Pricing

In this review we will be going over PHP/MySQL shopping carts that run both Linux and Windows servers. We will not be reviewing pay-per-month shopping carts. We feel these offer less value because they have expensive monthly fees. Also – they usually do not allow access to the source code of the system or much customization of the shopping cart. The following shopping carts below are open-source meaning that you can modify the source code and customize the shopping cart to your needs.

Magento is one of the newer shopping carts on the block but has already attracted a large following. The coding is based on the latest PHP 5 object oriented coding standards and the Zend framework.

1. Varian the company who backs the cart is very active in updating the code and fixing bugs
2. Multi-Store Capable
3. Nice default template

1. Heavily layered and overly complicated coding style and thousands of files requires a lot of time to learn and do customizations. Estimate about 2 – 5 x more for your budget for customizing it vs. other carts
2. Right now the technical documentation is very limited, making it difficult to customize and modify the programming of Magento beyond doing graphical changes.
3. Runs fairly slow. Plan on spending at least $25/month for a 1000 product store, or $50 – $100 month for stores with over that.

Oscommerce MS 2.2 – The Cart That Started Them All
Oscommerce is the basis for both Zen Cart and CRE Loaded. As such is it is simpler and does not have all of the contributions already added that Zen Cart and CRE Loaded do. It runs well though and is a good back to basics shopping cart.

1. Has the most available number of contributions and modifications
2. Recent security update brings it up to date with MySQL 5 and PHP 5

Disadvantages –
1. It can take a lot of time and money to install all the contributions you want (add-ons)
2. No graphic template system meaning it is harder to modify the design

CRE Loaded Chain Reaction Edition of Oscommerce
CRE Loaded is like Oscommerce but with many more contributions installed. Some of the nice contributions it has are Easy Populate which lets you populate your database from an Excel file, coupon codes, administrator access levels, template system, and an affiliate manager. CRE Loaded also has one of the Oscommerce templating systems installed which allows you to more easily integrate a design into the system and control which information boxes show on the left and right columns.

1. Many contributions from Oscommerce already installed

Disadvantages –
1. Contributions from can be more difficult to install, but CRE Loaded has many of its own already converted
2. Buggy code for some modules like multi vendor shipping

Additional Information
CRE Loaded comes in 3 verisons. The regular version is free. The Pro version adds better product attribute support and credit card encryption, and the B2B version adds seperate pricing level support.

Zen Cart – The Art of E-commerce
Zen Cart has a very nice wide array of features based on Oscommerce but has gone its own path. You can not install contributions directly from the Oscommerce web site onto Zen Cart. Some of the nice features include product attributes managers, template system, html editor for regular web page contents, built in coupon code system, ability to select what credit cards you accept, and more. An issue with Zen Cart right now is the Easy Populate contribution which would let you import products from an Excel sheet does not work yet. So if you need this feature we recommend the other shopping carts.

1. No licensing fees
2. Stable
3. Many contributions from Oscommerce already installed

Disadvantages –
1. not possible to use Oscommerce contributions, they must be converted to Zen Cart
2. Admin interface is a little messy in certain areas because there are so many contributions installed

X-Cart is a commercial package, but one of the most competitively priced and easy to modify.

1. Commercially supported and has very few if any bugs
2. Uses Smarty Templates system which many programmers like to work with for laying out the web site

1. Licensing fees for system and some add-on modules

OSC Max is an excellent version of Oscommerce that has many useful contributions installed. It is just as easy to use in the admin as the default Oscommerce installation.

1. No licensing fees
2. The contributions installed are very useful
3. Has wholesale/Reseller pricing module already installed
4. Well-documented

1. Personal preference – I don’t like the mopics image module, you have to separately upload small and large images, but easily fixed by installing on the fly thumbnails module

Joomla & Virtuemart
Installing and configuring Joomla & Virtuemart together was a snap. On the Virtuemart website they have a combined installer that installs Virtuemart with Joomla. This is the solution you would want if you have to have your CMS (Content Management System) combined with your shopping cart. Joomla we feel is the best CMS out there, but Virtuemart on the other hand is not the best shopping cart system. It is not a bad one though, it is just not as fully featured as the other solutions.

Overall we would say that Virtuemart is about equal with default Oscommerce, but not the loaded versions of Oscommerce: Zen Cart & CRE Loaded.

1. Easy to install
2. Combines well with the best CMS Joomla
3. Has the basic shopping cart features

1. Lacks a lot of high-end shopping cart features
2. Not as many add-on modules available

Shopping Cart Feature Comparison Chart
This feature comparison chart compares the out of the box features of each cart. Sometimes a cart will have an available add-on module to install the feature listed.

Final Thoughts
If you decide to go with an Oscommerce based shopping cart, we recommend that you start with one of the loaded versions – Zencart, CRE Loaded, or OSCmax – in order to save you lots of money on installing additional modules to the plain Oscommerce version. You can then use your development money to put in your own custom modifications, design, etc. rather than installing all of the basics.