From 0bab0905b38d09b89784e78759ffa50881b9d3a8 Mon Sep 17 00:00:00 2001 From: Govind Kushwaha <83280091+G0V1NDK@users.noreply.github.com> Date: Sat, 31 Jan 2026 15:00:15 +0530 Subject: [PATCH 1/3] Add SKILLS.md for best practices in OFBiz development This document outlines best practices and patterns for developing services in the Apache OFBiz framework, focusing on maintainability, performance, security, and consistency. It includes guidelines on workflow, service naming, logging, component dependencies, transactions, error handling, and more. --- .../bestpractices/skills-md-prompt.md | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 ofbiz-framework/bestpractices/skills-md-prompt.md diff --git a/ofbiz-framework/bestpractices/skills-md-prompt.md b/ofbiz-framework/bestpractices/skills-md-prompt.md new file mode 100644 index 00000000..1e7216d9 --- /dev/null +++ b/ofbiz-framework/bestpractices/skills-md-prompt.md @@ -0,0 +1,118 @@ +# SKILLS.md for Apache OFBiz Framework + +This document outlines best practices and patterns for developing services in the Apache OFBiz framework. It focuses on day-to-day development choices to ensure maintainable, performant, secure, and consistent code. Practices are derived from official documentation, community resources, and patterns in core components. + +## Workflow & Process +- **Definition First Policy**: Always define the service in `servicedef/services.xml` first, specifying inputs/outputs. Seek user/peer approval before implementing in Java/Groovy to align on interfaces. +- **Atomic Change Policy**: For refactors or optimizations, make one logical change at a time. Test and verify each before proceeding to minimize regressions. + +## Service Naming Best Practices +- Use consistent verbs from the codebase (e.g., create, update, delete, find, get, calculate, process). Avoid new verbs; reference established ones in `org.apache.ofbiz.service` or components. +- Use domain nouns from entity names in CamelCase (e.g., Party, Order, Product). +- Service name format: `verbEntityName` (e.g., `createParty`) or fully qualified (e.g., `party.createParty`). +- For scheduled services (jobs): + - Job names in UPPER_SNAKE_CASE with domain and qualifier (e.g., `ORDER_PROCESSING_JOB`). + - Use fully qualified `serviceName` in definitions. + - Define required parameters in `servicedef/services.xml`. + - For UI-visible jobs, seed associated entities like Product or Category. + +## Logging (Structured Messages) +- Format: `[Entity] [Context] - [Action/Outcome/Issue]`. +- Allowed phrases: not found, missing required field, invalid field, not allowed, already in state, not eligible, missing data, external call failed, no data, partial result, skipped, operation succeeded. +- Log levels indicate severity (e.g., INFO for success, ERROR for failures); avoid [Error] prefixes. +- Include primary keys, identifiers, and state for traceability. +- Use `Debug.logInfo()` or equivalents from `org.apache.ofbiz.base.util.Debug`. + +## Component Dependencies +- Call services/entities only from components in `ofbiz-component.xml` via ``. +- Add dependencies before cross-component calls. +- Core components (e.g., entity, service engines) are implicit. +- Ensure `component-load.xml` orders loading for plugins/custom components. + +## Service Implementation (MiniLang/XML vs Java/Groovy) +- Prefer MiniLang/XML for simple services in `servicedef/services.xml` for declarativity. +- Use Java/Groovy only for complex/performance-critical logic (e.g., via `engine="java"` or `engine="groovy"`). +- In XML, use `