Skip to content

Commit f834db6

Browse files
docs: add interface boundary examples to implementation philosophy (#42)
Add good/bad examples for bypassing vs using public interfaces. Motivated by microsoft/amplifier-app-cli#70. 🤖 Generated with [Amplifier](https://github.com/microsoft/amplifier) Co-authored-by: Amplifier <240397093+microsoft-amplifier@users.noreply.github.com>
1 parent 5fa3616 commit f834db6

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

context/IMPLEMENTATION_PHILOSOPHY.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,25 @@ class EnhancedMcpClient:
295295
# [50+ more lines of complex state tracking and retry logic]
296296
```
297297

298+
### Bad Example: Bypassing Public Interfaces
299+
300+
```python
301+
# Fragile: reaching into internal state instead of using public API
302+
def get_activator(resolver):
303+
bundle_resolver = getattr(resolver, "_bundle", resolver)
304+
activator = getattr(bundle_resolver, "_activator", None)
305+
return activator
306+
# Breaks when implementation changes; extend the interface instead
307+
```
308+
309+
### Good Example: Using Public Interfaces
310+
311+
```python
312+
# If you need access to something, extend the public interface
313+
def get_activator(resolver):
314+
return resolver.get_activator()
315+
```
316+
298317
## Remember
299318

300319
- It's easier to add complexity later than to remove it

0 commit comments

Comments
 (0)