發表文章

目前顯示的是 2020的文章

RESTful API 設計原則

HTTP method 讀取 GET 新增 POST 修改 PUT 刪除 DELETE Resource URI 使用名詞複數 一律小寫,使用 - 連接 GET /articles POST /articles PUT /articles/1 DELETE /articles/1 多個節點 /users/1/articles/1 HTTP status code 200 OK 1xx 訊息 2XX 成功 3XX 重新導向 4XX 客戶端錯誤 5XX 伺服器錯誤

Laravel命名規則

型態 規則 範例 Route 複數 articles/1 Route Name 帶點符號的蛇形命名 article.index Controller 單數 ArticleController Model 單數 Article Service 單數 ArticleService Repository 單數 ArticleRepository hasOne or belongsTo relationship 單數 articleComment All other relationships 複數 articleComments Method 小駝峰命名 getAll Trait 形容詞 Exportable View 蛇形命名 list.blade.php Config 蛇形命名 article.php Variable 小駝峰命名 $articleName Migration - 2020_01_01_000000_create_articles_table Table 複數 articles Primary key - id Foreign key 單數名稱_id article_id Table column 蛇形命名 article_click

SOLID (物件導向設計)

單一職責原則 (Single responsibility principle, SRP) 認為物件應該僅具有一種單一功能的概念。 開放封閉原則 (Open-Close principle, OCP) 認為「軟體體應該是對於擴充開放的,但是對於修改封閉的」的概念。 里氏替換原則 (Liskov substitution principle, LSP) 認為「程式中的物件應該是可以在不改變程式正確性的前提下被它的子類所替換的」的概念。 介面隔離原則 (Interface segregation principle, ISP) 認為「多個特定客戶端介面要好於一個寬泛用途的介面」的概念。 依賴反轉原則 (Dependency inversion principle, DIP) 認為一個方法應該遵從「依賴於抽象而不是一個實例」的概念。