ขอนำเสนอ 72 หลักการพื้นฐานการออกแบบซอฟต์แวร์ (Design Principles) และ 60 ชั้นเชิงทางสถาปัตยกรรมทั่วไป (General Architectural Tactics)
สำหรับ design principles ผมสรุปจากประสบการณ์ที่พบเจออยู่บ่อย ๆ โดยจำแนกเป็นหมวดหมู่ต่าง ๆ ซึ่งบางหลักการฯ ค่อนข้างคาบเกี่ยวมากกว่าหนึ่งหมวดหมู่พอสมควร เอาเป็นว่าไม่ต้องสนใจหมวดหมู่ที่ผมจำแนกนักละกันนะครับ เพราะผมรีบพิมพ์เลยไม่ได้อ้างอิงหลักวิชาการอะไร จำแนกโดยใช้วิจารณญาณล้วน ซึ่งบางหลักการฯ ก็ไม่เชิงเป็น design principles เสียทีเดียว แต่ขอรวบยอดมารวมด้วยกันเพราะเห็นว่าสำคัญและน่าจะไปด้วยกันได้ นอกจากนี้ผมยังนำ design principles จากงานออกแบบสถาปัตยกรรมก่อสร้างมาประกอบด้วย คือ harmony, balance, unity, contrast, emphasis, rhythm เพราะเห็นว่าสามารถประยุกต์กับงานออกแบบซอฟต์แวร์ได้ สำหรับ design principles และ general software architectural tactics ทั้งหมดที่นำมาเล่าสู่กันนั้น ในความจริงยังมีมากกว่านี้อีก ไว้มีโอกาสจะนำมาเล่าสู่เพิ่มเติมกัน เช่น หลักการพื้นฐานและชั้นเชิงการออกแบบด้าน security, interoperability, scalability, portability ฯลฯ หรือหลักการออกแบบซอฟต์แวร์เชิงพาณิชย์ (commercial software) ซึ่งมีหลากหลายกลเม็ดเด็ดพราย
สำหรับ general architectural tactics ทั้ง 60 ชั้นเชิง (tactic) ผมอ้างอิงจากหนังสือ ‘Software Architecture in Practice Second Edition‘ เขียนโดย Len Bass, Paul Clements และ Rick Kazman แต่จริง ๆ ยังมีมากกว่านี้อีกจากที่กล่าวก่อนหน้า ไว้มีโอกาสจะนำมาเล่าสู่กันเพิ่มเติมครับ
ใจจริงตอนแรกตั้งใจว่าจะอธิบายและยกตัวอย่างประกอบด้วย แต่ไป ๆ มา ๆ ชักเยอะ หากต้องอธิบายสงสัยคงยาวมิใช่น้อย และที่สำคัญคงต้องใช้เวลาพิมพ์มิใช่น้อย เลยขอยกมาเล่าสู่กันแบบแห้ง ๆ ไปก่อนละกันนะครับ ไว้มีโอกาสและจังหวะจะอธิบายพร้อมยกตัวอย่างประกอบให้นะครับ
นอกจากสิ่งที่นำมาเล่าสู่กันแล้ว ยังมีประเด็นสำคัญอื่นที่จำเป็นต่อการออกแบบซอฟต์แวร์และสถาปัตยกรรมซอฟต์แวร์อีก เช่น design patterns, architectural patterns, pattern ประเภทต่าง ๆ เช่น analysis patterns, anti patterns ฯลฯ และยังมี design styles และ architectural styles ซึ่งมีความสำคัญไม่ยิ่งหย่อนไปกว่ากัน และมีความสัมพันธ์กันอีกด้วย ลองดูรูปด้านล่างที่แสดงความสัมพันธ์กันนะครับ โดยอ้างอิงจากหนังสือ ‘SOA Principles of Service Design‘ เขียนโดย Thomas Erl แต่เสียดายที่ไม่มีแสดงให้เห็นว่าสัมพันธ์กับ architectural styles, architectural tactics กันอย่างไร แต่ถ้าอยากรู้ก็ไปตามดูรายละเอียดได้ในหนังสือ ‘Software Architecture in Practice Second Edition‘ ครับ
ความสัมพันธ์ระหว่าง Design Principles กับองค์ประกอบต่างๆ – 1
ความสัมพันธ์ระหว่าง Design Patterns กับองค์ประกอบต่างๆ – 2
ใครสนใจหลักการหรือชั้นเชิงไหนก็ค้นคว้าเพิ่มเติมได้จากอินเทอร์เน็ตและตำราต่าง ๆ ได้เลยครับ เพราะถือเป็น ‘general principles and tactics’ หรือจะสอบถามมาก็ได้ครับ หรือใครมีความคิดเห็นอื่นหรือหลักการหรือชั้นเชิงการออกแบบอื่น ๆ ที่นอกเหนือจากนี้ก็แนะนำกันเข้ามานะครับ
ลองทำความเข้าใจและฝึกฝนใช้สิ่งเหล่านี้ให้คล่องกันนะครับ ใครเป็น system analyst หรือ software architect ควรรู้จักและใช้สิ่งเหล่านี้เป็นนะครับ เอ้า…มาเริ่มกันเลย
Design Principles
General Design Principles
- Abstraction and Implementation
- Functionality and Non-Functionality
- Recursive
- Data Structure and Type ConversionObject-Oriented Design Principles
- Boundary
- Coupling
- Cohesion
- Modularity
- Association
- Aggregation and Composition
- Dependency
- Realization
- Hierarchy
- Classification
- Inheritance
- Generalization
- Specialization
- Information Hinding
- Encapsulation
- Contract
- Capability, Operation and Method
- Polymorphism
- Binding
- Primitive
- Reusability
- Granularity
- Passing (เช่น Pass by Value and Pass by Reference)
- Construction and Destruction
- Dispatch and DelegateGeneral Architectural Design Principles
- Balance
- Rhythm
- Harmony
- Unity
- Contrast
- EmphasisArchitectural Design Principles
- Monitoring
- Prototype
- Template
- Activation and Passivation
- Balance Concerns
- Visitor Object/Service
- Filter
- Verification and Validation
- Application Flow Control
- Logic Allocation
- Separation of Concerns
- Distribution
- Skin and Gut
- Connect to External Service/Resource
- Interoperation
- Discoverability
- Autonomy
- Single Point of Failure
- Fault Handling
- State Machine
- Communication Path
- Service Access Channel
- Simultaneous Access and Scheduling
- Divide and Conquer
- Synchronous, Asynchronous and Message Routing
- Audit Trail
- Persistent Handling
- Information Exchange
- Configureability
- Authentication and Authorization
- Localization (L10N) and Internationalization (I18N)
- Sensitivity and Trade-OffTransaction Design Principles
- Unit of Work
- Atomicity
- Consistency
- Isolation
- Durability
General Architectural Tactics
Availability Tactics
Fault Detection
- Ping/Echo
- Heartbeat
- Exception
Fault Recovery
- Voting
- Redundancy
- Spare
- Resynchronization
- Checkpoint/Rollback
Fault Prevention
- Remove from Service
- Transactions
- Process Monitor
Modifiability Tactics
Localize Modification
- Maintain Semantic Coherence
- Anticipate Expected Changes
- Generalize the Module
- Limit Possible Options
Prevent Ripple Effects
- Syntax of Data and Service
- Semantic of Data and Service
- Sequence of Data and Service
- Identity of an Interface of A
- Location of A
- Quality of Service/Data Provided by A
- Existence of A
- Resource Behavior of A
- Hide Information
- Restrict Communication Paths
- Use an Intermediary
- data (syntax)
- service (syntax)
- identity of an interface
- location of A
- resource behavior of A or resource controlled by A
- existence of A
Defer Binding Time
- Runtime Registration
- Configuration
- Polymorphism
- Component Replacement
- Adherence to Defined Protocols
Performance Tactics
Resource Demand
- Increase Computational Efficiency
- Reduce Computational Overhead
- Manage Event Rate
- Control Frequency of Sampling
- Bound Execution Times
- Bound Execution Sizes
Resource Management
- Introduce Concurrency
- Maintain Multiple Copies of Either Data or Computations
- Increase Available Resources
Resource Arbitration
- First-In/First-Out (FIFO)
- Fixed Priority Scheduling
- semantic importance
- deadline monotonic
- rate monotonic
- Dynamic Priority Scheduling
- round robin
- earliest deadline first
- Static Scheduling
Security Tactics
Resisting Attacks
- Authenticate Users
- Authorize Users
- Maintain Data Confidentiality
- Maintain Integrity
- Limit Access
Detect Attacks
- Intrusion Detection System (IDS)
Recovering from Attacks
- Restoring State
- Identifying an Attacker (Audit Trail)
Testability Tactics
Input/Output
- Record/Playback
- Separate Interface from Implementation
- Specialize Access Routes/Interfaces
Internal Monitoring
- Built-In Monitors
Usability Tactics
Run-Time Tactics
- Maintain a Model of the Task
- Maintain a Model of the User
- Maintain a Model of the System
Design-Time Tactics
- Separate User Interface
หวังว่าคงพอเป็นประโยชน์แก่นักออกแบบและพัฒนาซอฟต์แวร์บ้างไม่มากก็น้อยนะครับ ไว้จะแสดงรายชื่อหนังสือด้านการออกแบบซอฟต์แวร์และสถาปัตยกรรมซอฟต์แวร์เด็ด ๆ ให้ในวันหน้านะครับ
ณรงค์ จันทร์สร้อย
๑ สิงหาคม พ.ศ. ๒๕๕๓