This document outlines the gaps and inconsistencies found in the PatternKit library and the remediation plan to achieve 100% consistent, fluent, GoF-compliant implementations across all 23 design patterns.
| Pattern | Sync Result | Sync Action | Async Result | Async Action | in Params |
|---|---|---|---|---|---|
| Creational | |||||
| Abstract Factory | Yes | N/A | No | N/A | No |
| Builder | Yes | N/A | No | N/A | No |
| Factory | Yes | N/A | No | N/A | Yes |
| Prototype | Yes | N/A | No | N/A | No |
| Singleton | Yes | N/A | No | N/A | N/A |
| Structural | |||||
| Adapter | Yes | No | No | No | Yes |
| Bridge | Yes | No | No | No | Yes |
| Composite | Yes | No | No | No | Yes |
| Decorator | Yes | No | No | No | NO |
| Facade | Yes | No | No | No | Yes |
| Flyweight | Yes | N/A | No | N/A | Yes |
| Proxy | Yes | No | No | No | NO |
| Behavioral | |||||
| Chain | ResultChain | ActionChain | No | No | Yes |
| Command | Yes | N/A | Yes | N/A | Yes |
| Interpreter | Yes | No | No | No | No |
| Iterator/Flow | Yes | N/A | Yes | N/A | N/A |
| Mediator | Yes | N/A | Yes | N/A | Yes |
| Memento | Yes | N/A | No | N/A | No |
| Observer | Yes | N/A | Yes | N/A | Yes |
| State | Yes | N/A | Yes | N/A | Yes |
| Strategy | Yes | Yes | Yes | No | Yes |
| Template | Yes | No | Yes | No | NO |
| TypeDispatcher | Yes | Yes | Yes | Yes | Yes |
| Visitor (Fluent) | Yes | No | No | No | N/A |
- Chain (both Action and Result)
- Decorator
- Proxy
- Composite
- Bridge
- Adapter
- Interpreter
- Template (ActionTemplate)
- Decorator (ActionDecorator)
- Proxy (ActionProxy)
- Composite (ActionComposite)
- Bridge (ActionBridge)
- Adapter (ActionAdapter)
- Interpreter (ActionInterpreter)
- AsyncStrategy (AsyncActionStrategy)
Template<TContext, TResult>usesTContext contextnotin TContextDecorator<TIn, TOut>usesTIn inputnotin TInProxy<TIn, TOut>usesTIn inputnotin TIn
- TypeDispatcher uses
Dispatch() - All other patterns use
Execute() - Visitor uses
Visit()(deprecated, should forward to TypeDispatcher.Dispatch)
- FluentVisitor needs completing (double dispatch with IVisitable)
- Need async variants for FluentVisitor
Update these patterns to use in parameters consistently:
- Template:
Execute(in TContext context) - Decorator:
Execute(in TIn input) - Proxy:
Execute(in TIn input) - Interpreter:
Interpret(in IExpression, in TContext)
Decision: Keep pattern-specific semantics where meaningful:
Execute()- Standard execution (Strategy, Chain, Template, etc.)Dispatch()- Type-based dispatch (TypeDispatcher)Visit()- True visitor pattern (FluentVisitor)Interpret()- Expression evaluation (Interpreter)Transition()- State changes (StateMachine)Create()- Factory methods (Factory, AbstractFactory)
Priority order (based on common async use cases):
- AsyncChain (both AsyncActionChain, AsyncResultChain)
- AsyncDecorator
- AsyncProxy
- AsyncInterpreter
- AsyncComposite
- AsyncBridge
- AsyncAdapter
- AsyncFactory (for async creation)
- AsyncAbstractFactory
- ActionTemplate / AsyncActionTemplate
- ActionDecorator / AsyncActionDecorator
- ActionProxy / AsyncActionProxy
- AsyncActionStrategy
- ActionComposite / AsyncActionComposite
- ActionBridge / AsyncActionBridge
- ActionAdapter / AsyncActionAdapter
- ActionInterpreter / AsyncActionInterpreter
- Complete FluentVisitor with full double-dispatch support
- Add AsyncFluentVisitor
- Add ActionFluentVisitor
- Add AsyncActionFluentVisitor
For each new variant:
- Add comprehensive unit tests
- Add BDD-style scenario tests
- Update XML documentation
- Add usage examples
- Fix
inparameter consistency in Template, Decorator, Proxy - Add AsyncActionStrategy (completes Strategy family)
- Add ActionTemplate / AsyncActionTemplate
- Tests for above
- AsyncActionChain
- AsyncResultChain
- AsyncDecorator
- ActionDecorator / AsyncActionDecorator
- Tests for above
- AsyncProxy
- ActionProxy / AsyncActionProxy
- AsyncInterpreter
- ActionInterpreter / AsyncActionInterpreter
- Tests for above
- AsyncComposite / ActionComposite / AsyncActionComposite
- AsyncBridge / ActionBridge / AsyncActionBridge
- AsyncAdapter / ActionAdapter / AsyncActionAdapter
- Tests for above
- Complete FluentVisitor
- AsyncFluentVisitor
- ActionFluentVisitor / AsyncActionFluentVisitor
- Tests for above
- API consistency review
- Documentation updates
- Example updates
- Final test pass
- Fluent Builder Pattern: All patterns use
.Create()→Builder→.Build() - Immutability: Built instances are immutable and thread-safe
- Allocation-light: Minimize allocations on hot paths
inParameters: Useinfor read-only struct parametersrefParameters: Userefonly when mutation is required (e.g., StateMachine state)- Delegates: Define pattern-specific delegate types for clarity
- Try Pattern: Provide
TryXxx()variants that don't throw - Async/Await: Use
ValueTaskfor potentially synchronous completions - Cancellation: Accept
CancellationTokenin async variants - Naming:
{Pattern}<T>,Action{Pattern}<T>,Async{Pattern}<T>,AsyncAction{Pattern}<T>
src/PatternKit.Core/
├── Behavioral/
│ ├── {Pattern}/
│ │ ├── {Pattern}.cs # Sync result variant
│ │ ├── Action{Pattern}.cs # Sync action variant
│ │ ├── Async{Pattern}.cs # Async result variant
│ │ └── AsyncAction{Pattern}.cs # Async action variant
- All 23 GoF patterns implemented
- All patterns have consistent sync/async and result/action variants where applicable
- All patterns use
inparameters consistently (Note: Hooks need mutable context - correct design) - All patterns have fluent builder APIs
- All patterns are immutable and thread-safe after Build()
- All patterns have comprehensive tests
- All patterns have XML documentation
- All tests pass on net8.0, net9.0, net10.0
- AsyncActionStrategy - Async action strategy pattern
- ActionTemplate - Sync action template method pattern
- AsyncActionTemplate - Async action template method pattern
- AsyncResultChain - Async result chain (first-match-wins)
- AsyncActionChain - Async action chain (middleware-style)
- ActionDecorator - Sync action decorator
- AsyncDecorator - Async result decorator
- AsyncActionDecorator - Async action decorator
- ActionProxy - Sync action proxy
- AsyncProxy - Async result proxy
- AsyncActionProxy - Async action proxy
- AsyncInterpreter - Async expression interpreter
- ActionInterpreter - Sync action interpreter
- AsyncActionInterpreter - Async action interpreter
- AsyncComposite - Async composite pattern
- ActionComposite - Sync action composite
- AsyncActionComposite - Async action composite
- AsyncBridge - Async bridge pattern
- ActionBridge - Sync action bridge
- AsyncActionBridge - Async action bridge
- AsyncAdapter - Async adapter pattern
- IAsyncVisitable - Interface for async visitable elements
- IAsyncVisitor - Interface for async visitors
- AsyncFluentVisitor - Async fluent visitor
- AsyncFluentActionVisitor - Async action visitor
- Total Tests: 1,579 tests (344 PatternKit.Tests × 3 frameworks + 21 Generator.Tests × 3 + 167 Examples.Tests × 3)
- All Passing: net8.0, net9.0, net10.0
src/PatternKit.Core/Behavioral/Strategy/AsyncActionStrategy.cs
src/PatternKit.Core/Behavioral/Template/ActionTemplate.cs
src/PatternKit.Core/Behavioral/Template/AsyncActionTemplate.cs
src/PatternKit.Core/Behavioral/Chain/AsyncResultChain.cs
src/PatternKit.Core/Behavioral/Chain/AsyncActionChain.cs
src/PatternKit.Core/Structural/Decorator/ActionDecorator.cs
src/PatternKit.Core/Structural/Decorator/AsyncDecorator.cs
src/PatternKit.Core/Structural/Decorator/AsyncActionDecorator.cs
src/PatternKit.Core/Structural/Proxy/ActionProxy.cs
src/PatternKit.Core/Structural/Proxy/AsyncProxy.cs
src/PatternKit.Core/Structural/Proxy/AsyncActionProxy.cs
src/PatternKit.Core/Behavioral/Interpreter/AsyncInterpreter.cs
src/PatternKit.Core/Behavioral/Interpreter/ActionInterpreter.cs
src/PatternKit.Core/Behavioral/Interpreter/AsyncActionInterpreter.cs
src/PatternKit.Core/Structural/Composite/AsyncComposite.cs
src/PatternKit.Core/Structural/Composite/ActionComposite.cs
src/PatternKit.Core/Structural/Composite/AsyncActionComposite.cs
src/PatternKit.Core/Structural/Bridge/AsyncBridge.cs
src/PatternKit.Core/Structural/Bridge/ActionBridge.cs
src/PatternKit.Core/Structural/Bridge/AsyncActionBridge.cs
src/PatternKit.Core/Structural/Adapter/AsyncAdapter.cs
src/PatternKit.Core/Behavioral/Visitor/IAsyncVisitable.cs
src/PatternKit.Core/Behavioral/Visitor/IAsyncVisitor.cs
src/PatternKit.Core/Behavioral/Visitor/AsyncFluentVisitor.cs
test/PatternKit.Tests/Behavioral/Strategy/AsyncActionStrategyTests.cs
test/PatternKit.Tests/Behavioral/Interpreter/AsyncInterpreterTests.cs
test/PatternKit.Tests/Structural/AsyncCompositeTests.cs
test/PatternKit.Tests/Structural/AsyncBridgeTests.cs