patternsfactory
Factory Pattern pattern for C development
Installation
Follow the repository instructions for this skill and your agent. Review the files and dependencies before adding it to your workflow.
View source ↗GuidesSkill instructions
Factory Pattern
Function that encapsulates object creation, returning an allocated and initialized struct. Centralizes construction logic and hides allocation details from callers.
ikigai Application
Current usage:
-
ik_scrollback_create()- creates scrollback buffer -
ik_mark_create()- creates checkpoint marks -
ik_input_parser_create()- creates input parser
Convention: Use *_create() for heap allocation (caller owns), *_init() for initializing pre-allocated memory.
With ik_env_t: Factories should receive ik_env_t *env as first parameter for access to logger, config, and clock during construction.
Testing: Factories enable injecting dependencies at creation time rather than reaching for globals.
Examples
Read the usage examples in the source repository.
View source ↗Source history
- Indexed on
- 2026-01-20
- Index updated
- 2026-01-26
- Branch
- main
Index and sync dates describe this directory. View the source repository for code history.
GitHub ↗chat Comments (0)
Sign in to join the discussion and leave a comment.
No comments yet. Be the first to share your thoughts!