Monday, July 31, 2006

Pattern Infected :-(

--------------------------------------------------------------------------------
interface MessageStrategy {
 public void sendMessage();
}
--------------------------------------------------------------------------------
abstract class AbstractStrategyFactory {
 public abstract MessageStrategy createStrategy(MessageBody mb);
}

class MessageBody {
 Object payload;

 public Object getPayload() {  return payload; }

 public void configure(Object obj) {  payload = obj; }

 public void send(MessageStrategy ms) {  ms.sendMessage(); }
}
--------------------------------------------------------------------------------
class DefaultFactory extends AbstractStrategyFactory {
 private DefaultFactory() {
  ;
 }

 static DefaultFactory instance;

 public static AbstractStrategyFactory getInstance() {
  if (instance == null)
   instance = new DefaultFactory();
  return instance;
 }

 public MessageStrategy createStrategy(final MessageBody mb) {
  return new MessageStrategy() {
   MessageBody body = mb;

   public void sendMessage() {
    Object obj = body.getPayload();
    System.out.println((String) obj);
   }
  };
 }
}
--------------------------------------------------------------------------------
class DefaultFactory extends AbstractStrategyFactory {
 private DefaultFactory() {
  ;
 }

 static DefaultFactory instance;

 public static AbstractStrategyFactory getInstance() {
  if (instance == null)
   instance = new DefaultFactory();
  return instance;
 }

 public MessageStrategy createStrategy(final MessageBody mb) {
  return new MessageStrategy() {
   MessageBody body = mb;

   public void sendMessage() {
    Object obj = body.getPayload();
    System.out.println((String) obj);
   }
  };
 }
}
--------------------------------------------------------------------------------

Could you figure out what is the function of the above program? It's just a program to print a "hello world" to the console. Looking weird? This is what a pattern infected person can do, using them wrongly

Read the full thread of from the slashdot.org forum, over here.

Tuesday, July 04, 2006

Live CDs - Cool !!

What are Live CD's?

From the Wikipedia http://en.wikipedia.org/wiki/Live_CD 
LiveDistro is a generic term for an operating system distribution that is executed upon boot, without installation on a hard drive.  

The term "live" derives from the fact that it does not reside on a hard drive. Rather, it is "brought to life" upon boot without having to being physically installed onto a hard drive.

It is often said LiveDistros are a good way to demo or preview an operating system without having to install it to a hard drive.

Suppose your Windows crashed. And there is lot of information left in you c: drive, so you want to retrieve them before you re-install Windows. How to do it? All you can do earlier is to remove your harddisk, and connect to your friend's machine, then copy the data.

But after Live CDs, there is a easy way to do it.

Recommended Blog Posts