Wednesday, November 16, 2011

Monday, November 14, 2011

How to configure multiThread MDB in websphere

The maximum sessions property determines how many messages an MDB can process simultaneously. The default value for this property is 1, which means that an MDB must finish processing the first message on the queue before it can process the second, and so on (for you programmers, this essentially means that an MDB is single-threaded).

If the application server is not under a heavy load, you might want to increase the throughput of messages. In this situation, you can increase the value of the maximum sessions property to enable an MDB to process more than one message at once (this makes the MDB multi-threaded). It is worth noting, though, that increasing the value of maximum sessions will increase the load on your system, since you will now have multiple instances of the MDB running at the same time!

Details please check below link

Friday, November 11, 2011

Spring reference card

http://refcardz.dzone.com/refcardz/spring-configuration?oid=sb001

Design Pattern for Java resources

http://www.dzone.com/links/r/design_patterns_object_oriented_design_repository.html

Thursday, October 27, 2011

Why project failed

Below it is a very interesting article

1. Reduce co-location makes communication difficult.
2. Loss of key players will take months to recovery.
3. new technology learning curve.
4. New team need to time to build.

Saturday, October 8, 2011

HTML 5 Magic

Today I did some research regaridng HTML5, it is really impressive. I have the feeling HTML 5 will be the next wave on web. Below are some features:

1. SVG
2. VIDEO
3. GEOLOCATION
4. Cache and Database
5. Web wroker

Monday, October 3, 2011

Why Software Is Eating The World

Today I read a article which is very useful to inspire the developers.

Please check the link.

Friday, September 30, 2011

Best way to use Constractor

I had been working as consultant for about two months already. One interesting thing I found in those days regarding how to use consultant effectively.

1. Hire technical expert as technical leader, so other team members can learn from him. This way is better than hiring a trainer. This works very well if this company run into a new technical area.
2. Hire Junior consultants doing heavy load and lower technical tasks. Also those works are perfect for outsourcing.
3. Team members should include both full-time and contractors. A team contains only contractors will face long term maintainability issues in the long run. Some one in the team should audit the quality.

"Knowledge can be conveyed, but wisdom is only earned by experience of trying"

Friday, September 23, 2011

Check List for new project before coding

I recently read a article talking about check list before coding, it is very interesting, please check the link

Thursday, September 15, 2011

Mutable and Immutable Objects for Java

Below it is a nice article regarding this topic.

Thursday, August 11, 2011

Thursday, August 4, 2011

4 mistakes regarding tomcat

I just read a article regarding tomcat, please check.

Wednesday, July 20, 2011

About session security

Today I read a good article regarding session security, I want to share with you.

Please click for article

Below it is the summary.

Always regenerate a session ID (SID) when elevating privileges or changing between HTTP and HTTPS.
Check for suspicious activity and immediately destroy any suspect session.
Store all session information server-side, never store anything except the SID in the client-side cookie.
Confirm SIDs aren't from an external source, and verify the session was generated by your server.
Don't append the SID to URLs as a GET parameter.
Expire sessions on the server side, don't rely on cookie expiration to end a user session.
Use long and unpredictable session IDs.
Properly sanitize user input before setting headers with them.
When a user logs out, destroy their session explicitly on the server.
Check your session configuration.
Force users to re-authenticate on any destructive or critical actions.

Tuesday, July 19, 2011

Spring singleton and prototype

Recently I was asked something regarding spring singleton, below are some of my thought.

1. First Spring singleton is not same as java singleton. For example.

SampleBean beanOne = (SampleBean)context.getBean(“sampleBean1”);
SampleBean beanTwo = (SampleBean)context.getBean(“sampleBean2”);

Evern in spring application context, samepleBean1 and sampleBean2 refer to the same implementation, they are still not the same.

In Java singleton, they are the same thing.

2. For exmaple:
SampleBean beanOne = (SampleBean)context.getBean(“sampleBean”);
SampleBean beanTwo = (SampleBean)context.getBean(“sampleBean”);

Under singleton scope, beanOne is the same as beanTwo.
Under prototype scope, beanOne <> beanTwo

Tuesday, June 21, 2011

tomcat class loading thining

In the last couple years, I have been working with TOMCAT, we always use fat war file, which each web application use their own lib, there are very few library in common tomcat lib directory.

Good: Different application can use different version library, easy to configure, no library conflict issue.
Bad: I guess memory might be a issue. As every web application will start their own version.

Today I check one of the web application implementation in websphere, in web library, there are lot of common libraries.

Good: I guess most EJB related library should be in common.

Thursday, June 16, 2011

Software development methods Funny words

1. KISS: Keep it simple stupid
2. DRY: Do not repeat yourself
3. YAGNIl: You ain't gonna need it.


For point one and point three, I really experienced a lot in the last 10 years. Most of the time, system is getting complicated just because of poor design, overdesign. Also the system was built a lot of extra nice features which never been used, it also makes simple application complicated.

4. Law of Demeter - Code components should only communicate with their direct relations (e.g. classes that they inherit from, objects that they contain, objects passed by argument, etc.) http://en.wikipedia.org/wiki/Law_of_Demeter

Wednesday, June 8, 2011

How to mitivate a developer

Today I read a article which I totally agree with it. Details please check below link.

http://www.theserverside.com/tip/Five-ways-to-motivate-your-development-team

1. Give your developers the resources they need.
2. Recognize a job well done
3. Get rid of dead wood
4. Push for new software releases
5. Let developers develop

Wednesday, May 18, 2011

use maven to create a basic project

mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1.2 -DgroupId=com.travelsoft.services -DartifactId=HostServices

When Agile/Scrum should NOT be used

Today I read this article, it is very interesting. And I agree most of the points he list there. Details please check. http://blog.matrixresources.com/blog/when-agilescrum-should-not-be-used

Below are the list of quotes which I think are useful.

1. Non-High Profile Project
2. Stable Technology
3. No Major Process Innovation
4. Requirements are Stable
5. Quick Time to Market not Needed

Resource Characteristics:

1. Inability to Co-located
2. Low Cost Talent Available
3. Team Size Varies
Company Characteristics:

1. Command and Control Company Culture: “dictator” type project management
2. Contracts Require Full Scope and Documentation

Tuesday, May 17, 2011

Encrypt a password in JPA persistent.xml

Below is a example how to encrypt password in JPA persistent.

1. Generate a encrypted password (See previous blog)
2. Add below entrance into spring applicationcontext.xml




PBEWithMD5AndDES


JAMES_PWD


4





strongHibernateStringEncryptor







3. change persistent.xml




value="org.jasypt.hibernate.connectionprovider.EncryptedPasswordDriverManagerConnectionProvider"/>

How to encrypt password in spring configuration file

I just finish a project which use "jasypt" to encrypt the password in spring configuration file. Below are the steps and notes.

1. Regarding Maven entrance, please check below

org.jasypt
jasypt
1.7.1

2. Develop a program to encrypt password.

StandardPBEStringEncryptor encryptor = new StandardPBEStringEncryptor();
encryptor.setAlgorithm("PBEWithMD5AndDES");
encryptor.setPassword("JAMES_PWD"); // could be got from web, env variable...
return encryptor.encrypt(input) ;
3. Create a environment variable to hold temporary password
APP_ENCRYPTION_PASSWORD = JAMES_PWD

4. Change your spring configuration file to read property from file.


class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">





class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">


-->






class="org.jasypt.spring.properties.EncryptablePropertyPlaceholderConfigurer">



classpath:connection.properties



Tuesday, April 26, 2011

Comments after reading Test First development blog

Today, I read this very interesting blog regarding Test first development, link is below.
http://xebee.xebia.in/2011/04/26/take-aways-from-dr-venkats-session-on-test-first-development/

There are something really draw my attentions:

1. the importance of creating an environment to make people do the right thing than to force them to do it. The right environment can be created through leading by example and assertive communication
2. Hiring by attitude, and train for skill.
3. he gave a magnificent example by citing a movie "A Few Good Men". He told that during an argument inside the court in the movie, someone quoted a rule. And then, Tom Cruise came with the rule book in his hand asking the other person to show him rules for each and everything that he did ( "You eat 3 times a day, can you show it in the rule book. Oh God, How can you eat 3 times a day when its not written in the rule book").
4. in the end, he said, sometimes its almost impossible to correct things and then you can say to yourself that its just a job. In my home, I can do and will do things exactly the way I like, however, in a job, this might not be the case.

Wednesday, April 20, 2011

How to get file from filename

Recently I had a issue regarding how to read a file, as in eclipse environment and actually server environment, the relative directory is different, it caused a lot of problem, below it is a example which works for both environment.

File file ;
URL url = this.getClass().getClassLoader().getResource(fileName);

try {
file = new File(url.toURI());
} catch(URISyntaxException e) {
file = new File(url.getPath());
}

or to a string

URL loadedResource = this.getClass().getClassLoader().getResource(fileName);


InputStream inputStream = loadedResource.openStream();

BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
inputStream.close();
return sb.toString();

Tuesday, April 12, 2011

How to get salary increase by Eric spiegel

5) A developer’s best chance at achieving a maximum salary increase is to negotiate during the hiring process. Once you are on board, you are at the company’s mercy unless you bail

Very interesting idea I have to agree

Monday, April 11, 2011

Failure and innovative

Woody Allen :

If you are not failing every now and again, it is a sign you are not doing anything very innovative.

The only real failure in life is one not learned from

Tuesday, March 29, 2011

Command and control

Smart people does not like to be controlled. And also can not be controlled.

People who close to work can make better decision than most of the managers.

Tuesday, March 8, 2011

Comments on how to Manage developers

Below are some ideas and experience I want to blog about how to be a good developer manager

1. Manager is not about managing people, no one want to be managed. Good manager should know manage himself first, create a better environment for developers to manage themselves too. Lead by example and show people the direction, let others to follow themselves.

2. You have to know your team better.
a. Knows who is key people in the group, identify the key people is very important, you will know whom you should invest more time and money into.
b. Knows who is the expert but not a team player, who perform best inside a team, who perform best individual.
c. Knows each one's color (color theory)
d. Understand your team's ability and capacity. Do not try to stretch too much, as it will demotivate people.

3. Treat people with respect, never manipulate other people. If you do not want others do to you, do not do it to other people.

4. Social activity, such as lunch each Friday together if it is possible.
5. Learning activity, ask one developer to do a presentation each week. Helps to exchange the knowledge between developers.

6. Provide best equipment to developers will help them to high productivity.

7. Provide best working environments you can get, do not underestimate any complains about desk, noise, or other small things, as that could cause big issues to some people.

8. Prepare some group contest, or mind games once a month? or two weeks to enhance team work.

9. Only assign 80% of your capacity most of the time, if some developers tell you they are not in the mood, then you have room to give them some time to step back. Making sure they are working in high spirit. As developers productivity are not measured by hours.

Tuesday, March 1, 2011

Hiring strategy

hire-above-the-mean (or Lake Wobegon). Always hire people better than yourself.(???)

a. Always hire developers better than we have currently (IQ + EQ) at the same level.
b. When we measure the skill, we also need to consider the future grow.
c. For Senior position, skill + experience = 60%, EQ = 20%, 20%= future grow
For Intermediate position, skill + experience = 40%, EQ = 30%, 30%= future grow
For Junior position, skill + experience = 20%, EQ = 30%, 50%= future grow

Low EQ means low team spirit. Depends on the position, some senior position which does not require high EQ, and those experts can and prefer individually, if we have those positions, then EQ is not really required.

Reference below link for more details.

http://lifeofaprogrammanager.blogspot.com/2006/06/good-reading-for-development-managers.html

Monday, February 28, 2011

Regarding how to prioritize a bug fix

Today I read a very interesting article regarding regression testing.

Details please check http://www.ericsink.com/articles/Four_Questions.html

Every bug you found in your application, before you work on a fix, you should ask yourself below four questions:

Question One: When this bug happens, how bad is the impact? (Severity)

Question Two: How often does this bug happen? (Frequency)

Question Three: How much effort would be required to fix this bug? (Cost)

Question Four: What is the risk of fixing this bug? (Risk)