Java Sentiment inheritance and encapsulation (do not do yard farming)

Source: Internet
Author: User

These days the project uses the IBATIS specification SQL statement so that all SQL statements are entered manually. Especially when you encounter a table that has more than 30 fields, updates, insert statements that are simply annoying. It feels like programmers are really yards, or bricks, And no one else has a high salary. But recall that this kind of mechanical input can be avoided, and then I went to think about writing some tool classes, directly generated Ibatis entity class and XML mapping file, this generation process took only a minute. Just blame yourself for being stupid and then have a little insight

1, as a good programmer must be proficient in using a variety of tools to assist the development, or directly write their own needs of the tool class, so as to avoid a variety of repetitive mechanical labor, can not become "yards of farmers"

2, must be inherited and encapsulated this two Java concept deep imprinted in their own mind, the development process, can not be drawn up a variety of common methods encapsulated for their own multiple calls, such as a lot of people just getting started, the program needs to use session to obtain data, and then each method to get a session, Does this time feel very inconvenient, you just need to write a common method, then need to use the method of the session you will inherit (extends) your common method is OK,

protected HttpServletRequest req; Request Scope
protected HttpSession ses; Session scope
Protected HttpServletResponse res;//Response response

public void Setservletrequest (HttpServletRequest req) {
This.req=req;
This.ses=req.getsession ();

}

public void Setservletresponse (HttpServletResponse res) {
This.res=res;

}

For example, other methods inherit this method. This is not a great degree of simplification of the development!



Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Java Sentiment inheritance and encapsulation (do not do yard farming)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.