Design Smell: 执着于基本类型

  • 从基本类型转换领域模型(值对象)

代码片段1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
void AsyncLogging::append(const char* logline, int len)
{
muduo::MutexLockGuard lock(mutex_);
if (currentBuffer_->avail() > len)
{
currentBuffer_->append(logline, len);
}
else
{
buffers_.push_back(std::move(currentBuffer_));

if (nextBuffer_)
{
currentBuffer_ = std::move(nextBuffer_);
}
else
{
currentBuffer_.reset(new Buffer); // Rarely happens
}
currentBuffer_->append(logline, len);
cond_.notify();
}
}

代码片段1

从基本类型转换领域模型(值对象)


Design Smell: 执着于基本类型
https://pygyme.com/软件设计/design-smell-执着于基本类型/
作者
PYGYME
发布于
2020年4月2日
许可协议