-
Clean Code 無暇的程式碼- Ch2 有意義的命名
有意義名稱 Bad: int priceTable[] = new int[16]; Good: static final int PRICE_TABLE_MAX = 16; int price Table[] = new int[PRICE_TABLE_MAX]; 原則上 0 不用於魔法值,這是因為 0 經常被用作數組的最小下標或者變量初始化的預設值。 原文網址:https...
-
Clean Code 無暇的程式碼- Ch1 無暇的程式碼
Clean Code 無暇的程式碼:敏捷軟體開發技巧守則 作者: Robert C. Martin 我的前言 期待已久的書,一直很想閱讀,最近買了這本書,終於有機會有時間拜讀了。 在寫項目的時候,常常覺得自己寫的程序不夠乾淨、整潔、清爽,有很多冗贅的代碼。一來是時間上時程內的產出,當然最主要是自己本身實力不足、經驗不夠。 許多時候為了快速開發,選擇便宜行事的方式,代碼質量就被剝奪...
-
GoodBye 2019, Hello 2020
道別2019,展望2020! 2020年来啦!祝大家新年快乐~ by 初音未来_Crypton 大家元旦快乐!!!«٩(´ ꒳ `)۶» by 新科娘Official
-
Java - Livelock 活鎖
Livelock A thread often acts in response to the action of another thread. If the other thread’s action is also response to the action of another thread, then livelock may result. As with deadl...
-
Java - Thread Starvation 飢餓
Starvation and Livelock Starvation and livelock are much less common a problem than deadlock, but are still problems that every designer of concurrent software is likely to encounter. Ref: ...
-
Java - Thread Deadlock 死鎖
死鎖 【Java并发编程实战】頁205: 當一個線程永遠佔有一個鎖,而其他線程嘗試去獲得這個鎖,那麼它們將永遠被阻塞。 Deadlock (The Java™ Tutorials > Essential Classes > Concurrency) Deadlock describe a situation where two or more threa...
-
MySQL - SQL Optimizing 優化
Optimization SQL Statements 確定SELECT字段而不是SELECT * 如果表具有許多字段和許多行,則這將查詢大量不需要的數據。 Inefficient: SELECT * FROM Customers Efficient: SELECT FirstName, LastName, Address FROM Customers 選擇更多字段以避免S...
-
MySQL - SQL Basic 基礎
Basic SQL命令: 不分大小寫(Case Insensitive) 關鍵字不可以分割成多行 MySQL單雙引號皆可,但其它database只接受單引號 常數(Literal):不變的數據,不儲存於數據庫內部 Ref: database design - Reason why oracle is case sensitive? - Stack Overflo...
-
Git - Commit Message Guidelines 提交消息準則
type (scope): subject BLANK LINE body BLANK LINE footer subject & body: First line is 50 characters or less Then a blank line Remaining text should be wrapped at 72 characters Ref:...
-
Hello World
Hello World! 請多指教! _(:з」∠)_
-
Java - JSON 用法
Jackson Parse to Java primitive type { "admin_email": "abc@123.com", "admin_password": "abc123" } 只能取得第一層的參數,無法取得第二層的參數 如果使用optString(),會視為null並轉換空字串;如果使用getString(),會視為null拋出Excep...
-
Java - Thread Publication and Escape 對象的發佈與逸出
對象的發佈與逸出 發佈(publishing):能夠被當前作用域外的代碼所使用 逸出(escape):一個對象在尚未準備好時就將它發佈 常見逸出的有下面幾種方式: 靜態域逸出 public修飾的get方法 方法參數傳遞 隱式的this 以下分別說明: 靜態域逸出 // public修飾的靜態域,相當於發佈了這個對象 // person對象也間...
-
Java - Thread Immutable Objects 對象不可改變性
Immutable Objects An object is considered immutable if its state cannot change after it is constructed. Maximum reliance on immutable objects is widely accepted as a sound strategy for creatin...
-
Java - Thread Synchronization 線程同步機制
同步是一種概念,用於防止多個線程輸入代碼的特定部分,這又是避免線程問題的最基本概念。 Synchronization is a concept to prevent more than one thread from entering a specific part of code, which is - again - the most basic concept of avoi...
-
Java - Thread Safe 線程安全
何謂線程安全 參考【Java并发编程实战】頁17 & 頁18的定義: 線程安全,一個類是線程安全的,是指在被多個線程訪問時,類可以持續進行正確的行為 當多個線程訪問一個類時,如果不用考慮這些線程在運行時環境下單調度和交替執行, 並且不需要額外的同步措施,及在調用方代碼不必作其他的協調,這個類的行為仍然是 正確的,那麼這個類就是線程安全的 換句話說,就是多線...
-
Java - Risks of Thread 線程的風險
線程安全危險 線程安全的問題是微妙且出乎意料的,因為在沒有進行充分同步的情況下,多線程中的各個操作的順序是不可預測的,也就是容易造成線程安全問題。 簡單舉個例子: 下面的程序在單線程中運行是沒有問題的。 import net.jcip.annotations.NotThreadSafe; @NotThreadSafe class UnSafeSequence { priva...
-
Java - Thread Objects 線程對象
Create and Starting a Thread extends Thread class ThreadExample extends Thread { public static void main(String[] args) { System.out.println("Inside : " + Thread.currentThread().getNa...
-
Java - Concurrency 並發編程
基礎知識 用多線程只有一個目的:更好的利用cpu資源。 更詳細的說: 系統需要多功能處理,開啟進程非常耗費資源 進程間的通訊很不方便,因為大多數操作系統不允許進程訪問其他進程的內存空間 因為多線程程序是亂序執行,每次執行的結果都是隨機的。因此,只有亂序執行的代碼才有必要設計為多線程。 關於線程的一些概念: cpu時間片:我們操作系統看起來可以多個程序同時運行,分...
-
Java - JVM 虛擬機
Java Virtual Machine (JVM) is a engine that provide runtime environment to drive the Java code or applications. It converts Java bytecode into machines language. JVM is a part of Java Run Environ...
-
Java - Memory Allocation 內存分配
Where storage lives Registers This is the fastest storage because it exists in a place different from that of other storage: inside the central processing unit (CPU). However, the number o...