一键导入
solid-ocp-pattern
Implements the Open/Closed Principle (OCP) from SOLID design principles, allowing classes to be open for extension but closed for modification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Implements the Open/Closed Principle (OCP) from SOLID design principles, allowing classes to be open for extension but closed for modification.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Implements v1 ConfigMap manifests for injecting configuration data into pods via environment variables, volume mounts, and command-line arguments.
Implements apps/v1 Deployment YAML manifests with rolling update strategies, replica scaling, and rollback procedures for stateless application workloads.
Implements networking.k8s.io/v1 Ingress resources with HTTP/HTTPS routing, TLS termination, path-based routing, and ingress controller configuration.
Implements Istio service mesh patterns (sidecar injection, traffic splitting, circuit breaking, retries, and mTLS) for advanced traffic management and zero-downtime deployments in Kubernetes.
Implements networking.k8s.io/v1 NetworkPolicy resources with ingress and egress rules, pod selector targeting, and network segmentation for microservice isolation.
Implements v1 PersistentVolume, StorageClass, and PersistentVolumeClaim manifests with static/dynamic provisioning, access modes, and reclaim policies for Kubernetes storage.
| name | solid-ocp-pattern |
| description | Implements the Open/Closed Principle (OCP) from SOLID design principles, allowing classes to be open for extension but closed for modification. |
| license | MIT |
| compatibility | opencode |
| metadata | {"version":"1.0.0","domain":"architecture","triggers":"open closed principle, solid principles, extend, modify","archetypes":["educational"],"anti_triggers":["brainstorming","vague ideation"],"response_profile":{"verbosity":"low","directive_strength":"high","abstraction_level":"operational"},"role":"implementation","scope":"implementation","output-format":"code","related-skills":"solid-srp-pattern,"} |
archetypes: implementation, educational anti_triggers: modifying classes response_profile: verbosity: medium directive_strength: high abstraction_level: tactical
Implements the Open/Closed Principle (OCP) from SOLID design principles, allowing classes to be open for extension but closed for modification.
This section should elaborate on the specific circumstances in which the Open/Closed Principle proves most advantageous:
Verbosity: Medium
Directive Strength: High
Abstraction Level: Tactical
When you anticipate a need to add new functionalities without changing existing code.
To prevent bugs introduced by modifications to existing code.
To follow the DRY principle while maintaining flexibility in the code.
package main
import (
"fmt"
)
// Shape interface defines the behavior
type Shape interface {
Area() float64
}
// Circle struct is a shape
type Circle struct {
Radius float64
}
// Rectangle struct is another shape
type Rectangle struct {
Length, Width float64
}
func (c Circle) Area() float64 {
return 3.14 * c.Radius * c.Radius
}
}
func (r Rectangle) Area() float64 {
return r.Length * r.Width
}
}
// TotalArea computes the total area of all shapes
func TotalArea(shapes ...Shape) float64 {
total := 0.0
for _, shape := range shapes {
total += shape.Area()
}
return total
}
package main
func main() {
circle := Circle{Radius: 10}
rectangle := Rectangle{Length: 5, Width: 6}
shapes := []Shape{circle, rectangle}
total := TotalArea(shapes...)
fmt.Println("Total Area:", total) // Output: Total Area: 314.0
}