- 浏览: 2869049 次
- 性别:
- 来自: 武汉
文章分类
- 全部博客 (1173)
- 名言警句 (5)
- 心情随笔 (50)
- 数据库 (57)
- Java基础 (241)
- J2EE框架 (91)
- 数据结构 (12)
- 程序设计 (21)
- WEB技术 (128)
- 网络日志 (12)
- IT资讯 (247)
- linux (64)
- solaris (2)
- 其它 (143)
- WebService (4)
- 日语学习 (2)
- 机器人 (5)
- Android (5)
- cgywin (3)
- Game (1)
- DWR (1)
- spring (8)
- canvas (1)
- Guava (3)
- Modbus (5)
- 测试 (6)
- mongodb (9)
- Quartz (2)
- Cron (1)
- windows (2)
- 持续集成 (1)
- bootstrap (3)
- 结对编程 (1)
- nodejs (1)
- Netty (1)
- 安全 (3)
- webstorm (2)
- sparkline (1)
- Job (1)
- git (3)
- Maven (3)
- knockout (5)
- jquery (1)
- bower (1)
- docker (1)
- confluence (4)
- wiki (1)
- GoogleMap (1)
- jekyll (10)
- ruby (2)
- npm (3)
- browserify (1)
- gulp (3)
- openwrt (1)
- discuz (3)
- 输入法 (1)
- JPA (1)
- eclipse (2)
- IntelliJ (1)
- css (1)
- 虚拟机 (1)
- 操作系统 (1)
- azkaban (2)
- scrum (1)
最新评论
-
pangxiea_:
你好, 想请问一下 Linux下 这么使用rxtxcomm 在 ...
使用Java进行串口通信 -
abababudei:
请教一下,这个您是怎么解决的:/dev/ttyS2enteri ...
Java应用程序的MODBUS通讯 -
xuniverse:
hannibal005 写道楼主,我问下 request.se ...
用javascript与java进行RSA加密与解密 -
atxkm:
找了一下午,终于找到了
gulp 拷贝文件时如何移除文件目录结构 -
kalogen:
gtczr 写道非常感谢,经过我自己的修改,已经完美实现。发出 ...
用javascript与java进行RSA加密与解密
--Meaningful Names
* Use Intention-Revealing Names
* Avoid Disinformation
* Make meaningful distinctions (XXXData & XXXInfo)
* Use pronounceable names
* Use Searchable names (easily grep)
* Avoid Encodings
* Hungarian Notation
* Member Prefixes (The more we read the code, the less we see the prefixes.)
* Avoid Mental Mapping (clarity is king)
* Class Names (noun or noun phrase names, like customer,account)
* Method Names (verb or verb phrase names, like postPayment, save)
* Don't be cute (Say what you mean. Mean what you say)
* Pick One Word per Concept ("DeviceManager" & "ProtocolController"
Why are both not controllers or both not managers?)
* Don't Pun (Avoid using the same word for two purposes.)
* Use Solution Domain Names (go ahead and use computer science (CS) terms,
algorithm names, pattern names, math terms)
* Use Problem Domain Names (At least the programmer who maintains your code
can ask a domain expert what it means)
* Add Meaningful context
* Don’t Add Gratuitous Context
--Functions
* Small! (Blocks and Indenting: if else while ...
the function called within the block can have a nicely descriptive name.)
* Do One Thing (Sections within Functions: what “one thing” is ?)
* One Level of Abstraction per Function (like a top-down narrative.)
* Switch Statements (can't avoid switch, but we can make sure that each switch
statement is buried in a low-level class and is never repeated. )
* Use Descriptive Names.
* Function Arguments
* common Monadic Forms (Try to avoid Using an output argument instead of a
return value for a transformation is confusing.)
* Flag arguments (ugly)
* Dyadic Functions
* Triads
* Argument Objects
* Argument Lists
* Verbs and Keywords (assertEquals might be better written
as assertExpectedEqualsActual(expected, actual).)
* Have No Side Effects
* Output Arguments
* Command Query Separation (Functions should either do something
or answer something, but not both.)
* Prefer Exceptions to Returning Error Codes
* Extract Try/Catch Blocks (it is better to extract the bodies of the try
and catch blocks out into functions of their own.)
* Error Handling Is One Thing
* Don’t Repeat Yourself
* Structured Programming (every function, and every block
within a function, should have one entry and one exit.)
--Comments
* Comments Do Not Make Up for Bad Code
* Explain Yourself in Code
* Good comments:
- Legal Comments
- Infomative Comments
- Explanation of Intent
- Clarification
- TODO Comments
* Bad comments:
- Mumbling
- Redundant comments
- Misleading Comments
- Mandated Comments
/**
*
* @param title The title of the CD
* @param author The author of the CD
* @param tracks The number of tracks on the CD
**/
- Journal Comments
* Changes (from 11-Oct-2001)
* --------------------------
* 11-Oct-2001 : Re-organised the class and moved it to new package
* com.jrefinery.date (DG);
* 05-Nov-2001 : Added a getDescription() method, and eliminated NotableDate
* class (DG);
* 12-Nov-2001 : IBD requires
- Noise Comments
/**
* Default constructor.
*/
protected AnnualDateRule() {
}
- Position Markers
- Commented-Out Code (Don't Do this!)
- HTML comments
- Nonlocal Information
--Formatting
* Dependent Functions (If one function calls another, they should be vertically close)
... ... ...
--Objects and Data Structures
Procedural code (code using data structures) makes it easy to add new functions without
changing the existing data structures. OO code, on the other hand, makes it easy to add
new classes without changing existing functions.
* The Law of Demeter
a module should not know about the innards of the objects it manipulates.
* Train Wrecks, Hiding Structure
Objects expose behavior and hide data. This makes it easy to add new kinds of objects
without changing existing behaviors. It also makes it hard to add new behaviors to existing
objects. Data structures expose data and have no significant behavior. This makes it easy to
add new behaviors to existing data structures but makes it hard to add new data structures
to existing functions.
--Error Handling
* Use Exceptions Rather Than Return Codes
* Use Unchecked Exceptions
* Define Exception Classes in Terms of a Caller’s Needs
* Define the Normal Flow (Don't deal with business logic under catching exceptions)
* Don’t Return Null
* Don't pass null
--Boundaries
* Using Third-Party Code
We should avoid letting too much of our code know about the third-party particulars. It’s better
to depend on something you control than on something you don’t control, lest it end up
controlling you.
--Unit Tests
* Keeping Tests Clean
* A Dual Standard
* Rules:
- Fast Independent Repeatable Self-Valldating Timely
--Classes
* Classes Should be Small
* The Single Responsibility Principle
* Cohesion
--Systems
* Separate Constructing a System from Using It
* Dependency Injection
* Cross-Cutting Concerns
* Java Proxies
* AspectJ Aspects
--Emergence
* Refactoring
* No Duplication
* code expressive
* Simple Design
--Concurency
* Single Responsiblity Principle
- Concurrency-related code has its own life cycle of development
- Limit the scope of data
- Use copies of data
- Threads should be as independent as possible
* Thread-Safe Collections (concurrentHashMap)
* Executions Models (Bound Resources, Mutual Exclusion, Starvation, Deadlock,Livelock)
* Producer-Consumer
* Readers-Writers
* Keep Synchronized Sections Small
* Testing Threaded Code
- Get your nonthreaded code working first
- Make your threaded code pluggable
- Make your threaded code tunable
- run with More thread than processors
- run on different platforms
--Successive refinement
* examples
--Junit Internals
* refactors
--Refactoring serialdate
* First, make it work
* Then Make it Right
--Smells and Heuristics
- Inappropriate Information
- Obsolete Comment
- Redundant Comment
- Poorly Written Comment
- Commented-Out Code
- Build Requires More Than One Step
- Tests Require More Than One Step
- Too Many Arguments
- Output Arguments
- Flag Arguments
- Dead Function
- Multiple Languages in One Source File
- Obvious Behavior Is Unimplemented
- Incorrect Behavior at the Boundaries
- Overridden Safeties
- Duplication
- Code at Wrong Level of Abstraction
- Base Classes Depending on Their Derivatives
- Too Much Information
- Dead Code
- Vertical Separation
- Inconsistency
- clutter
- Artificial Coupling
- Feature Envy
- Selector Arguments
- Obscured Intent
- Misplaced Responsibility
- Inappropriate Static
- Use Explanatory Variables
- Function Names Should Say What They Do
- Understand the Algorithm
- Make Logical Dependencies Physical
- Prefer Polymorphism to If/Else or Switch/Case
- Follow Standard Conventions
- Replace Magic Numbers with Named Constants
- Be Precise
- Structure over Convention
- Encapsulate Conditionals
- Avoid Negative Conditionals
- Functions Should Do One Thing
- Hidden Temporal Couplings
- Don’t Be Arbitrary
- Encapsulate Boundary Conditions
- Functions Should Descend Only One Level of Abstraction
- Keep Configurable Data at High Levels
- Avoid Transitive Navigation
- Avoid Long Import Lists by Using Wildcards
- Don’t Inherit Constants
- Constants versus Enums
- Choose Descriptive Names
- Choose Names at the Appropriate Level of Abstraction
- Use Standard Nomenclature Where Possible
- Unambiguous Names
- Use Long Names for Long Scopes
- Avoid Encodings
- Names Should Describe Side-Effects
- Insufficient Tests
- Use a Coverage Tool!
- Don’t Skip Trivial Tests
- An Ignored Test Is a Question about an Ambiguity
- Test Boundary Conditions
- Exhaustively Test Near Bugs
- Patterns of Failure Are Revealing
- Test Coverage Patterns Can Be Revealing
- Tests Should Be Fast
发表评论
-
ATOM编辑器快捷键大全
2021-02-28 10:03 413在Github上总结的ATOM 快捷键,用ATOM 编辑器的 ... -
使用Amazon的AWS来搭建属于自己的shadowsocks服务器
2015-04-08 22:22 16182相信有不少水友已经 ... -
开车技术
2014-10-16 12:24 541如何判断车距,这个太实用了 一、超车变道时如何判 ... -
Running Jar file in Windows
2014-04-30 10:11 798Easiest route is probably upgr ... -
Windows的命令行下设置网络代理
2014-03-31 09:42 3394在公司访问网络的时候,需要设置代理,设置浏览器的代理是相当的 ... -
超全面的收房小知识
2013-12-29 15:09 743验房:就是竭尽全力发现问题,进而在装修的时候着手解决这些问题 ... -
Kmplayer的各种功能设置
2013-11-17 17:59 2130Kmplayer的各种功能设置 ... -
9 Ways To Make Thunderbird Load Your Email Faster
2013-09-14 15:57 1238If you asked anyone for the fi ... -
Protobuf 的安装使用总结
2013-09-12 13:28 8513ProtoBuf的官方下载包并不包含jar文件,需要用户自己 ... -
Java应用程序的MODBUS通讯
2013-09-06 14:15 17818实验目的 JAVA应用程序通过MODBUS协议RTU模式读 ... -
在本地使用java收发/调试Modbus协议数据
2013-08-28 13:59 185651. 安装Modbus仿真工具Mo ... -
Modbus Error Code List
2013-08-27 16:53 1667HEX Error Code for Modbus Plus ... -
49 款人脸检测/识别的API、库和软件
2013-08-26 19:58 1816自从谷歌眼镜被推出以 ... -
sublime配置全攻略
2013-08-17 14:16 2211sublime本身功能有限,我们需要装上一些插件使其变得 ... -
程序员提高效率工具
2013-08-12 11:14 1403windows下的虚拟桌面管理工具 windows xp ... -
Go 编程语言的 12 条最佳实践
2013-08-09 17:53 1097最佳实践 维基百科的定义是: “最佳实践是一种方法或技术 ... -
sublime 插件管理
2013-08-08 18:00 1239插件管理 1、安装Package Control 按C ... -
sublime2快捷键
2013-08-08 17:51 1128快捷键 Ctrl+L 选择整行(按住-继续选择下行) C ... -
sublime及相关资源
2013-08-08 17:10 913Sublime Text3 Buld 3038 中文优化注 ... -
为设计师准备的 15 个免费新鲜的字体
2013-08-04 17:45 1108Axe Handel Going Fast Ka ...
相关推荐
Find out how to write clean and elegant Python code that will optimize the strength of your algorithms, Discover how to embed your machine learning model in a web application for increased ...
Find out how to write clean and elegant Python code that will optimize the strength of your algorithms Discover how to embed your machine learning model in a web application for increased ...
Flask’s main task is to build web applications quickly and with less code. With its lightweight and efficient web development framework, Flask combines rapid development and clean, simple design. ...
Write reusable code and build complete machine learning systems from the ground up Learn specialized machine learning techniques for text mining, social network data, big data, and more Discover the ...
- Lots of code cleanup - Profiling of where the slowdowns are. On small tests, the cpp_btree lib beats it by 10-100x - Eigen::TensorFixed in nn_cpp would definitely help - Increasing dataset size ...
NumPy is an extension of Python, which provides highly optimized arrays and numerical operations.... Learning NumPy Array will help you be productive with NumPy and write clean and fast code.
Python pycharm learning code text record (7) 文章编号:Python学【2020】007号 日期:2020-02-18 文章为日常学习记录,以备温习使用,同时作为像我一样的新人学习使用,内容属于学习记录,版权归视频学习提供...
NumPy is an extension of Python, which provides highly optimized arrays and numerical operations.... Learning NumPy Array will help you be productive with NumPy and write clean and fast code.
内容部分提到的“Speed up your Python code with clean, readable, and advanced concurrency techniques”意味着通过使用高效、易于理解且先进的并发技术,可以使Python代码运行得更快。这说明了并发编程在提高...
The more important part, perhaps, was to clean and standardize the code. This is also important when you have to share code with coworkers and, dare I say, regulators. Using RStudio facilitates this ...
7. **专业书籍阅读**:像《Design Patterns》、《Clean Code》等经典著作,都是用英文写作的。阅读这些书籍能提升我们的专业素养,并增强英语阅读能力。 8. **语言习惯和语境**:了解技术场景下的英语表达方式,...