Loading
ADoyle
This is a live streamed presentation. You will automatically follow the presenter and see the slide they're currently on.
Free-View Version
Live Version
<Scan the QR code> <to view the slide in your phone>
Created By
ADoyle
长期的,功能繁多易变,趋于复杂的项目工程
短期的,功能有限或稳定,简单的项目工程
¯\_(ツ)_/¯
你是否遇到过这些情况:
认知与表述
We're better at doing it than knowing what we're doing.
--《What is an abstraction?》 Eric Normand
名正则言順,言順则事成
命名即认知
命名为指名
There are only two hard things in Computer Science:
cache invalidation and naming things.
-- Phil Karlton
1. find_a_record(id)
2. find_a_record_or_throw_error_if_null(id)
3. find_a_record_or_null_if_null(id)
有一千个读者,就有一千个哈姆雷特
Code is read much more often than it is written.
-- Raymond Chen - MSFT
保持一致性
Consistency
需求
Communication
红
蓝
Model
View
Controller
好
坏
一般
边界,意味着约定/约束
(强)约束
(弱)约定
为什么要设定边界?
如何划分边界?
如何避免重名?
代码的边界·尾递归优化
int factorial(int n, int acc) {
if (n == 0) return acc;
return factorial(n - 1, acc * n);
}
int factorial(int n, int acc) {
while (true)
{
if (n == 0) return acc;
acc *= n;
n--;
}
}
编译与执行
函数、模块、框架、系统
--《Separation of Concerns in ORM》 Vladimir Khorikov
When persistence logic leaks to domain logic
When domain logic leaks into persistence logic
--《Separation of Concerns in ORM》 Vladimir Khorikov
Most of the leaks come from thinking not in terms of the domain, but in terms of data. Many developers perceive the application they develop just like that. For them, entities are just a storage for data they transfer from the database to UI, and ORM is just a helper that allows them not to copy this data from SQL queries to C# objects manually.
状态是对数据的抽象。
数据多半不能直接被用户看到(比如你不能直接返回一个timestamp给用户),而状态则更贴近业务;
数据需要是原子的(数据库第一、二范式),而状态一般涉及一条以上的数据;
数据稳定性高,状态变数多:需求变化了,不应该去操作全量数据,而是修改状态控制;
数据适合放在有持久化的地方,而状态根据数据动态算出,适合放在内存中(当然,系统大到出现集群的概念以后,状态也可能需要持久化)。
数据库存储状态,即数据
应用操作并维护状态
业务逻辑 Business logic
应用逻辑 Application logic
数据逻辑 Data logic (暂未考虑)
尝试跨越职能的边界,站在新的角度看问题
Boundary Crossing
颜色
#74aaff
#94dc6f
#ff9900
Style