Hi Again Hanshuang,
In addition, I wanted to point out some things that made it a little more difficult for me (and maybe others) to understand your posted code and config files. Here are a few suggestions:
1) You have a MyResume class and a MyResumeImpl class. Typically, if you have two Java files someName and someNameImpl, the someName is an interface, and someNameImpl is a concrete class implementing that interface. In your case, the MyResumeImpl class does not implement a MyResume interface, so the naming is misleading. Because MyResumeImpl implements the MyResumeFacade interface, a better name for it might be MyResumeFacadeImpl.
2) You may have an application-specific reason for the naming, but usually domain objects do not start with a "My" prefix (e.g. MyResume). Sometimes local variables are given names with a "my" prefix (lowercase because it is not a type but a local variable name). For instance:
Code:
public class ResumeManager {
public Resume getResume(String id) {
Resume myResume = resumeDao.getResume(id);
}
}
But if you do not have a "Resume" domain object and the "My" prefix on MyResume does not add any value, I would remove it. This would mean it would make sense to remove "My" from all of the other classes/interfaces, but that is not too difficult.
3) You are not consistent in your bean naming:
Code:
<bean id="myresumeDao" class="data.dao.SqlMapMyResumeDao">
<property name="sqlMapClient" ref="sqlMapClient"/>
</bean>
<bean id="MyResume" class="data.domain.logic.MyResumeImpl">
<property name="MyResumeDao" ref="myresumeDao"/>
</bean>
It is a convention to start bean names with a lowercase letter. So your MyResume bean could be myResume instead. Also, your myresumeDao bean could be re-named myResumeDao so that it is the same name as the interface except with a lowercased first letter. And of course, you should change the MyResumeDao property so that it is lowercased. Following these conventions will help other Spring users more easily understand your code and config files. Of course, there is nothing to stop you from going against conventions, but without a good reason, you might as well follow them (especially when this whole post came about because of misnaming). Note: the MyResume bean should actually be named myResumeFacade, especially if you rename the MyResumeImpl class. You usually name a bean who's class implements an interface the name of the interface. Because MyResumeImpl implements the MyResumeFacade interface, you should name the bean myResumeFacade.
4) Last suggestion regarding your MyResumeImpl class:
Code:
public class MyResumeImpl implements MyResumeFacade {
private MyResumeDao myresumeDao;
public void setMyResumeDao(MyResumeDao myresumeDao){
this.myresumeDao = myresumeDao;
}
In this case, your property of type MyResumeDao is not named myResumeDao, so it does not have a true JavaBean's style setter method (you use setMyResumeDao instead of setMyresumeDao). Once again, you can name your properties whatever you want. However, it is not even an entirely different name; it is the convention with a slightly different capitalization scheme. Not a big deal, but I would strive to make things as consistent as possible.
Let me know if you have any questions, and sorry for being so nosey; I think your code would be more understandable if you follow some of the conventions though.
-Arthur Loder