On importance of book titles

How do I make a decision to purchase a book?

1. If I know the keywords (Java, .Net, SQL), I search online, read the book description, 3-4 reviews and click that button.

2. I go to my local Barnes amp; Noble bookstore and pick up some books from the shelves. I pick the books either from a well known publisher/series, or the ones with intriguing title. I may not purchase them eventually, but at least they have a chance.

Yesterday I went to B amp;N and after my usual scan of the Java section, I noticed a small red book on the top shelf (not a prime location) that put a smile on my face and I picked it up. The title was just brilliant:

“My Job Went To India and All I got was this lousy book. 52 ways to save your job “.

Our B amp;N has a large area where people just sit and read the books. If they like it, they buy it (sometimes from the Amazon), if not they put it back on the shelf.

I skimmed through this book and did not purchase it. The author was not able to sell me any of his ideas/advises. This book had some not too practical recommendations on managing your career and scattered bits and pieces on author’s experience in establishing a software shop in India. The author spent there a year and a half, but unfortunately did not have much to share.

So even though B amp;N is more expensive than online stores, it gives you a chance to check out a book…and not purchase it.

But that title was just perfect , and I’m sure many copies of this book will be sold (mostly online though). I take my hat off to the publisher of this book.

Commuters rules

Every morning I take a bus that gets me from New Jersey to Manhattan. The bus is comfy, I have my laptop with me so I can do some reading/coding/writing/listening. I know some people who take the same bus for years. This morning I’ve had a small talk with one of them while waiting for the bus. When we’ve boarded the half-empty bus, I took a seat and this guy told me (as usual), “It’s nice seeing you, Yakov ” and took another seat… two rows down.

When this happened for the first time, I was wondering why he did not sit down next to me taking the risk of having some fat snoring commuter as a neighbor later on? After a while, I realized that that by doing so he respects my privacy and does not want to change my (and his) plans for this commute. That’s why I did not waste my time talking to him, but had a chance to write this interesting blog post 🙂 During the next 30 min I’ll be doing some technical writing for work.

Here’s my tip for commuters: to eliminate the possibility of having a large person on the seat next to me, I usually pick a petite-size woman and take a seat next to her even if the bus is still half-empty.

Enjoy the ride!

Will Teach Java for Food in Your Country

Will Teach Java for Food in Your Country

Do you want to have a Java master class in your country and your town?

I’m ready to teach Java for food.

Does this mean that it won’t cost anything to you or your firm? No, this means that I will not make any money out of it.

Here “s your part:

1. Your town must be located within 9 hours of direct flight from New York.

2. You purchase two roundtrip air tickets and arrange for hotel transfer.

3. You book a room in a decent hotel in your town for two-three nights.

4. You pay for food.

5. If your country requires entry visas for US citizens, you pay the consulate fees.

Here “s my part:

I “ll deliver two six-hour training sessions. This can be Java basics tutorials or separate presentations on more advanced topics (Just print a program of one of the seminars Weekend With Experts to see my presentations).

This training should be scheduled either on Saturday/Sunday, or on Sunday/Monday.

Who am I to teach you Java?

I “m a J2EE architect and developer working for Wall Street financial companies, but most of all I enjoy travel and teaching programming languages (I teach Java part time at New York University). I authored/co-authored three books and has written dozens of technical articles. I “m a contributing editor at Java Developer’s Journal. I lead the Princeton Java Users Group. Recently Sun Microsystems has awarded me a title of Java Champion.

If you want to contact me regarding this deal, please send me an email at yakovfain@sys-con.com

Fine print: this offer does not apply to the cities located in USA and Canada.

Debugging Distributed Applications and Viagra

This morning I’ve been listening to the radio and the news were mixed with an infomercial by some urologist. While he was talking about erection, I was thinking about similarities with debugging distributed applications.

Here’s what I’ve learned (I do not remember the proper terms, but I got the point):

1. There are three reasons of erection problems: mental, physical and mixed.

2. Inexperienced doctors just prescribe Viagra.

3. But he (a good doctor), uses computers and techniques based on two

types of sleep to debug the issue and find the proper cure.

People have “deep ” and “shallow ” sleep, and during the deep sleep healthy men experience erection. So he asks his patients to sleep with a special computer that will “remember” if this patient had erection or not.

From a programming perspective, a human body is a super complicated multi-tier distributed application. I’m sorry for this analogy, but erection is sort of a user interface 🙂 If it does not happen, the end user is not happy.

So above “functional spec ” should translate into the following Java if-statement:

boolean wasErection, strong;

…

if (wasErection amp; amp; strong){

// the bug is in the mental tier,

// change the partner

} else if (!wasErection){

// the bug is in the physical tier,

// prescribe drugs A

} else{

// the bug is in both tiers,

// prescribe drugs B or change the partner

}

When you debug a multi-tier distributed application, which has, say performance problems, try to find the problematic tier and apply local fixes. But some people use “the Viagra approach”: upgrade the hardware (add more memory/processors), introduce clustering, etc. This solution helps for some time, but then another blue pill is needed… It’s always good to start with fine tuning of each application tier.

Viagra should be your last resort

Homeless: New York vs. Toronto

It’s my second week of training in Toronto and I can’t get used to the look and the number of homeless people and beggars this city has. There are homeless in New York as well, but they are different. They’re kinda professionals homeless, while these look real. In New York, I give money only to the musicians who play on the streets and in subways, but here, I give money to homeless. I spoke to locals, and they say that homeless in Toronto also have shelters, but some of them live on the streets because people like myself would give them money.

It was raining this morning while I was heading to my class. I saw at least ten people sleeping or just sitting right in the middle of sidewalk on these grid opening which exhaust some warm air. A couple of 20-year olds was sleeping under the same blanket under the rain. How can you not give? Some people say it’s drug related. I do not know.

You can walk on the streets and all of a sudden a passer by asks if you have some spare change… Where are all these advantages of “a better social system ” which is an advertised by the Canadian media?

What I found really better in Toronto was the subway system. It has not more than a 100 stations, but they are nice looking and clean, and the trains are moving almost silently. It’s something similar to monorail trains that operate in New York airports.

Let me conclude this post on even more positive note. Noble residents of Toronto! Rest assured that the data on homeless will not sneak in into these glossy reports on best places to live, and your city will stay on the wish-list of many people around the world.

But I’d rather get going back to New York 🙂

The first meeteng of the new Princeton JUG

Our first meeting will take place on December 6 from 7 to 9PM in East Windsor, NJ (close to Exit 8 of NJ Turnpike). The agenda:

1. 7:00-7:20 PM Getting to know each other while consuming food:

2. 7:21-7:30 PM A book raffle

3. 7:31-9:00 PM The presentation “Using Java Messaging in Financial Applications ” by Yakov Fain

I’ve created a Yahoo group at http://groups.yahoo.com/group/PrincetonJUG/ , and if you live in the area, join us! Just subscribe to this group to receive further announcements.

I’ll send the driving directions to the members of this group in a couple of days

New York – Toronto – Paris

Yesterday, I was told that in two days I have to be in Toronto for training. This time I’m a student and it’s a new hot software that I’ll be using in my next project. I never say no to learning, so I’ve booked the flight and the hotel. Hilton is going wild: they almost double the price if you do not book in advance. Fine, I’ll stay in Sheraton.I got the cab by the Rockefeller Center in NYC pretty fast. It’s been driven by an Arab driver, and he kept talking on the phone…Non stop. I did not understand a thing, which is good. Or bad? I’ve heard that when you take a cab in London you can ask the driver, “Who’s in town?… “. The flight was from Newark airport, so we had to take the tunnel. At the airport, th edriver said that he did not take creadit cards and there’s a $15 surcharge just for leaving the city. No problem, but no tips.

Continental is much better than Delta. When you fly Delta, everything feels so cheap. They promised bankruptcy last year, but it did not happen yet. Just keep the promise, guys! Continental is better. Easy computerized check in (if you do not check in the luggage).In Toronto airport the custom officer was asking too many questions. Most likely it happened because I wrote “Business” as a purpose of my visit. “I came here for training”. “What kind of training?”“Computer training” “What kind of computer training?”Ok, Ok, he’s bored…Another cab…This driver was wearing a turban and was listening to the radio in some unknown language, but the car was clean and comfy. I was sleeping.“Do you take credit cards?” “Yes, if you do not have cash”“This is better! Sure I do not have cash.”I left my bag in the room and went downstairs for dinner. The restaurant was surprisingly good for a business-oriented hotel chain. No, they did not have the Leffe beer that I usually drink, but Stella Artois was also fine. I’m planning to go to Paris in two weeks, and this is THE place to be. Food and drinks are superb at any restaurant there. Unfortunately, France is burning for the last thirteen days. They’ve asked for it. I did not realize before that this country is so weak. It’s so easy to blame America for invading Iraq… It did not help them, but now they do not know what to do… They are still waiting for something, as if they do not know that these people understand only the brutal force. They’ll get it … 5000 burned cars later. But their food is still the best in the world!

If French won’t stop these animals who came to their country and fck them right there in their own home, in five years the most popular dish in Paris will be falafel. FYI, the animals are not the teenagers setting cars on fire, but the people who give them the bottles with the Molotov cocktail and explain them how to pick the cars to be burned. Yes, shit like this can happen in America too, and some people tried to break the law in New Orleans after Katrina recently. But police got the order: ”Shoot”. It helped.

Anyway, I like France and wish this country only the best. Good night! Tomorrow is the first day of training…

Im starting Princeton Java Users Group

The company called Infragistics located in East Windsor, NJ have responded to my call and have offered to host a new JUG, so I’m opening the enrollment (it’s free). Thank you, Infragistics!

This group will meet monthly at 7:30PM. I’ve created a Yahoo group at http://groups.yahoo.com/group/PrincetonJUG/ , and if you live in the area, join us! Just subscribe to this group to receive further announcements.

I’m planning to have the first meeting in the beginning of December 2005. I’ll be the first speaker (of course!) and will have a talk on using Java Messaging in financial applications. No worries, this won’t be a one man show, and in the future, I’ll be inviting other speakers.

You can contact me about becoming a speaker, sponsor, or with any other questions/offers by sending an email at yakovfain at sys-con.com. You can find my Java-related articles over here .

Reacting to OS events from a Java program

Sometimes, you need to stop/re-route a batch Java processing. For
example, a program is processing a large result set from a database, it
takes too long and you need to stop it gracefully without killing the
process. If this program is deployed in production, you may run another
program or script that will make an OS level change that your long
running program will recognize. For example, you can start another
program that will create a small file with any content in a particular
directory. The very fact of existence of this file has to stop the
running program. Try to run the program below. It’ll stop as soon as
you will create the file c:\abc.txt

import java.io.File;

public class FIleCheck {

public static void main(String[] args) {

File killSignal = new File( “c:\\abc.txt “);

while (!killSignal.exists()){

System.out.println( “Processing the next row from a database… “);

}

}

}

If you do not want to do a file check on each loop iteration, use Java modulo operator to do it on every 100th read:

if ((i %100) == 0 amp; amp; killSignal.exists()) break;

There are other ways of interaction between a running Java program and the outside world, but this seems to be the simplest one.