Aug 29, 2012

Scenario 1: A web service receives http requests for data, places the request into an internal queue, and a separate worker thread pulls the work item from the queue and performs the work. For example, a trading system creates a buy order and places it in a queue, and a separate consumer thread picks up the order and sends it to the stock exchange. A typical producer and consumer scenario.

Scenario 2: Semaphore can be used to create worker threads even when the number of worker threads to be created is not known upfront. This is because a semaphore can be created with 0 permits, and wait until a number of releases have been made. For example, if you want to recursively traverse through nested folders and spawn a number of worker threads to move the html files found to a destination folder and increment the semaphore permits with a release() method call. A separate thread will wait with the acquire(numberofpermits) to acquire all the released permits before start archiving (i.e. zipping up) those files.

Scenario 3: Reference counting where a shared resource is incremented or decremented. The increment/decrement/test operations must be thread safe. For example, a counter that keeps track of the nummber of active logged in users by incrementing the count when users log in and decrementing the count when the users log out.

Solution: In general, a sem-a-phore means sending messages by holding the arms or two flags or poles in certain positions according to an alphabetic code. In programming, especially in Unix systems, semaphores are a technique for coordinating or synchronizing activities in which multiple processes compete for the same operating system resources. Semaphores are commonly use for two purposes: to share a common memory space and to share access to files. In Java, a semaphore is used for coordinating multiple threads.

Q. What is the difference between a mutex and a semaphore?A. Mutex: is a single key to a toilet. One person can have the key and occupy the toilet at the time. When finished, the person gives (or releases) the key to the next person in the queue. In Java, every object has a mutex and only a single thread can get hold of a mutex.

Semaphore: Is a number of free identical toilet keys. For example, having 3 toilets with identical locks and keys. The semaphore count is set to 3 at beginning and then the count is decremented as people are acquiring the key to the toilets. If all toilets are full, ie. there are no free keys left, the semaphore count is 0. Now, when one person leaves the toilet, semaphore is increased to 1 (one free key), and given to the next person in the queue.

Aug 28, 2012

Are you going for programming jobs at investment banks or financial institutions? Knowing some investment and trading terms will be useful

The investment banks and financial organizations do pay a very competitive remunerations and many of you aspire to work for such organizations. Here are a few questions and answers on different securities, derivatives, and FIX engine/trading system basics to familiarize yourself with some of the terminologies.

Q. What is a stock, share, or equity?A. Whether you say shares, equity, or stock, it all means the same thing. A stock is a share in the ownership of a company. Stock represents a claim on the company's assets and earnings. As you acquire more stock, your ownership stake in the company becomes greater. A stock is represented by a stock certificate. This is a fancy piece of paper that is a proof of your ownership. In today's computer age, you won't actually get to see this document because your brokerage keeps these records electronically.

Q. What is a Security?A. Security is a broader term which includes shares as well. There are two types of securities:

Q. How do primary and secondary financial markets differ? A. A financial market is a market in which people and entities can trade financial securities. The primary market refers to the market where securities are created, while the secondary market is one in which the previously created stocks are traded among investors. In the primary market, a company that needs money sells stock. In the secondary market, someone who owns stock sells their stock to someone else. The secondary market does not bring in money for a company.

Q. What is a derivative?A. A derivative is anything that is valued based upon some other asset. The derivative itself is merely a contract between two or more parties. Its value is determined by fluctuations in the underlying asset. For example, A call option is a derivative that gives the buyer the option (but not the obligation) to buy 200 shares of a certain stock at a pre-determined price. It is a derivative because the value of the option depends on what the underlying stock does. The most common underlying assets include stocks, bonds, commodities, currencies, and interest rates. Derivatives are generally used as an instrument to hedge risk, but can also be used for speculative (i.e betting) purposes as most derivatives are characterized by high leverage.

Q. What is the difference between options and warrants?A. The warrants are issued by companies to raise money, and the options are not. But both have lots of similarities.

Both options and warrants are based on an underlying asset such as stocks. They are exercised at a pre-determined price or strike price. The seller of an option or warrant is obliged to honor the terms of the option or warrant. The buyer of an option or warrant must pay a price (or premium) up front.

Both options and warrants expire at a pre-determined date.

Q. What are the different ways a company can raise money (i.e raise capital)?A.

1. Borrowing from a bank (debt security): Always short term (1 year or less) and the banks have the first claim on assets of a bankrupt firm.

2. Issuing preferred stocks (equity security): By choosing to issue new "preferred" stock to raise capital. Buyers of these "preferred stock" have special rights in the event the underlying company encounters financial trouble. If profits are limited, preferred-stock owners will be paid their dividends after bondholders receive their guaranteed interest payments but before any common stock dividends are paid.

3. Issuing common stocks (equity security): The companies that are in good financial health can raise capital by issuing common stock. Although common shareholders have the exclusive right to elect a ccompany's board of directors, they rank behind holders of bonds and preferred stock when it comes to sharing profits.

4. Issuing bonds (debt security): By issuing bonds, companies must make semi-annual or annual interest payments on the bond and must buy back the bond when it matures. Bonds can be both long and short term. This can be a substantial drain on a company's cash.

5. Issuing warrants (equity security): Warrants allow a company to generate money by selling stocks to the owner of a warrant who exercises the warrant. The warrants will only be exercised if the stock price is higher than the exercise price.

Q. What is a debt security?A. Debt securities are legal obligations to repay borrowed funds at a specified maturity date and provide interim interest payments as specified in the contract. Examples of debt securities include bonds, certificates of deposit, commercial paper, loans, and debentures. The debt securities increase the probability of bankruptcy and expected bankruptcy costs; reduce financial flexibilities

Q. What is the difference between equity security and debt security?A. Debt securities represent indebtedness or borrowing by the issuing company. On the other hand, equity securities represent ownership of the issuing company.

Bonds and stocks are both securities, but the major difference between the two is that stockholders have an equity stake in the company as the part owners of the company, whereas bondholders have a creditor stake in the company as the lenders. Another difference is that bonds usually have a defined term, or maturity, after which the bond is redeemed, whereas stocks may be outstanding indefinitely. A bond is a formal contract to repay borrowed money with interest at fixed intervals (semiannual, annual, sometimes monthly).

Bonds generally can trade anywhere in the world that a buyer and seller can strike a contractual deal. There is no central place or exchange for bond trading, as there is one for publicly traded stocks. The bond market is known as an "over-the-counter" market, rather than an exchange market. There are some exceptions to this as some corporate bonds are listed on an exchange. But the majority of bonds do not trade on exchanges.

Q. What is a share contract note?A. It is the confirmation of the share order via a contract note, which is sent to you via email or post to you by your broker.

Q. What do you understand by the term "settlement and transfer"?A. When you buy shares, on the other side of the transaction there is a seller. For every buy, there is a sell. The money you owe for the shares is owed to the seller and must be exchanged for the seller’s ownership in the company. This process is called settlement and transfer.

Q. What are the diffrent types of stock market orders?A. The most common ones are "on market" and "at limit". The orders could also be either "buy order" or "sell order"

On market: Usually one gets the stock at the ask price of the moment when the order reaches the exchange. A market order is the default option and is likely to be executed because it does not contain restrictions on the buy/sell price or the timeframe in which the order can be executed. So, you don't enter any price info while placing an order.

At limit: A limit order is an order to buy or sell a stock at a specific price or better. So, you need to enter a limit price when placing an order. A buy limit order can only be executed at the limit price or lower, and a sell limit order can only be executed at the limit price or higher. A limit order is not guaranteed to execute. A limit order can only be filled if the stock’s market price reaches the limit price. While limit orders do not guarantee execution, they help ensure that an investor does not pay more than a pre-determined price for a stock.

Stop order: An order to buy or sell a security when its price surpasses a particular point, thus ensuring a greater probability of achieving a predetermined entry or exit price, limiting the investor's loss or locking in his or her profit. Investors normally place a stop order before they go on a holiday.

Q. What is an exchange traded fund (ETF)?A. An exchange-traded fund (ETF) is a security that tracks an index, a commodity or a basket of assets like an index fund, but trades like a stock on an exchange. An ETF holds assets such as stocks, commodities, or bonds, and trades close to its net asset value over the course of the trading day. ETFs are attractive as investments because of their low costs, tax efficiency, and stock-like features.

Q. What is a FIX protocol?A. FIX stands for Financial Information eXchange protocol, which is an open specification intended to streamline electronic communications in the financial securities industry. FIX supports multiple formats and types of communications between financial entities including trade allocation, order submissions, order changes, execution reporting, email, and texting. For example, the CameronFIX is an engine that uses the open FIX standards. QuickFixJ is a free open source Java based FIX engine. Here is a simplified high level over view of a trading system written in Java.

FIX simplies the implementation of interfaces by using so called FIX engines. There are open source implementations as well as commercial ones. The FIX engine takes care of the functional aspects like defining the message semantics, supporting different types of messages like heart beat, test request, resend request, execution report, new order, rejection message, etc and non functional aspects like logging FIX messages, dealing with dropped connections, handling high trading volumes, etc.

Message trailer: Contains a message checksum and an optional signature.

The FIX message fields are basically the combination of a tag, which is a numerical identifier, with a value, which is a string and a delimiter, which is written as ^ (i.e. ASCII 0x01). In addition to hundreds of predined tags, FIX also supports custom tags between field numbers 5000 and 9999. Here is an example of a FIX message with a header, body, and trailer.

Aug 22, 2012

There are other real life scenarios where the java.util.concurrent package with the following classes can be put to great use.

CountDownLatch

CyclicBarrier

Here are some real life scenarios discusssed below to make use of the above classes.

Scenario: A main thread creates 3 database connections and assigns each of those connection to 3 different child threads that are spawned from the main thread. The main thread must wait while all the child threads are completed and then close all the database connections. So, how will you accomplish this?

Solution: This where the CountDownLatch comes in handy as you already know that there are finite (i.e 3) number of threads. CountDownLatch can be used by the main thread to wait on the child threads. A CountDownLatch will be created with 3 being the count.

CountDownLatch countDownLatch = new CountDownLatch(MAX_THREADS);

The main thread will spawn new threads and wait on the count to reach 0 with the awit( ) method.

countDownLatch.await();

As the each child thread process within the run( ) method, as the child thread completes processing, the count can be decremented with

countDownLatch.countDown();

Here is a simplified example where the worker threads wait for all the other worker threads to start with the startSignal and the main thread waits for all the worker threads to complete with a stopSignal as illustrated in the above diagram . Firstly, define a worker thread class.

The main thread is going to spawn 3 worker threads.....
Started: thread-1 but waiting for other threads to start.
Started: thread-2 but waiting for other threads to start.
Started: thread-3 but waiting for other threads to start.
worker threads can now start executing as all worker threads have started.....
Running: thread-1
Running: thread-3
Running: thread-2
finished executing the worker threads and the main thread is continuing.
The main thread can execute any task here.

Scenario: What if the above scenario has a specific requirement where the 3 children threads need to wait between each other? For example, if each of the 3 threads need to perform 2 tasks. Before the task 2 can be started by a thread, all the 3 child threads must finish task 1. The task 1 can be reading data from the database and task 2 could be performing some computation and finally these computations need to be consolidated and written back by a single thread.

Solution: A CyclicBarrier can be used if the number of children threads are know upfront and to implement waiting amongst child threads until all of them finish. This is useful where parallel threads need to perform a job which requires sequential execution. It has methods like cyclicBarrier.await( ) and cyclicBarrier.reset( );

Here is the simplified code to improve understanding. Firstly the WorkerTask thread.

Q. Why is it called a cyclic barrier?A. Because it acts as a barrier point for a number of worker threads to wait for each other to complete their tasks. The barrier is called cyclic because it can be re-used after all the waiting worker threads are released for the next barrier point.

A barrier is constructed with the following arguments to a constructor.

the number of threads that will be participating in the parallel operation.

an optional, amalgamation or consolidation routine to be run at the end of each step or iteration.

At each step (or iteration) of the operation:

each thread carries out its portion of the work to complete that step.

after doing its portion of the work, each thread calls the barrier's await ( ) method.

the await( ) method returns only when

-- all 3 threads have called await( ).
-- the amalgamation or consolidation method has run (the barrier calls this on the last thread to call
await( ) before releasing the awaiting threads).

if any of the 3 threads is interrupted or times out while waiting for the barrier, then the barrier is "broken" and all other waiting threads receive a BrokenBarrierException. This will propagate to all threads and for the other steps to halt, or for the steps to be interrupted externally by interrupting just one of the threads.

Q. So, when to use a CountDownLatch and when to use a CyclicBarrier?A. A CountDownLatch is initialized with a counter. Threads can then either count down on the latch or wait for it to reach 0. When the latch reaches 0, all waiting threads can resume.

If you want a set of threads to repeatedly meet at a common point, you are better served by using a CyclicBarrier. For example, start a bunch of threads, meet, do some stuff like data consolidation or amalgamation, meet again, validate some assertions, and do this repeatedly.

A given CountDownLatch can only be used once, making it inconvenient for operations that occur in steps, with intermediate results from the different threads needing to be consolidated between steps. The CountDownLatch also doesn't explicitly allow one thread to tell the others to "stop waiting", which is sometimes useful, for example, if an error occurs in one of the threads.

The CyclicBarrier is generally more useful than CountDownLatch in scenarios where:

a multithreaded operation occurs in steps or iterations, and

a single-threaded operation is required between steps/iterations, for example, to combine the results of the previous multithreaded steps.

Aug 20, 2012

Scenario: You need to load stock exchange security codes from a database and cache them for performance. The security codes need to be refreshed say every 30 minutes. This cached data needs to be populated and refreshed by a single writer thread and read by several reader threads. How will you ensure that your read/write solution is scalable and thread safe?

Solution: The java.util.concurrent.locks package provides classes that implement read/write locks where the read lock can be executed in parallel by multiple threads and the write lock can be held by only a single thread. The ReadWriteLock interface maintains a pair of associated locks, one for read-only and one for writing. The readLock( ) may be held simultaneously by multiple reader threads, while the writeLock( ) is exclusive. In general, this implementation improves performance and scalability when compared to the mutex locks (i.e. via synchronized key word) when

there are more reads and read duration compared writes and write duration.

It also depends on the system you are running on -- for example multi-core processors for better parallelism.

The ConcurrentHashmap is another example where improved performance can be achieved when you have more reads than writes. The ConcurrentHashmap allows concurrent reads and locks only the buckets that are used to modify or insert data.

Here are a few terminlogies you need to be familiar with in implementing locks.

Q. What is a reentrant lock?A. This can be considered as a replacement for the traditional “wait-notify” method. The basic concept is, every thread needs to acquire the lock before entering in to the critical section and should release it after finishing it. ReentrantLock eliminates the use of “synchronized” keyword to provide better concurrency

The term reentrant means if a thread enters a second synchronized block protected by a monitor that the thread already owns from , the thread will be allowed to proceed, and the lock will not be released when the thread exits the second (or subsequent) synchronized block, but only will be released when it exits the first synchronized block it entered protected by that monitor. Similarly, when you use reentrant locks, there will be an acquisition count associated with the lock, and if a thread that holds the lock acquires it again, the acquisition count is incremented and the lock then needs to be released twice to truly release the lock. A writer can acquire the read lock - but the reverse is not true. If a reader tries to acquire the write lock it will never succeed.

Q. What do you need to watch out for in releasing a lock?A. The locks need to be released in a finally block, otherwise if an exception is thrown, the lock might never get released.

Q. Why would you need a reentrant lock when there is synchronized keyword? How will you favor one over the other?A. The reentrant locks are more scalable as it allows concurrent reads. Having said this, the locking classes in java.util.concurrent.lock package are advanced tools for advanced users and specific situations like the scenario discussed above. In general, you should stick with synchronization unless you have a specific need like

the number of reads are far more than the number of writes.

demonstrated evidence through proper performance testing that synchronization in a specific situation is a scalability bottleneck.

Q. What are fair and unfair locks?A. One of the arguments to the constructor of ReentrantLock is a boolean value that lets you choose whether you want a fair or an unfair lock. A fair lock is one where the threads acquire the lock in the same order they asked for it. In another words, when the write lock is released either the longest-waiting single writer will be assigned the write lock, or if there is a reader waiting longer than any writer, the set of readers will be assigned the read lock. When constructed as non-fair, the order of entry to the lock are not necessarily in the arrival order.
If the readers are active and a writer enters the lock then no subsequent readers will be granted the read lock until after that writer has acquired and released the write lock. Here is a simplified example of read/write locks.

Aug 15, 2012

Article: Sample Java Resume or CV

A good Java resume or CV can make a world of a difference to open more doors to your career. Here is a sample resume that is extracted from my book "Java/J2EE Resume Companion" for experienced Java professionals. Even if you are not an experienced professional, it will guide you as to what you need to work towards. As you get more experienced, you need to update your Java resume or CV to highlight your accomplishments as shown below. There are more eye catching resume phrases and sample resumes for novice, career change, intermediate, cover letter, etc covered in the book in more detail with explanation.

Track record of delivering
quality Java/JEE based solutions over 8+ years in the Investment,
Insurance, Finance, Telecommunications, and Retail industries.

2.0+ years as a hands-on
architect, 2+ years as a technical lead, 3+ years in Java/JEE
development, and 3+ years in system integration.

Well versed with entire
development life cycle and facilitating agile practices.

Spearheaded the design and
development of a Spring MVC, Spring, and Hibernate based mission
critical system budgeted at $10 million, which earned high accolades
in the independent code and design reviews conducted by an
independent consultancy.

Achievements

Provided technical leadership
on the architecture, design, and successful implementation of a
mission critical 24x7 Java/JEE application valued at $10 million at
BrandName Ltd.

Enjoyed repeated success in
understanding business expectations, building effective solutions,
and facilitating agile development practices.

Re-architected, refactored,
and performance tuned a Websphere and J2EE based online insurance
application, which previously came down almost daily, became a true
24x7 applicationat BrandName Ltd.

Instrumental in building our
Java/JEE consultancy teams at Consultancy Ltd to grow from 6
consultants to 25 consultants and technical pre-sales activity in
placing the consultants at client sites.

Built an end to end vertical
slice for a JEE based billing application using popular frameworks
like Spring, Hibernate, JSF, Facelets, XHTML, Maven2, and Ajax by
applying OO design concepts, JEE & GoF design patterns, and best
practices.

Integrated other sub-systems
like loans application, equity markets online application system,
and documentation system with the structured products application
through JMS, Websphere MQ, SOAP based Web services, and XML.

Designed the logical and
physical data model, generated DDL scripts, and wrote DML scripts
for Oracle 9i database.

Position:Java/J2EE Technical
lead/Senior developer (Leadership, design, and
development focus of a number of Java/JEE based multi-tiered, high
volume (10,000 to 100,000 users), and distributed applications.)

Achievements:

Managed and mentored a group
of application developers, assigned responsibilities, elaborated use
cases, managed project schedules, and module targets.

DesignedanddevelopedStruts like MVC 2 Webframework using the
front-controller design pattern, which is used successfully in a
number of production systems.

Spearheadedthe “Quick Wins” project by working
very closely with the business and end users to improve the current
website’s ranking from being 23rd to 6th in just 3 months.

Normalized Oracle database,
conforming to design concepts and best practices.

Resolvedproduct complications at customer
sites and funneled the insights to the development and deployment
teams to adopt long term product development strategy with minimal
roadblocks.

Convinced business users and
analysts with alternative solutions that are more robust and simpler
to implement from technical perspective while satisfying the
functional requirements from the business perspective.

Self-published a book entitled
“Java/J2EE Job
Interview Companion” (ISBN
978-1-4116-6824-9), which is a best
seller at http://www.lulu.com and received 4.0 out of 5.0 star
user rating on http://www.amazon.com.

Published a “Java World” article entitled “Some Java
Topic”, which had over 40,000 views and positive review comments.

Aug 14, 2012

Article: Using Builders instead of Constructors to create Immutable objects

This article explains how you can create immutable objects in Java by using the builder design pattern as opposed to constructors. This will make your code more readable. Firstly, let's see what is not so elegant about using a constructor as shown below with a CashBalance object that takes 3 BigDecimal arguments. Then we will see how a builder class will make your code more intuitive.

Next time you are asked to explain a design pattern in an interview, you could pick this as opposed to the very common factory and singleton design patterns. This article also touch on other two important concepts like immutability and thread-safety.

So, why wasn't it elegant? The constructor takes 3 BigDecimal arguments, and for the user of the class it is not intuitive enough as to which is initialBalance, which is totCredits, etc. It would have been nicer if you could invoke the constructor something like

Constructing the object with an empty constructor and 3 setter methods are more elegant, but that will make your object mutable. Here is the builder design pattern to the rescue. Here is the builder defined as an inner class to construct the CashBalance object.

Aug 10, 2012

Article: Functional programming in Java

In addition to the usual set of concepts like OO programming, and AOP (Aspect Oriented Programming), the functional programming offers a different way to think about software and solve some of the problems. For example, manipulating a collection of objects and mathematical computations. Java is not a functional programming language. Scala, Clojure, and Groovy are functional programming languages and run on the JVM and can interact with legacy Java classes. Programming with multiple programming languages like Java, Scala, Clojure, and Groovy is known as the polyglot programming.

This article focuses on how you can implement functional programming in Java with some verbosity. You can't do the following in Java to iterate through a collection of items and print each item

Hmmm, you might think that the above functionality can be easily implemented by having two methods perform the relevant tasks. The true functional programming languages have much more concise syntax to achieve this. The real power of functional programming is realized when you want greater reuse of the functions as demonstrated below with Java code. You can have different combinations of iterating through a collection and computing each item in the collection. The Functional class provides different possible iteration logic and the Function interface provides different way to compute each item.

Step 1: Define the interface that applies some functionality to each item.

public interface Function<T> {
void apply(T item);
}

Step 2: Define the class that can process a collection in different ways.

So, understanding functional programming is very useful.If you want true functional programming, with closures and functions as first class objects, pick another language. Scala, Clojure, Groovy all run on the JVM and can interact with legacy Java classes.
This knowledge will be handy in writing code in JavaScript where functions are first class objects and can be referenced and passed around. In functional programming, you need to grasp the concepts like functions as first-class values, currying, immutable values, and closures.
Look at the JavaScript examples for better understanding of functional programming.

The above code basically constructs the condition which returns "true" within the paranthesis and puts the not outside because it must return "false" (i.e the validation should fail) if the given condition is satisfied.

Approach-2: Now, the tricky bit is to achieve the same results without the the ! operator.

Q. Can you give a real life scenario where you may have to use the second form?A. A typical real life scenario would be to implement the business validation rules. Some validation rules do change frequently due to legislative changes, etc and hard coding those rules within code is not a good idea. A more flexible approach would be to use a business rules engine like Drools or custom write your validation engine by storing the validation rules and relevant error messages in a database. This will enable the validation rules to be modified as it changes due to legislative changes or other business drivers. A very simplified database schema will look like

The rules are comma separated and the logical operator joining the rules is determined by the join_type. The join type can be either OR or AND. The validation error message is displayed if the validation rule returns false. This means, if the portfolio is not authorized and the cashAvailable is less than the cashDepletion then display the validation error message "There are insufficient funds". The cashAvailable, cashDepletion, and authorized are fields with corresponding getter methods in the bean "Portfolio". The version flag is important because you might be working in multiple streams of development sharing the same development database and you don't want a new rule that was added in one of the development streams to break the other streams. The validation engine will have code something similar to

Aug 7, 2012

How to standout from other Java/JEE professionals?

The developer world is very competitive. It's difficult to stand out from the pack, but this blog illustrates with three different scenarios where you can make yourself shine - at an interview, in your resume and at work to take the road less traveled.

"You can standout from the people who are more experienced or qualified than you are by presenting yourself in a different light as a well-rounded professional"

1. At Java/JEE Job Interviews

Let’s have a look at a typical Java/JEE Job interview scenario, where a candidate is asked the following popular interview question:

Q. What are the two main OO techniques for code reuse? Which one of those two will you favor and why? A. Most candidates will correctly say:

Class inheritance.

Object Composition.

Some will then go on to say that "object composition should be preferred over class inheritance (i.e. implementation inheritance). A few will then continue to briefly explain that… “If there is no ‘is a’ relationship then use composition for code reuse. Overuse of implementation inheritance can break all the sub classes, if the super class is modified. Do not use inheritance to just get polymorphism. If there is no ‘is a’ relationship and all you want is polymorphism, then use interface inheritance with composition, which gives you code reuse."

Some interviewers will be digging a bit deeper to make sure that the candidate really understands the OO concepts. Only a handful of candidates fully understand OO concept and will be able to elaborate with all the vital information as discussed below. This will enable those candidates to stand out and make a real impression on the interviewer(s) or prospective employers.

"Class inheritance is static and it is done at compile time. In object composition, functionality is acquired dynamically at run-time by objects collecting references to other objects. This is possible because objects are accessed via their interfaces. So, one object can be replaced by other objects as long as they have the same type."

If permitted, these better candidates will also continue illustrating...

"Interface inheritance should be preferred over implementation inheritance because it promotes the design concept coding to interface and reduces coupling. If you look at Gang of Four (GoF) design patterns, you can see that it favours interface inheritance to implementation inheritance. For example, the decorator design pattern used in java.io.* classes where responsibilities to objects are attached at run-time. The template method design pattern is a typical example for the implementation inheritance used mainly in application frameworks so that the overriding class can implemnt additional behavior".

Note: Before you elaborate, ask the interviewer if it is okay to do so. In some interviews, you will be given a sample problem to code, where interviewer will be expecting good understanding of OO concepts. This is is just an example, and similar approach should be used to other interview questions relating 16 key areas like coding, performance, transaction management, etc.

In most cases, most of us know the basic answer and have worked with these practically, but being able to give a clear and concise answer will make you standout from the pack and get a job offer as a first preference and also power to negotiate your salary or rates. So, refreshing prior to interviews can really pay off. Also, being thorough in key fundamentals can make the interviewer over look any other weaknesses like not having worked extensively with a particular framework or an application server.

The second most important aspect is to prepare prior to your job interview by going through your past achievements using the SAR (Situation-Action-Result) technique. Here is an example.

Situation:

Performance problem where the application server had to be restarted every day.

Action:

Used JMeter to simulate the load conditions and reproduce the issue.

Identified the cause of the problem to be leaking database connections due to not properly closing the connections under exceptional scenario.

Fixed the issue by closing the database connections in the finally block.

Tuned the JVM settings and configured proper service timeouts.

Load and endurance tested the fixed code with the load testing tool JMeter to confirm that the issue has been fixed.

Result:

The application becomes a true mission critical 24x7 type with much improved performance.

2. In your Java/JEE Resume(s)

Today many prospective employers embrace networking as the key source for finding a new position. Even when candidates are brought through a networked source, the first thing one would say is "Ask them to send their resume and I will see what I can do". There are no clear cut definitions in separating an ordinary resume from a resume that stands out. This is always subjective based on the prospective employer. Some guidelines can be drawn to compare an ordinary resume with a one that is more effective.

An ordinary resume markets you just as a techie, uses ordinary phrases, information is not quantified, packed with irrelevant and trivial information fulfilling your needs not the employers’ needs, one size fits all, lots of responsibilities included…. phrases, and vital information is scattered throughout.

An outstanding resume markets you as well balanced candidate with technical skills, soft skills, and business focus, uses perfect phrases in a clear and concise manner, achievements are quantified, addresses employers’ real needs, replaces responsibilities included… phrases with on the job accomplishments, resume is customized to the position applied for, and the important information is in the first page.

You could transform your achievement that was shown in the above example as an eye catching phrase on your resume as shown below:

Re-factored and performance tuned a JEE based online insurance application, which previously came down almost daily, became a true 24x7 application.

So taking the effort to writing a resume that stands out from the pack can open more doors for you than people who are better qualified than you.

3. At Work

Being a well-balanced developer with good technical skills, outstanding soft skills, and business focus can do wonders to your career. Being a visible contributor is the key. Knowing the key areas and core concepts can save a lot of development time and improve the overall quality of the software. One example that comes to my mind is the very common "Concurrent Modification" Exception. Many of us get through solving this by trial-and-error in a time consuming manner. But if your fundamentals are clear then you would save heaps of time by knowing what exactly to be done to solve the problem. More often you make a good impression on your superiors and peers by pro-actively identifying potential issues related to performance, multi-threading, transaction management, security, quality coding, etc and fixing these issues before they become a major headache. Just being a techie alone not enough. One needs to have good technical skills complemented with excellent soft skills and good domain knowledge to succeed in his/her career.

So, how do you improve your problem solving skills?

Look at existing solutions to common problems, e.g. design pattern to solve a particular problem.

Create a problem and then solve it -- for example, create a connection leak issue and then fix it, create a memory leak and then fix it, create a performance issue due to back tracking regex or SQL with cartesian product and then fix it, create a security hole and then fix it, create a thread dead lock situation and then fix it, etc.

Sometimes explaining the problem to another person or asking a few questions can unlock the mental floodgate.

These gestures will make you stand out from the pack and consequently can do wonders to your career. You don’t have to wait for 2-3 years to be what you dream of becoming. Proactive self learning is the key to succeed in your career.

"Real job security in IT is not all about working for the same company, but keeping your knowledge and skills relevant. You need to have both technical & non-technical skills"

Your career is your responsibility, and not your company's. I strongly believe that this site will shed lots of light to motivate, inform, and fast-track your Java career. It is very satisfying get positive feedback.