Extreme Programming Assignment | Shilian Address Book | 832402221吴茂平_832402215林子涵

832402215林子涵 832402215林子涵 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区

Extreme Programming Assignment | Shilian Address Book: Favorites, Multiple Contact Methods, and Excel Import/Export

ItemContent
Course for This AssignmentSoftware Engineering (FZU–MU) · EE308FZ
Team NameShilian
Team MembersWu Maoping (Student ID 24125854, GitHub: WuMaoping-David), Lin Zihan (Student ID 24124966, GitHub: linzi-gip)
Assignment RequirementsAn address book that supports (1) bookmarking contacts, (2) multiple contact methods per contact, and (3) Excel import and export; cloud deployment optional. Two-person collaboration, delivered through a GitHub repository with at least 3 commits, and each member publishes their own blog. See the assignment post.
Objectives of This AssignmentDesign the module split before writing code: break the requirements into three independently verifiable parts (data layer / Excel layer / interface layer), then deliver in small commits with cross review and merges, ending with an address book that is publicly reachable and survives an export-then-import round trip without data loss.
Other Referencesopenpyxl documentation · MDN localStorage · ECMA-376 SpreadsheetML · Project CODING_STANDARDS.md

This article is the content shared by both team members. Each member publishes it on their own blog; division of work, contribution ratio and PSP tables are listed per person at the end.

Table of Contents

1. Project Address

TypeDescriptionFull link
GitHub repositoryShilian address book organization repositoryhttps://github.com/shilian-addressbook/shilian-addressbook
Coding standardsCODING_STANDARDS.mdhttps://github.com/shilian-addressbook/shilian-addressbook/blob/main/CODING_STANDARDS.md
Online deploymentShilian address book (Render, deployed)https://shilian-addressbook-org.onrender.com/
Pull request#1 Wu Maoping: project source and mobile layouthttps://github.com/shilian-addressbook/shilian-addressbook/pull/1
Pull request#2 Lin Zihan: Excel import validationhttps://github.com/shilian-addressbook/shilian-addressbook/pull/2
ReleaseShilian Address Book v1.0.0https://github.com/shilian-addressbook/shilian-addressbook/releases/tag/v1.0.0
Run instructionsREADME.mdhttps://github.com/shilian-addressbook/shilian-addressbook/blob/main/README.md

The stack is deliberately lightweight: the front end is plain HTML / CSS / JavaScript with no build step and no third-party libraries, and the back end is the Python standard library http.server plus openpyxl for workbooks. Anyone who clones the repository can run python server.py, so there is no "dependency will not install" risk at grading time.

python -m pip install -r requirements.txt
python server.py          # open http://127.0.0.1:8765 in a browser
python -m unittest -v     # run the workbook unit tests

On Windows the project can also be started by double-clicking start.cmd.

2. Overall Result

The address book home page: a one-line title block, a toolbar (search / import / export / new contact), the "All" and "Favorites" filters, and a card grid. Bookmarked contacts carry a filled star in the top right corner.

img

The two screen recordings below demonstrate different parts of the feature set in real use:
![Video 1: feature walkthrough (28 s)]

![Video 2: feature walkthrough (40 s)]

About the videos: both are real browser screen recordings covering different parts of the workflow. The demo contacts (Wu Maoping, Lin Zihan) are fictional and every phone number and email address is sample data; no real personal information is shown.

3. Module Breakdown and Technology Choices

Design first, code second is what made this collaboration fit the deadline. Before writing any code we fixed exactly one thing: the three layers talk to each other only through the contact object, and nobody is allowed to reach across the boundary and rewrite someone else's layer.

user interaction
      |
      v
+------------------------------+  structure, styling, responsive layout
| interface layer              |
| index.html / style.css       |
| app.js                       |  render list, search, filter, form, requests
+--------------+---------------+
               |  POST /api/import  ·  /api/export (JSON / xlsx binary)
               v
+------------------------------+
| service layer  server.py     |  static files, routing, request size limit, error funnel
+--------------+---------------+
               |  contacts: list[dict]
               v
+------------------------------+
| data layer  workbook.py      |  xlsx read/write + contact field validation
| browser localStorage         |  persistence of contacts and favorite state
+------------------------------+
FileResponsibilityOwner
index.html / style.csspage structure, visual design, narrow-screen layoutWu Maoping
app.jscontact CRUD, search, favorites filter, calls to import/exportWu Maoping
server.pylocal HTTP service, routing, 5 MB request limit, exceptions folded into 400Wu Maoping
workbook.pyxlsx generation and parsing, header and per-row validationLin Zihan
test_workbook.pyworkbook unit testsLin Zihan
CODING_STANDARDS.md / README.mdcoding conventions and run instructionsboth

The contact object shared by all three layers looks like this. "Multiple contact methods" was designed from the start as an array grouped by type, not as fixed fields such as phone1/phone2/email — that single decision is why the spreadsheet can map one contact to one row and one information type to one column later on:

{
  "id": "0b2f…",
  "name": "Wu Maoping",
  "favorite": true,
  "methods": {
    "电话": ["202-555-0101", "202-555-0199"],
    "邮箱": ["wu@example.com"],
    "社交账号": ["ping_demo"],
    "地址": ["示例市青禾路 18 号"]
  }
}

(The methods keys are the four contact-method types: phone, email, social account, address.)

4. Feature Implementation Notes

4.1 Bookmarking Contacts (25 pts)

A bookmark is not a separate "favorites list"; it is a boolean field favorite on the contact object, stored together with the contact in localStorage. That way, deleting a contact, importing contacts or switching filters can never leave an entry in a favorites table that no longer exists in the contact table.

Entry point one: the star button on the card. Clicking it maps the whole contact list into a new array and flips only the target element:

const star = button(contact.favorite ? "★" : "☆", () => {
  if (save(contacts.map((item) => item.id === contact.id
    ? { ...item, favorite: !item.favorite } : item))) {
    status(`收藏:${contact.name}`);
    [...$("list").querySelectorAll(".star")]
      .find((node) => node.dataset.id === contact.id)?.focus();  // keep focus in place
  }
}, { class: "star", "aria-pressed": String(contact.favorite) });

Entry point two: the favorites filter, which combines with search. The "All / ★ Favorites" control is a favoritesOnly flag that is and-ed with the search query, so both conditions apply at the same time:

const shown = contacts.filter((contact) =>
  (!favoritesOnly || contact.favorite) &&
  [contact.name, ...Object.values(contact.methods).flat()]
    .some((value) => value.toLocaleLowerCase().includes(query)));

Search matches the name and every contact method, so "find a bookmarked person by email" is a single step. The result area shows shown / total in real time, and the empty state distinguishes three cases — no match, no favorites yet, no contacts yet — instead of showing a blank page.

img

A few details:

  • the star is its own button inside the card, bound to the contact through data-id, so clicking it never triggers "edit";
  • aria-pressed expresses the bookmark state, so keyboard and screen-reader users get it too;
  • un-bookmarking while the favorites filter is active removes the card immediately and returns focus to the filter button instead of dropping it on body;
  • the favorite state is exported into the spreadsheet's "favorite" column (是 / 否, yes/no) and restored on import — moving favorites between devices is the easiest link in this chain to forget.

4.2 Multiple Contact Methods per Contact (10 pts)

Four method types are supported: phone, email, social account, address, and each type can hold several entries. The kinds configuration drives the form dropdown, the card rendering and the spreadsheet column order at once, so adding a type is a one-line change.

The edit dialog starts with one row of "type dropdown + value input + remove". "+ Add contact method" appends rows dynamically, and a guard keeps at least one input row so the form is never empty:

function addMethod(kind = kinds[0], value = "", focus = false) {
  const row = make("div", "", { class: "method" });
  const select = make("select", "", { "aria-label": "联系方式类型" });
  for (const item of kinds) select.append(make("option", item, { value: item }));
  const input = make("input", "", { maxlength: "500", placeholder: "填写内容" });
  row.append(select, input, button("移除", () => row.remove()));
  $("methods").append(row);
}

On save the rows are folded into arrays by type, and empty rows are ignored:

const methods = Object.fromEntries(kinds.map((kind) => [kind, []]));
for (const row of $("methods").children) {
  const value = row.querySelector("input").value.trim();
  if (value) methods[row.querySelector("select").value].push(value);
}

Validation rules (implemented on both sides — the front end gives human-readable messages, the back end is the safety net): name 1–100 characters; at most 25 entries per type; at most 500 characters per entry; no tab, newline or other control character in any field (it would break the spreadsheet cell structure). The address book is capped at 5,000 contacts; beyond that the write is refused instead of being silently truncated.

img

The card flattens every entry of a contact in the fixed order phone → email → social account → address, each with its type prefix, so it is obvious that these are several ways to reach one person rather than several different people.

4.3 Excel Export (25 pts)

The requirement is "one contact per row, one information type per column", so the header is a fixed six columns and HEADERS is the single source of truth:

NameFavoritePhoneEmailSocial accountAddress
Wu Maoping是202-555-0101
202-555-0199
wu@example.comping_demo示例市青禾路 18 号

Several values of the same type are joined with a newline inside one cell, which satisfies both "one contact per row" and "multiple values":

HEADERS = ("姓名", "收藏", *METHODS)

row = [contact["name"], "是" if contact["favorite"] else "否"]
row.extend("\n".join(contact["methods"][kind]) for kind in METHODS)
sheet.append(row)

The pitfall we hit: phone numbers turning into scientific notation. If written as numbers, Excel shows 13800138000 as 1.38E+10, and 0591-8888 6666 may even be recognised as a date. The fix is to write the whole row as text:

for cell in sheet[sheet.max_row]:
    cell.data_type = "s"      # force a string
    cell.number_format = "@"  # text format, keeps leading zeros

The exported file also gets three things that make it immediately usable: a bold header row with the first row frozen (freeze_panes = "A2"), autofilter enabled on the header (auto_filter), and column widths sized to the content. Exporting an empty address book produces a header-only template that can be handed to someone else to fill in and import back.

img

4.4 Excel Import (25 pts)

Lin Zihan hardened this part. The idea is validate everything first, then write once: if any row is invalid, nothing is written, so a half-imported state is impossible.

Layer one: header validation. The header is compared against HEADERS, and both duplicate column names and extra non-empty columns beyond the template are rejected (otherwise a user can easily add a "notes" column and have it silently dropped):

rows = sheet.iter_rows(min_col=1)
columns = len(HEADERS)
header_values = [cell.value for cell in next(rows, ())]
if any(value not in (None, "") for value in header_values[columns:]):
    raise ValueError("表头有额外的列,请使用导出的模板。")
headers = tuple(header_values[:columns])
nonempty = [value for value in headers if value not in (None, "")]
if len(set(nonempty)) != len(nonempty):
    raise ValueError("表头包含重复的列名,请使用导出的模板。")
if headers != HEADERS:
    raise ValueError("表头不匹配,请使用导出的模板。")

Layer two: per-row validation with the real row number. The favorite column accepts only yes / no / blank, formulas are rejected (this blocks injections such as =1/0), blank rows are skipped, short rows are padded with empty values, and error messages carry the actual row number:

try:
    if any(value not in (None, "") for value in values[columns:]):
        raise ValueError("包含额外的非空列,请只在模板列内填写。")
    if any(cell.data_type == "f" for cell in cells):
        raise ValueError("不接受公式,请粘贴为文本。")
    ...
except ValueError as error:
    raise ValueError(f"第 {number} 行:{error}") from error

Layer three: resource limits. The upload body is limited to 5 MB (checked against Content-Length in server.py), the decompressed size to 30 MB (against zip bombs), and the data to at most 5,000 rows. The workbook is streamed with read_only=True so a large sheet does not blow up memory.

Layer four: writing back to the front end. The parsed contacts are appended to localStorage and distinguished from existing data by id (contacts with the same name can coexist and are never overwritten). After a successful import the view switches back to "All", the search box is cleared, and the status line reports imported N contacts.

img

4.5 Page Style and Responsiveness (10 pts)

The styling does not aim for decoration; it aims for "understood at a glance, tapped accurately on a phone":

  • dark green primary colour on an off-white background, card grid with grid-template-columns: repeat(auto-fit, minmax(min(100%, 270px), 1fr)), so three columns on desktop, two on a tablet and one on a phone;
  • the heading uses clamp(2.25rem, 6vw, 3.75rem) and scales with the viewport instead of overflowing on a phone;
  • every interactive element has a :focus-visible outline (3 px, offset 2 px), so keyboard focus is visible;
  • on narrow screens (≤540 px) the toolbar becomes a two-column grid: search takes a full row, import/export sit side by side, new contact takes a full row, and buttons are at least 44 px high, which is the recommended touch target size;
  • a Chinese/English switch: all strings live in englishLabels and are swapped in bulk through textContent, together with document.title, aria-label and lang;
  • contact content is always rendered with textContent and never with innerHTML, which removes XSS at the root.
@media (max-width: 540px) {
  .toolbar { display: grid; grid-template-columns: minmax(0, 1fr); }
  .toolbar > .actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toolbar > .actions .primary { grid-column: 1 / -1; }
  .toolbar button { min-height: 44px; }
}

5. Tests and Acceptance

Workbook unit tests (python -m unittest -v, all 6 cases pass):

Test caseWhat it verifies
test_round_trip_preserves_text_and_multiple_valuesexport then import keeps multiple methods, leading zeros and the favorite flag
test_invalid_row_reports_locationan invalid row is reported with the correct row number
test_empty_export_is_templateexporting an empty address book yields a header-only template
test_duplicate_header_reports_problemduplicate header names are rejected
test_extra_nonempty_data_column_reports_rowan extra non-empty column in a data row is reported with its row number
test_short_row_and_blank_extra_column_are_validshort rows and formatted-but-empty extra columns still import correctly

End-to-end manual acceptance:

ItemHow it was checkedResult
Page layoutchecked at desktop viewport and at 390 px width, no horizontal scrollingpass
Contact operationscreate, edit, delete, and search by phone numberpass
Favoritesbookmark a contact, switch to the favorites filter, reload and confirm the state persistspass
Multiple methodsadd two phones and one email to the same contact, check the card and the exported contentpass
Excel round tripexport, clear browser data, import back, verify leading zeros and favorite statepass
Invalid workbookimport a file with a wrong header / extra column / formula, confirm the error and that no data was addedpass
Cloud deploymenton the public HTTPS page, add and bookmark a contact, export and import againpass

6. GitHub Collaboration and Commit History

Both members worked in the same organization repository with feature branches and pull requests, and neither pushed to main directly:

  1. Wu Maoping created the repository and the README, branched wu-contact-improvements off main, and imported the project baseline together with the "blank contact method" validation;
  2. Lin Zihan branched lin-excel-validation from Wu Maoping's branch, added the Excel header and extra-column validation plus 3 unit tests, and committed after the tests passed;
  3. Wu Maoping went back to his branch to add the mobile toolbar layout, then opened pull request #1 and asked Lin Zihan to review and merge it; Lin Zihan opened pull request #2 and asked Wu Maoping to review and merge it;
  4. After the merges, Wu Maoping adjusted the Render configuration to give the organization repository its own deployment service, and tagged the v1.0.0 release.

Commit history and per-contributor counts:

img

#Commit messageAuthor
1Initial commitWu Maoping
2Add the address book and validate blank contact methodsWu Maoping
3Improve the mobile address book toolbarWu Maoping
4Merge pull request #1 from wu-contact-improvementsWu Maoping
5Improve Excel header and extra-column validationLin Zihan
6Merge pull request #2 from lin-excel-validationWu Maoping
7Prepare a separate Render service for the organization repositoryWu Maoping
MemberGitHub accountCommitsMain changes
Wu MaopingWuMaoping-David2initial commit; mobile toolbar layout (plus the two pull-request merges and one deployment configuration commit)
Lin Zihanlinzi-gip1Excel header and extra-column validation, 3 new unit tests
Total—3meets the "at least 3 commits" requirement

About the two numbers: the Contributors graph excludes merge commits by GitHub's own rule, which is why it shows 2 + 1, while the commit history page lists 7 commits on main (including the two pull-request merges and one deployment configuration commit); the commit list is authoritative.

The screenshot was taken right after pull request #2 was merged, so the history page shows the 6 commits that existed at that moment; the 7th commit, the Render deployment configuration, was pushed afterwards.

The coding standards live in CODING_STANDARDS.md: four spaces and snake_case for Python, two spaces and camelCase for the front end; a workbook format change must update the importer, the exporter, the README and the round-trip tests together; each commit covers one verifiable change, uses an English message that says what changed, and is reviewed by the other member who also runs the relevant checks before merging.

7. Division of Work and Contribution Ratio

img

MemberRoleResponsibilitiesContribution
Wu Maopingteam leadrequirement breakdown and milestones; repository setup and branching strategy; interface layer and interaction (list, search, favorites, form, bilingual switch); server.py routing and error funnel; mobile layout; pull-request organisation and merges; cloud deployment50%
Lin ZihanmemberExcel data layer (workbook.py export/import, header and per-row validation); unit tests and regression; export-then-import round-trip verification; post-deployment public acceptance50%
Total——100%

8. Difficulties and How We Solved Them

AreaThe difficulty we actually hitHow we solved it, and the result
Data structure designThe page lets one contact hold several contact methods, while the spreadsheet requires one contact per row; the two sides did not line upBefore coding we fixed methods as an array grouped by type, and joined multiple values of the same type with a newline inside one cell. Result: adding a type or a column never changes the structure
Local run handoverOn Windows the PowerShell script was blocked by the execution policy, and double-clicking the HTML file showed an unstyled page, so it was hard to tell whether the service had startedAdded a double-clickable start.cmd; index.html detects the file: protocol and shows a startup guide; the instructions now consistently use http://127.0.0.1:8765
Front-end / back-end boundaryAt first the front end hard-coded the validation and the back end barely validated anything, so importing an invalid file crashed the pageAgreed that the front end gives messages and the back end is the safety net; server.py folds BadZipFile / InvalidFileException / ParseError and friends into a 400 with a readable error message
A real problem found in reviewLin Zihan's first import implementation only sliced by column count, so a user adding a "notes" column had it silently dropped, and duplicate headers were not reported eitherReview added the "extra non-empty column" and "duplicate header" checks, each with its own unit test, growing the suite from 3 to 6 cases
Cloud deployment acceptanceThe first deployed service was bound to a personal repository, not the organization repository being handed in, so the link the teacher opened might not match the delivered codeCreated a separate Render service for the organization repository so it deploys that repository directly; after going live we ran add → bookmark → export → clear → import on the new HTTPS address

9. PSP Tables

Each member fills in their own table (time in minutes). In each person's blog only their own table is their record.

Wu Maoping

PhasePlannedActual
Planning and requirement analysis3032
Design2530
Coding4855
Code review2025
Testing and fixing4043
Blog, screenshots and demo (draft)6066
Total223251

Lin Zihan

PhasePlannedActual
Planning and requirement analysis2023
Design3035
Coding2030
Code review4041
Testing and fixing4040
Blog, screenshots and demo (final)6066
Total210235
...全文

相关推荐

高校技术转移中心如何选型管理系统?数智化工具如何破解成果转化三大难题?.docx

科易网基于行业知识库+行业大数据+科技资源要素+AI模型,以AI,赋能技术转移、成果转化、技术经理人培训、知识产权管理、区域产业分析与布局、地方科技招商、创新创业大赛等场景,推出科技创新领域的AI工具、场景化服务和数智化解决方案,推动科技创新与产业创新智能化发展。

BIZKEEN

iperf3 安卓版 - 手机网络测速工具(客户端/服务端/双向打流)

基于 iperf3 3.22 源码交叉编译的 Android 原生测速 App,手机可直接作为 iperf3 客户端或服务端。 功能:客户端/服务端双模式;TCP/UDP;多并发流;反向下载 -R;双向打流 --bidir;UDP 带宽按 Mbps 设置;实时速率曲线与当前/平均/峰值;历史记录;Material3 界面。 安装:下载 APK,允许未知来源安装。支持 Android 7.0+,架构 arm64-v8a / armeabi-v7a / x86_64。iperf3 遵循 BSD-3-Clause 协议,版权归 ESnet。

 吖吖伊

生产制造企业智慧工厂MES一体化管理平台解决方案.pptx

生产制造企业智慧工厂MES一体化管理平台解决方案.pptx

公众号:优享智库

考虑分布式电源运行特性的有源配电网智能软开关SOP规划方法【IEEE33节点】(Matlab代码实现)

内容概要:本文研究了考虑分布式电源运行特性的有源配电网智能软开关(SOP)规划方法,并基于IEEE33节点系统进行了Matlab代码实现。该方法旨在通过引入SOP这一先进的电力电子装置,提升配电网对分布式电源(如光伏、风电)的接纳能力与运行灵活性。研究综合考虑了分布式电源出力的波动性和不确定性,构建了以网损最小、电压偏差最小等为目标的优化模型,并采用合适的智能优化算法求解SOP的最佳安装位置和容量配置。文中详细阐述了模型构建的理论基础、关键约束条件的处理方式以及仿真算例的设置与结果分析,验证了所提方法在改善配电网电压质量、降低网络损耗和促进清洁能源消纳方面的有效性。; 适合人群:具备电力系统分析、优化算法基础,从事配电网规划、分布式能源接入等相关研究的研究生、科研人员及电力公司技术人员。; 使用场景及目标:① 掌握智能软开关(SOP)在现代有源配电网中的应用原理与规划方法;② 学习如何将分布式电源的运行特性融入配电网优化模型;③ 获取基于IEEE33节点系统的Matlab代码实现,用于复现经典算例或进行二次开发研究。; 阅读建议:此资源紧密结合理论与实践,不仅提供了详细的数学模型推导,还给出了完整的Matlab代码。读者应在理解优化模型和SOP工作原理的基础上,结合代码进行仿真调试,深入分析不同场景下SOP的配置方案对配电网性能的改善效果。

茜姐_博客

技术转移机构想要获得官方认可,需要满足哪些资质认定标准?.docx

技术转移机构想要获得官方认可,需要满足哪些资质认定标准?

BIZKEEN
评论
收藏 已收藏
分享
返回顶部