Go read this article if you want to see some code.
1. Packages/namespaces : no more 152 characters prefixes to ensure uniqueness
Packages/namespaces (packages = java, namespaces = .NET) are not the greatest thing since slice bread (did you forget about kool-aid?) but they are the handiest solution to avoid methods, objects or constants to have the same name. I give you a simple example.
I have two methods :
- one that truncates a string of its last character (who wants to do that???)
- one that truncates a number of its decimals
I would write these methods :
The problem is that they have both the same signature
With packages/namespaces, I could have the following signatures to differenciate them.
Of course, I could have done it a million ways (extending String and Number objects, give them different names, etc) but for the purpose of the demonstration, I have done it that way.
2. Work locally : forget about global variables circa 1987
Global variables are prohibited since 1992 by GVIP (G
3. Ajax : be a part of web2.0
You want to be the next golden-boy of the web2.0 era? Better start using Ajax
now. But wait! Ajax is a mess with all of those callback, failure and timeout functions here and there. Will it stop me from being a billionaire?
4. Inheritance : for greater powers
I wouldn't recommend you to use inheritance just to impress women. Inheritance is far too complex for its benefits (you won't get more women) unless you have a very complex application. And by complex, I mean more complex than building a space shuttle