TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Where DRY Applies

1 点作者 chriskrycho超过 1 年前

1 comment

eternityforest超过 1 年前
I&#x27;m pretty big time DRY extremist. Mostly because I have had so many issues in real life whenever I&#x27;m dealing with lists of things, I always wind up forgetting one ingredient in the recipe or step in a project... It&#x27;s easier to DRY than to automatically verify stuff is im sync.<p>My new thing lately has been JSON schemas.<p>I use them to set defaults, to decide what properties to save and load, to eliminate unnecessary defaults when saving, to generate __slots__, and for verifying correctness at different steps in the program, like when accepting data from an API call.<p>I&#x27;m still using manual type annotations though, it doesn&#x27;t seem like there are common tools for making a class from a schema in a way that MyPy understands.<p>They also serve as the source of truth documentation for the data. I&#x27;m not sure why I didn&#x27;t start using them a long time ago!<p>I wonder what other similarly powerful DRY tools I&#x27;m not using but should be?
评论 #38128223 未加载