Python learning-----project design 1.0 (design thinking and ATM environment construction)

 

Table of contents

Foreword:

Project development process

MVC design pattern

What is the MVC design pattern?

ATM project requirements

Environment construction of ATM project


Foreword:

        I personally have been learning Python for about a month. During this month, I published many articles about Python and created a column for starting Python learning ( https://blog.csdn.net/m0_73633088/category_12186491.html ), Here I am very grateful to all of you for your company all the way. Your support is the inexhaustible driving force for my creation. So in this issue, I plan to design a simple project. Through the design and method of this project, I will summarize the learning results of Python at this stage. At the same time, I will soon enter the next stage of learning. Let's learn Python happily together and make progress together!

        Well, without further ado, let's get straight to the point.

Project development process

        In the process of learning programming, we will do a small project through programming, so what is the specific process of doing a customer-oriented project? At the same time, what content do we need to consider during the development process? Let's take a look together!

1. Needs analysis: determine what the real needs of users are like

(1). Determine the user's needs and the basic functions of the project

(2). Analyze the feasibility of the project and the overall difficulty of the project

(3). Write requirements documents and confirm with customers

2. The overall design of the project outline: preliminary analysis and overall design of the entire project

1. Determine the overall framework, determine the overall idea of ​​the technical direction and determine the framework model

2. Form an overall profile document

3. Project design: determine the development time flow and time extraction

1. Determine the sequence of development work

2. Determine the timeline

3. Division of labor

4. Detailed design: concrete realization of project functions

Group programmers discuss: project ideas, logic flow, function description, and technical point description.

5. Coding: code implementation according to the predetermined design

6. Unit Testing: Basic Checks

7. Project overall test: carry out specific tests on the project according to the realization of functions (software test engineer)

8. Project release

9. Post-maintenance

 The above is a user-oriented project development process, you can refer to

 

MVC design pattern

        When we are working on a project, how should we typeset the code or related functions to make the project more intuitive, readable, and easier to understand. At this time, you should use the MVC design pattern

What is the MVC design pattern?

        If there are small partners who have done projects, when we first start the project, we will generally put some functional codes into the same execution file. At this time, we will find that our code has hundreds of lines! The most important thing is that if there is a small problem in one line, the entire code will run incorrectly, and then you have to find the bug line by line, which will be very troublesome. If you sample the MVC design module, you can avoid these problems. 

MVC architecture (each performing its own duties):
    high cohesion --> function specialization of program/function/module.
    Low coupling --> as low as possible between functions
    to avoid one wrong, all wrong situations. Improve development Timely project focus. A project development structure derived from better troubleshooting problems

illustrate:

M: model-->module layer-->mainly responsible for the operation of data, adding, deleting, modifying and checking (database)
    C:controller-->control layer-->mainly responsible for the realization of functions
    v:view-->view layer-- >Mainly responsible for providing interaction and things for users to see (front end)

 So after reading these, everyone should consider the MVC design pattern when designing projects in the future, which will make your projects more perfect!

 

ATM project requirements

        Everyone has been to the bank to deposit and withdraw money. These are familiar to you. Then the ATM project introduced in this issue is to simulate the function of depositing and withdrawing money in a bank, as well as related functions such as user login, registration, and transaction query. , In this issue, I will introduce in detail the environment construction requirements of this project, as well as related functions such as MVC design modules, and I will explain the code implementation in the next issue.

Project requirements:

Suppose you go to an ATM machine for the first time, first register, log in, deposit money, check the balance, withdraw money, deposit money, check the flow, log out, log out, log out the user

1. Register

See the interface of the ATM machine, there is a registration, login button selection ------ select registration

After choosing to register, enter the registration interface, -------Start the registration operation, enter the user name/real name/ID card, set the password, and confirm the password [It will be judged at this time, if the two passwords are the same, the registration is successful; Otherwise, you need to re-register】------Registration is successful

After successful registration:

Become an ATM user, that is, you have your own account in the ATM system, and your user data [username, password, balance, turnover...]

2. Login

After the registration is successful, return to the login interface, enter the user name and password, and then log in [Log in only if the user name exists and is correct and the password is correct; if the user name does not exist, you need to return to the registration interface to register first; if the user name exists, But if the user name or password is incorrect, you have to log in again], as long as the user name and password are correct, you can log in successfully

3. Save money

After successful login, enter the ATM function operation interface (deposit money, withdraw money, transfer money, check the balance, check the running bill), select the deposit operation you want - put in cash - confirm the deposit - deposit successfully . The amount of deposit is user data, stored in the database

4. Check balance

After the deposit operation is completed, it will jump to the ATM function operation interface (deposit money, withdraw money, transfer, check balance, check the current bill), select the function of checking the balance --- confirm to view --- display your balance --- Exit the check balance interface and return to the ATM function operation interface

5. View running water

From the ATM function operation interface, choose to view the transaction function----confirm to view---return to the transaction status (whether to print the receipt)---exit to view the transaction---return to the ATM function operation interface

6. Withdraw money

If there is no other operation, if you withdraw money directly, you must log in first, and then enter the ATM function operation interface, select the withdrawal function, enter the withdrawal amount, confirm the withdrawal, after withdrawing, log out, and return to the ATM function operation interface. At this time, the deposit amount changes again, that is to say, the user data changes again, and the database needs to be updated. 

 

7. Log out

In the case of logging in, avoid logging in again, all you need to log out of the conversion at this time before you can log in to other accounts

8. Logout

In the case of already logged in, the user can be logged out, which will delete all the data of the user

Environment construction of ATM project

        This is the preparatory work. To implement it, you need to prepare a folder named ATM project, and then prepare related subfolders in it. These subfolders have corresponding code functions and time functions, and the folders include:

api folder, config folder, core folder, DB folder, lib folder, and a main program that executes the program run.py

The following are the contents and functions associated with these folders: 

api-->application programming end course-->criminal tools-->commonly used function module
    uesr_i.py: user function module-->register, log in
    bank_i>py: bank function module-->save money Withdraw money
        
config-->settings-->put configuration information (data information/database account/python environment configuration)
    setting.pyu-->this time put the configuration information of the project (the location where the user data is saved)
    
core- ->Core module-->It is equivalent to the front end, which is written for the user to see/interact. # Realize the
    view layer (the interface seen by the ATM)
    src.py-->Interactive content, start the interface
  
    
DB -->Database-->Database, where json files are used to save/read data
    user_data-->This is a folder,
    db_handle.py__ for storing user data>Module for operating database content 1. Write Enter data 2. Check data
    
lib-->toolkit-->put special functions (decorators)
    common.py-->place to write decorators
    #Decorator to determine whether the user has successfully logged in
    
run.py--> Project startup file
readme.md--> project documentation

This issue is here first, in the next issue I will explain in detail how to write the code, see you next time~

share a wallpaper 

 

Guess you like

Origin blog.csdn.net/m0_73633088/article/details/129222552