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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

What if your domain model could validate the UI for free?

27 点作者 gcanti将近 11 年前

4 条评论

bshimmin将近 11 年前
The tcomb library seems to do quite a lot, some of which might be sort of useful, but the example supplied here doesn&#x27;t really seem to support why you might use it. The code in fact just seems weird to me: if you&#x27;re having to use a try&#x2F;catch to do some really basic form validation, then obviously that&#x27;s horribly wrong... but the example below, under &quot;Further Reading&quot;, which is (I think?) proposed as the better solution, doesn&#x27;t really seem any different from how you might go about solving this problem were you not to use any library at all, except you wouldn&#x27;t have the struct stuff. Very unconvincing, if you ask me.<p>Contracts.js is quite a different approach, maybe even to an orthogonal problem, but perhaps is more interesting: <a href="https://github.com/disnet/contracts.js" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;disnet&#x2F;contracts.js</a>
couchand将近 11 年前
I think this looks pretty cool; I like how simple and general the last validation function is. If you&#x27;re generating the UI from the model all the better (it looks like there&#x27;s a note on this front at the bottom of the tcomb.js readme). This would be remarkably easy to do with React, and it all could be abstracted into a simple configuration framework.<p>Looks like there&#x27;s a typo in the last example: you probably want to use the Struct param in the fetch function rather than explicitly creating a User.<p>Seems like the makings of something like Bootstrap for domain models here. Neat.
评论 #8168650 未加载
评论 #8169158 未加载
marcosdumay将近 11 年前
&gt; What if your domain model could validate the UI for free?<p>Then your domain modeling language will be as detailed and error prone as the UI designing language, and completely unsuitable for the task. As the article exemplifies.<p>Abstraction and detail are at odds against each other. You simply can not have both.<p>Also, why verify the domain description? You must check that the UI fits the problem, not a short description of it.
keithnoizu将近 11 年前
What if you could sell your one measly old cow for three magic beans. ;)