2019 to do the project summary

Disclaimer: This article is a blogger original article, shall not be reproduced without the bloggers allowed. https://blog.csdn.net/qq_40646143/article/details/86302044

1, first of all speaking the code

Projects, each layer naming convention (incorporated herein by reference Alibaba's development manual):

  • Service / Dao layer naming Method
  • 1), a method of obtaining a single object with a prefixed get.
  • 2) obtaining a plurality of object methods to do with the prefix list, the end of the plural form, such as: listObjects.
  • 3), obtain statistical method worth prefixed with the count.
  • 4), the insertion method is prefixed with save / insert.
  • 5), delete methods prefixed with remove / delete.
  • 6), prefixed by a modified method of update.

 

2, is the succession of expansion

                      

 

FIG subclass above example this is a car and the car suv car category class, sedan class suv vehicle class and vehicle is extended, respectively

My question appears in the service implementation class this place, because the suv car class is a subclass car class, when suv car class data storage, it should first call the Save method car class, and then calls itself to expand on the car class field to save, because, suv car is a car made to expand the car owned property also has a class suv car, should not directly operate this table without reference method for storing car class.

3, testCaset problems

Write your own every method, should correspond to a testCase, verify write their own method logic is correct to note the following two aspects

The first database is testCase can not be operated, such as changing the data, the following use @Rollback (false)

 

The second is that you write at the end of the service method to testCase, must determine whether your logic is correct as such, use Assert.assertNotNull () method to determine whether the found data, if the data is null, you will be prompted an error.

 

4, issue service method parameters

For example, the following parameters of a method to update the resource --- passed is an object, rather than (Long id, boolean flag)

  • Doing so few benefits
  • 1), limiting the role of the user entity object can pass, avoiding the others casually pass by value
  • 2) background mybaties use flushCache refresh the data when the refresh is an object, not you pass id and boolean values
  • Expand mybaties 
  • flushCache: If set to true, the statement when calling a secondary cache will be cleared away. select statement is false by default

5, do project issues

  • According to the development plan to go to complete a functional module and then doing something functional modules, this function can not do half, another function to do it again, I made this mistake, you know the consequences
  • Development, we need to think, you first have to understand what you are doing something that is functional, first of all get something in to get something, to complete the final effect is like, not just give you schedule tasks, you copy someone else's code
  • There is a copy of the problem, not the brain can not copy someone else's code, before you copy the code to know other people what it meant, and then copy
  • Modify the database data, you can not use the View tool (Nacivat) directly modify, view of the tool is to allow people who do not use the sql, but can not be used as a tool for developers to view, so that our foundation sql
  • In the project, if you need to insert similar rights to data such as death data, we need the items into your webapp folder sql statement following sql file, if the project data is deleted, you can also find sql on the project statement

 

6, the definition of the constant need to write in the configuration file, not directly defined in the code as follows

  • If the hero banner next time you need a change of name, I need to re-find the hero banner on the project?
  • Defined in the configuration file, you can modify the configuration file directly to the next, simple and convenient

 

7, expand SpringContextUtils get javaBean objects

1), if a service interface injection to achieve a class, can be written

 

Service class

@Service("bannerService")
public class BannerServiceImpl extends EcService implements BannerService 

Get javaBean, find use as follows

SpringContextUtils.getBean(BannerService.class).find(bean)

2), if below an interface implementation class obtain both a serviceImpl follows javaBean

public interface SecUserService

Two months following implementation class

   

To get one now javaBean example, as follows

SpringContextUtils.getBean("secUserService", SecUserService.class).find(bean);

 

8, language skills

  • Urgent need to improve ah ah ah

 

Guess you like

Origin blog.csdn.net/qq_40646143/article/details/86302044