Extreme Programming

Extreme Programming
Team NameAmberBlaze
Team LOGOLOGO
Teammember NameRongcheng Xie  Molan Xue
Student FZU ID832201126     832201130
Course for This Assignment2401_MU_SE_FZU
Assignment RequirementsExtreme Programming
Objectives of This AssignmentThe objective of this assignment is to develop a Program that fulfills four key functions: bookmark contacts, enabling multi-contact methods, supporting import/export of data, and deploying the program for practical use.
Other Reference1. WeChat Mini Program Design Guide 2. Javascript Style Guide 3. WeChat Developer Tools 4. The Art of Construction

1. About Project

1.1 Project Address

1.2 Commits Log

在这里插入图片描述

1.3 Coding Standard Link

2. Functional Implementation

2.1 Functional Structure Diagram

Functional Structure Diagram

2.2 Bookmark Contacts

Bookmark ContactsFrontendFunctionalityUsers can mark important contacts as bookmarked or remove the bookmark by clicking the bookmark button. The status field visually indicates whether the contact is bookmarked or not.
ImplementationFunction 'collect':
Implemented in pages/index/index.js, it listens for the bookmark button click event, toggles the bookmark status, and refreshes the UI dynamically. The UI is bound to the status field using WXML for real-time updates.
Workflow1. User Interaction: The user clicks the bookmark button next to a contact in the list. This triggers the collect function, which receives the contact's unique _id and its current status as parameters.
2. Function Execution (collect):If the status is 1 (not bookmarked), it updates the status to 2 (bookmarked). If the status is 2 (bookmarked), it reverts the status back to 1 (not bookmarked).
3. UI Update:After toggling the status, the function calls self.loadContactsFromDatabase() to reload the updated contact list from the database. The page dynamically reflects the new bookmark status through the WXML binding.
4. User Feedback:The function uses wx.showToast() to display feedback:"Successfully bookmarked" for bookmarking."Bookmark removed" for unbookmarking.
BackendFunctionalityUpdates the bookmark status of a contact in the contacts collection of the database.
ImplementationFunction 'update':
Updates the status field of a contact document using its _id in the cloud database​(index).
Workflow1. Database Update: The collect function communicates with the backend cloud database via contactsCollection.doc(_id).update. It updates the status field in the contacts collection: Sets status: 2 to mark the contact as bookmarked. Sets status: 1 to unbookmark the contact.
2. Data Retrieval: After the database update, self.loadContactsFromDatabase() fetches the updated contact list. This ensures the frontend reflects the latest changes.

2.3 Add Multiple Contact Methods

Add Multiple Contact MethodsFrontendFunctionalityUsers can input contact details such as name, phone number, email, and address, and upload a profile picture for the contact.
ImplementationFunction 'collect':
1. Functions onNameInput, onPhoneInput, etc.: Capture user inputs and store them in the page's data.
2. Function chooseAvatar: Allows users to select a profile picture.
3. Function saveContact: Submits form data and calls cloud database APIs to save the data​(addContact).
Workflow1. User Interaction: The user fills in the contact details such as name, phone number, email, address in a form presented on the "Add Contact" page. If the user chooses to upload a profile picture, they can do so via the file upload feature (handled by the chooseAvatar function).
2. Form Submission: When the user clicks the "Save" button, the saveContact function is triggered. This function collects all the form data stored in the page's data object and performs basic validation: 1. Checks if required fields (e.g., name and phone number) are filled. 2. If validation fails, an error message is shown using wx.showToast() to prompt the user to complete the form.
3. Data Handling: If the validation succeeds, the saveContact function constructs a data object containing the form inputs, including optional fields like avatar (profile picture) and note. The function then sends this data object to the backend by calling the cloud database's add method.
4. User Feedback: Upon successful submission: A success message ("Contact saved") is displayed using wx.showToast(). The user is redirected to the homepage (or another appropriate page) via wx.redirectTo().
BackendFunctionalitySaves the contact information to the contacts collection in the cloud database.
ImplementationFunction 'contactsCollection.add':
Adds a new record to the database, storing fields like name, phone, email, and address​(addContact).
Workflow1. Receiving Form Data: The saveContact function on the frontend sends the form data to the backend using the contactsCollection.add method. This method communicates with the cloud database and receives the submitted data as input.
2. Data Insertion: The cloud database processes the request and inserts the data into the contacts collection. Each contact record is saved as a document (name, phone, email, address, avatar, note, status, and associations.)
3. Response Handling: On successful insertion, the backend returns a success response to the frontend. In case of an error, the backend sends an error response, which is handled by the frontend to inform the user.

2.4 Import and Export

Import and ExportFrontendFunctionalityAllows importing contact data from an Excel file and exporting existing contact data to an Excel file.
ImplementationFunction 'importData':
Uses wx.chooseMessageFile to select the file, processes it with the XLSX library, and submits parsed data to the database.
Function 'exportData':
Retrieves contact data from the database, formats it into an Excel file, and saves it to the user directory​(index).
Workflow1. File Selection: The user selects a file (Excel) to import contact data. Using the wx.chooseMessageFile method, which allows the user to pick a file from their device.
2. File Parsing: The selected file is read using the wx.getFileSystemManager().readFile method. The XLSX library processes the file content to parse it into a JavaScript array.
3. Data Validation and Upload: The parsed data is looped through to extract individual rows (representing contacts). For each row, the contactsCollection.add method is called to store the contact details in the cloud database.
4. User Feedback: After successful storage, a success message is displayed using wx.showToast.
BackendFunctionalityHandles data storage during import and retrieval during export.
ImplementationImport: Uses contactsCollection.add to insert records.
Export: Uses contactsCollection.field().get to fetch all contact data​(index).
Workflow1. Data Storage: For each parsed row, a new document is inserted into the contacts collection using contactsCollection.add. The data includes fields such as name, phone, email, address, and optional fields.
2. Response Handling: The backend returns a success response for each document inserted. In case of an error, it logs the issue and notifies the frontend for user feedback.

2.5 Web Deployment

Web DeploymentFrontendFunctionalitySupports accessing the application features through a web browser.
BackendFunctionalityDeploys APIs and cloud functions to handle requests from the web frontend.
ImplementationCloud functions are used to provide endpoints for data operations. A RESTful API can be deployed on cloud platforms like Huawei Cloud or Alibaba Cloud.
WorkflowDatabase Integration: Use the same cloud database (contacts collection) as the mini-program.

3. Product Presentation

3.1 User Interface

Firstly, find SoCiaLConTacT in my Recently Used Mini Programs section and click to enter.
You will see the following user interface:
interface

Currently, the data for the Mini Program Cloud Development Console is as follows:
MPCDC

3.2 Feature 1: Bookmark Contacts

Users can bookmark a contact by clicking the star icon next to the contact’s name. Once clicked, the icon changes to a filled yellow star, indicating that the contact has been successfully bookmarked. Clicking the icon again will remove the bookmark, reverting the star icon to its original outline, visually confirming the removal of the bookmark.
Bookmark Contacts1
Bookmark Contacts1
After Bookmark Contacts, the data in the Mini Program Cloud Development Console changed, the status changed to 2 (bookmarked):
MPCDC

3.3 Feature 2: Add Associated Contacts

Click the “View Associated Contacts” button to enter the interface for viewing contacts associated with this contact.
在这里插入图片描述
Enter the contact interface associated with Jiali, but there are no contacts associated with Jiali on this interface
在这里插入图片描述
Add by selecting existing contacts in the address book
在这里插入图片描述
At this point, the interface displays the contacts associated with Jiali, implementing the add multiple contact methods
在这里插入图片描述
在这里插入图片描述

3.4 Feature 3: Add Multiple Contact Methods

By clicking on the ‘Add Other Information’ button on the contact details interface
在这里插入图片描述
Allow more contact information to be associated with this contact
在这里插入图片描述
在这里插入图片描述

3.5 Feature 4: Import and Export

Users must provide data in the following predefined structures, including fields such as name, phone number, email, address, and notes. This ensures that the system can accurately parse information and store it in the database.
规范格式
Click the ‘Import Contacts’ button below the mini program
在这里插入图片描述
Select an information table from the local file that meets the required structure specifications
在这里插入图片描述
在这里插入图片描述
Finally, the contacts will be automatically sorted in alphabetical order
在这里插入图片描述
The video demonstration of the import process is shown in the following figure
在这里插入图片描述
Click the Export Contacts button below the mini program
在这里插入图片描述
By clicking on the file management application inside the Android phone, click on the WeiXin folder in the internal storage to find the exported file.
在这里插入图片描述
The final exported data is consistent with the data we stored and meets the requirements for exporting data functionality
在这里插入图片描述

3.5 Feature 4: Web Deployment

Our project has successfully implemented Tencent Cloud cloud deployment, efficiently handling core functions such as data export and user identity acquisition through cloud functions. In our project, the two key features of exportData and getOpenId have been deployed and tested on Tencent Cloud, providing stable service support for users.
Web

4. Teamwork

FZU IDNameResponsibilitiesContributions
832201126谢荣城Responsibilities1. Design and develop the frontend modules, including page layouts and styles.
2. Implement user interaction logic.
3. Integrate the import and export functionality in the frontend.
4. Document the development process and write parts of the blog.
50%
Work1. Frontend Implementation: Responsible for key files such as index.js, addContact.js, and selectassociations.js.
2. UI Design: Designed the mini-program's interface style and user experience.
832201130薛墨澜Responsibilities1. Set up the cloud backend, including database configuration and API interfaces.
2. Implement contact CRUD operations, association logic, and log recording functionality.
3. Handle backend logic for file upload/download.
4. Assist in frontend debugging and feature integration.
50%
Work1. Backend Implementation: Primarily responsible for cloud database operations and data interface development.
2. Technical Support: Resolved technical issues during development and optimized code structure.

5. Difficulties Encountered and Detailed Solutions

DescriptionSolution AttemptsResults
谢荣城:
Difficulty in Parsing and Importing Excel Files
Implementing the import functionality was challenging due to the variety of Excel file formats provided by users. Some files lacked proper headers, while others had inconsistent data types, leading to parsing errors or incorrect data import into the database.Finding a Suitable File Parsing Tool:
Initially, manual parsing of Excel data was attempted, but it proved inefficient due to the complexity of the formats. After searching for solutions on platforms like 优快云 and GitHub, we chose XLSX.js, which can parsing Excel files with support for multiple formats. After integrating the library, our team studied its official documentation and related tutorials to gradually master its usage for parsing Excel files.
Successfully implemented file parsing and import functionalities with standardized handling. The system effectively detects non-compliant files and provides clear feedback to users. Users can now seamlessly upload files using the standardized template, significantly improving the stability and accuracy of data imports.
Designing a Standardized Template:
We designed a standardized Excel template was designed early in the project, specifying column names and formats such as name, phone, email. Before importing data, users were provided with a template download link, and validation logic ensured that uploaded files adhered to the template structure.
Local Testing and Debugging:
Conducted multiple rounds of local testing using the WeChat Developer Tool by uploading files with different issues such as extra headers, missing fields to analyze error messages. Identified that encoding issues caused some files to fail parsing. After researching solutions online, our team resolved this using FileReader alongside XLSX.js to handle encoding problems.
薛墨澜:
Synchronization Between Frontend and Backend
During frequent user operations such as quickly bookmark contacts and unbookmark contacts, discrepancies were observed between the frontend interface and backend database. For instance, the frontend would display a contact as bookmarked, while the database state remained unchanged.Analyzing the Root Cause:
By reviewing logs in the WeChat Cloud Development Console, our team identified that the issue was caused by improper handling of asynchronous requests, where the frontend refreshed the interface before receiving the database update result. After researching similar issues on 优快云, our team learned that proper use of Promises and callback functions could address this problem.
The optimized solution ensured stable synchronization between the frontend and backend, even during rapid user operations.
Optimizing Asynchronous Logic in Frontend:
Replaced nested callback functions in the frontend with async/await to ensure that the database update process completed before refreshing the interface. During local testing, our team used browser debugging tools and console.log statements to verify the correct sequence of data updates.
Using Cloud Database Triggers:
After studying the WeChat Developer documentation, the team implemented cloud database triggers to notify the frontend of changes in real time whenever the database state was updated. Combined this approach with a local caching mechanism to reduce the performance impact of frequent user actions.

6. PSP Table

  • 832201126 谢荣城
Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning240300
• Estimate240300
Development12001350
• Analysis200250
• Design Spec150200
• Design Review90120
• Coding Standard6080
• Design200250
• Coding400450
• Code Review5070
• Test5070
Reporting360300
• Test Repor120130
• Size Measurement9050
• Postmortem & Process Improvement Plan150120
Sum18001950
  • 832201130 薛墨澜
Personal Software Process StagesEstimated Time(minutes)Actual Time(minutes)
Planning180200
• Estimate180200
Development8601000
• Analysis200220
• Design Spec150180
• Design Review90100
• Coding Standard5060
• Design180200
• Coding250280
• Code Review4050
• Test200240
Reporting300320
• Test Repor120180
• Size Measurement9070
• Postmortem & Process Improvement Plan9070
Sum13401520
Extreme programming (XP) is a software development methodology that emphasizes teamwork, communication, simplicity, feedback, and customer satisfaction. Here are some key practices for XP: 1. Planning: Planning is an essential part of XP. The team plans the project in short iterations called "sprints" and they prioritize the tasks to be done in each sprint. 2. Pair programming: Pair programming is a technique in which two programmers work together on the same computer. One programmer writes the code and the other reviews it. This helps to catch errors and improve the quality of the code. 3. Continuous integration: Continuous integration is the practice of integrating code changes into the main codebase frequently. This helps to identify and fix integration issues early in the development cycle. 4. Test-driven development: Test-driven development (TDD) is a development technique in which tests are written before the code is written. This helps to ensure that the code is correct and meets the requirements. 5. Refactoring: Refactoring is the process of improving the design of the code without changing its functionality. This helps to keep the code maintainable and flexible. 6. Simple design: XP emphasizes keeping the design of the code simple and easy to understand. This helps to reduce complexity and improve maintainability. 7. Continuous feedback: XP emphasizes continuous feedback from the customer and the team. This helps to ensure that the project is on track and meets the customer's needs. These are just some of the key practices of XP. By following these practices, the team can improve the quality of the code, reduce the risk of errors, and deliver high-quality software that meets the customer's needs.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值