Skip to content

refactor: architecture restructure - eliminate Hungarian notation, reorganize directories, remove Factory - #4

Merged
voidvec merged 3 commits into
masterfrom
refactor/naming-and-architecture-restructure
Aug 9, 2026
Merged

voidvec merged 3 commits into
masterfrom
refactor/naming-and-architecture-restructure

Conversation

@voidvec

@voidvec voidvec commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Overview

Comprehensive architecture refactoring in three areas:

1. Eliminate Hungarian notation

Unified to Qt-style semantic naming (members keep m_ prefix):

  • m_p/m_sp/m_up pointer prefixes removed
  • m_n/m_i/m_ui integer prefixes removed
  • m_b boolean prefix removed
  • m_str string prefix removed
  • ms_ static members changed to s_
  • NetworkRequestUtility renamed to NetworkRequestUtils (file + class)
  • NamEntry renamed to ThreadNamEntry
  • Local variables/parameters semanticized: uiId->requestId, iMax->maxConcurrent, etc.

2. Directory restructuring

source/ reorganized into 4 subdirectories:

  • core/ - Core infrastructure (manager, pool, registry, runnable, qtcompat, progress)
  • requests/ - Request types (common, download, upload, MT-download)
  • features/ - Feature extensions (utils, environment, oauth2, collection, postman)
  • infra/ - Low-level components (mmap, cookiejar, strategies)

3. Remove deprecated NetworkRequestFactory

  • Deleted NetworkRequestFactory class declaration and implementation
  • All call sites switched to NetworkRequestRegistry::instance().create()

Verification

  • All targets compile successfully
  • 9/9 tests pass with zero regressions

消除匈牙利命名法,统一为 Qt 风格语义化命名 (成员保留 m_ 前缀):
- m_p/m_sp/m_up 指针前缀 → 去除类型编码
- m_n/m_i/m_ui 整型前缀 → 去除类型编码
- m_b 布尔前缀 → 去除类型编码
- m_str 字符串前缀 → 去除类型编码
- ms_ 静态成员 → s_
- NetworkRequestUtility → NetworkRequestUtils (文件 + 类)
- NamEntry → ThreadNamEntry
- 局部变量/参数: uiId→requestId, iMax→maxConcurrent 等

source/ 目录重组为 4 个子目录:
- core/     — 核心基础设施 (manager, pool, registry, runnable, qtcompat)
- requests/ — 请求类型 (common, download, upload, MT-download)
- features/ — 功能扩展 (utils, environment, oauth2, collection, postman)
- infra/    — 底层组件 (mmap, cookiejar, strategies)

移除废弃的 NetworkRequestFactory,调用点改为 Registry。

同步更新 CMakeLists.txt, QMake .pro, 测试代码, AGENTS.md, 设计文档。
wangrh0909
wangrh0909 previously approved these changes Aug 7, 2026

@voidvec voidvec left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审总结

重构整体质量良好,三项核心任务(命名消除、目录重组、Factory 移除)完成得很好。

必须修复 (2)

  1. maxRedirections copy-paste bug — source/core/networkrequestmanager.cpp:644 参数名应改为 maxConcurrent
  2. #include Qt 头文件应使用尖括号 — source/requests/networkcommonrequest.cpp:17-18 的 #include "QThread" 和 #include "QHttpMultiPart" 应改为 #include 和 #include

详细评审报告见 .codebuddy/pr-review-report.md

QMutexLocker locker(&m_mutex);
m_mapRunnable.insert(r->requestId(), r);
m_runnableMap.insert(r->requestId(), r);
return true;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[CRITICAL] Copy-paste bug: maxRedirections → maxConcurrent

// 声明 (第 71 行):
bool setMaxThreadCount(int maxConcurrent);

// 私有实现 (第 644 行) — BUG:
bool NetworkRequestManagerPrivate::setMaxThreadCount(int maxRedirections)

参数名 maxRedirections(最大重定向次数)是错误的 — 这个函数的职责是设置线程池的最大线程数。这是一个明显的复制粘贴错误,应改为 maxConcurrent 与声明和 public 接口保持一致。

Suggested change
return true;
bool NetworkRequestManagerPrivate::setMaxThreadCount(int maxConcurrent)

m_nBytesSent = 0;
m_bytesReceived = 0;
m_bytesSent = 0;

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[MAJOR] Qt 头文件应使用 <>,第 18 行同样问题

项目中其他所有 Qt 头文件均使用 #include <QThread> 格式,此处使用引号 "" 违反编码规范。

Suggested change
#include <QThread>
#include <QHttpMultiPart>

wangrh0909
wangrh0909 previously approved these changes Aug 9, 2026
@voidvec
voidvec merged commit d1dd4b8 into master Aug 9, 2026
3 checks passed
@voidvec
voidvec deleted the refactor/naming-and-architecture-restructure branch August 9, 2026 11:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants