Saturday, February 12, 2011

Please Sir, don’t apply that Design pattern here…

Not sure how to start on this, but since many years I have seen a disturbing trend in Software industry - Being obsessed with technology, being obsessed with new things and having those inner fetish towards the tools rather than the work itself.
What I mean is sometimes developers/architects use certain technologies not because there is a need in the current architecture but because either it’s an ‘in thing’ everyone is using or it’s something new they recently learned or may be got a free book on it.
For instance, I worked with some highly techie guys who created a very robust multi-tier system which use to communicate with many third party data stores (including mainframes). And for each system the folks used different set of middle wares. Somewhere they were using MSMQ, somewhere IBM MQ and what else. You name the middleware and they had used it.   
I talked to one of the guy to understand why it was done, and he clarified “we were bunch of young guys mad about new things with lot of zeal to try them”.  End result, when the whole big application was transferred to a new team, they had no clue what was going on, and even the previous guys were not having the complete information to give a good KT (quite obviously there was no documentation what so ever)
Being a techy guy I myself get interested in new tools, but that’s my leisure time work and not when I am doing official project. Software folks need to understand that learning is a good thing but should be tried on a personal level, may be a PoC. Just because you have learned new things doesn’t mean you should simply apply it everywhere.
(just to list few of the other over used things - Design patterns, XMLs, and now every manager is talking about Cloud :). In a recent meeting, few managers kept using Cloud and SaaS interchangeably, and even after lot of argument I was not able to convince them that both the things are different)

Edit: Recently came across two articles on the same lines, good read:-
The Duct Tape Programmer
The 7 deadly sins of software development

Wednesday, February 9, 2011

Eclipse plugin editor > Extension tab Issues

While adding / updating any extension in Eclipse Plug-in Editor, many times you may have seen that you add an extension point and right click on it > New > Shows only “Generic”.
For example, in tutorials available on web you will see something like this: 
But in your IDE you will only get the Generic option. Also many other extension options are missing.
Solution: Get the source for the corresponding plugins. One way is to download the eclipse with source included. But that can be too length process. Another quick fix is using Eclipse 'Install new Software' wizard:
  1. Go to Help - Install new Software
  2. Select the helios (corresponding) site
  3. In the filter box type: Eclipse RCP Plug-in Developer Resources 
  4. Select the filtered option displayed and install. 
  5. Restart Eclipse and you should get the proper options while working with Extensions

Friday, February 4, 2011

Equinox: Reading External File

I was looking for a way to read a file from the current directory. The business scenario is: We are opening a socket connection from an equinox bundle.
Currently the port for the socket communication is hard coded. In a rare scenario it’s possible that the port will be already in use. We should be able to provide the port from outside the execution environment. 

One way is to pass it through the launch arguments. But sometimes getting hold of config.ini or starting the application from console may not be possible. (In case of custom launchers)

Second option is to read the port from an external file. We can use following to pick the file:

this.getClass().getProtectionDomain().getCodeSource().getLocation() - Gets the current location of the bundle.

If we have kept the file with port at the same location then read the file using:
URL url = new URL(this.getClass().getProtectionDomain().getCodeSource().getLocation()
+ "/../messages.properties");
InputStream inputStream = url.openStream();
Properties properties = new Properties();
try {
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace(); 
}
socketport=properties.getProperty("SocketPort"));

Not sure if that's the best way. But surprisingly I didn't find any other way to read a file from the current path kept outside the bundle; and even this is specific to Equinox and not available in other OSGi implementations. If anyone is aware of any other way then do let me know