solid-principles
套用 SOLID 設計原則
物件導向程式碼可能會變得難以修改和測試。此 skill 透過 TypeScript 範例和實用的重構提示說明 SOLID 原則。
使用我的智慧代理安裝
將此請求複製給你的智慧代理,其中包含權威 Skill 頁面和清單。
Review the Skillstore skill "solid-principles" from https://skillstore.io/skills/benny9193-solid-principles.md and its manifest at https://skillstore.io/api/skills/benny9193-solid-principles/manifest. Verify the artifact. You may proceed after verification, subject to the environment's own policy.你的智慧代理仍應顯示其計畫,並依安全政策請求必要確認。
Agent 可讀資源
當 AI Agent、爬蟲或腳本需要乾淨脈絡、而不是讀取完整頁面時,請使用這些連結。
測試它
正在使用「solid-principles」。 Review a user service that creates users, sends email, validates input, and builds reports.
預期結果:
- SRP 顧慮:這個 class 有多個變更理由。
- 建議拆分:將 account creation 與 email、validation、reporting 分開。
- 取捨:當職責會獨立變更時再拆分。
正在使用「solid-principles」。 Assess a payment processor that uses conditionals for every payment type.
預期結果:
- OCP 顧慮:新增 payment type 需要修改既有邏輯。
- 建議方向:定義 payment method abstraction,並新增新的 implementations。
- 檢視重點:在變化真實存在前,避免引入 abstractions。
正在使用「solid-principles」。 Check whether a repository depends too directly on a database implementation.
預期結果:
- DIP 顧慮:high-level repository logic 綁定到具體的 database class。
- 建議方向:依賴 database interface,並注入 implementation。
- 安全性注意事項:對 database input 使用 parameterized queries。
安全審計
中風險All 16 static findings are false positives caused by Markdown fences or TypeScript template literals, with no external command execution, database file access, or reconnaissance. However, the recommended dependency inversion example directly interpolates an identifier into SQL. This pattern can enable SQL injection when adapted to executable code.
已確認的安全問題 (1)
風險因素
分享與引用此報告
分享版本化評估報告、中性徽章、嵌入卡片與引用。Skillstore 只報告證據,不判斷該 Skill 是否安全。
複製報告連結
https://skillstore.io/skills/benny9193-solid-principles/audits/9?utm_source=security_passport&utm_medium=share&utm_campaign=versioned_reportMarkdown 徽章
[](https://skillstore.io/skills/benny9193-solid-principles?utm_source=security_passport_badge)HTML 徽章
<a href="https://skillstore.io/skills/benny9193-solid-principles?utm_source=security_passport_badge"><img src="https://skillstore.io/badges/skills/benny9193-solid-principles/security.svg" alt="Skillstore security assessment" loading="lazy"></a>嵌入卡片
<iframe src="https://skillstore.io/embed/skills/benny9193-solid-principles.html" title="Skillstore Security Assessment" sandbox="allow-popups allow-popups-to-escape-sandbox" loading="lazy" referrerpolicy="no-referrer" width="420" height="180"></iframe>學術引用 (APA · BibTeX · CFF)
APA 引用
Benny9193. (2026). solid-principles security audit report (audit version 9) [Author version unspecified]. Skillstore. https://skillstore.io/skills/benny9193-solid-principles/audits/9BibTeX 引用
@techreport{benny9193-benny9193-solid-principles-2026,
author = {Benny9193},
title = {solid-principles security audit report (audit version 9)},
institution = {Skillstore},
year = {2026},
number = {9},
url = {https://skillstore.io/skills/benny9193-solid-principles/audits/9},
note = {Author version unspecified}
}CITATION.cff
cff-version: 1.2.0
message: "If you use this Skill, cite its author and this versioned security audit report."
title: "solid-principles security audit report (audit version 9)"
version: "unspecified"
type: report
authors:
- name: "Benny9193"
date-released: "2026-07-23"
url: "https://skillstore.io/skills/benny9193-solid-principles/audits/9"
identifiers:
- type: other
value: "skillstore:benny9193-solid-principles:audit:9"
description: "Skillstore immutable audit report identifier"
比較變體
2 個可安裝變體每位作者的技能都保留為獨立的可安裝項目。推薦變體依 Skillstore 證據排序。
為何此變體排名第一
doubleslashse-solid-principles
2026-09-09
Skillstore 評分
評分依據 證據置信度: 高你可以打造什麼
重構 service class
將混雜的職責拆分為聚焦的 services、validators、repositories 和 report generators。
檢視物件導向設計
使用 SOLID 檢查清單找出緊密耦合、過於寬泛的 interfaces,以及脆弱的繼承。
教授設計原則
透過簡單的 TypeScript 範例和實用的警示訊號說明每項原則。
試試這些提示
用簡單的方式說明 Single Responsibility Principle。提供一個小範例,以及一個 class 違反它的跡象。
檢視這個 class design 是否違反 SOLID。指出可能的原則、說明風險,並建議聚焦的重構方式。
協助我使用 SOLID principles 重構這個 object-oriented module。保持設計簡單,並說明每個取捨。
依照 SOLID principles 比較兩個 proposed designs。突顯 extension points、substitution risks、dependency direction,以及 over-engineering risk。
最佳實務
- 當測試困難、變更會連鎖影響,或變化反覆出現時,套用 SOLID。
- 偏好符合既有領域行為與命名的小型 abstractions。
- 確保教學範例安全,尤其是 database input 相關內容。
避免
- 在出現真實變更壓力前,就把每個 method 都拆成新的 class。
- 在 composition 能讓行為合約更清楚時,仍使用 inheritance。
- 將使用 string interpolation 的範例 SQL 複製到 production code。