葵花宝典第一部

来源:互联网 发布:帝吧出征事件2016数据 编辑:程序博客网 时间:2024/06/09 17:35

1、方法签名中的参数不要使用Map 

Map作为入参的Method在使用时极容易因为Key的维护造成代码维护的不方便

publicList<User> queryUsers(Map<String,Object){
 
 
}

 

2、Method的参数不易过多

Method参数过多时需要封装成参数对象

publicclass UserDaoImpl{
 
    publicList<User> queryUsers(String name,String email,String phone,Integer sex,String address,Long start,Integer limit){
         
 
    }
}
---->
packagecom.lifeix.apollo.user.dao.params;
publicclass UserQueryParams{
    privateString name;
    privateString email;
    privateString phone;
    privateInteger sex;
    privateString address;
    ... ...
}
publicclass UserDaoImpl{
    publicList<User> queryUsers(UserQueryParams userQueryParams,Long start,Integer limit){
     
    }
}
0 0
原创粉丝点击