In the learning model, please pay more
Description:
First, the case description:
1. Simulate the picture site in the form of blog.
2. The main users are ordinary browser, registered users (Blogether, system administrator (admin).
3. Website Storage Data is a Picture (PIC), Pictures (List), Photo Comments;
4. Main behavior
4.1 Browser (Browser) browsing (PIC) and Classification (List), Query (Find), and Comments (COMEOUT).
4.2 Registered Users (Browse), Classification (Find), Upload, Download (Download), Crete, Delete (Issue) ) The Control function. Registration (Enrol), Login Edit (Edit), Encrypted (ISSUE), etc.
4.3 Administrators (Admin) The Audit, the AUDIT, the backup (BACKUP), the Control function. For the management function of the Registered User (Browse), Query (Find), Create, Delete, Audit, etc.
5. The main module has
5.1 Class: Browser, Registered User (Bloger), System Administrator (Admin), Picture, Picture Classification (List), Pictures, Personal.
5.2 Function or Interface:
A, Image Browse (FindPic), Image UploadPic, Image Download (CreatePic), Image Removal (Delpic), Image Release (IssuePic), Image Review (AuditPic) , Image Backup (Backuppic), Picture Management (ControlPic). B, Classification Browse, Createlist, Createlist, Classification Delete (Issuelist), Classification AuditList, Classification Management (Controllist).
C, comment browsing (COMEOUTCOMMENT), Review Deletion, AuditComment, Comment Management.
D, User Registration (Enrol), login,
e, personal information browsing, personal information query (createpersonal), personal information editing, personal information deletion, personal information encryption (EncryptPersonal), personal information publishing (IssuePersonal) , Personal information review (AUDITPERSONAL), personal information management (ControlPersonal).
6. This example is confirmed for learning Java mode, non-real cases.
mode:
I. Simple factory
1. Basic simple factory (SimpleFactoryBisic):
1.1 Design Ideas:
Simple factory is a class creation mode and is also called Static Factory Method mode. Simple factory model is to create which product class created by a factory class based on incoming parameters.
In this example, a single simple factory build system is used, and its role is positioned:
Factory role: Bloger because of the main executor of business logic in the system, is also a direct caller of specific product role.
Abstract Product Role: Result, Result is an interface or abstract class, responsible for the definition of specific product roles, and interact with the client.
Specific product role: PIC, List, Comment, Personal, objects created by factory classes, but also the client actual operation object.
Client: browser, admin, calling factory class bloger generates the Result instance, and calls Result to work.
1.2 UML map:
1.1 Reflections: In this example, a single simple factory model is poor. The shortcomings of its exposure are: 1, the specific product class is small, the attribute and method cannot be uniform in the same interface, and it is impossible to protrude. Difficulties are difficult to divide. Enhance the product class unnecessary method. 2, Bloger role function misplaced. 3. Simple factory model is undoubtedly simple.
1. Expanded simple factory (SimpleFactoryUpgrade):
2.1 Design Ideas:
On SimpleFactoryBasic, according to the user rights division module, reflect the inheritance relationship between users. According to the dependency reversal principle, the specific function is abstracted as an interface. Different users can create themselves, and different users can only call their own functions. The regulations are clear and the functions are clear.
2.2 UML diagram:
2.1 Thinking:
In this case, it is effective to solve difficulties in division of user rights on Basic. At the same time, the Bloger class is released, making the program clearer, making the contradiction between the properties and method conflicts of the specific product class to a certain resolution, have certain implementability. The disadvantage is mainly in the specific product inter-product attributes and methods, and the conflict between the products and the interface is still.