From 95829c86b220dfdb8e52f11e948fc615ecfb450d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=AD=E5=9F=8E=E5=B0=8F=E5=88=98?= Date: Mon, 6 Jul 2020 14:28:00 +0800 Subject: [PATCH] docs: Data uploader SDK Content --- Chapter1 - iOS/1.75.md | 7 +++++-- Chapter1 - iOS/1.80.md | 38 ++++++++++++++++++++++++++++++++------ Chapter1 - iOS/chapter1.md | 2 +- SUMMARY.md | 2 +- 4 files changed, 39 insertions(+), 10 deletions(-) diff --git a/Chapter1 - iOS/1.75.md b/Chapter1 - iOS/1.75.md index 9249d7c..f00a2ea 100644 --- a/Chapter1 - iOS/1.75.md +++ b/Chapter1 - iOS/1.75.md @@ -1,4 +1,4 @@ -# 如何写好测试 +# 写好测试,提升应用质量 > 软件测试的功能非常重要,现在结合过往经验谈谈如何做软件测试 @@ -50,5 +50,8 @@ > UITest可以测你页面渲染的对不对、按钮点击是否有问题 +不过 macaca appium 都可以做到iOS自动化 -不过 macaca appium 都可以做到iOS自动化 \ No newline at end of file + + +12318 * 0.09 + 4091 * 0.04 + 3216 * 0.0316 + 5099 * 0.0164 +5351 * 0.0579 + 3196 * 0.0475 + 6092 * 0.0123 + 4382 * 0.0652 + 3238 * 0.0633 + 5617 * 0.0642 + 3211 * 0.0492 + 6296 * 0.0437 + 7089 * 0.0921 + 5274 * 0.025 \ No newline at end of file diff --git a/Chapter1 - iOS/1.80.md b/Chapter1 - iOS/1.80.md index e98ec44..8d1f640 100644 --- a/Chapter1 - iOS/1.80.md +++ b/Chapter1 - iOS/1.80.md @@ -121,7 +121,7 @@ _##keyName = [decoder decode##dataType##ForKey:NSStringFromSelector(@selector(ke // 初始化一份默认配置 - (void)setDefaultConfigurationModel { PCTConfigurationModel *configurationModel = [[PCTConfigurationModel alloc] init]; - configurationModel.url = @"https://.com"; + configurationModel.url = @"https://***DomainName.com"; configurationModel.isUpload = YES; configurationModel.isGather = YES; configurationModel.isUpdateClear = YES; @@ -1147,6 +1147,20 @@ NS_INLINE NSString *PCTGetTableNameFromType(PCTLogTableType type) { @end ``` +上面有个地方需要注意下,因为经常需要根据类型来判读操作那个数据表,使用频次很高,所以写成内联函数的形式 + +```objective-c +NS_INLINE NSString *PCTGetTableNameFromType(PCTLogTableType type) { + if (type == PCTLogTableTypeMeta) { + return PCT_LOG_TABLE_META; + } + if (type == PCTLogTableTypePayload) { + return PCT_LOG_TABLE_PAYLOAD; + } + return @""; +} +``` + ### 5. 数据存储流程 @@ -1348,6 +1362,8 @@ NS_INLINE NSString *PCTGetTableNameFromType(PCTLogTableType type) { - 由于频率会比较高,所以需要做节流的逻辑 + 很多人会搞不清楚防抖和节流的区别。一言以蔽之:“函数防抖关注一定时间连续触发的事件只在最后执行一次,而函数节流侧重于一段时间内只执行一次”。此处不是本文重点,感兴趣的的可以查看[这篇文章](https://segmentfault.com/a/1190000018445196) + - 上报流程会首先判断(为了节约用户流量) - 判断当前网络环境为 WI-FI 则实时上报 @@ -1514,10 +1530,14 @@ NS_INLINE NSString *PCTGetTableNameFromType(PCTLogTableType type) { ![Xcode 测试覆盖率](https://raw.githubusercontent.com/FantasticLBP/knowledge-kit/master/assets/2020-07-06-XcodeTestCoverage.png) 也可以使用 [slather](https://github.com/SlatherOrg/slather)。在项目终端环境下新建 `.slather.yml` 配置文件,然后执行语句 `slather coverage -s --scheme prism-client-Example --workspace prism-client.xcworkspace prism-client.xcodeproj`。 + + 关于质量保证的最基础、可靠的方案之一软件测试,在各个端都有一些需要注意的地方,还需要结合工程化,我会写专门的[文章](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.75.md)谈谈经验心得。 -## 五、 接口设计 +## 五、 接口设计及核心实现 + +### 1. 接口设计 ```objective-c @interface PrismClient : NSObject @@ -1596,7 +1616,11 @@ NS_INLINE NSString *PCTGetTableNameFromType(PCTLogTableType type) { } ``` -真正处理逻辑的是 `PCTService` 类。这里贴一下代码,点击展开 + + +### 2. 核心实现 + +真正处理逻辑的是 `PCTService` 类。 ```objective-c #define PCT_SAVED_FLOW @"PCT_SAVED_FLOW" @@ -1772,9 +1796,9 @@ NS_INLINE NSString *PCTGetTableNameFromType(PCTLogTableType type) { // 基础配置 - (void)setupConfig { - _requestBaseUrl = @"https://common.***.com"; - _metaURL = @"prism/metrics/meta"; - _payloadURL = @"prism/metrics/detail"; + _requestBaseUrl = @"https://***DomainName.com"; + _metaURL = @"prism/***"; + _payloadURL = @"prism/***"; } - (void)executeHandlerWhenAppLaunched @@ -2479,6 +2503,8 @@ UT 是质量保证的一个方面,另一个就是 MR 机制。我们团队 MR - [WAL](https://en.wikipedia.org/wiki/Write-ahead_logging) - [WCDB 的 WAL 模式和异步 Checkpoint](https://cloud.tencent.com/developer/article/1031030) +- [sqlite vacuum](https://www.sqlite.org/lang_vacuum.html) +- [彻底弄懂函数防抖和函数节流](https://segmentfault.com/a/1190000018445196) diff --git a/Chapter1 - iOS/chapter1.md b/Chapter1 - iOS/chapter1.md index 2f1b844..ba3cbfd 100644 --- a/Chapter1 - iOS/chapter1.md +++ b/Chapter1 - iOS/chapter1.md @@ -78,7 +78,7 @@ * [72、架构设计心得](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.72.md) * [73、Ruby学习](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.73.md) * [74、带你打造一套 APM 监控系统](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.74.md) - * [75、如何写好测试](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.75.md) + * [75、写好测试,提升应用质量](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.75.md) * [76、iOS Crash分析](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.76.md) * [77、iOS 打包系统构建加速](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.77.md) * [78、App 上架包预检](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.78.md) diff --git a/SUMMARY.md b/SUMMARY.md index cd4a840..01005e1 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -77,7 +77,7 @@ * [72、架构设计心得](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.72.md) * [73、Ruby学习](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.73.md) * [74、APM](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.74.md) - * [75、如何写好测试](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.75.md) + * [75、写好测试,提升应用质量](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.75.md) * [76、iOS Crash分析](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.76.md) * [77、iOS 打包系统构建加速](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.77.md) * [78、上架包预检](https://github.com/FantasticLBP/knowledge-kit/blob/master/Chapter1%20-%20iOS/1.78.md)