<?xml version="1.0" encoding="utf-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"><channel><title>菜鸟分享</title><link>https://www.lingdu818.cn/</link><description>乐于分享</description><item><title>优秀API设计的十大原则</title><link>https://www.lingdu818.cn/?id=6</link><description>&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;每个软件开发人员都使用API。“优秀”的API设计就像魔法。不过，我不知道有多少人可以解释为什么有的API很复杂、很难学，而有的则干净、简单、使用起来堪称是一种快乐。关于这个问题，我将在文中回答，并提供优秀API设计的十条法则。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;1.只做你今天需要的&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;这是最顶级的规则。只解决今天必须解决的问题，最小化需要完成的答案。解决明天的问题的诱惑力是巨大的。但是一定要顶住诱惑！不要提前发布代码，重点是注重缩小发布周期。如果需要花几个小时的时间来回答新问题，那么就不用再猜测明天会出现什么问题了。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;2.API模块化&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;将大型问题转化为规模较小的、可单独解决的问题。模块化API更容易学习，并且可以随时间而改变。你可以用新模块替代旧模块。可以一个一个地教导模块。也可以将API的实验部分从稳定或传统的部分中单独分出来。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;4.使用自然语义&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;不要发明新概念。只使用开发人员众所周知的概念，作为类系统的基础。如果你发现自己需要解释概念，那说明你出错了：要么你在解决以后的问题，要么你正在错误地构建API。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;5.API的自我约定&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;每个类都要严格使用相同的样式和约定。一致性是指当一个人学会这一个类时，他就能够融会贯通地掌握全部的类。文档化约定，让它们成为贡献者必须的标准。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;6.API的可扩展性&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;易扩展性有许多好处，并不仅仅在于受到贡献者的欢迎。它还可以让你延缓实现功能，因为“如果需要的话，后面再添加也很方便”。不需要的功能就不添加，这也是一种双赢。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;7.完全测试&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;每个类和方法必须经过恶意代码的完全测试。要像写代码一样写测试，然后像API提供给外界约定文档一样使用测试。每当代码改变的时候就运行这些测试。不要担心代码覆盖率。重要的是外部约定。也可以考虑使用约定生命周期。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;8.分层式成长&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;保持API突出重点，然后在顶部将新的API分层，以便于它们能随着时间的推移成长。可扩展性并不意味着无限期的成长。明确API的范围，并在范围内执行。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;9.保持简单易用&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;最终的测试要看API的简单易用程度。你写的例子，能不能让你的代码看起来更简单？你是不是强迫用户说明他们不在乎的选项？有没有毫无价值的额外步骤？要注重约减少API的可视面积。&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;10.保持可移植性&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; color: rgb(85, 85, 85); font-family: &amp;quot;Microsoft Yahei&amp;quot;; font-size: 15px; text-align: justify; text-wrap: wrap; background-color: rgb(255, 255, 255);&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;不要让系统概念泄漏到API。整洁有目的地抽象：这个API可以运行在任何操作系统上。API必须能够隐藏实现，但要注意第4条规则，以及要使用自然抽象。&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 10 Nov 2023 23:48:18 +0800</pubDate></item><item><title>网站下雪效果，只需添加几行代码</title><link>https://www.lingdu818.cn/?id=7</link><description>&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; text-indent: 30px; color: rgb(78, 83, 88); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; text-wrap: wrap; background-color: rgb(255, 255, 255); outline: 0px !important;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;这是一段通过js引用实现的网站&lt;span class=&quot;wp_keywordlink_affiliate&quot; style=&quot;box-sizing: border-box; outline: 0px !important;&quot;&gt;全站下雪&lt;/span&gt;的效果，你可以自行修改雪的颜色以配合你的主题。&lt;/span&gt;&lt;/p&gt;&lt;h1 class=&quot;wp-block-zibllblock-biaoti title-theme&quot; style=&quot;box-sizing: border-box; font-size: 20px; margin: 20px 0px; font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; line-height: 1.1; color: var(--theme-color); position: relative; padding: 0.1em 0px 0.1em 1.1em; border: none; text-wrap: wrap; background-color: rgb(255, 255, 255); outline: 0px !important;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;教程&lt;/span&gt;&lt;/h1&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; text-indent: 30px; color: rgb(78, 83, 88); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; text-wrap: wrap; background-color: rgb(255, 255, 255); outline: 0px !important;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;1、在你的头部文件代码里增加下面这段js代码&lt;/span&gt;&lt;/p&gt;&lt;pre class=&quot;wp-block-zibllblock-enlighter&quot; style=&quot;box-sizing: border-box; overflow: auto; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 13px; padding: 0px; margin-top: 0px; margin-bottom: 0px; line-height: 1.42857; color: rgb(78, 83, 88); word-break: break-all; overflow-wrap: break-word; background-position: 0px 0px; background-color: rgb(255, 255, 255); border: none; border-radius: 4px; outline: 0px !important;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;&amp;lt;script src=&amp;quot;https://unpkg.com/magic-snowflakes/dist/snowflakes.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&amp;lt;script&amp;gt;var sf = new Snowflakes({color: &amp;quot;#cccccc&amp;quot; //雪花颜色});&amp;lt;/script&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;/span&gt;&lt;/pre&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; text-indent: 30px; color: rgb(78, 83, 88); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; text-wrap: wrap; background-color: rgb(255, 255, 255); outline: 0px !important;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;2、其中&amp;nbsp;&lt;/span&gt;&lt;code style=&quot;box-sizing: border-box; outline: 0px !important; font-family: Menlo, Monaco, Consolas, &amp;quot;Courier New&amp;quot;, monospace; font-size: 14.4px; padding: 2px 4px; color: rgb(255, 60, 152); background-color: rgba(253, 153, 153, 0.2); border-radius: 4px; margin: 2px;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;color: &amp;quot;#cccccc&amp;quot;&lt;/span&gt;&lt;/code&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;&amp;nbsp;代表雪花的颜色，可根据自己喜好更改&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; text-indent: 30px; color: rgb(78, 83, 88); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; text-wrap: wrap; background-color: rgb(255, 255, 255); outline: 0px !important;&quot;&gt;&lt;br/&gt;&lt;/p&gt;&lt;p style=&quot;box-sizing: border-box; margin-top: 0px; margin-bottom: 20px; overflow-wrap: break-word; text-indent: 30px; color: rgb(78, 83, 88); font-family: &amp;quot;Helvetica Neue&amp;quot;, Helvetica, Arial, sans-serif; font-size: 16px; text-wrap: wrap; background-color: rgb(255, 255, 255); outline: 0px !important;&quot;&gt;&lt;span style=&quot;font-size: 20px;&quot;&gt;完成之后刷新网站就可以看到网站下雪了&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;</description><pubDate>Fri, 10 Nov 2023 23:44:38 +0800</pubDate></item></channel></rss>