2013年9月4日星期三

Beginners need to solve the following " menstrual problems " andscattered !

All about object-oriented , http://bbs.csdn.net/topics/390528973 http://bbs.csdn.net/topics/390536618
took some time to answer to both the landlord and hope beginners detours , not in the "object-oriented " and object-oriented , to advance understanding JavaBean + DAO mode ( simply put, is the complete separation of data and methods ; If you really do not understand , it recalls the C language under " structure + function -style" programming ideas , process-oriented you can understand it, for a month more simple object-oriented how to tangle ? ) , simplifying future programming, JavaSE accelerate the learning speed .
Why is there a generic , why reflection , why is there pure POJO? The idea is to let your " data" and " Operation" completely separated ; similar to " fridge with - open play, the Close method , vehicles have - driving, braking method" absolutely code Pojo which no longer appear in the !
who later write the following code to your project manager such 2B with you forever !

package beantest.bean;

/**
*冰箱
*
*/
public class Fridge {
private String name;

public String getName() {
    return name;
}

public void setName(String name) {
    this.name = name;
}

/**
* 冰箱具有打开的行为
*/
public void open(){
    System.out.println("打开"+name);
}

/**
* 冰箱具有关闭的行为
*/
public void close(){
    System.out.println("关闭"+name);
}
}

enterprise-class design ideas and SSH framework with MVC single case , agents , Aop , etc.,
but basically only the object-oriented Dao + JavaBean, there is no other ; rarely even inheritance , look Refbacks , Auspicious , Han Shunping the SSH video , only to find two : HibernateTemplate, ActionSupport only ; Therefore, if beginner again entangled in so-called over- abstraction, encapsulation , inheritance , polymorphism , it will only delay the progress of learning Java !
such a post asked :
Pharaoh and the talk of the town a couple . Pharaoh is a university professor , talk of the town is an accountant , and their parents are alive . Pharaoh and the talk of the town has a son, 15 years old , and in secondary school. Pharaohs sometimes play tai chi, talk of the town sometimes go part-time lectures . With the idea of ​​OO describe their relationship


can answer this way , of you may have a more elegant code , design ideas , but within 20 years will not change .
Here is the project's package structure :
db inside the database ( we are using List instead of a real database )
bean bag inside the entity ( traditionally known as JavaBean, POJO, Entity , etc. )
dao package inside is CRUD class ( for a basic operation of data is CRUD)
logic package is the business logic ( eg : to determine whether the two are husband and wife , to determine whether the parents alive , etc. )
util package for storage : data dictionary as well as some commonly used regular , IO, date tools


package beantest.bean;

/**
*爱好
*
*/
public class Hobby {
    /**
     * 主键--在数据库中的下标
     */
    private int id;
/**
* 名称
*/
private String name;
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public Hobby(int id, String name) {
    super();
    this.id = id;
    this.name = name;
}
@Override
public String toString() {
    return "Hobby [id=" + id + ", name=" + name + "]";
}

}


package beantest.bean;
/**
*  职业
*/
public class Job {
    
/**
*  主键--在数据库中的下标
*/
private int id;

/**
* 名称
*/
private String name;
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public Job(int id, String name) {
    super();
    this.id = id;
    this.name = name;
}
public Job() {
    super();
}
@Override
public String toString() {
    return "Job [id=" + id + ", name=" + name + "]";
}

}


package beantest.bean;

import java.util.List;
/**
*  人
*/
public class Person {
    
/**
*  主键--在数据库中的下标
*/
private int id;
/**
* 姓名
*/
private String name;
/**
* 性别 1-男  2-女
*/
private int male;
/**
* 年龄
*/
private int age;
/**
* 是否在世 
*/
private boolean isLive;
/**
* 父亲id引用  -1表示不存在
*/
private int fatherId;
/**
* 母亲id引用  -1表示不存在
*/
private int motherId;
/**
* 爱人的id引用 -1表示不存在
*/
private int loverId;
/**
* 职业的id引用  -1表示不存在
*/
private int jobId;
/**
* 由于可以有多个爱好,所以一个人拥有爱好ID的集合
*/
private List<Integer> hobbyList;
public List<Integer> getHobbyList() {
    return hobbyList;
}
public void setHobbyList(List<Integer> hobbyList) {
    this.hobbyList = hobbyList;
}
public int getId() {
    return id;
}
public void setId(int id) {
    this.id = id;
}
public String getName() {
    return name;
}
public void setName(String name) {
    this.name = name;
}
public int getMale() {
    return male;
}
public void setMale(int male) {
    this.male = male;
}
public int getAge() {
    return age;
}
public void setAge(int age) {
    this.age = age;
}
public boolean isLive() {
    return isLive;
}
public void setLive(boolean isLive) {
    this.isLive = isLive;
}
public int getFatherId() {
    return fatherId;
}
public void setFatherId(int fatherId) {
    this.fatherId = fatherId;
}
public int getMotherId() {
    return motherId;
}
public void setMotherId(int motherId) {
    this.motherId = motherId;
}
public int getLoverId() {
    return loverId;
}
public void setLoverId(int loverId) {
    this.loverId = loverId;
}

public int getJobId() {
    return jobId;
}
public void setJobId(int jobId) {
    this.jobId = jobId;
}
public Person() {
    super();
}
public Person(int id, String name, int male, int age, boolean isLive,
        int fatherId, int motherId, int loverId, int jobId) {
    super();
    this.id = id;
    this.name = name;
    this.male = male;
    this.age = age;
    this.isLive = isLive;
    this.fatherId = fatherId;
    this.motherId = motherId;
    this.loverId = loverId;
    this.jobId = jobId;
}
@Override
public String toString() {
    return "Person [id=" + id + ", name=" + name + ", male=" + male + ", age="
            + age + ", isLive=" + isLive + ", fatherId=" + fatherId
            + ", motherId=" + motherId + ", loverId=" + loverId + ", jobId="
            + jobId + "]";
}


}


package beantest.dao;

import java.util.List;

/**
*单表 CRUD的类
*/
public class BaseDao<T> {
/**
* 操作哪个表
*/
private List<T> table;

public BaseDao(List<T> table) {
    super();
    this.table = table;
}
/**
* 插入
*/
public void insert(T t){
    table.add(t);
}
/**
* 查询
*/
public T query(int id){
    return table.get(id);
}

/**
* 修改
*/
public void update(T t,int id){
table.set(id, t);
}
/**
* 删除
*/
public T delete(int id){
    return table.remove(id);
}
}


package beantest.db;

import java.util.ArrayList;
import java.util.List;

import beantest.bean.Hobby;
import beantest.bean.Job;
import beantest.bean.Person;
import beantest.util.Dectionary;

/**
*数据库,每个数据库的记录的id从0开始
*
*/
public class DataBase {
public static List<Person> personDb=new ArrayList<Person>();
public static List<Job> jobDb=new ArrayList<Job>();
public static List<Hobby> hobbyDb=new ArrayList<Hobby>();
//初始化数据库并设置关联
static{
    //初始化person数据库
    Person p0=new Person(0, "老王的父亲", Dectionary.Male, 60, Dectionary.Live, -1, -1, 1,-1);
    Person p1=new Person(1, "老王的母亲", Dectionary.Female, 60, Dectionary.Live, -1, -1, 0,-1);
    
    Person p2=new Person(2, "老李的父亲", Dectionary.Male, 60, Dectionary.Live, -1, -1, 3,-1);
    Person p3=new Person(3, "老李的父亲",  Dectionary.Female, 60, Dectionary.Live, -1, -1, 2,-1);
    
    Person p4=new Person(4, "老王", Dectionary.Male, 40, Dectionary.Live, 0, 1, 5,0);
    Person p5=new Person(5, "老李", Dectionary.Female, 40, Dectionary.Live, 2, 3, 4,1);
    
    Person p6=new Person(6, "儿子", Dectionary.Male, 15, Dectionary.Live, 4, 5, -1, 2);
    personDb.add(p0);    personDb.add(p1);    personDb.add(p2);    personDb.add(p3);
    personDb.add(p4);    personDb.add(p5);    personDb.add(p6);  
    //初始化job数据库
    Job job0=new Job(0, "教师");
    Job job1=new Job(1, "会计");
    Job job2=new Job(2, "上中学");
    jobDb.add(job0);jobDb.add(job1);jobDb.add(job2);
    
    //初始化hobby数据库
    Hobby h0=new Hobby(0, "太极拳");
    Hobby h1=new Hobby(0, "兼职讲课");
    hobbyDb.add(h0);
    hobbyDb.add(h1);
    
    //设置爱好
    List<Integer> wangList=new ArrayList<Integer>();
    List<Integer> liList=new ArrayList<Integer>();
    wangList.add(0);
    liList.add(1);
    p0.setHobbyList(wangList);
    p1.setHobbyList(liList);
}
}


------ Solution ------------------------------------ --------

------ Solution ---------------------------------------- ----

top landlord
Incidentally contacts points
------ Solution --------------------------------- -----------
great, top End closer look
------ Solution ----------------- ---------------------------
Collectors , very grateful !
------ Solution ---- ----------------------------------------
was such
------ Solution - -------------------------------------------
control you the looked at musicstore:

1.logic divided into three packages : admin, cart, catalog

2. database has only one package : data
which UserDB, ProductDB etc. belong dao; ConnectionPool, DBUtil, SQLUtil etc. belong db;

3. initialize the database sql file is generated ,

------ Solution ---------------------------------- ----------

------ Solution -------------------------------------- ------
landlord to understand what it is you want to say ?
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
accelerate progress : I endorse this attitude . To see more , some things will naturally understand. And you can know what is the latest technology being applied
------ Solution ----------------------------- ---------------


you can talk about the development of the order ? Which package out first ?
------ Solution ---------------------------------------- ----
little changes:



public  void personDoSth(int personId ){
    Person p=personDao.query(personId);
   
   
    for ( Integer i: p.getHobbyList()){
    Hobby h=hobbyDao.query(i);
         System.out.println(p.getName()+ " like"+ h.getName());
    }
      
}



lc.personDoSth(4);
lc.personDoSth(5);



Hobby h0=new Hobby(0, " swiming");
    Hobby h1=new Hobby(1, " part-time teacher");
    Hobby h2=new Hobby(2, " baseball");
    Hobby h3=new Hobby(3, " hiking");
    hobbyDb.add(h0);
    hobbyDb.add(h1);
    hobbyDb.add(h2);
    hobbyDb.add(h3);
     

    List<Integer> wangList=new ArrayList<Integer>();
    List<Integer> liList=new ArrayList<Integer>();
    wangList.add(0);
    liList.add(0);
    liList.add(1);
    liList.add(2);
   
    p4.setHobbyList(wangList);
    p5.setHobbyList(liList);
   

------ Solution ------------------------------------- -------
OOA & D. ..
------ Solution ------------------------ --------------------

------ Solution ---------------------------- ----------------

------ Solution -------------------------------- ------------
landlord good, encouragement
------ Solution - -------------------------------------------
good detail , good , up posture .
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
summed it up well. .
------ Solution ---------------------------------------- ----
top one ! Be helpful for beginners , personal feel to practice the most important . Nice one post !
------ Solution ---------------------------------------- ----
[quote]

normal development process,

Thanks so much in control of my musicStore, great feeling.

I musicStore, logic like you have the servlet write ah ?
------ Solution ---------------------------------------- ----

thanks so much in control of my musicStore, great feeling.   
  
I musicStore, logic like you have the servlet write ah ?  

If the project is very hurry, you can put the servlet , if it is fairly standard items , we try to make the jump servlet control pure ; such as the most simple " login " program, you can write in a servlet :

String userName=request.getParameter("userName");
String password=request.getParameter("password");
UserInfo userInfo=userInfologic.login(userName,password);

UserInfoLogic , he wrote :

public UserInfo login(String userName,String password){
UserInfo userInfo=userInfoDao.queryByUserNameAndPassword(userName,password);
return userInfo;
}


very supportive of the LZ to share a good thing for everyone ! See this code, also like to say a few words.

In fact, layering is to carry out their duties , improve code reusability.

Dao (Data access Object) layer , by definition , is a database access . At this point, we pass a user name and password to get data dao , in fact, the business logic into a dao processed . Now that you have written a business logic layer, I think , we should split this code :
1. Dao , according to the username to obtain a userInfo object (Dao layer is responsible )
2. judge UserInfo the password with the password request is consistent ( logical layer is responsible )

Thus, in accordance with the user name for access to users and in accordance with the user name , password access users, the frequency of the application , there will be different .

This is the personal view point , I hope to communicate with you ~ !
------ Solution ---------------------------------------- ----
If the logic is not complicated, it's easier ?

String userName=request.getParameter("userName");
String password=request.getParameter("password");
UserInfo userInfo=userInfoDao.queryByUserNameAndPassword(userName,password);



------ Solution ------------------------------------- -------

    
    
write the code shellfish    
  
 

------ Solution ------------------------------------ --------
top one ! Be helpful for beginners , personal feel to practice the most important . Nice one post !
------ Solution ---------------------------------------- ----
very intuitive , benefit , copy saved
------ Solution ------------------------ --------------------
MVC hierarchical model to a great , do not always recommended for beginners to write java code jsp , especially dao layer
------ Solution - -------------------------------------------


just a file organization method , you can consider ~ As for the code , I've already made ​​my view clear thinking , ah ~

Logic in

public UserInfo login(String userName,String password){
    UserInfo userInfo=userInfoDao.queryByUserName(userName);
    // 执行密码验证
    checkPassword(password, userInfo.getPassword());
    return userInfo;
}

------ Solution ------------------------------------- -------
support such posts
------ Solution -------------------------- ------------------
this development model for me as a beginner is very long experience ah , the landlord can not put the project file sent to me ah. < br> ------ Solution ----------------------------------------- ---
right. Taught the
------ Solution ------------------------------------- -------
landlord too very grateful
------ Solution ---------------------- ----------------------


I C
------ Solution --------------------------------- -----------
from object-oriented perspective , job and hobby are the person of a property , has now become a kind , very unexpected. From a database point of view to put them into something like easy to understand.

MVC is more important is the feeling .
------ Solution ---------------------------------------- ----
I just want to say , bean is not a panacea , the landlord overkill .

In fact , JavaBean / POJO popularity of so many novices will not write anything in addition to bean .

depending on the specific design of the framework of your company , depending on what level you do is work .


this sentence quite agree .
------ Solution ---------------------------------------- ----
learn about. .
------ Solution ---------------------------------------- ----
write well
Thank you for sharing
top of a
------ Solution ---------------------------------- ----------
taught , for me to learn a lot in terms of this little rookie !
------ Solution ---------------------------------------- ----

this sentence quite agree .  

I feel it, this points to what level of people who , if I like this dish , you have to object-oriented and object-oriented scholars . These are two different realm , I now see a hill , watching the water is water. So A , had a solid rookie to come .
------ Solution ---------------------------------------- ----
very good example , you can learn the next
------ Solution - -------------------------------------------

this sentence quite agree .  


Why is it overkill ? How would you do ?
------ Solution ---------------------------------------- ----
good menstrual paste it !
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
write well , jacking
------ Solution ------------------------------- -------------
good, good ideas
------ Solution ------------------- -------------------------

------ Solution ----------------------- ---------------------
very good look
------ Solution ---------- ----------------------------------
you are putting programming highbrow drag it back from the Countrymen people. . Enterprises in the program design does it so something .
------ Solution ---------------------------------------- ----
support ! . only become more tangled tangled , tangled to no longer entangled , then congratulations, you finally understand ! . or to keep the progress
------ Solution ---------------------------------- ----------
not see , feel a little advanced , but it should be useful to look , csdn is a good place , hoping to find what they want
------ Solution --------------------------------------------
the LZ only one word , transparent ! ! !
------ Solution ---------------------------------------- ----
good, very powerful , is worth studying , pondering, taste. Thank
------ Solution --------------------------------------- -----
very nice . . . .
------ Solution - -------------------------------------------
good information , worthy of collection.
------ Solution ---------------------------------------- ----
good thing ah , worthy of collection
------ Solution --------------------------- -----------------
good, good !
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
good things, very useful for beginners
------ Solution ----------------------------- ---------------
lz very clear ideas on the development of enterprise-level hierarchical thinking feeling very understanding
------ Solution --- -----------------------------------------
top landlord , great explain .
------ Solution ---------------------------------------- ----
Cock ! Please keep up the progress ! ! !
------ Solution ---------------------------------------- ----
access points. . .
What is menstrual problems
------ Solution -------------------------------- ------------
landlord , as Mao said above, I saw some textbooks DAO is an interface it ? Also , vo also spoke of the bean , right ?
------ Solution ---------------------------------------- ----
lz that designs amazing oh why do I read a description of that part of it is a blank ? Will lz is how to think about how to achieve this realm !
------ Solution ---------------------------------------- ----
god worshiped first collection
------ Solution --------------------- -----------------------
learn about, mark .
------ Solution ---------------------------------------- ----

- ----- Solution --------------------------------------------
Person p3 = new Person (3, " talk of the town father ", Dectionary.Female, 60, Dectionary.Live, -1, -1, 2 , -1 ) ;
here is not the "father" should be replaced by "mother" , accidentally saw , they mention , hope LZ forgive me ha ! Landlord is to force ! ! !
------ Solution ---------------------------------------- ----
I was to pick up points
------ Solution - -------------------------------------------

------ Solution ----- ---------------------------------------
good stuff , keep back slowly see
------ Solution ------------------------------------- -------
learn about.
------ Solution - -------------------------------------------
good things ah , learning
------ Solution ------------------------------------ --------
me behind, it seems to update their knowledge about the structure of the .
------ Solution ---------------------------------------- ----

not so dry it ?
------ Solution ---------------------------------------- ----
novices learn
------ Solution - -------------------------------------------
JavaBean == POJO == Entity???
------ Solution ------------------------------- -------------
why use super ()?



public Hobby(int id, String name) {
    super();
    this.id = id;
    this.name = name;
}




------ Solution ------------------------------------ --------
learn ,
------ Solution --------------------- -----------------------
Although I was a novice, but I do not think that in order to seek fast while ignoring basic , the landlord is someone who , learn encapsulation, inheritance, , polymorphism, understanding abstract classes, interfaces, and object-oriented design ideas and patterns have a fundamental significance for understanding the jdk API is also a great help, this will also decide your future in technology can go far . If we are away for business models that learn quickly and those who do sell any difference
------ Solution ------------------- -------------------------
upstairs was super () do not understand this , which is a subclass of java constructor calls the parent class constructor function method, even if the words do not write also implicitly called inheritance if he does not learn , ask him to understand thing ?
------ Solution ---------------------------------------- ----
super: call a constructor or method of the superclass.

I will not even super they do not understand ? Just feel no need to use

------ Solution ------------------------------------ --------
if not write the words also implicitly called ? understand
------ Solution ----------------- ---------------------------
always thought that they are not for beginners , and a lot of reading after the discovery also need to consolidate ah ~
------ Solution - -------------------------------------------

the normal development process , the first to engage in bean, db ( stored ddl statements , sql scripts, etc. ) , they are the ORM one to one, so first entity and a database built ;   
then write BaseDao, just write basic CRUD; write each entity dao;   
Then logic, logic called dao; encounter complex queries, then come back to write on the inside of an entity Dao specific SQL or HQL statement ;   
then write main or junitTest test logic correctness ;   
Finally write Jsp and servlet.   
Util package throughout, such as writing a JavaBean time to define constants , we went to write   
Dectionary; sql use to date and String conversion , we went to write DateFormatUtil; pages use to upload and download , we'll write IOUtil; reception reception parameters to be determined in the servlet legitimacy , such as ID cards , email validation , etc., we need to write RegExpUtil.   
 

University's own architecture through projects , Util this step learn
------ Solution ------------------------- -------------------
have several questions:
1.logic class how to define ? an entity corresponds to one ? when the system becomes large after , logic classes become more rows 2000 - 3000 , how to deal with ?
2. obtain a Person whether adult approach logic inside or in Person inside ?
3.javaBean should refer to a class of logic class?
------ Solution -------------------- ------------------------
LZ intentioned ah
------ For reference only ---------------------------------------
then the above :

package beantest.logic;

import beantest.bean.Hobby;
import beantest.bean.Job;
import beantest.bean.Person;
import beantest.dao.BaseDao;
import beantest.db.DataBase;
import beantest.util.Dectionary;
/**
*业务逻辑的类
*
*/
public class LogicClass {
    BaseDao<Person> personDao=new BaseDao<Person>(DataBase.personDb);
    BaseDao<Job> jobDao=new BaseDao<Job>(DataBase.jobDb);
    BaseDao<Hobby> hobbyDao=new BaseDao<Hobby>(DataBase.hobbyDb);
/**
* 判断两个人是否是夫妻关系,并输出谁是丈夫,谁是妻子
*/
public  boolean assertHusbanAndWife(int id1,int id2){
    Person p1=personDao.query(id1);
    Person p2=personDao.query(id2);
    boolean flag=false;
    if(p1.getLoverId()==id2&&p2.getLoverId()==id1){
        flag=true;
        System.out.println(p1.getName()+"和"+p2.getName()+"是夫妻");
        if(p1.getMale()==Dectionary.Male){
            System.out.println(p1.getName()+"是丈夫\t"+p2.getName()+"是妻子");
        }else{
            System.out.println(p2.getName()+"是丈夫\t"+p1.getName()+"是妻子");
        }
    }
    return flag;
}
/**
*显示人的职业
*/
public  void printPersonJob(int personId){
    Person p=personDao.query(personId);
    Job j=jobDao.query(p.getJobId());
    System.out.println(p.getName()+"是一名"+j.getName());
}
/**
*判断一个人的父母是否健在
*/
public boolean juggParent(int personId){
    boolean flag=false;
    Person p=personDao.query(personId);
    Person father=personDao.query(p.getFatherId());
    Person mother=personDao.query(p.getMotherId());
    if(father.isLive()&&mother.isLive()){
        flag=true;
        System.out.println(p.getName()+"的父母健在");
    }else if(father.isLive()){
        flag=false;
        System.out.println(p.getName()+"只有父亲健在");
    }else if(mother.isLive()){
        flag=false;
        System.out.println(p.getName()+"只有母亲健在");
    }
    return flag;
}
/**
* 根据父母的ID查询孩子
*/
public Person queryChildByParent(int fatherId,int motherId){
    Person child=null;
    for(Person p:DataBase.personDb){
        if(p.getFatherId()==fatherId&&p.getMotherId()==motherId){
            child=p;
            Person father=personDao.query(fatherId);
            Person mother=personDao.query(motherId);
            Job job=jobDao.query(child.getJobId());
            System.out.println(father.getName()+"和"+mother.getName()+"有一个儿子,"+child.getAge()+"岁了,在"+job.getName());
            break;
        }else{
            continue;
        }
    }
    return child;
}
/**
*描述谁做什么的方法
*/
public  void personDoSth(int personId,String what,int hobbyId){
    Person p=personDao.query(personId);
    Hobby h=hobbyDao.query(hobbyId);
    System.out.println(p.getName()+"有时候"+what+h.getName());
}
public static void main(String[] args) {
    LogicClass lc=new LogicClass();
    //老王和老李是夫妻
    lc.assertHusbanAndWife(4, 5);
    //老王是一名大学教授,老李是一名会计
    lc.printPersonJob(4);lc.printPersonJob(5);
    //他们的父母都健在
    lc.juggParent(4);lc.juggParent(5);
    //老王和老李有一个儿子,15岁了,在上中学
    lc.queryChildByParent(4, 5);
    //老王有时候去打太极拳,老李有时候去兼职讲课
    lc.personDoSth(4, "去打",0);lc.personDoSth(5, "去",1);
}
}


package beantest.util;

/**
*数据字典
*
*/
public class Dectionary {
    
/**
* 男人
*/
public static final int Male=1;
/**
* 女人
*/
public static final int Female=2;
/**
* 活着
*/
public static boolean Live=true;
/**
* 死亡
*/
public static boolean Dead=false;
}

Output:

老王和老李是夫妻
老王是丈夫 老李是妻子
老王是一名教师
老李是一名会计
老王的父母健在
老李的父母健在
老王和老李有一个儿子,15岁了,在上中学
老王有时候去打太极拳
老李有时候去兼职讲课


find useful Bangding scattered End Score Results posted .
------ For reference only -------------------------------------- -




tell beginners quickly accelerate progress , not in that "object-oriented " very mysterious
------ For reference only ----------------- ----------------------

normal development process , the first to engage in bean, db ( stored ddl statements , sql scripts, etc. ) they are ORM one to one, so first entity and the database built ;
then write BaseDao, just write basic CRUD; write each entity dao;
Then logic, logic called dao; encounter complex queries, then come back to write on the inside of an entity Dao specific SQL or HQL statement ;
then write main or junitTest test logic correctness ;
Finally write Jsp and servlet.
Util package throughout , such as writing a JavaBean time to define constants , we went to write
Dectionary; sql use to date and String conversion , we went to write DateFormatUtil; pages use to upload and download , we'll write IOUtil; reception reception parameters to be determined in the servlet legitimacy , such as ID cards , email validation , etc., we need to write RegExpUtil.

------ For reference only ---------------------------------- -----

thanks so much in control of my musicStore, great feeling.

I musicStore, logic like you have the servlet write ah ?
If the project is very hurry, you can put the servlet , if it is fairly standard items , we try to make the jump servlet control pure ; such as the most simple " login " program, you can write in a servlet :

String userName=request.getParameter("userName");
String password=request.getParameter("password");
UserInfo userInfo=userInfologic.login(userName,password);

UserInfoLogic , he wrote :

public UserInfo login(String userName,String password){
UserInfo userInfo=userInfoDao.queryByUserNameAndPassword(userName,password);
return userInfo;
}

------ For reference only ----------------------------------- ----
  The reply deleted by an administrator at 2013-08-05 13:12:08

------ For reference only ---------------------------------- -----

http://download.csdn.net/detail/smallyamateh/5875117 Free Credits
------ For reference only ---- -----------------------------------

enterprise level stuff really is not difficult, I think that was a lot of detours his left .
------ For reference only -------------------------------------- -

teaching more specific than I , Dao, DaoImpl etc. , vo is used to indicate front view to facilitate the EL expressions show.
------ For reference only -------------------------------------- -

Eclipse automatically generated.
------ For reference only -------------------------------------- -

in the current MVC pattern basically can say , dao, service, servlet , and so strictly speaking not a JavaBean; while EJB inside various Javabeans too complex to temporarily abandon the EJB is wise selection.
------ For reference only -------------------------------------- -
  The reply deleted by an administrator at 2013-08-22 10:14:32

------ For reference only ---------------------------------- -----
  The reply deleted by an administrator at 2013-08-22 10:15:23

------ For reference only ---------------------------------- -----

1, small system , then an entity corresponds to a Logic; big system, then a small module corresponds to one , such as logging , logging and recovery, photo album management , etc., can be written as a different classes.
2, PersonLogic years, or a page directly use JSTL tags .
3, from the current system without EJB speaking , javabean == pojo == entity; others called " assembly component".

没有评论:

发表评论