Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

《实现模式》 #6

Open
aikin opened this issue Jun 22, 2019 · 2 comments
Open

《实现模式》 #6

aikin opened this issue Jun 22, 2019 · 2 comments

Comments

@aikin
Copy link
Owner

aikin commented Jun 22, 2019

image

@aikin aikin closed this as completed Jun 22, 2019
@aikin aikin reopened this Jun 22, 2019
@aikin
Copy link
Owner Author

aikin commented Jun 22, 2019

  • 模式:用于解决反复发生的设计问题的简单,雅致的解决方案。
  • 灵活性,模块性,已经创建可理解的,清晰的设计。

保持代码的价值观:让代码更加体现出,沟通,简单,灵活。
沟通:代码可读性高,用代码体现出我们的业务逻辑。
简单:简单设计,不要做无畏的抽象,降低逻辑的复杂性。
灵活:可扩展性要高。

软件的成本:

cost(total) = cost(develop) + cost(maintain)

维护的成本

cost(maintain) = cost(understand) + cost(change) + cost(test) + cost(deploy)

金钱的时间价值和未来的不确定性,由于不确定性的存在,实现策略应该更倾向于带来即时收益而非长远收益。

@aikin
Copy link
Owner Author

aikin commented Jun 22, 2019

命令式:阅读代码时,需要跟随着代码的执行流程。阅读者需要在大脑中建立起一个程序状态、控制流、数据流的模型。
声明式:更多的是简单的描述。

命令式:

public static junit.framework.Test suite() {
   Test result = new TestSuite();
   ...complicated stuff...
   return result;
}

如果要知道,哪些测试会被执行?就需要知道,suite 的具体实现,需要读懂,理解后,才能知道它的功能。

声明式:

@RunWith(Suite.class)
@TestClasses({
  SimpleTest.class,
  ComplicatedTest.class
})
class AllTests {
}

要了解,哪些测试会被执行?只要找到注解的地方,就知道哪些测试就会运行。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant