xlcoder166 发布的文章
String vs StringBuilder vs StringBuffer in Java
String vs StringBuilder vs StringBuffer in Java
--- | String | StringBuffer | StringBuilder |
---|---|---|---|
Syntax | String var = new String(str) | StringBuffer var = new StringBuffer(str); | StringBuilder var = new StringBuilder(str); |
Mutability | immutable | mutable | mutable |
Thread | Safe | Safe | Not Safe |
JDK | 1.0 | 1.0 | 1.5 |
Note | Constant String Pool |
JAVA 中的 StringBuilder 和 StringBuffer 适用的场景是什么?
stringbuffer固然是线程安全的,stringbuffer固然是比stringbuilder更慢,固然,在多线程的情况下,理论上是应该使用线程安全的stringbuffer的。
然而,然而,然而,有谁给我一个实际的案例来显示你需要一个线程安全的string拼接器?对不起,至少在我浅薄的十几年编程生涯中还没有遇到过,也许,仅仅是也许,这个地球上的确是存在这样的编程需求的,然而,它至少跟99.99...99%的程序员是无关的。
面向对象是如何工作的(How Objects Work)
How Objects Work - 面向对象是如何工作的
面向对象的全貌和概念
面向对象是从编程语言进化为编程技术的
1967 年挪威设计的 Simula 67 编程语言首次提出
艾伦 凯设计的 Smalltalk 沿用此架构,开创“面向对象”的概念
观察者模式
观察者模式
模式功能
模式预期
模式实现
Laravel Multiple Language
Laravel Multiple Language
Depend on HTML tag "language' and 'lang' directory package
Use Middleware Set Session locale
Generate each language standard Url
Java Annotations
Java Annotations
"Annotations are only metadata and do not contain any business logic"
"Annotations only provide information about the attribute (class/method/package/field) on which it is defined. The consumer is a piece of code that reads this information and then performs the necessary logic."
@Override annotation in above code. Even if I don’t put @Override, code works properly without any issue.
@Override tells the compiler that this method is an overridden method (metadata about the method), and if any such method does not exist in a parent class, then throw a compiler error (method does not override a method from its super class).
if I would have made a typography mistake and used the method name as toStrring() {double r}, and if I wouldn’t have used @Override, my code would have compiled and executed successfully
Git 命令与场景
基础概念
工作区,暂存区,保存区
commoit -> tree -> blob
git init -> git add -> git commit -m
数据库范式
数据库范式
范式保证数据库操作的原子化,即Insert,Update,Delete,减少数据冗余
1. Define
First normal form (1NF)
is a property of a relation in a relational database. A relation is in first normal form if and only if the domain of each attribute contains only atomic (indivisible) values, and the value of each attribute contains only a single value from that domain属性具备原子性且唯一值
How to Design Programs - Prologue
Hence any reasonably complete program consists of many building blocks: some deal with input, some create output, while some bridge the gap between those two.
1. From Problem Analysis to Data Definitions
Identify the information that must be represented and how it is represented in the chosen programming language. Formulate data definitions and illustrate them with examples.
2. Signature, Purpose Statement, Header
State what kind of data the desired function consumes and produces. Formulate a concise answer to the question what the function computes. Define a stub that lives up to the signature.
3. Functional Examples
Work through examples that illustrate the function’s purpose.
4. Function Template
Translate the data definitions into an outline of the function.
5. Function Definition
Fill in the gaps in the function template. Exploit the purpose statement and the examples.
6. Testing
Articulate the examples as tests and ensure that the function passes all. Doing so discovers mistakes. Tests also supplement examples in that they help others read and understand the definition when the need arises—and it will arise for any serious program.
Design Recipes apply to both complete programs and individual functions.
ECMAScript 6 Meta Reflect&Proxy
ECMAScript 6 Meta Reflect&Proxy
Reflect
Reflect is a built-in object that provides methods for interceptable JavaScript operations. The methods are the same as those of proxy handlers. Reflect
is not a function object, so it's not constructible.
Unlike most global objects, Reflect is not a constructor. You cannot use it with a new operator or invoke the Reflect object as a function. All properties and methods of Reflect are static (just like the Math object).
Reflect.apply()