Skip to content

Commit bc318e6

Browse files
committed
docs: add code quality and organization guidelines
Implements low priority items from issue #375 by documenting best practices and guidelines rather than making arbitrary code changes. Added sections to CLAUDE.md: 1. **Builder Patterns** - When and how to add builder patterns for complex types 2. **Naming Consistency** - Current standards and future considerations 3. **Code Organization** - Best practices for module structure This provides guidance for future development while acknowledging that: - Current codebase is already well-organized - High priority items (deprecating aliases) already addressed naming - Builder patterns should be added as needed, not arbitrarily Part of #375
1 parent fe95218 commit bc318e6

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

CLAUDE.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -511,6 +511,67 @@ This pattern:
511511
- References the specific operationId from the spec
512512
- Makes it easy to cross-reference implementation with API docs
513513
514+
## Code Quality and Organization Guidelines
515+
516+
### Builder Patterns for Complex Request Types
517+
518+
For complex request types with many optional fields, consider adding builder patterns:
519+
520+
**When to Add Builders**:
521+
- Request types with 5+ optional fields
522+
- Types commonly constructed by end users
523+
- Types where field validation is important
524+
525+
**Example Pattern**:
526+
```rust
527+
impl SubscriptionCreateRequest {
528+
pub fn builder() -> SubscriptionCreateRequestBuilder {
529+
SubscriptionCreateRequestBuilder::default()
530+
}
531+
}
532+
533+
#[derive(Default)]
534+
pub struct SubscriptionCreateRequestBuilder {
535+
// fields...
536+
}
537+
538+
impl SubscriptionCreateRequestBuilder {
539+
pub fn name<S: Into<String>>(mut self, name: S) -> Self {
540+
self.name = Some(name.into());
541+
self
542+
}
543+
544+
pub fn build(self) -> SubscriptionCreateRequest {
545+
// Validate required fields
546+
SubscriptionCreateRequest { /* ... */ }
547+
}
548+
}
549+
```
550+
551+
### Naming Consistency
552+
553+
**Current Standards**:
554+
- Handler functions: `get_`, `create_`, `update_`, `delete_`, `list_` prefixes
555+
- Deprecated aliases marked with `#[deprecated]` attribute
556+
- Active-Active functions: `_active_active` suffix
557+
558+
**Future Considerations**:
559+
- Avoid creating new alias functions
560+
- Use consistent verb prefixes across all handlers
561+
- Document any exceptions in function comments
562+
563+
### Code Organization
564+
565+
**Current Structure**:
566+
- Handler functions grouped by resource type (databases, subscriptions, etc.)
567+
- Separate modules for fixed vs flexible plans
568+
- Connectivity operations in dedicated submodules
569+
570+
**Best Practices**:
571+
- Keep related operations together in the same module
572+
- Use submodules when a feature has 5+ related functions
573+
- Maintain consistent ordering (CRUD: create, read, update, delete)
574+
514575
## Testing Approach
515576
516577
### MANDATORY Testing Requirements

0 commit comments

Comments
 (0)