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