<section id="nice" data-tool="mdnice编辑器" data-website="https://www.mdnice.com" style="font-size: 16px; padding: 0 10px; word-spacing: 0px; word-break: break-word; word-wrap: break-word; text-align: left; margin-top: -10px; line-height: 1.25; color: #2b2b2b; font-family: Optima-Regular, Optima, PingFangTC-Light, PingFangSC-light, PingFangTC-light; letter-spacing: 2px; background-image: linear-gradient(90deg, rgba(50, 0, 0, 0.04) 3%, rgba(0, 0, 0, 0) 3%), linear-gradient(360deg, rgba(50, 0, 0, 0.04) 3%, rgba(0, 0, 0, 0) 3%); background-size: 20px 20px; background-position: center center;"><blockquote data-tool="mdnice编辑器" style="display: block; font-size: 0.9em; overflow: auto; overflow-scrolling: touch; padding-top: 10px; padding-bottom: 10px; padding-left: 20px; padding-right: 10px; margin-bottom: 20px; margin-top: 20px; text-size-adjust: 100%; line-height: 1.55em; font-weight: 400; border-radius: 6px; color: #595959; font-style: normal; text-align: left; box-sizing: inherit; border-left: none; border: 1px solid RGBA(64, 184, 250, .4); background: RGBA(64, 184, 250, .1);"><span style="color: RGBA(64, 184, 250, .5); font-size: 34px; line-height: 1; font-weight: 700;">❝</span>
<p style="padding-top: 8px; padding-bottom: 8px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px; margin: 0px; line-height: 26px; color: #595959;">2020-04-15</p>
<p style="padding-top: 8px; padding-bottom: 8px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px; margin: 0px; line-height: 26px; color: #595959;">杭州</p>
<span style="float: right; color: RGBA(64, 184, 250, .5);">❞</span></blockquote>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px;"><img src="http://img.ricstudio.top/blog/69fee4d33f09fb8165698636b202c12.png" alt title style="max-width: 100%; border-radius: 6px; display: block; margin: 20px auto; object-fit: contain; box-shadow: 2px 4px 7px #999;"></figure>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">近期得了个机会,把自己两年前的一个项目重写了一遍,刚好前段时间读了《clean code》和《head first design pattern》,于是在整个重写过程当中,有意识的按照里面提到的一些设计模式和编码规则进行重构设计,整个过程下来心情非常的愉悦,写代码就像写诗,大概就是这种感觉。再对比两年前自己写的的项目代码,感悟就很深刻了。</p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">以前写代码,很多时候都陷入了<strong style="color: #3594F7; font-weight: bold;"><span>「</span>羊群效应<span>」</span></strong>,为了避免犯错,照葫芦画瓢,对很多不合理的设计和重复冗余的代码都置若罔闻,不去深究。实际上错过了很多优化提升自己的机会。而且,这种<strong style="color: #3594F7; font-weight: bold;"><span>「</span>遵从教条主义的危害很大<span>」</span></strong>,遇到水平高的代码还好,如果遇到水平一般设计差的,编码风格、编程思维会被带偏,很容易陷入瓶颈(这里主要指的不是技术瓶颈,而是代码设计、抽象建模的那种编程思维)。就像我两年前写出来的代码,可读性很差,更别谈高内聚低耦合、OCP、SRP这些东西了,得亏重写的是我自己,不然保不准会有一个同事拿着大刀来砍我,问我写的什么玩意儿。</p>
<p data-tool="mdnice编辑器" style="padding-top: 8px; padding-bottom: 8px; line-height: 26px; color: #2b2b2b; margin: 10px 0px; letter-spacing: 2px; font-size: 14px; word-spacing: 2px;">很多时候,我们做的业务功能可能很简单,很基础,但这并不代表我们应该马马虎虎的对待,加入一些设计模式,多注重代码整洁的规约,会让这些业务功能变得不那么“简单”。
<em style="font-style: normal; color: #3594F7; font-weight: bold;"><strong style="font-weight: bold; color: #3594F7;"><span>「</span>就像《程序员修炼之道》所引的,吾等采石之人,当心怀大教堂之愿景。<span>」</span></strong></em> 即使我们所做的事情很基础,也需要心怀愿景,告诉自己在建筑的不仅仅是城墙,而是大教堂,继而把事情做精做细。</p>
<figure data-tool="mdnice编辑器" style="margin: 0; margin-top: 10px; margin-bottom: 10px;"><img src="http://img.ricstudio.top/blog/d346b3be14f4a977a4b0f7e1b9dbdb5.png" alt title style="max-width: 100%; border-radius: 6px; display: block; margin: 20px auto; object-fit: contain; box-shadow: 2px 4px 7px #999;"></figure>
</section>

近期工作有感