Reality is a perception. Perceptions are not always based on facts, and are strongly influenced by illusions. Inquisitiveness is hence indispensable

Monday, June 8, 2009

Wailing is our Birth Right, ... right?

If you happen to read dilbert, you would appreciate working on software (no sarcasm). Dilbert exaggerates the ignorance of the non-techie manager, claims to throw light on the self-righteous attitude and ineptitude of human beings. Dilbert in fact represents every thing a typical slashdotter/digger represents. I hate dilbert for that, but I love much more for being that. My geekiness quotient may not be as high, but nerd-meter rarely fails to tune to the frequencies of the nerd stations.

Most folks who enter an organisation (barring the freshers) have a good amount of apprehension, once you get them talking, you will find that almost everyone has some thing or other to say. Most of them crib about their boss/collegues, and other choose to complain about of the following A.) Company B.) Work/Work culture C.) Compensation.

To be fair to the management, Team building is not an easy exercise. Team is more than sum of the individuals. Most workers agree with this, but their egos don't. This is the core cause of resentment. Human tendency to compare with peers always leads them to confusion. To make a judicious decision, one needs to think of the pros-cons and evaluate them. Unfortunately, we don't do that when giving our commentary (free-speech any one). Life would have been more simpler and logical if introspection was built into our gene code. Humans are not logical, as Jim Kirk correctly summarised.

A greek philosopher from Athens, was once found squatting besides the citadels' entrance. A passerby came to him asking how the people of city would behave. The wise man in turn asked the stranger, where he came from and how the people over there treated him. The stranger told him that he was from sparta and was full of praise for spartans. The wise man told him that the athens would be no different. Some time passed by and another stranger came to him with a similar inquiry. The stranger many qualms and complaints about the sparta. The wise man's reply was still the same.

Thursday, April 30, 2009

Puzzles and more physics

To cut the long story short, visit http://www.faqs.org/faqs/puzzles/archive/physics/

Wednesday, April 22, 2009

2^6 things you wish you did!

Found this on digg, the original source seems to be down (digg effect?)

This is Google's cache of http://laptoplogic.com/resources/64-things-every-geek-should-know. It is a snapshot of the page as it appeared on 21 Apr 2009 10:39:57 GMT. The current page could have changed in the meantime. Learn more

64 Things Every Geek Should Know

April 21, 2009 at 03:04:28 AM, by Blair Mathis



If you consider yourself a geek, or aspire to the honor of geekhood, here's an essential checklist of must-have geek skills.

The term 'geek', once used to label a circus freak, has morphed in meaning over the years. What was once an unusual profession transferred into a word indicating social awkwardness. As time has gone on, the word has yet again morphed to indicate a new type of individual: someone who is obsessive over one (or more) particular subjects, whether it be science, photography, electronics, computers, media, or any other field. A geek is one who isn't satisfied knowing only the surface facts, but instead has a visceral desire to learn everything possible about a particular subject.

A techie geek is usually one who knows a little about everything, and is thus the person family and friends turn to whenever they have a question. If you're that type of person and are looking for a few extra skills to pick up, or if you're a newbie aiming to get a handhold on the honor that is geekhood, read on to find out what skills you need to know.

1. The Meaning of Technical Acronyms
USB - Universal Serial Bus
GPU - Graphics Processing Unit
CPU - Central Processing Unit
SATA - Serial ATA
HTML - Hyper-text Markup Language
HTTP - Hypertext Transfer Protocol
FTP - File Transfer Protocol
P2P - Person to Person data sharing
2. How to Reset RAM
If you rolled your eyes here, that is a good thing. If not, you have many things to learn, young padawan. It's amazing how few people know how to do this. If you're unsure, hit up the link below to find out how:

http://www.yousaytoo.com/sudjarwo/how-to-reset-ram-in-a-computer/29133
3. Identify Keyloggers

Internet cafes are the most likely place you'll find them, followed by library, perhaps, and maybe even you own house if you've some unscrupulous friends/family. Identity theft groups warn about keyloggers and advocate checking out the keyboard yourself before continuing. Can you identify a keylogger, however, if one is plugged into the back of the system?

Here's what one looks like:

Hit up this link for excellent info on keyloggers on public computers and how to protect yourself:

, http://www.ghacks.net/2007/06/28/how-to-defeat-most-keyloggers-on-public-computers/
4. Surf the Web Anonymously
We won't make any assumptions about why you may need this particular skill, but the fact remains that every geek should know how to traverse the Internet with the highest amount of security possible.

Aside from the safest method--which is using a connection that is not yours--you will need the ultimate in proxies...Tor. Tor is an onion-routing system which makes it 'impossible' for someone to find out who you actually are.

5. Bypass a Computer Password on All Major Operating Systems
Obviously you shouldn't use this to gain unlawful access to a computer. If you're a geek, however, you'll eventually end up in a situation where someone forgets their password, you acquire a machine with an operating system you cannot access, or similar situation.

See this tutorial for info on how to bypass the password on the three major operating systems: Windows, Mac, and Linux.

http://www.joetech.com/2009/01/29/how-to-crack-the-account-password-on-any-operating-system/
6. Find a Users IP Address on AIM
Knowing someones IP address is actually pretty useless in this case, but most people don't realize that. If someone is harassing you via AIM and you can't get them to stop, discovering their IP and sending it to them--with a nicely worded threat of law enforcement involvement should they not stop--is likely enough to send them scamping away with tail between legs.

http://www.elitehackers.info/forums/archive/index.php/t-2827.html
7. Hide a File Behind a JPEG
So you need a nice spot to hide your blackmail personal files. You could, of course, bury them deeply within a series of random, useless folders, but there's always the chance of them being discovered. A password protected RAR is the best choice, but it's a bit obvious despite the most boring title you could give it.

A sneaky person would hide the important file behind a completely random and boring family reunion photo, where no person in their right mind would shift through.

http://www.online-tech-tips.com/computer-tips/hide-file-in-picture/
8. Crack a Wifi Password
This is one of those things you don't need to do (hopefully), but that you still need to know just for the sake of knowledge. A strong WPA password is very secure, but most people don't want to bother learning a convoluted series of letters, numbers, and symbols, instead opting for random everyday words.

A good overall tutorial on wifi and cracking can be found here: http://docs.lucidinteractive.ca/index.php/Cracking_WEP_and_WPA_Wireless_Networks

9. Monitor Network Traffic

The Internet is a vast place with a bit of everything. Whether you're curious about what your roommate is downloading, your kid is getting into, or any leeches living around you who've unscrupulously breached your wifi, knowing how to analyze network traffic is an invaluable skill.

Here is a list of dozens of network analyzers, as well as some general info to get you started: http://www.slac.stanford.edu/xorg/nmtf/nmtf-tools.html

10. Recover Master Boot Record
A virus or other problem can lead to an MBR error, which will make it impossible to access install. Many users would simply become frustrated and reinstall, but not you! Every geek should know how to recover the master book record.

Here is an excellent guide to get started: http://www.ntfs.com/mbr-damaged.htm

11. Retrieve Data off Hard Drive
There will come some point in your life when a hard drive craps out sans warning. It could be due to a number of reasons--physical damage, file corruption, etc. There are computer service centers that would be happy to extract the data for a (hefty) fee; a true geek would be the one working at center, not taking his or her drive there.

To find out how to retrieve data off a damaged hard drive, read here: http://laptoplogic.com/resources/5-ways-to-retrieve-data-off-a-crashed-hard-drive

12. Load Rockbox onto an MP3 Player
The firmware that comes on your average mp3 player is intended for those who are scared of advanced features; often, the only audio settings available are a few prearranged EQs. If you're an audiophile--or simply frustrated with the lack of control over your music settings--Rockbox is the firmware for you. Open source and free, it can be installed on several different types of players and enables full control over what you listen to.

http://rockbox.org
13. Unbrick a Smartphone
No geek can resist the allure of flashing the newest beta firmware onto their shiny smartphone. The byproduct of that is sometimes a bricked phone, which would leave many sobbing into their pillow at night. To avoid rendering your $400 gadget into a door stopper, learn the fine art of unbricking and then flash away.

As the method used to fix a phone will vary, this is the best place to start looking for answers: http://www.howardforums.com/

14. Replace a Laptop Keyboard
Keyboards get gummy after awhile. If you use yours a lot (aka: all day), then you probably eat over it at some point. Crumbs get into the keys and things are sticking, and before you know it, you need a new keyboard.

http://www.refurbished-laptop-guide.com/how-to-remove-a-laptop-keyboard.html

15. Rip Streaming Videos
Streaming videos are officially in vogue. We're not going to make any assumptions about what type of videos you are streaming and may want to keep, but no matter what it is, any geek could rip them while sipping a Red Bull and watching the latest episode of BSG.

Here's a hint to get you started: http://applian.com/download-videos/

16. Strip Windows DRM
DRM is incredibly annoying. With many online stores now offering DRM-free mp3 audio files, it would seem it's not as big of an issue as it used to be. That is not not the case, however, with all videos bearing a DRM as well as music of a higher-quality than MP3.

Stripping Windows DRM is not legal. If you're a geek, your probably don't care: http://undrm.info/remove-DRM-protection/FairUse4WM-freeware-DRM-removal-Windows-software-Strip-copy-protection-from-WMV-ASF-WMA-Windows-Media-Player.htm

17. Homebrew Hack Game Systems
Gaming consoles are notorious for having features you can't use simply because the manufacturer decided to lock them down. As a geek, you can't just be satisfied with the features they decided to give you. No, you have to crack that case open and take a peek inside. Every geek should know how to homebrew hack their system and unlock it's full potential.

18. Find a Website IP Address Without Web/Command Prompt Access
Some school admins think they're being sneaky when they lock down the command prompt and block all major IP search websites and block all the websites you actually want to visit. Of course, that is child's play for any geek.

First, to get a new command prompt, open Notepad and type: command.com. Then, save as "cmd.bat". You now have a command prompt.

Now, open the command prompt and type "ping http://www.website.com/" to find the IP address of that website.

Enter the website into the browser and you will officially have impressed all your friends.

19. Bypass School or Work Website Blocks
What is a horrific situation for an average computer user is a simple irritation for an everyday geek. To bypass a website block/filter, simply enter that websites IP address in instead of the actual site address.

20. Screw with Wifi Leeches
Nobody likes a wifi leech. At best, they're simply using up your valuable bandwidth. At the worst--and far more likely, they're stealing your identity and watching your activities. After watching your network and identifying the leech, use this trick to flip their browser upside down and let them know you don't appreciate the intrusion.

http://tech.nocr.at/hacking-security/baffle-wifi-leeches-with-an-upside-down-ternet-2/

21. Hexadecimal and Binary Number Systems
Everyone knows the normal, everyday digit system used. It takes a special--possibly psychotic person--to also know hexadecimal and binary number systems.

Here is an excellent interactive tutorial on learning the two systems: http://www.wisc-online.com/objects/index_tj.asp?objID=DIG1102

22. How to Hot Wire a Car
If your family always turns to you any time their computer hiccups, their DVD player needs fixed, or their home security system doesn't activate, it's only a matter of time before someone asks you how to hot wire a car. Wouldn't it be great to be able to answer them?

To learn this unique skill, read here: http://howto.wired.com/wiki/Hot_Wire_Your_Car

23. Increase Wifi Range
With so many small portable gadgets gaining more and more sophisticated web browsers, in addition to gaming systems like the PSP and DS, getting the most use out of your wifi is practically a geek necessity.

Here is a good guide on extending your wifi's range: http://www.mavromatic.com/archives/000451

24. Carrying a Computer Cleaning Arsenal on Your USB Drive
A good geek prepares for their friends stupidity. No matter how many times you tell them to stop downloading porn, they keep doing it until their machine is so infected it can't drag itself into a grave. An arsenal of portable malware cleaners, a portable task manager, anti-virus, etc, will make those impromptu purging sessions all the easier.

25. Running an Operating System from a USB Thumb Drive
Most people don't even understand what the magical operating system is. As a geek, you should transcend that basic knowledge and have a small operating system on your thumb drive handy for those times you need computer access but don't know the password to a nearby computer.

http://www.pendrivelinux.com/

26. Understand What "There's no Place Like 127.0.0.1" Means
A lot of geeks wear this shirt as a short hand code for their computer finesse--or maybe just to screw with other people who stare but cannot figure out what it means. No matter the reason, if you'd like an answer, check out the link below.

http://www.tech-faq.com/127.0.0.1.shtml
27. Read 1337 At Normal Speed
Sure, everyone knows about it and it's no longer cool, but if you're going to proclaim yourself as a geek, you should be able to read it full speed. Who wants to choke in front of the wannabe that learned to read it full speed and flaunts it in your face?

http://www.wikihow.com/Read-and-Write-in-1337
28. At Least One Fictional Language
And not only should you know a fictional language, but you should use it to say something about yourself. Do you choose Klingon or Quenya?

Here's a list of constructed languages: http://en.wikipedia.org/wiki/List_of_constructed_languages

29. How to Survive in a Linux Argument
Linux is gaining an all around higher standing in the geeksphere, and it's bound to enter a conversation at some point (which will invariably end up turning into an argument). If you want to keep up, you'll need to understand the basic points of Linux, as well as the general info of all basic things.

Here's a good place to read and gain a foothold: http://www.linux.com/articles/feature/

30. Identify Major Constellations
For those times you venture from the air-conditioned, computer filled basement of your parents house (or something like that), look up at the stars and have yourself a Galileo moment. The stars may just be dots to many people, but with the handy website below, you'll be stopping man-belts and lions in no time.

http://www.sky-watch.com/astronomy-guide/major-constellations.html
31. Use a Camera in Manual Mode
Sure, you could just use auto mode like everyone else too afraid to learn what some letters and numbers mean, but then you wouldn't be much of a geek, would you? The oft-ignored dial on a camera is the key that unleashes the best quality photos possible, and every geek should be a whiz at using one.

http://digital-photography-school.com/digital-camera-modes
32. Who Mulder and Scully Are
It seems that in the plethora of geek websites, there always appears a joke about Mulder and Scully, the two main characters from the X-Files. If you don't know who they are, you'll be left in the dark, alone, contemplating what exactly it was you were doing in the 90's that you wouldn't understand the joke.

http://en.wikipedia.org/wiki/Mulder_and_Scully_(song)

33. Javascript
HTML is running the world (not really). Everyone knows some HTML and it makes them feel empowered. As a geek, you want to transcend that basic knowledge others share and know a little more. JavaScript is the answer--it is easy to learn if you're not actually interested in web programming, but simply curious, and it looks scary to anyone who doesn't know it.

http://www.yourhtmlsource.com/javascript/basicjavascript.html

34. How to Unlock an iPhone
Sure, most geeks wouldn't be caught dead with an iPhone, but what about your friends? You're the smart techie, they'll expect your to know how to unlock it.

http://www.pcworld.com/article/137223/how_to_unlock_an_iphone.html

35. How to Install Mac OS X on a PC
Just because you don't want Mac on your PC doesn't mean you shouldn't know how to do it. Knowledge is power, right? Go ahead, use this to stump your friends and family.

http://dailyapps.net/2007/10/hack-attack-install-leopard-on-your-pc-in-3-easy-steps/
36. Build a PC
If you purchase a ready-made PC, you can be sure of one thing--you're paying more than you should. Assembling your own PC isn't too hard, and is the first thing you should be aiming to accomplish as a geek.

Here is a massive article on assembling your own PC: http://www.pcmech.com/byopc/

37. Tethering a Smartphone
Nothing like a little wifi on the move, eh? Tethering a smartphone means using the Internet on your laptop/netbook via your cell phone. Of course, the method to do this depends on your phone, but here's an article to get your started:

http://www.tech-recipes.com/rx/2276/smartphones_bb_treo_tether_modem_usa_carriers/
38. Wiring a Home Theater System
Home theater systems used to consist of a TV and a chair. Gone are those days of simplicity, however, and setting up a modern system can be pure mind-boggling horror. Where does the modulator go, why does the DVD player have no video and the cable box no sound?

Here's a tutorial, including excellent diagrams, to show you how: http://www.prillaman.net/ht_info_8-wiring.html

39. Replacing a Laptop LCD
Laptop LCDs are vulnerable to many different mishaps: accidental pressure spots, shadows, airsoft pellets.... No matter, there will come a point when you need to swap your LCD for a new one. Now, as a geek, you probably don't have an extended warranty. If that's the case, here are some excellent pages and pictures on replacing the display:

http://www.fonerbooks.com/laptop_4.htm
40. Make a Laptop Cooling Pad
Can you believe these cost $50?! A geek will need one, because data crunching/DVD ripping/videos playing/rendering at the same times tends to cause excess heat. Instead of shelling out your hard earned dollars, make your own like so: http://www.instructables.com/id/Lazy-mans-laptop-cooler/

41. Unleash a Laser Pointer's full potential
A normal person uses a laser pointer to drive their dog crazy. A geek uses it to melt butter for their grilled cheese sandwich. To unless a laser pointer's full strength, crack open the case, fry the resistor with a hot soldering iron, then snap it back together and keep it away from flesh/eyes/airplanes. The pointer will burn out after a few hours, but what a fun few hours they will be.

Note: this is dangerous. Don't do anything stupid.

42. Keyboard Shortcuts
This will depend on your operating system and the apps you use, so there's no tutorial available. However, that is irrelevant--you're a geek, you can find them yourself. Shortcuts are the difference between a slow computer user and a geek. The geek will always will out in a speed contest, because they do practically everything from their keyboard.

43. Soldering Glasses Together

Nerds use tape on broken glasses; geeks use solder. 'Nuff said.

44. How to Execute a Shell Script
If you're a true geek, you'll need to do this at some point. Below are instructions on how to do so. Remember: always be cautious when running a script, you don't want your computer to turn into a door stop, now do ya?

http://www.mcsr.olemiss.edu/unixhelp/scrpt/scrpt1.2.html
45. How to Hack a Pop Machine
Okay, so stealing isn't cool. Still, hacking is simply a misunderstood art, right? So hacking a pop machine isn't really stealing, because it's not about the pop, it about the pleasure of getting your way. Or something like that. (Newsflash, it is illegal, don't do it.) If you want to try your fingers at getting a free Coke, check out this link:

http://skattertech.com/soda-machine-hack/
46. Turn a Laptop into a Digital Picture Frame
So you want to show off pictures of your dog and that girl you once met, but you want to do it in an uber geeky way. Any schmuck can go to Walmart and buy a digital picture frame for a grossly inflated price. But you...oh, you're too smart for that. No, instead you'll find an old laptop on eBay for $5 and turn it into a true work of art.

http://repair4laptop.org/notebook_picture_frame.html
47. How to Mod a Flash Drive Case
All the geeks are doing it.... Whatever. The case your flash drive came in is probably weak and most certainly plain. Why not jazz it up with your own unique style?

Here's one such case mod, and dozens of related projects: http://www.instructables.com/id/Metal-USB---Flash-drive-case-mod/

48. Do Cool Things to Altoids Tins
People are obsessed with these things. Altoids tins are durable, small, and just begging to be filled with LEDs, mp3 players, audio amps, and maybe some snuff. A good geek will find millions of uses for these little metal wonders. If you need a mental boost, however, here's some interesting links:

http://www.squidoo.com/altoids-tins
49. Convert Cassette Tapes to Digital Audio Files
If your geekhood started in the 90's, then you probably have a least a few (dozen) cassette tapes still sitting around. Why not breathe digital life into them before they fall ill to mortal fate?

http://lifehacker.com/software/mp3/alpha-geek-how-to-digitize-cassette-tapes-222394.php
50. Lock Your Computer with a USB Drive
You don't want anyone getting into your files while you're gone. A normal password would be enough to keep most people out, but what if you got super-secret X files on your computer? You can lock your machine down with a USB drive via these instructions:

http://lionjkt.wordpress.com/2008/12/31/how-to-lock-your-computer-with-usb-drive/
51. Run Your Own Ethernet Line
Wifi has taken the place of a wired connection in many homes, and with good reasons--you can go anywhere, no cables necessary. What about those...sensitive...activities that you'd rather the neighborhood script kiddie didn't see on your wifi? An Ethernet cable is your solution.

To wire your own Ethernet, hit up this link: http://www.ertyu.org/steven_nikkel/ethernetcables.html

52. Set Up a Streaming Media Server
With digital files becoming the ultimate medium, many people have hundreds of gigabytes worth of music, videos, and pictures. You could keep them on a portable hard drive, but then you're have to take it everywhere, and only one person could use it at a time. The solution is a streaming media server, something no geek can live without.

http://www.n00tz.net/2008/07/vlc-media-server-ubuntu-hardy/
53. Setting up a VPN
If you're like most geeks, you can't live without your computers. They store your life in some poetic fashion, holding files you feel a personal connection with.... Anyway, if you are at work and suddenly realize you left an important picture at home (or you need blackmail material pronto), having a VPN ready to go will save you big time.

http://www.computernetworkinghelp.com/content/view/41/1/
54. Turn Webcams into Security Cameras
Is someone stealing your Netflix DVDs? Do you suspect it is a fat hairy man in his boxers taking them each morning? If so, you can get your proof using a couple webcams and a bit of software.

http://www.simplehelp.net/2006/09/27/how-to-use-your-pc-and-webcam-as-a-motion-detecting-and-recording-security-camera/
55. Control Your House Lights with a Computer
Controlling the lights in your house via computer is a great way to freak out the neighborhood kids ding-dong-ditching (assuming you wire up a Halloween scream motion sensor, also). If you reasons are less nefarious, you simply use it to turn on and off lights without having to life ye butt from thy seat, which is a good reason in itself.

http://www.instructables.com/id/Control-lights-in-your-house-with-your-computer/
56. Play Retro Games without Retro Consoles
This applies to the geeks who enjoy gaming. Setting up an emulation PC on your TV is a great way to relive those games of old.

57. Put LEDs Inside a Lightbulb
The days of hot incandescent and mercury-laden fluorescent are gone, and in are the days of long lasting, low heat, low consumption LEDs. As any good geek, you want to be able to say "I was doing X long before it became mainstream." Here's your chance--the following link will show you how to put an LED inside a lightbulb, something sure to stump your friends the same way Grandpa's ship-in-a-wine-bottle used to stump you.

http://blog.makezine.com/archive/2006/06/make_a_led_bulb.html
58. Create Music with Keyboard
How awesome is KeyBored? This little app gives all of your QWERTY keys a piano note. When you type, it sounds like an infant monkey punching a keyboard. If you've got some musical chops, it won't take you long to figure out the Star Wars theme or find a hidden musical message in Counter Strike control buttons.

http://thebatman.net/keybored/
59. Make Your Office Ergonomic
Face it--you spend a lot of time at your desk. You might even have a few extra pounds and pallid skin to show for it. While those things are temporary, far to common and more serious is the carpal tunnel, eye strain, and back problems you'll develop from having a poor workspace.

Hit up this link to create a body-friendly workspace that will keep you limber and flexible: http://www.ergotron.com/tabid/305/language/en-US/default.aspx

60. Adding a Third Monitor
Studies show that dual monitor increase work productivity by 30%. As a geek, you'll need a third monitor to equal the dual setup of a layman (if that makes sense). While any hack with a VGA port can add a second monitor, it takes a true geek to add a third (or more). This will vary based on graphics/OS, so hit up Google for a tutorial or two.

61. How to Convert a DVD to x264 (or XviD or DivX)
It might seem like child's play to you, but many individuals do not understand the fine art of converting a DVD into a digital file, let alone the careful skills it takes to achieve a happy balance between size and quality.

Here is an excellent tutorial demonstrating how to rip a DVD with the multi-platform free software Handbrake: http://howto.diveintomark.org/ipod-dvd-ripping-guide/

62. Flash System BIOS
Ya gotta do it some time, so stop putting it off and man up. Flashing the BIOS on your laptop might seem scary (as it should--fear keeps you on your toes and prevents mistakes), but it's not (actually, it is, but if you even understand why you need to do this, you've gotta have at least a few chops by now). Warning--you can seriously bork your computer doing this!

http://www.pcstats.com/articleview.cfm?articleID=1605
63. How to Irrecoverably Protect Data
TrueCrypt, my friends. Learn to use TrueCrypt. If you have ask why, you don't need it.

64. The Fastest way to Kill a Computer
It's said that you have to get into a killers mind to understand their weaknesses, right? Same goes for the unfortunate boobs who always kill their laptops. Here's a list of all the different ways you can accidentally kill a computer--arm your family and friends, and save yourself grief (because it's surely you they will call when something goes horribly, horribly wrong).

http://www.pcstats.com/articleview.cfm?articleID=1720

Sunday, March 29, 2009

Argument against business process expression languages

After a long awaited vacation, I'm back in office, It has been a refreshing experience. The next thing I see is myself getting invited into a meeting room and being shown assigned to a team dealing with work-flows. These are my first thoughts after looking at what I have in my plate...

The most interesting thing about workflow software, is the ability to plug-in custom rules. They are highly configurable and customisable. Typically every workflow consists of series of acitivities with transitions connecting them. There are business rules written on top of these, which essentially dictate the life-cycle of the flow. In addition to this, there is a provision for forms (for user interaction). There is a strong constraint (what can/not be done) on the usage of these. These contracts/interfaces are designed for the most specific purpose of writing/wiring processes and come with a GUI designer. This provides superb illustration of what is happening where. So what is that, which struck a wrong note?

The entire suite is designed with the noble intention that non-techie folks can use them. So the language is designed to be declarative (in the sense you specify what is needed and don't dictate how it is accomplished). There is an editor which assists in writing code using this syntax. This whole thing assumes that programing in general purpose languages is tricky and meant for programmers alone, (Utterly wrong IMO). Any imperative language is same in the sense, you have assignment, conditional and looping constructs. Some are better in that they provide rich data structures and memory management. A language meant for writing rules tries to emulate these in a more elaborate form. Did the authors ever heard about 3rd generation languages like BASIC and COBOL? They were supposed to be user friendly (read like english).

I have to strongly disagree with the 'noble intention', one may ask why?, the answer: I am not a business analyst and I am being asked to fix defects in code written with myriad syntax! If it were so easy in the first place, the analysts themselves would fix them, why me? Isn't it the case where magic turns into mayhem? Why invent a language instead of specifying a framework with a strong contract?

I may be complaining out of frustration, but I am not yet speaking of my inability to customise the UI, or introduce some kind of pattern for the sake of consistency. Understanding a moderately large workflow (not authoring) itself is taxing. I will probably need another break, so when is my next vacation...

Thursday, January 1, 2009

Web development framework - Struts 1 - part2

In this post, we will see some nuances involved in struts-config.xml, as described earlier, struts-config is set of guidelines for actionservlet that help request delegation.

Struts config example


The following xml file illustrates some of the common features.
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="SimpleFormBean" type="org.ui.beans.SimpleFormBean"/>
</form-beans>
<global-exceptions>
</global-exceptions>
<global-forwards>
<forward name="welcome" path="/Welcome.do"/>
<forward name="success" path="/success.jsp"/>
<forward name="showLogin" path="/csaLogin.jsp"/>
</global-forwards>
<action-mappings>
<action input="/csaLogin.jsp" name="SimpleFormBean" parameter="simpleShow" path="/show" scope="session" type="org.ui.actions.SimpleStrutsAction"/>
<action path="/Welcome" forward="/welcomeStruts.jsp"/>
</action-mappings>
<message-resources parameter="com/myapp/struts/ApplicationResource"/>
<message-resources key="newBundle" parameter="com/myapp/struts/NewResource"/>

<!-- ========================= Validator plugin ================================= -->
<plug-in className="org.apache.struts.validator.ValidatorPlugIn">
<set-property
property="pathnames"
value="/WEB-INF/validator-rules.xml,/WEB-INF/validation.xml"/>
</plug-in>
</struts-config>




The config file is made up of three major aspects: formbeans, action mappings, message-resources. ActionServlet processes the action mappings and identifies the action to be used for the current request. The 'path' attribute influences the decisions. The action element in xml also specifies the target action class in 'type' attribute and form bean to be used using 'name' attribute. The form bean listed in 'name' also listed under form beans element in the config xml file. The class used for bean representation is mentioned here. An action element can also directly map to a html or jsp file.

The action class contract dictates the use of execute() method. (however, using dispatch action forms with parameters, we can call any method of our choice). The form-bean as discussed earlier, is a good candidate for validation actions.

An example of how validations would look.

public ActionErrors validate(ActionMapping mapping, HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (getName() == null || getName().length() < 1) {
errors.add("name", new ActionMessage("error.name.required"));
}
if(getNumber() <= 0){
errors.add("number",new ActionMessage("error.posnumber.needed",getNumber()));
}
{
int x = (int)getNumber();
double y = x;
int res = ((Double)y).compareTo(getNumber());
if(res != 0){
errors.add("number",new ActionMessage("error.integer.needed",getNumber()));
}
}
return errors;
}


The jsp file meant to use the errors looks like this:

  <div id="page1">
<html:errors bundle="newBundle"/>
<html:form action="show.do" method="post">
<div class="fields">
<label for="user">USER</label> <html:text property="name" ></html:text>
<html:errors bundle="newBundle" property="name"></html:errors>
<label for="user-id">USER-ID</label><html:text property="number" ></html:text>
<html:errors property="number"></html:errors>
</div>
<span class="buttons">
<html:submit property="submitType" value="submit1"/>
<html:submit property="submitType" value="submit2"/>
</span>
</html:form>

</div>


The attribute bundle="newBundle" is another aspect, the message properties can be customised (one of the starting steps for internationalisation, no we won't be looking at it in this post). We can have as many message/resource bundles as we like. Have a look at struts-config.xml. The bundle attribute in error tags should map to the key attribute given in struts config.

That summarised our discussion on basic struts.

Web development framework - Struts 1 - part1

For web development in j2ee, one needs to know about basic deployment strategy. The 'basic' stuff includes, knowledge of web server and configuration files required by the framework. For servlet/jsp applications web.xml, or deployment descriptor is the key. Production apps have their own framework and come with their own framework (scripts and config files), this is not the objective of this exercise though.

To simplify development, people have been developing utilities. Struts is one such aid. Supported by Apache. This is over and above the basic strategy. Struts dictates that the users provide config file(s). Let us see the various aspects involved in configuration in this blog.

Web.xml


Web.xml is the starting point for any web application. For a struts application the web.xml looks in the following fashion.
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<jsp-config>
<taglib>
<taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-html.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
</jsp-config>
</web-app>




To understand the above, one needs to have some know how of relation between: servlet-class, servlet-name and servlet-mapping. They are supposed to provide degrees of freedom to various stakeholders namely: the java developer, the server admin or (author of deployment descriptor) and the network admin responsible for url allocation.

All struts applications try to mock front-controller pattern. (A true front controller has no logic what so ever and just delegates, it is left to application designers to come up with the delegators/handlers. In struts 1.xx this is achieved only by using a 'request processor', which is not the default. The delegation logic is held by front-controller in default case. The user can configure the delegation rules). The front-controller is called 'ActionServlet' and is part of struts library. In the above example all urls that match the regex *.do are mapped to this servlet. There are some initialization parameters given to action servlet, the most important of these is the 'config' parameter, we supply struts-config.xml(s) here. Multiple config.xmls are allowed and are comma separated. The config.xmls contain the rules to be followed for request delegation. These are used by ActionServlet.

When a request hits actionservlet, the servlet tries to map it to the appropriate action. Action is a specialised controller. ActionServlet also maps the request parameters to a bean, called as form-bean in struts lingo. By the time request reaches action class, the form-bean gets populated and acts as a data structure. Validation of parameters can be done in the Action class, but the most appropriate location would be form-bean, as per ObjectOriented model. We will see more of struts-config.xml in the next part

Last but not the least are tld definitions provided at the end. These have more to do with jsp tag-libs than struts framework. Think of them as helper classes.

Note


Struts 2 and Spring framework are ideologically more similar than struts 1. In the former, user is allowed to dictate the front-controller (dispatch servlet), user is not forced to extend framework classes. This amounts to greater freedom of design (loose coupling or framework agnostic design). However, how many times did we see an application design change radically?

Popular Posts

Labels

About Me

Well for a start, I dont' want to!. Yes I am reclusive, no I am not secretive; Candid? Yes; Aspergers? No :). My friends call me an enthusiast, my boss calls me purist, I call myself an explorer, to summarise; just an inquisitive child who didnt'learn to take things for granted. For the sake of living, I work as a S/W engineer. If you dont' know what it means, turn back right now.