1) "Prefer composition to Inherentance."
--From GOF
2) A word about checked exceptions:
The great value of exceptions is the unification of error reporting: a standard machanism by which to report errors, rather than the popourri of ignorable approaches that we had in C.
I believe taht have a single mechanism for handling errors is excellent, and I believe that using a separate channel(exception handling mechanism) for moving the exceptions around is good, but it seems to me that checked exception do not do this; instead, they tend to intrude (a lot) into your "normal working code" and thus a step backwards.
"I intend to put a lot more RuntimeExceptions into my Java code."
--From Bruce Eckel
3) "Design patterns help you learn from other's successes instead of your own failures."
--From Mark Johnson
4) "Separate things that change from things that stay the same."
5) The basic concept of a pattern can also be seen as the basic concept of program design: adding a layer of abstraction.
6) Classifying patterns:
1> Creational:
How an object can be created.
This often involves isolating the details of object creation,
so your code isn't dependent on what types of objects there are and thus doesn't have to be changed when you add a new type of Object.
Eg. Singleton, Factory, Factory Method, Abstract Factory, Builder and Prototype patterns.
2> Structural:
Objects are connected with other objects to ensure that changes in the system don't require changes to those connections.
Eg. Adapter, Bridge, Composite, Decorator and Proxy.
3> Behavioral:
Objects that handle particular types of actions within a program.
These encapsulate processes that you want to perform, such as interpreting a language, fulfilling a request, moving through a sequence (as in an interator), or implementing an algorithm.
Eg. Observer, Visitor, Iterator, Command, Chain of Responsibility, Template Method and Strategy patterns.
7) "We should forget about small effenciencies, say about 97% of the time: Premature optimization is the root of all evil."
-- From Donald Knuth
8) Design Principles (SOLID):
1> Single Responsibility Principle (SRP)
A class should have only one reason to change.
2> Open-Close Principles (OCP)
Software entities like classes, modules and functions should be open for extention but close for modifications.
3> Liskov Substitution Principles (LSP)
Derived types must be completely substitutable for their base types.
4> Interface Segregation Principles (ISP)
Clients should not be forced to depend upon interfaces that they don't use.
This principle teaches us to take care how we write our interfaces. When we write our interfaces we should take care to add only methods that should be there. If We add methods that should not be there, the classes implementing the interface will have to implement those methods as well. For example if we create a an interface called Worker and add a method lunch break, all the workers will have to implement it. What if the worker is a robot?
As a conclusion, Interfaces containing methods that are not specific to it are called polluted or fat interfaces. We should avoid them.
5> Dependency Inversion Principle (DIP)
1. High-level modules should not depend on low-level modules. Both should depend on abstractions.
2. Abstractions should not depend on details. Details should depend on abstractions.
-->Interface Oriented Programming & Spring Ioc & Google Guice
9) Law of Demeter
a.k.a. "Don't talk to strangers."
An object A can request a service (call a method) of an object instance B, but object A should not "reach through" object B to access yet another object C, to request its services. Doing so would mean that object A implicitly requires greater knowledge of object B's internal structure. Instead, B's interface should be modified if necessary so it can directly serve object A's request, propagating it to any relevant subcomponents. Alternatively, A might have a direct reference to object C and make the request directly to that. If the law is followed, only object B knows its own internal structure.
Reference Links:
1) http://www.oodesign.com/design-principles.html
相关推荐
《Ken Henderson:The Guru's Guide to Transact-SQL》是一本深入探讨Transact-SQL语言的专业书籍,由Addison-Wesley出版社出版。该书在Book Pool评选的近十年计算机专业图书中脱颖而出,成为SQL领域的经典之作。...
标题 "goclipse插件guru.exe" 涉及的是在Windows环境下使用Eclipse集成开发环境(IDE)配合goclipse插件进行Go语言编程时的一个重要工具——`guru.exe`。`guru.exe`是Go语言官方提供的一款强大的源代码分析工具,它...
PDF Guru v1.0.13 是一款全能的PDF处理工具,它提供了多种功能,旨在帮助用户高效地管理和编辑PDF文档。作为一个免费且开源的版本,它为用户提供了无需付费即可享受的专业级PDF解决方案。 首先,PDF Guru的核心功能...
guru:GO语言代码导航工具,go 1.10版本,64位,亲测可用
在Go语言的开发环境中,`gocode`、`godef`和`guru`是三个非常重要的工具,它们极大地提升了开发效率和代码理解能力。以下是关于这三个工具的详细解释: 1. **gocode**: `gocode`是Go语言的一个自动完成工具,它为...
在这个主题中,我们将关注三个重要的Go语言开发工具:`gocode`、`godef`和`guru`。 1. **gocode**: `gocode` 是一个自动完成工具,用于Go语言的IDE或编辑器。它提供了强大的代码补全功能,能够帮助开发者快速地...
Supply Chain Guru is cutting edge software that allows you to perform both supply chain simulation and optimization. This enables you to directly solve problems involving supply chain strategic ...
I can pretty much guarantee that anyone who uses SQL Server on a regular basis (even those located in Redmond working on SQL Server) can learn something new from reading this book.
为了在Eclipse这样的集成开发环境(IDE)中提升Go语言的开发体验,开发者通常会安装一系列插件,如gocode、godef和guru。这些插件提供了诸如自动补全、代码跳转和上下文分析等功能,极大地提高了开发效率。 1. **...
在Go语言的开发环境中,`guru`和`godef`是两个非常重要的辅助工具,它们可以帮助程序员更高效地理解和调试代码。这两个工具都属于Go生态中的“源码探索”工具,提供了对Go代码的深度分析和定位功能。 首先,让我们...
golang 代码导航工具 Go Guru.exe 在开发golang项目的过程中我们希望我们的编辑器回答我们各种各样的问题。例如: 标识符(名字,对于变量、常量、函数、语句块)在哪里申明? 所有对此申明的引用在哪里? 此表达式...
guru:GO语言代码导航工具
vga_utility_oc_guru_2.rar是技嘉发布的一款显卡调整工具,也可以称之为显卡超频工具,它可以让你调节显卡的各项参数,如核心频率速度及核心电压,在允许的范围内调整显卡参数可以增强显卡的性能。亦可调显卡风扇的...
Guru MES宣传手册
《Python库mypty-boto3-devops-guru详解与应用》 在当今的软件开发领域,DevOps(Development和Operations的组合)已经成为一种不可或缺的实践,它强调开发人员与运维人员之间的紧密协作,以实现快速、可靠且频繁的...
book : The Guru's Guide To Transact SQL.Pdf, if u want to understand sql in deep
goeclipse用的guru.exe,比较难搞到,即时也是下载不了的,这个保证可用,放到GoPath/bin下即可
**明基逐鹿 Guru EIS决策支持系统**是一款专门设计用于企业信息管理和决策制定的高效工具,它旨在整合企业内部的各类业务数据,提供全面、即时的信息支持,从而提升企业的运营效率和决策质量。 该系统的核心是利用*...
这里我们主要关注三个工具:gocode、godef和guru,它们是Go语言开发中的得力助手,尤其对于使用Eclipse IDE的开发者来说更是必不可少。这些工具通常会打包成一个压缩文件,如"gocode_godef_guru_64bit.rar",便于64...
标题 "guru godef gocode" 涉及到的是三个重要的Go语言开发工具,它们对于提升Go语言编程效率和代码理解具有显著作用。在本文中,我们将深入探讨这三个工具的功能、使用方法以及如何与Eclipse等集成开发环境(IDE)...