Skip to main content

Dealing two cards down

Posted by daniel on October 22, 2004 at 11:39 AM EDT

Playing Texas Hold-em with your code

Kimmy-the-wonderwife loves to watch celebrity poker on cable. Each player gets two cards dealt face down. Then after some betting three cards are dealt face up in the middle of the table. More betting, another card up, more betting, one more card up, and finally more betting. Each player's final hand consists of the best hand that can be built from their two cards and any three of the five face up cards.

What makes the game interesting to play and watch is how much information is presented out in the open. But which of the five face up cards will other players use? What are their face down cards? It turns out that much of the information communicated is through the betting. Better players are aware of how to mislead the other players into coming to false conclusions based on the combination of betting and the exposed cards.

Don't ask me why I make these connections - but I was thinking about poker in connection with Paul Tyma's article The New Obfuscation. You don't just map one method name to the same name all of the time in a one to one mapping. It would be like betting transparently in the poker game. Consider this example from the article of mapping method names to other names.

public long getPayroll(int x) {  }    →    abc
public long getPayroll() { }          →    xyz
public long saveState(int x) {  }     →    xyz
public long getDate() { }             →    abc 

This is a clever example because "The interesting point is that where getPayroll had two overloaded versions, those methods are now renamed to different names. That is, the original overloading relationship is gone. Also, methods that were previously unrelated now have overloading relationships. Assuming that method overloading is a tool that conveys information (i.e. the two original getPayroll methods were different implementations of the same task), that information is now gone."


In today's Weblogs, Bob Lee points to a Russell Miles article on Porting the Cuckoo's Egg. "The CuckoosEgg interceptor routes method invocations to alternative implementations in his ReplacementFeature class."


In Also in Java Today , Malcolm Gladwell, author of the Tipping Point, writes in the New Yorker about The Talent Myth: Are Smart People Overrated? He quotes Enron's policy, "We hire very smart people and we pay them more than they think they are worth." They followed the McKinsey recommendation of "sorting employees into A, B, and C groups. The A's must be challenged and disproportionately rewarded. The B's need to be encouraged an affirmed. The C's need to shape up or be shipped out." Gladwell writes that you need to measure potential and not talent, intelligence, and performance.

In a feature article from webservices.xml.com, Marc Hedlund offers an introduction to The New Bloglines Web Services. By offering a web services API, he writes, Blogilines makes it "very easy for developers to use RSS and Atom content for many purposes, and the services will also ease the traffic pileup that aggregators are beginning to cause for many large RSS/Atom publishers." He also shows off the power of the API by developing a Swing feed-reader with just 150 lines of Groovy code.


In Projects and Communities , the JavaPedia entry on StringBuffer has been updated to include a link to the new Tiger class StringBuilder which "is designed for use as a drop-in replacement for StringBuffer in places where the string buffer was being used by a single thread"

The Java Enterprise community's Verge project "is a suite of tools that help developers build J2EE applications by providing a variety of tools and frameworks that developers can use to minimize the up-front overhead of creating those frameworks themselves."


Are Math functions called on the wrong object? In today's Forums, Kcpeppe writes "angle.sin() makes much more symantic sense than Math.sin( angle) because.. that is what you are doing, asking an angle for it's sin. In the other case, you are asking a third party to evaluate sin. Much less polymorphic and relies more on overloading. "

Here's a Completely wild starter: type safe subtypes of primitives using erasure from Bruce Chapman. He begins with the suggestion that we "Add support in the language for type safe sub types of primitives, these erase at compile time (after type checking) to their primitive supertype."


In today's java.net News Headlines :

Registered users can submit news items for the java.net News Page using our news submission form. All submissions go through an editorial review before being posted to the site. You can also subscribe to thejava.net News RSS feed.


Current and upcoming Java Events :

Registered users can submit event listings for the java.net Events Page using our events submission form. All submissions go through an editorial review before being posted to the site.


Archives and Subscriptions: This blog is delivered weekdays as the Java Today RSS feed. Also, once this page is no longer featured as the front page of java.net it will be archived along with other past issues in the java.net Archive.

Playing Texas Hold-em with your code