How to get rid of the coffee smell

Woke up and noticed a nice-looking coffee maker by the TV – complimentary from the hotel. How sweet! A sealed foil coffee bag is right there too. As per printed directions, I ‘m carefully tearing open package and removing filter pack. A really nice smell of a ground coffee fills the room.

The next set of directions is printed right on the coffee maker. Not a rocket science either. Pouring in a cup of fresh water, inserting the filter pack with coffee, pressing the red button…

Voila! One minute later, the fresh pure water was turned into a brown liquid with no taste, and more importantly no smell of coffee. Good job guys, you made it! This experiment always works in any hotel room regardless of the coffee or coffemaker brand.

The next destination is a street cafe where the coffee is not free, but has a taste and a smell.

On Google and free food

Fortune magazine has published an interesting article about Google called Chaos by Design . I ‘m not going to bore you with mumbling about how Google is still going up while Microsoft is definitely goes down. I ‘ll talk about important stuff: Google employees enjoy free food. Even the journalist of a solid financial publication, could not stop himself from literally starting the article from talking about free and festive cafeterias.

That ‘s remains a fact of life: the most important thing for any human being is food. And free food is a pinnacle of human life. Multi-billion deals are being signed just because someone took someone for a free lunch or dinner. Free is the magic word. It does not really matter that a person who was treated with a free lunch is a millionaire…

Have you ever thought of what ‘s the main difference between human beings and animals when it comes to eating habits? I did. Animals eat when they are hungry, while people eat when they see food available. Especially a free food. Please answer this question, but be honest: how many times do you re-fill your plate in all-you-can-eat buffets? I know, at least three. You ‘d never do this if you had to pay even $5.

Yesterday I was flying over from New Jersey to Seattle. The free food sucks on the planes these days. The beer or wine costs $5. I did not purchase the beer giving myself a lame excuse that I had to work on the book and drinking beer would lower my productivity. What a BS. Most likely, subconsciously, I was saving five bucks. What a shame! On the way back I ‘m buying two beers. The hell with the book.

Many years ago I was working with one of the former Pan Am managers. He told me that they were allowed to fly for free, and the food on the plane was great. So he ‘d check the Pan Am menus on various destinations, picked what he liked and spent a weekend flying, say to Italy and back just for food.

Ten years ago I was working for an oil company that had subsidized lunches: pay three bucks and eat anything you want, and the food was of a restaurant quality. One brave guy decided to ban himself from going to this cafeteria, because otherwise he would not stop eating and gained weight.

If you are running a company and want to attract top talents, offer free lunches to your employees. I ‘ll check your menu, and if it ‘s good, I ‘ll quit my current job and will work for you. Will work for food!

Adobe Flex: Program in Style or an Elevator Pitch

We usually run Flex training for private clients of Farata Systems , but once in a while we teach public classes for people with different programming background (my next Flex class at New York University starts in November). All students usually get excited by Adobe Flex, but each of them comes with different understanding of how to do things right. So I “ll tell you the story that might have happened in a real life, but first, let me remind you of an old Indian tale about seven blind men and an elephant . In short, one blind man touched the elephant “s head, the other one touched the tail, someone was by the leg. And each of them visualized an elephant differently based on what he touched hellip; My students usually arrive to the classroom early, but this time three seats were empty. Five minutes later I got a phone call from one of them explaining that they got stuck in the elevator and will stay there for another fifteen minutes until the serviceman arrives. Needless to say that each of them had a laptop (do not leave home without it), so I gave them a short assignment to trying to help them use this time productively.

Here “s the assignment: Create a Window with a Panel that can resize itself by clicking on the button +/- that is located in the right corner of the panel. One click should minimize the panel “s height to 20 pixels, and a subsequent one should maximize to 100 pixels, and so on.

For example, these are the two states of such panel:

I forgot to tell you that one of these guys was a Cobol programmer, the other one had Java background, and the third one was a Smalltalk fan.

From Cobol to Flex

The Cobol programmer thought to himself, rdquo;We used to write long programs because during job interviews they usually ask how many lines of code did I write. These guys are different, so to earn a good grade, this program should be small rdquo;. He finished the program on time and this is what it looked like:

lt;?xml version= “1.0 ” encoding= “utf-8 “? gt;

lt;mx:Application xmlns:mx= “http://www.adobe.com/2006/mxml ” layout= “absolute ” gt;

lt;mx:Panel id= “thePanel ” title= “The Panell ” height= “90 ” width= “100% ” headerHeight= “20 ” / gt;

lt;mx:HBox width= “100% ” horizontalAlign= “right ” paddingRight= “2 ” gt;

lt;mx:Label text= “- ” fontSize= “16 ” width= “20 ” height= “17 ” fontWeight= “bold ”

id= “minimizeActions ”

click= “{if (minimizeActions.text== ‘+ ‘){

minimizeActions.text= ‘- ‘;

thePanel.height=100;

} else {

minimizeActions.text= ‘+ ‘;

thePanel.height=20;

}

} ” / gt;

lt;/mx:HBox gt;

lt;/mx:Application gt;From Java to Flex

The Java programmer thought, “The standard Flex Panel class does not have the property that remembers the current state of the Panel, but Flex components are easily extendable, so I “ll create a descendent of the Panel in ActionScript, add a private state flag (minimized) , public setter and getter, and resize function. This way my new Panel class will be reusable and self contained. rdquo; This is his reusable ActionScript class called ResizableJPanel:

package {

import mx.containers.Panel;

public class ResizableJPanel extends Panel {

// state of the panel

private var isPanelMinimized:Boolean;

public function get minimized():Boolean{

return isPanelMinimized;

}

public function set minimized(state:Boolean){

isPanelMinimized=state;

}

public function resizeMe():void{

if (minimized){

minimized=false;

height=maxHeight;

} else {

minimized=true;

height=minHeight;

}

}

}

}

This is Javist ‘s mxml code:

lt;?xml version= “1.0 ” encoding= “utf-8 “? gt;

lt;mx:Application xmlns:mx= “http://www.adobe.com/2006/mxml ” xmlns:local= “* ” layout= “absolute ” gt;

lt;local:ResizableJPanel id= “aPanel ” height= “90 ” width= “100% ”

title= “The Panel ” minHeight= “20 ” maxHeight= “100 ” headerHeight= “20 ” / gt;

lt;mx:HBox width= “100% ” horizontalAlign= “right ” paddingRight= “2 ” gt;

lt;mx:Label text= “- ” fontSize= “16 ” width= “20 ” height= “17 ” fontWeight= “bold ”

id= “minimizeActions ” click= “resizePanel(aPanel) ” / gt;

lt;/mx:HBox gt;

lt;mx:Script gt;

lt;![CDATA[

function resizePanel(thePanel:ResizableJPanel):void{

if (thePanel.minimized){

minimizeActions.text= “- “;

thePanel.resizeMe();

} else {

minimizeActions.text= “+ “;

thePanel.resizeMe();

}

}

]] gt;

lt;/mx:Script gt;

lt;/mx:Application gt;

From Smalltalk to Flex

The Smalltalk guy thought, “Let me see if the standard Panel is a dynamic class. If not I “ll extend it just to make it dynamic and will be assigning the panel “s state on the fly. I hope Yakov is not one of these object-oriented Nazis rdquo;. This is his panel ActionScript class that just adds a dynamic behavior to the Panel:

package{

import mx.containers.Panel;

public dynamic class ResizableSmtPanel extends Panel

{

}

}

His mxml class looked like this:

lt;?xml version= “1.0 ” encoding= “utf-8 “? gt;

lt;mx:Application xmlns:mx= “http://www.adobe.com/2006/mxml ” xmlns= “* ” layout= “absolute ” gt;

lt;ResizableSmtPanel title= “The Panel ” id= “thePanel ” height= “90 ” width= “100% ”

minHeight= “20 ” maxHeight= “100 ” headerHeight= “20 ” gt;

lt;/ResizableSmtPanel gt;

lt;mx:HBox width= “100% ” horizontalAlign= “right ” paddingRight= “2 ” gt;

lt;mx:Label text= “- ” fontSize= “16 ” width= “20 ” height= “17 ” fontWeight= “bold ”

id= “minimizeActions ” click= “resizePanel() ” / gt;

lt;/mx:HBox gt;

lt;mx:Script gt;

lt;![CDATA[

function resizePanel():void{

if (thePanel.minimized){

minimizeActions.text= “- “;

thePanel.minimized=false;

thePanel.height=thePanel.maxHeight;

} else {

minimizeActions.text= “+ “;

thePanel.minimized=true;

thePanel.height=thePanel.minHeight;

}

}

]] gt;

lt;/mx:Script gt;

Since we are not in the classroom, I “m not going to go to a code review and lengthy discussions, I will just say the I gave an “A rdquo; to each of these guys…and here ‘s the Flex version: lt;?xml version= “1.0 ” encoding= “utf-8 “? gt;

lt;mx:Application xmlns:mx= “http://www.adobe.com/2006/mxml ” xmlns= “* ” layout= “absolute ” gt;

lt;mx:Component className= “ResizablePanel ” gt;

lt;mx:Panel gt;

lt;mx:Script gt;

[Bindable]

public var minimized:Boolean = false;

lt;/mx:Script gt;

lt;/mx:Panel gt;

lt;/mx:Component gt;

lt;ResizablePanel title= “The Panel ” id= “thePanel ” minimized= “false ” height= “{thePanel.minimized?thePanel.minHeight:thePanel.maxHeight} ” width= “99% ”

minHeight= “20 ” maxHeight= “100 ” headerHeight= “20 “/ gt;

lt;mx:HBox width= “99% ” horizontalAlign= “right ” paddingRight= “2 ” gt;

lt;mx:Label text= “{thePanel.minimized? ‘+ ‘: ‘- ‘} ” fontSize= “16 ” width= “20 ” height= “17 ” fontWeight= “bold ”

id= “minimizeActions ” click= “{thePanel.minimized=!thePanel.minimized} ” / gt;

lt;/mx:HBox gt;

lt;/mx:Application gt;

What “s the morale of this story? Learn another language, no matter what ‘s your current background. Initially you will try to bring your own culture to this new language, but eventually your horizons will broaden, which will make you a better programmer.

P.S. Isn “t it funny that the Cobol guy “s version was the shortest one? But was it the best one? Can you offer a different solution?

Recommended Java books

I keep hearing on te radio that every person has to eat five fruit servings a day. But this is about phisical health. How about mental healthy diet for Java developers? I recommend to consume at least five Java books a year. JDJ has published a review of Java books that I like, which includes four books.

The fifth one is “Java Reflection in Action ” from Manning. This 250-page book has lots and lots of useful and well covered information not only about reflection, but also about proxies, class loaders, stack introspection and design patterns. A really good book.

Bon Appetite!

Brian Goetz has been hired by Sun

Brian Goetz, has been hired by Sun Microsystems as a Technical Evangelist and he will be joining the SE organization at Sun. Brian will get to continue his role in the Java Community as an “Evangelist “.

I have an honor to know Brian personally, and have to say that he belongs to a really small and exclusive group of experts who really know what ‘s uder the JVM ‘s hood, and what ‘s the best way to design multi-threaded applications.

My short review of his new book is located over here . This book is one of the best Java books of the year.

On one hand, Sun is laying off several thousands of people, on the other hand, they hire the best of the best: recently they ‘ve hired lead JRuby developers , and now Brian. I guess, JS decided to improve the overall quality of the workforce.

Congratulatins, Brian and good luck!

Joel against Sprint

Sprint sent their new phone to Joel Spolsky for a review. And he did it . Joel did not like the phone. Now Sprint does not like Joel.

I trust Joel ‘s review, but I ‘m still not sure if he should have published such an agressive post. Every pot has its lid. If the price is right, there could be many people who will like this phone. Because this may be the only phone/service with MP3 they can afford.

I often receive review copies of new books from publishers. Only some of them stand out, but I prefer not to write about the books I do not like. For example, I already had 4 books on AJAX, which I do not really like, so I just ignored them. Yesterday I ‘ve received the fifth one, which looks very promising. I ‘ll finish reading it in a couple of weeks and will write a review, if I still like it. Otherwise, I ‘ll keep my mouth shut. Being a book author myself, I know how much time the authors spent to give birth to their one and only. And again, each book has its readership, no matter I like it or not.

Buying butter in New York

I work on project with Joe, a brilliant business analyst from Chicago . He knows financial industry back and forth. He ‘s so good that the client does not mind flying him over to New York every other week and pay for his stay in Midtown Manhattan hotels. When Joe is in town, we often go to have lunch together. Yesterday, when he asked me of I want to join him for lunch, I said that I have plans – I had to go to Citarella at 75th street to buy some butter. This statement got him excited. He said, “Only in New York a person can walk 20 blocks just to get some special butter! “. I politely explained that regular butter that is sold in supermarkets is junk, and he should not eat it. He said that I should get “Land ‘O ‘lakes ” butter that according to Consumer Reports is the best butter. Yeah, right! Consumer report believes that Toyota is the best car as well. I usually eat the French butter called President, but last week a friend of mine gave me to try a butter from a Ronny Brook farm , which she buys at Union Square Market on Saturdays. This is THE butter! If you are older than Internet, you might remember that taste of a real butter that some people in villages were making for themselves.

Ayway, Joe got excited and started to google the butter. To his surprise, there is a Web site where the US Department of Agriculture tells you how to buy butter . I really respect the USA authorities, but when it comes to war in Iraq and buying butter, I have a different opinion.

The USA is a great country where everyone has something to eat. When I came to this country fifteen years ago with no money in my pockets, I thought that the brand “I can ‘t believe it ‘s butter ” tasted great. Now I understand that this is garbage. But it was affordable to me. Chicken legs – 39 cents a pound, hot dogs two packs for a dollar. This was OK at that time. I survived, and now can afford to purchase better quality products. If, God forbid, I ‘ll be poor again again (caused by things that are not controlled by you: disease, divorce, my son gets accepted to Harward, et. al.), I ‘ll start eating at Golden Arches (a.k.a. McDonalds).

Not every American programmer can afford to own a nice house (not a mortgage) and drive a luxury car. But any computer programmer (and business analyst) in the United States can afford to eat tasty and healthy food (do not even try to tell me that eating fat is bad – it ‘s not even funny anymore). Have a good day, and treat yourself to a good lunch and dinner tonight

I just sold my business card for 97 cents

I just sold my business card for 97 cents to the soup nazi , which is a small soup place made famous by Jerry Seinfield. They have a large glass jar with a sign “Give us your business card and you ‘ll get 10% “. So I gave them my business card, what the heck!

Here comes the mathematical quiz: how much money did I spent for lunch today if the sales tax in New York is 8.65%?

Do Spring combined with Hibernate weigh less than EJB?

Lofi Dewanto in his blog asks if Spring framework used with Hibernate is still a lightweight or a heavyweight champion of Java frameworks?

I believe that not only this combo, but even each of them separately is pretty heavy as ANY framework. Only reusable loosely coupled components are lightweights.

Spring framework is advertised as a set of components that can be used separately, but you can also wire them together by adding two pounds of XML. The minute you do this, you fall into an XML trap. So if you use any single component of the Spring framework it ‘s lightweight. But as soon as it takes two to tango, and you are pulling a tiny roll of thin wire out of your pocket, it becomes heavyweight. Because wires (a.k.a. XML) tend to twist and create a mess.

Speaking of Hibernate, I ‘m not even sure WHY so many people are using it in the first place? I can understand if an enterprise architect is laying out a new design of a stack of business applications and wants to enforce to a firm-wide standard for data persistence. But if you are developing a typical CRUD application, especially when it comes to using already existing and not perfectly designed database, why even bother with Hibernate? Do you really hate or afraid of SQL?

Anyway, take an application built on the Spring framework components interconnected with thin wires, put on top of it Hibernate with the wires of different diameter, and maintainability of your application decreases while hard to find bugs are making themselves at home in your application.

During the last three to four years many people like bashing EJBs as an unnecessary complicated framework with lots of convoluted XML descriptors. Now EJB 3.0 with its annotations is trying to appeal to enterprise developers again. This won ‘t be easy, because bad memories last for years. But do not kid youself when you substitute EJB for Spring/Hibernate combo. Your life won ‘t be easier at all.

I do believe in standalone POJOs which know nothing about environment they are in (an IoC concept works fine), and know how to perform a specific function, i.e. send a message, manage transactions, create a pretty report based on provided SQL, model some financial process, find an optimal route, e.t.c. Just pass the required parameters to this black box, get the result back and do whatever you want with it. Stop wiring, just write the freaking code specific to your business application and forget about it when the new project start. Do not forget though about independent reusable components.

Spring is probably one of the best Java frameworks available today. It has only one drawback: it ‘s a framework.