Shaaf's blog

A technical blog about Java, Kubernetes and things that matter

Command

By using the command pattern you are seperating the operation from the invoking object. And just because of that it becomes easier to change the command without chagning the caller/s. This means that you could use Command pattern when you might have the following situation

You want to parameterize objects to perform an action You want to specify, execute and queue requests at different times.

Just to quickly start you need a command object, An interface will keep it easy going in this case, thus providing you with the option of extending other classes e.g. Swing MenuItem or Button. Below the execute Method is the one invoked to do something when this command is called or asked to do its stuff. Where as the getCommandName is assumed as a unique name how ever I am sure we can always come up with a better implementation for uniqueness.


Implementing the adapter

Typically when implementing an interface you would have to implement all the methods that exist in that interface. A very good example is the MouseListener in the java Swing. When you need to implement more then one method where as typically you might be catching only one of them. Saying that you would also find a Mouse Adapter provided as well. Some of us use that often. And that is part of the Adapter pattern. It makes life easier for me sometimes.


wasprofile -create -delete

Sometimes you require to do things silently, without any questions asked and “Just Do It” attitude is required.

I often find my self with this problem.

If you want to delete or create a Websphere profile from your command line try the following. (I have tried on RSA only)

# deleteing a profile
wasprofile -delete -profileName MyProfile

You should get the following message on deletion

INSTCONFSUCCESS: Success: The profile no longer exists.

Creating a websphere profile


Abstract Factory pattern

Factories have been a key pattern in building applications, its fascinatingly simple, effective and to the point. When starting to learn a design oriented approach to applications or API, I would always recommend a factory pattern as one of the key starting notes of highlight in your design.

So today I am talking about the Abstract Factory pattern. Its not an “abstract” class or object that you call a pattern. But its a Factory of facotries and that is what exactly makes it so much wordingly abstract. Having “abstract” classes is there but just some other side of the coin.


Crocus - CSV Reader

Easy to use ready to go CSV File Reading utility. Read One or Multiple files into a RecordManager, quick access to the file with segmentation into Fields and Records. Merge Multiple CSV files in one. Listener to CSV Files.

Download Here

Organization: A CSV file is broken up as follows A CSVField has a group of characters A CSVRecord has a group of CSVFields A CSVFile has a group of record