Custom Search

Monday, June 23, 2008

The 11 Awesomest Games of 2010 year

The 11 Awesomest Games of 2010

2010 should be an awesome year. At least for those of us outside the Bird Flu Plague Zone. And for those of us not fighting in the wars against Iran, North Korea, Syria, China, Iraq and Afghanistan. For us, it'll all be about the games ...

These are the glorious games glowing down at us from the peak of the 360/Wii/PS3 generation, when developers will be making the hardware sing and when every PC will have 8 gigabytes of RAM to play with. Games like ...

1. Mass Driver
360/PS3

"This load of heroin has to be in Philadelphia in 10 minutes. And, Philadelphia is 150 miles away."

"Don't worry. I know just the guy."

Mass Driver is Grand Theft Auto at 1,000 miles an hour. Your character has the magical ability to enhance the acceleration of any boat, airplane, car, truck, tractor, tank or little red wagon to insane, mach-plus speeds, thundering across a game world hundreds of miles wide. Get going too fast and the vehicles can burn up in the atmosphere. The only way to slow down is by smashing through buildings, trees, mountains, other cars, livestock and crowded amusement parks ...

Add in a slow-motion feature to see the looks on your roadkill's faces milliseconds before impact, and you've got a crank-addled adrenaline-junkie game for the discerning lunatic. This could be the game that finally makes Jack Thompson take up arms.

2. Star Wars: Jedi Saga
Wii

First of all, this is real Wii swordfighting. Not that half-hearted "flick to activate sword swing No. 1" Red Steel crap. Real lightsaber fighting, the glowing blade mapped to your Wiimote.

And, it's every lightsaber battle from all six movies. You lightsaber your way right the damn hell through waves of storm troopers, then the boss battle is some famous duel from the movies. Darth Maul, Count Dooku, that one retarded four-armed robot thing with the completely unprotected heart, all of them, leading up to a climactic duel with Darth Vader.

In the bonus levels, you get to switch sides and cut down the good guys.



Us survivors of the Cold War know one thing: If superpower ever meets superpower, everybody in the vicinity is getting fucked up. Therefore, any game that features superheroes fighting that doesn't also feature them knocking down entire buildings with each errant blow, is nothing but filthy digital lie. See THIS VIDEO for evidence:


Further research can be found in the climax of Matrix: Revolutions.

That's why Superhero Brawl gives you 10 city blocks to annihilate. If you want to damage Iron Man, you got to fling his ass through a building ...

... and if you really want to damage him, throw him through the foundation and make the freaking building collapse on top of him. Throw him into a tanker truck hauling rocket fuel, throw him into the core of a nuclear reactor and trigger a meltdown.

Do it right, and the last minute of each fight will look like a nuclear aftermath, smoke and rubble stretching to the horizon.

This is the scale of game Sony implied the PS3 could pull off during their ridiculous hype campaign. Let's see if they can live up to it.


3. World War Omega
PC

This is the Combined Arms Simulator PC gamers have been dreaming about from the first time a shot was fired in anger over a modem. A sprawling world war, a Battlefield 2 but with one gargantuan, persistent map that everybody plays on.

There'll be AI units to do grunt jobs like holding positions and supply lines. There'll be RPG elements like statistics, character growth, and chain of command “guilds.”

And, Normandy-sized invasions with 5,000 players.


Give the Chinese control of one army and the United States control of the other, and we'll fight all of our wars this way. Nobody gets hurt except the millions of neglected girlfriends.


4. Total Kung Fu
Wii

This is for all of us who secretly think those Dance Dance Revolution style rhythm games look like fun but fear they'll threaten our sexuality.

Total Kung Fu has the same frantic, spastic stepping and flailing as DDR ...



... only instead of dance moves, your movements are translated to vicious, bone-crunching kicks and punches.


We're talking lightning-fast blurred fists, '70s kung fu movie-style fighting where punching and blocking is done with the same desperate, heart-pounding frenzy it takes to keep up with the beat in the harder levels of DDR. You wouldn't even need a floor pad, just an extra Wiimote and nunchuck to strap to your ankles.

Also: Online Multiplayer. Yes, it's tough to do for a rapid-fire twitch fighting game. But this is 2010, Nintendo. Figure it out.


5. Hard Cell
360/PS3

Ah, who can forget the first time we directed the guy on the screen to walk across a narrow catwalk suspended over lava, only to have the guy turn to the screen and say, "Eat my fuckmeat, muchacho! In case you didn't know, lava is hot."

Hard Cell is a third-person game where you control an avatar that isn't particularly happy about being controlled. You can see the character and you can give him commands, but he doesn't necessarily agree with your goal.

Doing a good job of not getting your character hurt or killed will make him happier, filling your “Rapport Meter." Filling the meter makes him faster, more responsive, and overall more willing to work with you rather than against you. But lead him into dead ends, forget to take time to find food, fail to look out for his safety ...

You're working with a deep (that is, well-written) and complex character, operating from the most advanced A.I. ever to appear in a game. You'll build trust, you'll become friends.

Which you'll think is great, until the end of the game when you find out you have to sacrifice his life to win. This is an hours-long affair during which he will lie bleeding on the floor, screaming "WHY, DAVID? WHY?!?!?" over and over again at the screen. Did I mention that the guy knows your name?


6. Whipping Boy
Wii

Here's the secret of the Wii. In the markets where Wii Sports isn't included as a pack-in game, and you have to buy it separately, it still outsells Zelda: Twilight Princess. Why?

It's the boxing. Punching something with your actual fist wrapped around the Wiimote is enormously satisfying. It taps into something primal, releases those violence endorphins that fuel all mankind. Hell, even in tennis, the satisfying THOCK! from the Wiimote speaker when the racket smacks the ball, plus the rumble jolting your hand with the impact ... you can just feel the frustrations of the day lifting through the soothing salve of simple violence.

So you take Wii Sports Boxing, add in the most detailed character creation system the hardware can handle (after all, wrestling games have been perfecting this for years). Let me create the exact replica of my old boss, or my neighbor who kicked my dog, whoever. Their voices, too, we'll have a huge range of sound clips and accents to pick from so they sound almost like the real life counterpart. And then, we beat the shit out of them.

The Wi-Fi connection will let gamers somehow download and trade whipping boys, borrowing from people who have made perfect Tom Cruise or George Bush dummies. They can even download user-created custom weapons to beat them with ...

And that's it, that's the whole game. What else does it need? You come home, in a bad mood. You turn on your Wii, you pound your tormentor until you feel better. It'll be the first game to ever sell 50 million copies.


7. Deconstructionist
Wii

Take Whipping Boy even further. Here you work for a demolition company. You got that job because you happen to be a gigantic robot.

Take the Wiimote and nunchuck and guide your crushing robotic hands to tear out walls and roofs and support beams with the satisfying sound of snapping timber and crumbling stone.


It's not just mindless smashing. You've got to take out this building without damaging the ones next to it, you've got to make it fall a certain direction or collapse in its own footprint, etc. Until you get to a level where there's an emergency and you've got to clear two blocks in two minutes, then it is just a mindless, frantic rampage of destruction.

Seriously, you're going to see workplace violence drop through the floor once these bastards hit the shelves. I feel less murderous just talking about it.


8. Killchain
360/PS3

A puzzle game for people who hate puzzle games and love brutal death. In Killchain you are an assassin who has no weapons, and no fighting skill. What you can do, is freeze time.

So, with each level you'll find yourself in a bustling city, then, time will slow until all of the people are frozen like statues. You can then position any person or object, arranged so that once time resumes you'll create a chain reaction of chaos that will ultimately kill the target.

Cut the brake lines on this car over here, make this lady spill her groceries, set this dog so that it runs across the sidewalk, event triggering event in a ridiculously roundabout Rube Goldberg chain of accidents.


By level 12, you're trying to kill a target who's two miles away, on the sixth floor of a locked office building. By level 30 you'll be studying the TV watching habits of your target, realizing he watches baseball every afternoon, then sneaking onto an airfield, reprogramming a plane's flight path so that it crashes into the stadium where his favorite team is playing, the sight of which will give him a fatal heart attack.

Winning will take thought, patience, creativity and the ability to think outside the box. Who says you can't stimulate those things and have grotesque decapitations in the same game?

9. H vs. Z
360/PS3

It starts out as a standard zombie-killing game, you and your strike force beating back the hordes of the undead as they slowly take over the civilized world. You take out the undead, you level up in strength and experience, you get better weapons. But in H vs. Z, if you get bitten, or get bitten enough times, you become a zombie.

And, you stay a zombie. You're now preying on your squad mates, eating their flesh to upgrade your own strength. As a zombie you can "smell" their internal organs so you can pick out the choicest meat needed to upgrade your zombie skills.

The whole time your former mates are begging and screaming your name, saying "FRANK! It's me! Don't you recognize me! FRAAAAANK UGGGGHHhhh ..."

Your game is stored on a locked file on the hard drive. Reset the game, you're still a zombie. You can't change it. Not until you finish the game. Hey, that's life.

10. World of Starcraft
PC

This is the gaming version of the flying car. Everybody wants it, nobody wants to give it to us. It was even the subject of a famous April Fool's hoax on Gamespot.com.


Starcraft stands today as the most compelling fictional world ever created in gaming. The three-way intergalactic war between the humans and the Zerg (insects whose entire technology is organic, from their cities to their flying transports) and the Protoss (a race so highly-advanced and civilized they make the humans look like the Zerg).

I realize that knowing all this makes me some kind of sci-fi geek. But that's OK, because the whole world knows a sci-fi geek is about six steps up the social ladder from a fantasy geek and studies show they have more sex.

That's why there are more of us. We're outbreeding them. Even now, even in the shadow of the Lord of the Rings craze, Sci-fi movies and TV shows outnumber anything starring dragons and sorcerers 3-to-1.

There are 8 million WoW players right now. Give me World of Starcraft, with ships and technology and lasers, and the Zerg splicing their genes to create huge-ass bugs that can bite through tanks ... hell, we'll triple that number.


11. S.N.A.F.U
PC

There's never been a war simulation.

Oh, they've made lots of games like Command and Conquer, but those aren't war simulations. They're "strategy games," fancy versions of Risk, pushing little toy tanks around a game board.

No, I want a war simulation. The ultimate war simulation, where our noble battle against an international terrorist organization quickly turns into a gut-twisting quagmire.

In S.N.A.F.U., you have to worry about civilian casualties, and fuzzy intelligence, and negative media coverage, and funding ...
Rumors will circulate that the single-player mode is, in fact, unwinnable. People will play online, only to find the map objectives changing half an hour into the game, completely against their will.

We've done a whole separate article about this game, HERE

These games came from the imaginations of David Wong and a bunch of PWoT fans.

Mass Driver, Hard Cell and World War Omega were thought up by Haimoimoi.
Jedi Saga was suggested by The Black Knight and I got ants in my pants and probably millions of Star Wars fans everywhere.
Total Kung Fu was sort of suggested by Vermillion.
H vs. Z was the brainchild of spermus.

Year 2010 - Microsoft Important

2010 will be an important year for Microsoft

Every year is important for Microsoft, but the way things are shaping up, I think 2010 will be its most important yet. And although the company has yet to confirm any concrete details about where it's going in the near-term, it has been especially tight-lipped lately about the future of Windows and the Xbox 360. And if you ask me, those two products will be at the center of the company's issues in 2010.

Why 2010? The way I see it, this year is pretty much over for Microsoft. Sure, the company will finally stop the sale of XP (or so we think) and the Xbox 360 will see some minor improvements made to its software, but all in all, nothing too major will happen this year. And considering 2009 will be the year that Microsoft tries to solidify itself as the major player in the gaming and OS markets, it makes perfect sense to suggest that 2010 could be one of the most important years in the company's storied history.

But if it doesn't wake up and realize that it's in some serious trouble with Windows and the Xbox 360 could face problems if it continues to be compared to the Playstation 3, 2010 could also be one of the worst years in the company's history.

2010 will mark a new decade, but it will also mark a new beginning for Microsoft. By then, the days of total Windows dominance may be over and the Xbox 360 may be considered an also-ran in the video gaming space. Beyond that, if the company continues to flounder in the online industry, what's left for the once-powerful tech firm? Suffice it to say that 2010 could be the year that makes or breaks Microsoft.

Windows

Regardless of where Bill Gates stands on the issue, Windows 7 won't be coming out in 2009. Simply put, Microsoft has too much invested in Vista and needs more time to make it work before it can be replaced by the operating system's follow up. Beyond that, it could be an even greater blunder if the company released the new OS next year considering the possibility of a modified ecosystem in the OS market: the threat of Apple and Linux and the online component that we've been hearing about for so long.

But if Vista doesn't improve considerably over the next two years and vendor support doesn't start to pick up, Microsoft will be forced to pick up the pieces and get Windows 7 out the door. And let's also not forget that the company has been more than willing lately to mention the new OS in passing even though Vista has only been out for a short while.

I simply don't see Vista gaining much ground over the next two years. Vendors are still quite unhappy with the product and Microsoft admitted itself that there are a number of issues with the OS that still need to get worked out. And considering the fact that Ballmer has hinted that an XP reprieve could be possible, should we really believe Microsoft when it says that Vista is its future?

The way it's shaping up, 2010 will be the year Microsoft will try to increase Windows' viability. And while I'm not convinced that the company will do it, it simply doesn't make sense to say that it can happen this year or next with Vista. Microsoft will do what it can over the next two years to revive Vista and after failing or realizing that outside pressures from Apple and maybe even Linux are becoming a bit too much, the company will use 2010 as the year to unveil Windows 7 and try to offer a more compelling product.

Xbox 360

I'm a firm believer that when it's all said and done, Microsoft's Xbox 360 console will win this generation's battle. That said, my prediction is rooted in my belief that Microsoft knows what it's doing with in its gaming division and will update the product as needed to address the concerns it's hearing loud and clear from consumers.

As I mentioned, I simply don't see Microsoft doing too much with the Xbox 360 this year. And why should it? The console is still selling relatively well at its current price and the threat of the Nintendo Wii destroying its competitors is diminishing each day. But 2009 could be an entirely different story altogether.

So far, Microsoft has said that it will not install Blu-ray into the Xbox 360 even though Sony is using it as a major selling point in the Playstation 3. And considering the chances of Blu-ray having a major impact in 2009 are slim, there's really no reason for Microsoft to install it and play nice with Sony that year.

But what if Blu-ray becomes a success in 2009 and the de facto leader in entertainment by 2010? If that happens, wouldn't Microsoft be forced to either update the Xbox 360 or rush its production cycle and release a new console with updated graphics and a Blu-ray drive installed?

In other words, Microsoft may feel like it's in the driver's seat right now, but when taken at face value, it's actually in a defensive posture and will need to wait and see what develops in the entertainment industry before it can accurately make a move on the gaming side. And let's face it -- the chances of anything major happening with Blu-ray in the next year are slim considering the price of players and a slew of other issues that the Blu-ray Association has yet to overcome. But if it does, as some have said it will, Microsoft will be forced to make a move in 2010 so it doesn't look like the also-ran.

2010

The importance of 2010 is not arbitrary. When I considered the current state of affairs at Microsoft and took a look at the industry as a whole, 2010 quickly jumped out at me. When it comes to Windows Vista, there's little chance that Microsoft will do much other than try to repair its reputation in the OS space before 2010. And if it doesn't succeed or it fails to attract the kind of customer base it needs while Apple continues to update its OS, it makes perfect sense for Microsoft to follow suit in 2010.

On the Xbox 360 front, Microsoft is being controlled by external factors. Will Blu-ray be a success? Will people be more willing to buy a PS3 because of Blu-ray? Will the Xbox 360 falter because of its lack of Blu-ray support? Certainly none of these questions will be answered next year, but by 2010, Blu-ray will either be a major success or follow LaserDisc to the media junk heap. If it's the former, Microsoft will be forced to react and probably try to save its console and maybe its entire gaming division by doing something in 2010.

But in the end, no one is sure what Microsoft has up its sleeve and quite a few things can happen between now and 2010. But if you take an objective look at the current state of affairs, I doubt too many can say that 2010 isn't one of the most important years in the company's history. If it succeeds in its endeavors that year, it may have a business strategy that can carry it through the next decade. If it fails, ruin may eventually hit Microsoft by the end of the next decade.

API Code

Google's ad revenue sharing solution

Only websites with over 100,000 daily page views across user pages are eligible to participate in the AdSense API program. If your site does not meet this requirement, if you need read more go to google adsense policies.

The Google AdSense API is ideal for developers whose users create their own content through blogging, web publishing, forum/wiki/community creation, or any other application where substantial web content is generated.

Share revenue with your users. You choose how you want the AdSense revenue on user-generated pages to be allocated between you and the users creating the content. In addition, you will earn referral bonuses for referring new users to AdSense.

Engage your community. By allowing users to share in the revenue generated by their actions on your site, you are encouraging them to be more engaged with your program. Users are motived to create more high-quality content and to be more active on your site, leading to increased adoption and traffic.

Fully integrate the user experience. The entire AdSense process, from AdSense account creation to placing ads and monitoring performance, can be seamlessly integrated into the existing look and feel of your site.

JAVA Reflection API

In this feature article, Ian Darwin (author of O'Reilly's Java Cookbook) provides examples of Java's beautiful Reflection API, which allows your code to reach down into the JVM and do some of the same things that the Java runtime does: discover and load class files, instantiate classes, discover and invoke constructors and methods, discover and set/get fields, and more.
Mirror, mirror, on the wall...

No, this is not about me looking at myself, or even my own code. Rather, it's my nomination for the Beautiful Code API. There is plenty of beautiful stuff in the Java SE API, but to my mind one of the most sublime pieces is Sun's Reflection API. While some dynamic languages let you do what Reflection does, I'm not aware of any other compiled, strongly-typed language (other than, perhaps, Java knock-offs like C#) that have anything like it.

So what is Reflection? Also known as Introspection, the Reflection API allows you to operate on classes and objects in ways such as the following:

* Load a class file into memory at run time, knowing only its name;
* Given a class, examine its methods, fields, constructors, annotations, and so on;
* Given a class, invoke constructors and methods;
* Given a class and an instance, access fields;
* Given an interface, create proxies for it dynamically.

A class named Class

It might seem strange to have "a class named Class" (maybe no more so than creating an object of class Object, I guess). But java.lang.Class has been around since the earliest days of Java; at least JDK 1.0, so I guess most of these uses were planned even then.

Time for a code example. Suppose you've invented a new API called a Showlet, sort of a cross between an Applet and a Servlet. You think lots of people will want to write their own Showlets. Create an interface for it:


package showoff;

public interface Showlet {
public void show();
}

Publicize it (this step omitted from this article; you're on your own). Now whenever somebody wants to write a showlet, they just implement your public interface. Say I write one called IanShow:


package com.darwinssys.jellybeans;
import showoff.Showlet;
public class IanShow implements Showlet {
public void show() {
System.out.println("OK, here's what I show: A234JQ");
}
}

Nothing very elaborate, but enough to show (so to speak) the operation. Your code will need to load this class, even though my class was written after your class, so you can't have a compile-time dependency on my class. However, to use it is no problem:


public class MyBigApp {
public static void main(String[] args) throws Exception {
String className;
// stub getting name of user-defined class from config file
className = "com.darwinsys.jellybeans.IanShow";

// Create this user's ShowLet
Class c = Class.forName(className);
Showlet s = (Showlet)c.newInstance();

// Now we have a showlet, make it do its thing:
s.show();
}
}

The whole magic part is the two lines of code below the comment "Create this user's Showlet". The first line uses the Class class' static forName() method to dynamically load the IanShow.class file from your classpath into the JVM. At this time the class file will be found, inspected, verified, and loaded into memory; after this it is treated pretty much like any other class in your application. The second line creates an instance of this class. The main requirement for this to succeed is that there must be a public, no-argument constructor in your class. Since this is the default constructor in Java, it's a safe bet. But in case the user messes up, one of a variety of Exceptions is just waiting to be thrown. See the JavaDoc, or compile this code in an IDE with the throws clause commented out. In a real "extensible application" model, you'd want to catch some of these and give better warnings.

One of the most annoying problems is ClassCastException, which would happen if the user provided a class that doesn't implement the Showlet interface. This would occur after the newInstance() call but before the assignment to variable "s". To prevent this exception, you'd normally use the built-in instanceof operator, but that requires the class be known at compile time. There is an isInstance method in the Class class; a more cautious version of the Showlet creation is thus:


Class c = Class.forName(className);
Object o = c.newInstance();
if (o instanceof Showlet) {
Showlet s = (Showlet)c.newInstance();
...
} else {
System.err.printf("Sorry, class %s is not a Showlet%n",
className);
}

What does all this give you? An extension or plug-in mechanism that is completely independent of user-defined classes. As long as they correctly implement your published interface, they will load and run.
Plan B

If for some reason you prefer inheritance, make Showlet be an abstract class with show() an abstract method. The instance classes then extend this rather than implement it. Everything else is pretty much the same.
Getting to Class

Class.forName() is one way of getting a Class descriptor, and it's familiar to anybody who's written a "JDBC 101" program (even though it's not how you get your database driver in real life). There are two other ways of getting a Class descriptor.

If the class whose descriptor you want is known at compile time, just say typeName.class. The "class" keyword in Java, if it appears after a "." with a type name before that, generates an expression of type "Class" for the given type. So String.class returns the same as Class.forName("java.lang.String"), for example.

Finally, if the class is not known but you have an object of the class, you can ask it for its class.


Class c = someRandomObject.getClass();
println("Object is of class " + c.getName());

What does this give you? One way or another, you should now be able to get a Class descriptor for any class in a Java program.
MyJavaP

The standard JDK has always included a program called javap, the Java printer. Javap has two main functions: it provides a quick view of a class' external structure, and it provides a detailed dump of a class' internal byte code. The latter is beyond the scope of the Reflection API; you would have to use a byte code library such as the Apache Byte Code Engineering Library (BCEL). The former, however, can easily be implemented using Reflection. When run against java.lang.Object, the Java SE implementation produces this output:


Compiled from "Object.java"
public class java.lang.Object{
public java.lang.Object();
public final native java.lang.Class getClass();
public native int hashCode();
public boolean equals(java.lang.Object);
protected native java.lang.Object clone() throws java.lang.CloneNotSupportedException;
public java.lang.String toString();
public final native void notify();
public final native void notifyAll();
public final native void wait(long) throws java.lang.InterruptedException;
public final void wait(long, int) throws java.lang.InterruptedException;
public final void wait() throws java.lang.InterruptedException;
protected void finalize() throws java.lang.Throwable;
static {};
}

I wrote a simple clone of javap, called MyJavaP. An earlier version of this was contributed to the Kaffe project. The output is as follows:


class java.lang.Object {
public java.lang.Object()
public native int java.lang.Object.hashCode()
public final native java.lang.Class java.lang.Object.getClass()
protected void java.lang.Object.finalize() throws java.lang.Throwable
protected native java.lang.Object java.lang.Object.clone() throws java.lang.CloneNotSupportedException
public final native void java.lang.Object.wait(long) throws java.lang.InterruptedException
public final void java.lang.Object.wait() throws java.lang.InterruptedException
public final void java.lang.Object.wait(long,int) throws java.lang.InterruptedException
public boolean java.lang.Object.equals(java.lang.Object)
public java.lang.String java.lang.Object.toString()
public final native void java.lang.Object.notify()
public final native void java.lang.Object.notifyAll()
}


As you can see, it misses some details, and the static code block. But, for a simple implementation (about sixty lines), it does not badly. The core of the implementation is shown in these twenty lines of code:


Class c = Class.forName(className);
System.out.println(c + " {");

int mods;
Field fields[] = c.getDeclaredFields();
for (Field f : fields) {
if (!Modifier.isPrivate(f.getModifiers())
&& !Modifier.isProtected(f.getModifiers()))
System.out.println("\t" + f);
}
Constructor[] constructors = c.getConstructors();
for (Constructor con : constructors) {
System.out.println("\t" + con);
}
Method methods[] = c.getDeclaredMethods();
for (Method m : methods) {
if (!Modifier.isPrivate(m.getModifiers())) {
System.out.println("\t" + m);
}
}
System.out.println("}");

Membership Lists

Suppose you want to become a famous Java author by creating a big fat book full of API cross-reference. Knowing there are new releases of Java SE every 12-18 months, do you:

* a) Read the javadoc, and type up a huge document with all the information for each class, or
* b) Write a program that extracts all this information mechanically, and sends it direct to your typesetting program?

If you answered "a", give yourself zero points, and thanks for playing! The correct answer is of course "b". In fact, using classes from java.util.zip along with Reflection makes this whole thing pretty easy. Once you have a Class object, there are methods in it with names like getConstructors(), getFields(), getMethods(), and so on. Each returns an array of descriptor objects, e.g. Constructor, Field, Method. These classes in java.lang.reflect (and their parent class Member) provide detailed information about one member in the given class. For example, a Method object contains the corresponding method's name, visibility, argument list, and so on. If a method is overloaded, each overload will return one Method.

The basic idea for the cross reference program, then, expressed as pseudo-code, is:


for (ZipEntry entry : new ZipFile(name).entries()) {
if (entry represents a Class) {
Class c = Class.forName(entry.getName());
for (Field f : c.getMethods()) {
print a field;
}
for (Method m : c.getMethods() {
print a method;
}
}
}

Of course, the real code is a bit more complex. And, in fact, I wrote it with the view that I might want to re-use parts of the code, so the outer loop and the "if entry represents a class" logic are in the abstract class APIFormatter; the logic of what to do with a given class is deferred to the template method doClass() in a subclass. The standard example is CrossRef, but there is another usage example in the JUnit test case APIFormatterTest. Finally, CrossRefXML extends CrossRef and overrides some of the output methods to output an XML document instead of a text document.
JavaBean Introspector
Several APIs use classes from the Reflection API. The JavaBeans API (java.beans) was both designed as a simplification layer to make it easier to use reflection for the less-ambitious task of getting an object's list of "properties" - fields that have setter/getter method pairs- and hence to make it easy for GUI builder tools to discover information about "Java Beans". The spec included the now-well-known setter/getter accessor pattern, requirement of a no-argument constructor, and the optional BeanInfo configuration file. Sun hoped and expected that tool building companies would produce GUI builders (based on JavaBeans) that would compete with Visual Basic. Arguably they have done so, in tools like Eclipse and NetBeans with their respective visual builders.

The Introspector is the main class you need to know. Its getBeanInfo() method takes a class name and returns a general-purpose BeanInfo object. This represents the list of properties either exposed by the bean or specified in the eponymous configuration file.
A new methodology - Dynamic Method Invocation

If you have a Method descriptor, you can invoke that method on any object of a class that contains it. Just call the Method's invoke() method passing the object (you can pass null if you're invoking a static method), and the argument list packed as an array of Object. Assume you are given class X containing this method:


public void work(int i, String s) {
System.out.printf("Called: i=%d, s=%s%n", i, s);
}

To find and invoke this method dynamically, given an instance of it called "x", all you need to do is:


Class clX = x.getClass();

// To find a method, need array of matching Class types.
Class[] argTypes = { int.class, String.class };

// Find a Method object for the given method.
Method worker = clX.getMethod("work", argTypes);

// To invoke the method, need the invocation
// arguments, as an Object array.
Object[] theData = { 42, "Chocolate Chips" };

// The last step: invoke the method.
worker.invoke(x, theData);

By itself this is a bit tedious to code, but it is background for the next few sections.
Dynamic Proxy and AOP

The Proxy pattern is well known: one object stands in for another. A Proxy can be created in Java using an interface and two classes, the "real" implementation and a surrogate or wrapper which implements the same interface and ultimately forwards each method call through to the "real" implementation. For example, if I want to create a Proxy for the Showlet example above, say, to verify the user's credentials before passing control to the provided Showlet, a do-nothing proxy impementation can be as simple as this:


public class ShowletProxy implements Showlet {
Showlet realObject; // set in constructor

public void show() {
realObject.show();
}
}

In real life the Proxy can do all sorts of other things, such as testing security, logging method calls and their parameters, network calls (used in RMI and EJB), and so on.

A more complete hand-written Proxy might look like this:


public class ShowletProxy implements Showlet {
Showlet realObject; // set in constructor

public void show() {
final String className = realObject.getClass().getName();
if (securityOK()) {
log("About to call " + className);
realObject.show();
log("Completed " + className);
} else {
log("Security - rejected " + className);
}
}
}


The downside of this is that it is tied to a particular interface, namely Showlet. What if you want to proxy ten, a hundred, or a thousand classes? It just doesn't scale. You need a way to write the proxies dynamically. That is, of course, the dynamic proxy mechanism. Introduced to Java in Java SE 1.3, the dynamic proxy mechanism in class java.lang.reflect.Proxy allows you to create a proxy to any interface dynamically, given only the interface and a general-purpose InvocationHandler. The InvocationHandler is where you specify what to do before and after the method invocation. An InvocationHandler allows you full control over the actual invocation of methods in the "real" object that is being proxied. There is only one method in the Invocation handler interface; a typical implementation might look something like this:


class MyInvocationHandler implements InvocationHandler {

private Object realObject; // set in Constructor

/**
* Method that is called for every call into the proxy;
* this has to invoke the method on the real object.
*/
public Object invoke(Object proxyObject, Method method, Object[] argList)
throws Throwable {
log("About to call " + className + "." + method.getName());
Object ret = method.invoke(realObject, argList);
System.out.println(" Completed.");
return ret;
}
}

The InvocationHandler's invoke() method is where the dynamic proxy calls your code; the "method.invoke()" is where your proxy calls the real object's method. The names are the same, but they are different steps along the chain, and the argument lists differ. Although the InvocationHandler's invoke() method is passed a reference to the dynamic proxy, it is not passed an reference to the "real" object, so this has to be provided in the class, either by a Constructor or (for greater flexibility) in a set method.

To create the dynamic proxy, use the Proxy class' newProxyInstance() method, which requires a ClassLoader (see below), one or more interfaces that are to be handled (as an array of Class objects), and a reference to the InvocationHandler:


Showlet generatedProxy = (Showlet) Proxy.newProxyInstance(
Showlet.class.getClassLoader(),
new Class[] { Showlet.class }, handler);

Because it's a nuisance to create the InvocationHandler and the Dynamic Proxy, this is normally delegated to a Factory method. Factory is another well-known design pattern used throughout Java: a class makes up objects for you (see for example Locale.getInstance() and Calendar.getInstance()).

In the code download you will find a class called DynamicProxyFactoryDemo which implements a Factory for the proxies; note that the main program now has no idea that proxying is going on; it deals only in the interface (and the factory).


public static void main(String[] args) {

Showlet showlet = ShowletFactory.getInstance();
System.out.println("Showlet Proxy object is " +
showlet.getClass().getName());
System.out.println("All done");
}

What does this give you? With Dynamic Proxy, you can create one proxy that will proxy all (or selected) requests for a huge number of methods on a large number of objects. However, the proxying has some setup complexity, so it's best if you can abstract object creation into the factory.
Aspects of change

A more generic way of handling this notion of proxying is to use programming language constructs to help automate it. This has lead to the rise of "Aspect Oriented Programming", or AOP. AOP uses some interesting vocabulary, but an "Aspect" is some function (such as logging or validation) that needs to applied automatically to a range of classes. Two important AOP implementations are Aspect/J (original site at PARC; current site at Eclipse.org) and the Spring Framework AOP. Spring provides a very general-purpose Bean Factory that is configured entirely by a configuration file, and a large array of pre-written beans. Useful in this context is their AutoProxyFactoryBean, which will automatically apply proxying to an arbitrary number of methods based on several seclection mechanisms, including one that uses Regular Expressions.

Since I'm sure there will be a BC article on Spring, I won't steal this article's thunder, but if you want a peek meantime, check out the Spring Framework site.
ClassLoaders and SecurityManagers and more, oh my

One topic I've not covered here is the notion of security. Java provides a SecurityManager class that can be used to limit what classes can do. A ClassLoader is, of course, the object that is responsible for loading classes. Java provides a default ClassLoader, but you can write your own. The topics of ClassLoaders and SecurityManagers are important, but this article is already at its maximum length. I urge you to learn about these topics, especially if you are going to be using dynamic classloading of classes provided by other, possibly untrusted, entities. These topics are discussed in my Java Cookbook (O'Reilly, 2e 2004) as well as in the Sun-provided documentation.
Conclusion

The Reflection API is truly sublime, because it allows your code to reach down into the JVM and do some of the same things that the Java runtime does: discover and load class files, instantiate classes, discover and invoke constructors and methods, discover and set/get fields, and more. In this Beautiful Code, I've shown some real-world code that uses this beautiful API.

Keystone Websites

Creating a website need not be an expensive and complicated process. Catering to the needs of individuals and small businesses is difficult for large web design houses, because building a smaller-scale website rarely yields enough to cover their overheads. Unfortunately, many of the small-scale web design shops lack the kind of talent needed to build a site that looks professional and functions properly.

Keystone Websites has been created specifically to fulfill this need. We prefer to work with you on a one-on-one basis to create your web presence, tailor-made to your budgetary requirements. Our desire is to build a relationship, because a website grows with your needs and ambitions, and requires continuous nuturing. We will employ the latest web technologies and utilize the most up-to-date standards to implement a solution that is elegant, accessible, and secure.
To help demystify the web design process, we have created an easy-to-follow guide that describes what happens as we build your website. The guide is supplemented by a comprehensive glossary of terms, for your convenience. An understanding of the basic process gives you the power to shape that process to suit your needs. But just as there is no need to understand how a car engine works to be a driver, there is similarly no need to understand the mechanics of a web page to be a useful contributor to the design process. Our goal is to empower you with the ability to have as much, or as little involvement as you like.
Digital Keystone's mission is to be the leading provider of information solutions and services.
Our goal is to increase our clients' efficiency and profitability by making business processes easier to conduct and manage.
Our success will yield sustainable prosperity to staff and our associates
The W3C note on XHTML media types is not very specific about how XHTML should be served. Use of the word "should" creates ambiguity, which may be why Ian Hickson felt compelled to write about it. For your convenience, we have re-worked a table from the document's summary

US Mower:
Based in Washington state, US Mower is a supplier of industrial mowing equipment. Keystone Websites was tasked with modernizing the existing website. Out went the code-heavy pages created in Microsoft Publisher, to be replaced by lean, hand-coded XHTML. The new site has an improved structure, together with substantial performance gains and a corresponding decrease in overhead.



The existing visual design was fairly robust, so Keystone Websites created a new look that was an evolution of what came before. The red, white, and blue theme was carried over to complement the company's logo, which itself was slightly reworked to give it a modern feel. A special page was created to act as a host for various product video clips. The total development time for the site was about 2 weeks, and all communication between the client and Keystone Websites took place via email.



US Mower distributes products through an extensive network of dealers around the United States and Canada. To assist the user, the dealer in the directory has links to their respective websites, as well as links to Google-based location maps.

Just Photo:
On this project, Simon Jessey of Keystone Websites was given a functional specification for a website that had to provide information and photography services for a photographer based in Hamburg, PA. The specification was a document containing information on style, color, content, and structure. Keystone Websites worked closely with the client to produce the desired result, from the initial visual design concept to the testing and deployment.



The site is hand-coded using a combination of HTML, CSS, and Microsoft's ASP (Active Server Pages) technology. Sophisticated CSS float techniques were used to create the gallery pages, and a fully-functional control panel was built so that the client could alter many of the site's dynamic features. The total development time of the site was 5 weeks.

The Queen Bean Coffee Bar & Cafe:

The Queen Bean Coffee Bar & Cafe is a collaborative effort. Simon Jessey, senior designer at Keystone Websites, worked with a small group of talented individuals to produce this dynamic website. The group was given a brief to design a site for a small, Pennsylvania-based coffee bar from scratch. The site had to be built using Macromedia's ColdFusion server-side language, and provide E-commerce capabilities with the PayPal shopping cart system.

The site features a welcoming Flash animation (delivered within a pop-up), a Flash-based "menu", and a fully-featured control panel that enables the client to alter any dynamic feature of the site. Total development time was 10 weeks, including client consultation and liaison.