Tuesday, 13 December 2011

Compilation error due to method ambguity - Java

Today I encountered some new compilation error (atleast to me it's new). For example, there are two methods in the class.

public void doSomething(String value) {
// do something
}

public void doSomething(Long value) {
// do something with Long
}


And if you try to call this method

doSomething(null);

The compilation error will occur and states that, The method doSomething(String) is ambiguous for the type AmbguityTest. This is due to the fact that, the compiler doesn't know which method to invoke since both accepts a null value.

The solution is to add a cast to the argument. So, we can call like this.

doSomething((String)null); // To call String version
doSomething((Long)null); // To call Long version

Wednesday, 16 November 2011

My passion for web services

I always wanted to work in web services, back in 2006 when I was working in Hewlett Packard, I overheard my seniorsaying 'exposing any method as web service' I got interest in it. After some initial reading and understanding I realized that any java method or functionality can be exposed as web service, so that client programs from remotelocations can consume them. I also learned that web services are B2B (Business to Business) communication where applications talk to each other by exchanging XML documents.

I am really excited the way web services achieve interoperability among applications developed using heterogenious frameworks. A .Net application can consume web services exposed bya java and vice versa. The central idea is the usage of XML which is platform and technology neutral. Later, I came to knowabout REST web services. I don't have detailed knowledge of REST web services, though I know the core idea.

Now, after 5 years of knowing web services, I really didn't get a chance to work in real life project using web services.All I did were hello axis, hello jax-ws, hello-metro web services which are very basic. I am seriously considering writingOracle java web services certification and then later IBM SOA certifications. I will be posting more web services materialfrom now on, especially the information on critical errors I got during development and deployment of web services and how I fixed them.

Tuesday, 1 November 2011

How to learn?

Today I became interested in learning application server administrative concepts. Since I am a Java Developer, I am familiar with Weblogic and JBoss servers and how to start/stop, deployapplications etc. To learn more administration stuff, I went through Oracle weblogic documentationand I totally lost!!! There is simply too much information, links, sub-links, sub-sub-links atmultiple levels. I got confused and sleepy. Just then I realized that, I cannot learn this byrote or by memorization. This is to be learned by really administering it. My current job rolemay not give me full control to administrate an application server, I decided not to bother mybrain anymore and learn must be need basis.
In my case, always its proven that learning is need basis. For example, I need to learn how tosetup a Datasource, then quickly I will spend couple of hours reading datasource configurationand prepare steps to be followed. I will execute those steps in the test environment, make changesto steps as and when needed. Finally, after thorough review by peers, the steps will be executedin production environment. So, I learned datasource configuration this way. In the same way, Ilearned jQuery as my previous job needed it.
So the rule is to learn as demand arises.

Tuesday, 14 June 2011

jQuery Mobile Ajax page navigation behaviour / way to disable it

jQuery mobile uses Ajax to navigate to different pages by default. This means, the target page's DOM is embedded into the current page. So when you view the source of HTML in browser window, you will only see the first page's HTML. Due to this Ajax request, subsequent
pages will be dynamically added to current page as DOM. This helps light page loads and transition effects on mobile phones.

However, I had a situation where I am reading data from one HTML form and submitting to another HTML form. The form submission failed because the second form does not exists in the page. Because of this I cannot access 'document.secondform.username' since there is not 'secondform' physically present in the page.

To avoid this, I disabled Ajax using the following code.

If you are using links using Anchor tag, add the following attribute to avoid Ajax call.
data-ajax="false"
If you are using form submission, add the following AFTER jQuery JavaScript reference.
$(document).bind("mobileinit", function()
{
$.extend( $.mobile , {
ajaxFormsEnabled: false
});
});

By using above code, the default request model of jQuery mobile changes from Ajax to pure HTTP. The tradeoff is we cannot do transition effects over mobile phones. It's a design decision to make when designing functionality.

Thursday, 2 June 2011

Resetting Oracle XE 'SYSTEM' account password.

SYSTEM and SYS are the default accounts and you'll need to supply password at the time of installing Oracle express edition.
If you forgot your Oracle XE 'system' account password, follow these steps to reset. In fact, I forgot and reset it just now.


Windows: Open any DOS window and do the following.

C:\set ORACLE_SID=XE (or your service id)
C:\set ORACLE_HOME= (Eg: C:\oraclexe\app\oracle\product\10.2.0\server)
C:\sqlplus / as sysdba

You should see SQL> prompt with DBA privileges. Next, issue sQL command to alter the passwords for SYSTEM and SYS accounts.

SQL> alter user system identified by ;
SQL> alter user sys identified by ;

You need to reset password for both SYSTEM and SYS accounts.

Wednesday, 20 April 2011

About Punctuality


Why things will not start on time? I suffered countless number of times waiting for people in the meetings. I developed a phobia to be on time strictly! I am really proud of this but I ended up waiting and waiting in most of the situations. Especially during interviews, the consultants schedule the interview exactly at 9:00 AM. I will reach the office by 8:30 AM. I needed 30 minutes to get used to the environment. But, I will end up taking interview at 3:00 PM!! I wonder why people set times and finally skip schedules. Is it because of negligency, or they just don't reallize the time? However, I decided to be punctual for everything. Oops!
Got to attend a meeting in two minutes.

Tuesday, 12 April 2011

Making new employees productive

I joined typical 'desi' IT company in Singapore couple of weeks before. After working in so called 'Singaporean' companies for almost four years, I was really excited to work in new environment. I revised my old books and refreshed my memory and prepared for the first day of work. My expectation was, I will be given bunch of documents / digarams to go through for a week and start working immediately. So that, I can prove what I am quickly. Once I joined here, I lost all of my enthusiasm. After one week of sitting without computer (belive me, sys.admin here is a part-time employee), I was given brand new computer boxes the next week. That means, I will have to setup everything on my own. Ok! No problem! I setup my own pc and sat in a place that looks like a kitchen table. Then, somebody gave me four documents to go through and asked me to create few HTML/JSPs. The guy gave me documents disappeared to client place. The guy asked me to create HTML/JSPs left for marriage for three weeks. The people who recruited me were no longer seen there. All on vacation I guess! Great! Two more weeks passed and this is my third week. Loosing interest day by day in my new job! What a pity!

Ok! If I recruit somebody, or if I am a manager, I follow the following tips to make new recruits productive.

1. I arrange them training, so that they can clarify their thousands of doubts without clarifying them the hard way.
2. I will make sure somebody is available to them so that they can clarify their 'on the job' doubts, atleast for a month.
3. I belive in jump starts. So, best way to get productive is to get into job, start with small tasks and grow to bigger ones.
4. A friendly envionment is mandatory. All these guys behaving like enemies to each other. Typical Indian mentality!
5. Briefing about overall architecture of the project, this gives senior developers like me to adopt to the system quickly and to start contribution.

Can't think of more, I realized the heck today. What to do! Just have to stick to it until a year atleast. My job search again depends on this company's annual bonus which is going to be paid to me!

Thursday, 17 March 2011

Reacting to the production problem (software, ofcourse)

Procution problem start with PANIC and ends with PEACE, but its in your hand to avoid CHAOS.

I almost worked for four years in a production environment support web sites for media giants in Singapore.Also faced so many production problems and learned so many lessons during code deployment, troubleshootingand finally solving problem thus keeping business user's trust. I summarize the following points to keep inbrain while working on production envionment be it banking, media or any other.

Things to consider when deploying code to production

1. I am bored to write documents. But a detailed document which outlines the steps to follow to deploy code production is mandatory to avoid forgetting things in the last minute. Once the document is ready, all we have to do is just follow the steps and thats all. No stress. Moreover, by preparing document, we can come to timing as well. Let's say if takes 2 minutes to deploy each module and it can take 30 munutes finish total deployment. If we have the duration then we can keep everyone informed.
If something goes wrong, atleast we can save our back by showing the pre-reviewed and pre-approved document to our managers that we followed the procedure.

2. Plan for failures - if something goes wrong, how soon we can bring back the system to normal state. It is important to mention 'rollback plan' in the deployment document. After all, if we cannot deployment our code we don't want to ruin the system. Its our moral responsibility to bring back the system to normal.

3. Avoid peek hours - especially in media domain, early morning is the peek time to churn out news. Business users hate to wait for deployments. So, choosing off-peak hours for deployment is better. If something goes wrong, atleast we will have couple of hours to troubleshoot and debug the problem. I prefer mid-nights for deployments to avoid calls/smses from bosses for every 10 minutes asking whether everything is okay! Irritating! But its their concern too! isn't it?

Thigs to consider when troubleshooting production problem

1. If system fails suddently, your phone on your desk rings immediately. And the chaos starts!!! Everyone sits on your head from managers, to end users to CEO. All you have to do is STAY COOL. Tell them that you're working on the problem. If you panice ALONG WITH THEM, you can't even remember server password!!!

2. Solving production problem is two step process. First, we MUST thoroughly understand the problem. We must be 100% sure that a specic 'scenario' caused the problem. Second, once we establish the fact that root cause of the problem we need to think of possible solutions to fix the problem. My approach is to quickly fix the problem (even if it is workaround) just to make bosses and end-users happy for the moment. Once they're silient, I will take my own time to refactor the code and fix the problem permanently for good.

3. Document the problem and solution you applied in a log. This helps the next poor guy who takes over the system after you quit the company :) After all, you don't want to distrub other guy's family life at night 2 am.

4. On top all these things, important thing is to STAY COOL AND CALM even if you cannot fix the problem. If you think you need more time or you cannot fix the problem, better to escalate the issue to manager. The manager probably calls some expert or architect who can advice you or fix the problem by themself.

Tuesday, 15 February 2011

My job hunting addiction in Singapore

I decided to change my job when one consultant called me in the middle of September 2010 and tempted me about a Vignette opening in one of the reputed investment bank here in Singapore. In fact, until that day, I had no intension of changing job. I thought of giving a try. I updated my profile and sent to the consultant. To my surprise, eventhough I posses what they're looking for, I haven't got interview call!! Since then, my mind keep thinking of job change and applying jobs became my addiction. After attending few interviews and being rejected several times, I understand that there are many factors in Singapore job market which influence the recruitment strategy. Please note that these are my personnel observations and I may be wrong! Just observations ...

1. Main important factor is salary. Every position in Singapore has fixed budget. Let's say, Java developer. The budget for this position would be somewhere between 4000 SGD to 4500 SGD maximum for a 5 years experienced professional. Eventhough the candidate is from IIT or MIT doesn't matter. Budget is fixed. Companies will not offer a dollar extra because they have a burden of EMPLOYER CPF CONTRIBUTION and AWS on top of the salary. I didn't get jobs because my current salary is far above market standard.

2. Language barrier - Companies need people who can speak mandarin to communicate with their China offshore teams. Moreover, they prefer people from their own race to socialize with them. Since I am an Indian guy, not much response from non-Indian IT companies.

3. Political barrier - Yes. From company's perspective, why they need to hire me? I am an expat who is on Permanent Residence. They would prefer to hire local people with less experience and provide training! By doing this, they are impressing government and contributing to their country's economy.

4. Competition - Not only from fellow Indian guys, also I need to compete with people from China, Phillipines etc etc.
Also, when Indian guys takes interview, they ask questions on API and fact memorisations.

5. I am not a scholar acadamically though I had couple of Java certificatins. Singapore job market doesn't need any certifications. SOmetimes companies think I am over qualified due to these certifications.

After spending many sleepless nights thinking about all these things, I just removed my resume from job sites and decided to continue in my current job for few months. But surely I will give a try later ...

Saturday, 8 January 2011

Certifications - a myth?

I did my Java programming and web compoment development certifications. They surely helped me to strengthen my skills on web development. I learned so much from them. Unfortunately, over a period of time I forgot everything. I realized this when I attended few technical telephone interviews, I couldn't answer the questions. After I failed in the interview, I went back and revised the topics I studied for certifications. Oh shit! I read all this stuff before and mastered! So, what's the point of spending $$ to do certifications if I am not FULLY implementing those skills I acquired for certification.

Moreover, I realized that certification is something which acts as a supporting factor to your education and experience. Especially, here in Singapore, nobody will give you a job because you are certified in MQ-Series, the criteria for job is whether you have worked in MQ-Series. Certification is just optional. So, unless you are experienced in a particular technology, your certification is not going to help.

Wednesday, 5 January 2011

Iterative Development vs. SDLC

It's my favourite topic. My current project badly requires Agile and Iterative development approach, however I failed to convince my orthodox project leader about this. We are struggling with often changing requirements, gaps, miscommunication and working with people who lacks interest in work and bad attitude. Leaving behind political, personnel issues, Iterative development is good because it gives transparency to the customer. Customer can see working software rather than plain documents on how software works. Nobody is going to appreciate for documents. What customer wants is real software. I hate to bog down in details of requirements and analysis stuff.

Nothing in the world is constant except change. Even we freeze the requirements, they are infact not freezed. Just after signing requirements documents, I got a call from one of the stakeholderwho participated in the project kick-off meeting. She wanted to change things here and there. This is the beginning of the changes. I know stakeholders who changed requirements even before the day of software release.The bad thing about SDLC is we try to define everything at once and we insist on sticking to the plan. I strongly believe in Murphy's law and don't expect things to go smooth. On the other side, if we follow more Agile, Iterative development approach, myself and my team have flexibility to embrace change, and time to respond to customer's needs. Ultimately, our job is to deliver what customer want. For customer, time, money and working code are the successful factors.

New Year - 2011

I used to blog before, I had created few blogs and later I deleted them in frustration. However, I made a new year resolution to start blogging again. This is due to the flow of thoughts in my mind. Now a days, I have too many thoughts going on in my brain wasting many many brain CPU cycles. Now, I have a way to share my flow of thoughts by serializing my thoughts to blog. I came to know that, the longer the blog exists in time, the more chances of getting listed in Google search results. Not sure of this, but decided to give a try. Blogging is good to share experiences, ideas and to spend time whenever possible.