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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: When to decide to evolve my design pattern?

3 点作者 gkrishna大约 4 年前
Hi all,<p>When I start developing my applications mostly I prefer to start with MVC pattern.<p>I have difficulty in deciding when to choose a different pattern and which one. The books that I have read mostly describes how the pattern works. But I couldn&#x27;t find resource that can help me decide in which scenario I should change my pattern.<p>Can someone please help me point me in the right direction?<p>Thanks.

1 comment

shoo大约 4 年前
The original idea for documenting design patterns goes something like this:<p>&gt; Documenting a pattern requires explaining why a particular situation causes problems, and how the components of the pattern relate to each other to give the solution.[3] Christopher Alexander describes common design problems as arising from &quot;conflicting forces&quot;—such as the conflict between wanting a room to be sunny and wanting it not to overheat on summer afternoons. A pattern would not tell the designer how many windows to put in the room; instead, it would propose a set of values to guide the designer toward a decision that is best for their particular application. &gt; Pattern documentation should also explain when it is applicable.<p>-- <a href="https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Design_pattern" rel="nofollow">https:&#x2F;&#x2F;en.m.wikipedia.org&#x2F;wiki&#x2F;Design_pattern</a><p>Some key parts of documenting a pattern are:<p>Describing the context, the situation in which a problem arises; clearly describing which problem is to be solved; describing a solution to the problem (ideally compared against alternatives); and discussing in what situations a proposed solution would or would not be applicable<p>If a book is only talking about how to implement some pattern rather than when it might make sense to use it, or how to derive the pattern from the constraints of a problem, that book won&#x27;t really help you do design.<p>You could learn more about how to write an engineering design document that describes a context, states a problem and a clear goal to be solved, explores some alternative solutions and then recommends a particular solution.<p>Rule of thumb: solve the problem you actually have, not the problem you want to have. If there isn&#x27;t a problem causing you a lot of pain, don&#x27;t change anything. If there is a problem causing you a lot of pain, start brainstorming what changes you could make that might reduce the pain!