A collection framework for Java Fundamentals Enhancement Note 37: User Login Registration case

Source: Internet
Author: User

1. Login Registration Case Analysis diagram:

2. User Login case detailed analysis and subcontracting implementation :

(1) User Login case Detailed analysis ( object oriented thinking )

The following actions allow us to be more consistent with object-oriented thinking :

• What are the classes ?

User class

Test class

• What are the items in each class ?

User class:

Member variables: User name, password

Construction method: Non-parametric construction

Member Method: GetXxx ()/setxxx ()

Login, register

If the user class content is more, the future maintenance is more troublesome, in order to more clear classification, we have divided the user into two categories:

User Basic Description class:                           

Member variables: User name, password

Construction method: Non-parametric construction

Member Method: GetXxx ()/setxxx ()

User Action class:

Login, Register

Test class:

Main method

• What is the relationship between classes and classes?

In the test class, create an object for the user action class and the user base description class, and use its functionality.

(2) User Login case subcontracting

• Functional Partitioning

• Module Partitioning

• Divide by module First, then by function

This time we choose to divide by function:
User basic Description Class pack: Cn.itcast.pojo
User Operation interface: Cn.itcast.dao
User Action Class Pack: Cn.itcast.dao.impl
This is the collection implementation , followed by the IO implementation, again is the GUI implementation, the end is the database implementation
User test class: Cn.itcast.test

3. User Login Case user basic description class and user operation interface implementation:

(1) user Basic Description class: Users

1  PackageCn.itcast.pojo;2 3 /**4  * 5 * This is the user basic description class 6  * @authorMr He7  * @versionV1.08  *9  */Ten  One  Public classUser { A     //User name -     PrivateString username; -     //Password the     PrivateString password; -      -      PublicUser () { -         Super(); +     } -  +      PublicString GetUserName () { A         returnusername; at     } -  -      Public voidSetusername (String username) { -          This. Username =username; -     } -  in      PublicString GetPassword () { -         returnpassword; to     } +  -      Public voidSetPassword (String password) { the          This. Password =password; *     } $     Panax Notoginseng  -}

(2) user operation interface:Userdao

1  PackageCn.itcast.dao;2 3 ImportCn.itcast.pojo.User;4 5 /**6 * This is an interface for users to operate 7  * @authorMr He8  * @versionV1.09  *Ten  */ One  Public InterfaceUserdao { A     /** - * This is the user's login function -      * @paramusername the * User name -      * @paramPassword - * Password -      * @returnreturns whether the login was successful +      */ -      Public Abstract BooleanIsLogin (string Username, string password); +      A     /** at * This is the user's registration function -      * @paramuser information for users to register -      */ -      Public Abstract  voidregist (user user); -}

A collection framework for Java Fundamentals Enhancement Note 37: User Login Registration case

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.