Monday 31 August 2009

Outsourcing ... be afraid?

As a person who specialises in technology and living in a, by economic definition, 1st world country, I would be lying if I maintained I had never felt threatened by the trend to outsource development functions to lower cost destinations.


Owing to my stereotyped views of hoards of highly educated, ambitious graduates willing to work twice as hard for a quarter of my salary, I decided to do a little bit of research and rationalise my views.


With reference to outsourcing, the trend presents opportunities as well as threats plus you need to look at reflexive trends as well.

Outsourcing will provide a software engineer with good planning skills and skills with colloborative development tools, with new opportunities to collaborate with offshore development teams as well as contribute to development. These days you need to full understanding of the goals of any IT undertaking and use technology to manage as well as work yourself. 



In essence the job itself is changing, no longer can a software engineer just immerse himself in technology, the need to understand the benefit the technology brings to an organisation is paramount, and to be able to communicate that benefit to the organisations management structure is also of primary importance. We all need to not only appraise technologies from a technical perspective but from a business and revenue generating perspective as well. 


The ability to assess how much effort a technology will take to implement and its direct or indirect contribution to an organisations revenue streams is now not just a manager function, its needs to be understood by the software engineers themselves.


If you analyse and for a minute accept the points I have made above, the following needs to be considered too. Technology is also empowering people with a traditionally non-managerial role to manage themselves and to set their own targets and report their progress in colloboration with their co-workers or co-participants in any unit of work. With good implementation the senior management can access the data they need to for progress reports and to draw up budgets. 


This puts pressure in an organisation on the lower level of management who are neither as tech-savvy nor possess the ability to actually DO the work.  


With regards to reflexive trends in outsourcing, in outsourcing markets you have the following trends, wage inflation and more worker centric employment legislation.

A demand for outsourcing services will inflate wages to the point that it becomes more cost effective to operate in the host country, especially coupled with the relative wage stagnation in the technology sector in Western Europe and US.

One of the other reasons companies outsource is that the host country affords less employment rights to workers enabling productivity increases using factors such as unpaid overtime, easy and rapid dismissal and hiring processes. As the workforce gentrifies political pressure to provide more employment rights will come to the fore, in many cases rendering outsourcing less profitable and effective than at present.

Outsourcing also drains the host company of intellectual property and the ability to effectively secure data and IP rights so this also has to be looked at when assessing trends in the technology sector.

In my opinion, outsourcing decisions have been taken in many cases , by managers who are under pressure to deliver short term financial benefit, and who themselves don't understand, and are reporting to people who do not understand, the full implications of outsourcing.

I think we are entering a mature stage in the outsourcing cycle which will see its use level off or drop in some sectors.



In essence we have the following forces at play:
1) Rising costs in outsourcing destinations
2) Falling or stagnating costs in "outsourcer" destinations.
3) Political pressure to protect labour markets in traditionally "outsourcer" destinations
4) Increased expectations and political pressure in outsourcing nations to improve working conditions
5) Increased concerns for intellectual property rights and data security
6) Increased public awareness of data security and the resulting legislative and social accountability of corporations.


To sum up, I think outsourcing is less of a threat than I originally thought, and will be a declining trend. 


This is cold comfort to those of you who have lost your jobs owing to outsourcing, but its maybe worth looking at these factors and remembering that technology also influences one other thing; the rate of change. Changes in employment trends and other changes in society are happening at such a pace these days it is very difficult to stay ahead or even keep up, and we all at some point, unless we are very lucky get caught out.


Never a truer word said than the only thing constant is change. 

Thursday 20 August 2009

Groovy Precompiling



Maybe anybody who is interested in Groovy can make a few comments about this.


The requirement is that we offer functionality that extends what exists in core functionality of a java web application surrounding the persistence lifecycle.

So I added functonality which, will execute a groovy script which has been associated with an event and object type EG preupdate and Widget. The script also needs to be updateble within the session lifecycle.

This works well and adds loads of flexiblity but there will be an obvious performance hit owing to the creation of a groovy shell and execution of the script during the persistence lifecycle.

So my collegue suggested we look into precompilation of the scripts into classes and executing these in a native java environment rather than creating a Groovy shell and running the script, which will need to be dynamically compiled every time the script executes.

This was achieved in essence by creating an instance of the compiler , compiling the script to a class file and storing it somewhere pre-execution, and then when the script needed to be executed, Loading the class (Will always be a subclass of the Script class) and calling the run() method


So to compile we we do this and the resultant output is a .class file.


CompilerConfiguration cc = new CompilerConfiguration();
cc.setTargetDirectory(destdir);
cc.setScriptBaseClass("groovy.lang.Script");

Compiler c = new Compiler(cc);

c.compile(myClassName,myScript);


Now we need to retrieve the class and for that we need a ClassLoader, so I extended the ClassLoader to create a FileClassLoader which finds the file on the file system, creates a byte array from the file, which it passes into the defineClass method of the ClassLoader class definition.

We create the script by creating a new instance of the class and clalling the run() method on it:


FileClassLoader fcl = new FileClassLoader();

start = System.currentTimeMillis();

Class cls = fcl.loadFromFile(DIR + "//DIR//" + classname + ".class", classname);

Binding b = new Binding();
b.setProperty("obj","compiled");

Script scr = (Script) cls.newInstance();
scr.setBinding(b);
scr.run();

The result of this is the as doing this :

GroovyShell gs = new GroovyShell();
gs.setVariable("obj","interpreted");
gs.evaluate(script);

The theory is that every time you pass the script in a string variable to a shell it needs to compile and then execute the script and precompiling will prevent the need for this, thus providing a performance gain as essentially, it not executing a script which needs to be dynamically compiled, but is executing precompiled code.

I tested for performance and since I have the groovy plugin installed in my Eclipse IDE, the script is compiled and cached even when using the shell so there is not real performance gain when I test in the IDE, but will this be a more efficient way of using Groovy on the webserver?

Will update this post when I have an answer