@totaland/create-starter-kit 1.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (228) hide show
  1. package/README.md +130 -18
  2. package/bin/index.js +109 -21
  3. package/package.json +2 -2
  4. package/templates/backend/.github/agents/ /360/237/216/255 planner.agent.md" +92 -0
  5. package/templates/backend/.github/agents/api-architect.agent.md +41 -0
  6. package/templates/backend/.github/agents/code-reviewer.agent.md +26 -0
  7. package/templates/backend/.github/agents/code-simplifier.agent.md +41 -0
  8. package/templates/backend/.github/agents/code-skeptic.agent.md +74 -0
  9. package/templates/backend/.github/agents/docs-specialist.agent.md +25 -0
  10. package/templates/backend/.github/agents/implementation-plan.agent.md +160 -0
  11. package/templates/backend/.github/agents/janitor.agent.md +90 -0
  12. package/templates/backend/.github/agents/ms-sql-dba.agent.md +25 -0
  13. package/templates/backend/.github/agents/plan.agent.md +115 -0
  14. package/templates/backend/.github/agents/planner.agent.md +15 -0
  15. package/templates/backend/.github/agents/playwright-tester.agent.md +13 -0
  16. package/templates/backend/.github/agents/postgresql-dba.agent.md +18 -0
  17. package/templates/backend/.github/agents/prd.agent.md +202 -0
  18. package/templates/backend/.github/agents/research-technical-spike.agent.md +170 -0
  19. package/templates/backend/.github/agents/software-engineer-agent-v1.agent.md +165 -0
  20. package/templates/backend/.github/agents/task-planner.agent.md +375 -0
  21. package/templates/backend/.github/agents/task-researcher.agent.md +255 -0
  22. package/templates/backend/.github/agents/tdd-green.agent.md +60 -0
  23. package/templates/backend/.github/agents/tdd-red.agent.md +60 -0
  24. package/templates/backend/.github/agents/tdd-refactor.agent.md +85 -0
  25. package/templates/backend/.github/agents/tech-debt-remediation-plan.agent.md +50 -0
  26. package/templates/backend/.github/agents/typescript-mcp-expert.agent.md +91 -0
  27. package/templates/backend/.github/agents/ultimate-thinking-beastmode.agent.md +644 -0
  28. package/templates/backend/.github/agents//360/237/216/255 generator.agent.md" +264 -0
  29. package/templates/backend/.github/agents//360/237/216/255 healer.agent.md" +44 -0
  30. package/templates/backend/.github/agents//360/237/216/255 pom.agent.md" +308 -0
  31. package/templates/backend/.github/instructions/a11y.instructions.md +369 -0
  32. package/templates/backend/.github/instructions/ms-sql-dba.instructions.md +25 -0
  33. package/templates/backend/.github/instructions/object-calisthenics.instructions.md +302 -0
  34. package/templates/backend/.github/instructions/performance-optimization.instructions.md +420 -0
  35. package/templates/backend/.github/instructions/playwright-python.instructions.md +62 -0
  36. package/templates/backend/.github/instructions/playwright-typescript.instructions.md +86 -0
  37. package/templates/backend/.github/instructions/security-and-owasp.instructions.md +51 -0
  38. package/templates/backend/.github/instructions/self-explanatory-code-commenting.instructions.md +162 -0
  39. package/templates/backend/.github/instructions/spec-driven-workflow-v1.instructions.md +323 -0
  40. package/templates/backend/.github/instructions/sql-sp-generation.instructions.md +74 -0
  41. package/templates/backend/.github/instructions/task-implementation.instructions.md +190 -0
  42. package/templates/backend/.github/instructions/typescript-mcp-server.instructions.md +228 -0
  43. package/templates/backend/.github/prompts/ai-prompt-engineering-safety-review.prompt.md +229 -0
  44. package/templates/backend/.github/prompts/architecture-blueprint-generator.prompt.md +321 -0
  45. package/templates/backend/.github/prompts/breakdown-epic-arch.prompt.md +65 -0
  46. package/templates/backend/.github/prompts/breakdown-epic-pm.prompt.md +57 -0
  47. package/templates/backend/.github/prompts/breakdown-feature-implementation.prompt.md +127 -0
  48. package/templates/backend/.github/prompts/breakdown-feature-prd.prompt.md +60 -0
  49. package/templates/backend/.github/prompts/breakdown-plan.prompt.md +508 -0
  50. package/templates/backend/.github/prompts/copilot-instructions-blueprint-generator.prompt.md +293 -0
  51. package/templates/backend/.github/prompts/create-agentsmd.prompt.md +248 -0
  52. package/templates/backend/.github/prompts/create-github-issue-feature-from-specification.prompt.md +27 -0
  53. package/templates/backend/.github/prompts/create-github-issues-feature-from-implementation-plan.prompt.md +27 -0
  54. package/templates/backend/.github/prompts/create-github-issues-for-unmet-specification-requirements.prompt.md +35 -0
  55. package/templates/backend/.github/prompts/create-implementation-plan.prompt.md +156 -0
  56. package/templates/backend/.github/prompts/create-llms.prompt.md +209 -0
  57. package/templates/backend/.github/prompts/create-specification.prompt.md +126 -0
  58. package/templates/backend/.github/prompts/create-technical-spike.prompt.md +230 -0
  59. package/templates/backend/.github/prompts/csharp-nunit.prompt.md +71 -0
  60. package/templates/backend/.github/prompts/ef-core.prompt.md +76 -0
  61. package/templates/backend/.github/prompts/folder-structure-blueprint-generator.prompt.md +404 -0
  62. package/templates/backend/.github/prompts/gen-specs-as-issues.prompt.md +165 -0
  63. package/templates/backend/.github/prompts/generate-custom-instructions-from-codebase.prompt.md +239 -0
  64. package/templates/backend/.github/prompts/java-junit.prompt.md +64 -0
  65. package/templates/backend/.github/prompts/memory-merger.prompt.md +107 -0
  66. package/templates/backend/.github/prompts/multi-stage-dockerfile.prompt.md +46 -0
  67. package/templates/backend/.github/prompts/playwright-automation-fill-in-form.prompt.md +29 -0
  68. package/templates/backend/.github/prompts/playwright-explore-website.prompt.md +19 -0
  69. package/templates/backend/.github/prompts/playwright-generate-test.prompt.md +19 -0
  70. package/templates/backend/.github/prompts/postgresql-code-review.prompt.md +214 -0
  71. package/templates/backend/.github/prompts/postgresql-optimization.prompt.md +406 -0
  72. package/templates/backend/.github/prompts/project-workflow-analysis-blueprint-generator.prompt.md +294 -0
  73. package/templates/backend/.github/prompts/prompt-builder.prompt.md +142 -0
  74. package/templates/backend/.github/prompts/remember.prompt.md +125 -0
  75. package/templates/backend/.github/prompts/review-and-refactor.prompt.md +15 -0
  76. package/templates/backend/.github/prompts/sql-code-review.prompt.md +303 -0
  77. package/templates/backend/.github/prompts/sql-optimization.prompt.md +298 -0
  78. package/templates/backend/.github/prompts/suggest-awesome-github-copilot-agents.prompt.md +72 -0
  79. package/templates/backend/.github/prompts/suggest-awesome-github-copilot-chatmodes.prompt.md +71 -0
  80. package/templates/backend/.github/prompts/suggest-awesome-github-copilot-collections.prompt.md +149 -0
  81. package/templates/backend/.github/prompts/suggest-awesome-github-copilot-instructions.prompt.md +88 -0
  82. package/templates/backend/.github/prompts/suggest-awesome-github-copilot-prompts.prompt.md +71 -0
  83. package/templates/backend/.github/prompts/technology-stack-blueprint-generator.prompt.md +242 -0
  84. package/templates/backend/.github/prompts/typescript-mcp-server-generator.prompt.md +90 -0
  85. package/templates/backend/.github/prompts/update-implementation-plan.prompt.md +157 -0
  86. package/templates/backend/.github/prompts/update-markdown-file-index.prompt.md +76 -0
  87. package/templates/backend/Project_Folders_Structure_Blueprint.md +529 -0
  88. package/templates/backend/README.md +99 -0
  89. package/templates/backend/biome.json +45 -0
  90. package/{template → templates/backend}/drizzle.config.ts +1 -1
  91. package/{template → templates/backend}/package.json +9 -4
  92. package/templates/backend/pnpm-lock.yaml +4240 -0
  93. package/templates/backend/src/features/health/health.test.ts +23 -0
  94. package/{template → templates/backend}/src/features/health/index.ts +1 -0
  95. package/templates/backend/src/features/health/schemas.ts +29 -0
  96. package/templates/backend/src/features/orders/controller.ts +18 -0
  97. package/templates/backend/src/features/orders/index.ts +10 -0
  98. package/templates/backend/src/features/orders/schemas.ts +62 -0
  99. package/{template → templates/backend}/src/index.ts +3 -36
  100. package/templates/backend/src/lib/openapi.ts +25 -0
  101. package/templates/backend/src/lib/validateRequest.test.ts +84 -0
  102. package/templates/backend/src/lib/validateRequest.ts +72 -0
  103. package/{template → templates/backend}/tsconfig.json +2 -2
  104. package/{template → templates/backend}/vitest.config.ts +8 -1
  105. package/templates/frontend/.env.example +7 -0
  106. package/templates/frontend/.github/agents/ /360/237/216/255 planner.agent.md" +92 -0
  107. package/templates/frontend/.github/agents/api-architect.agent.md +41 -0
  108. package/templates/frontend/.github/agents/code-reviewer.agent.md +26 -0
  109. package/templates/frontend/.github/agents/code-simplifier.agent.md +41 -0
  110. package/templates/frontend/.github/agents/code-skeptic.agent.md +74 -0
  111. package/templates/frontend/.github/agents/docs-specialist.agent.md +25 -0
  112. package/templates/frontend/.github/agents/implementation-plan.agent.md +160 -0
  113. package/templates/frontend/.github/agents/janitor.agent.md +90 -0
  114. package/templates/frontend/.github/agents/ms-sql-dba.agent.md +25 -0
  115. package/templates/frontend/.github/agents/plan.agent.md +115 -0
  116. package/templates/frontend/.github/agents/planner.agent.md +15 -0
  117. package/templates/frontend/.github/agents/playwright-tester.agent.md +13 -0
  118. package/templates/frontend/.github/agents/postgresql-dba.agent.md +18 -0
  119. package/templates/frontend/.github/agents/prd.agent.md +202 -0
  120. package/templates/frontend/.github/agents/research-technical-spike.agent.md +170 -0
  121. package/templates/frontend/.github/agents/software-engineer-agent-v1.agent.md +165 -0
  122. package/templates/frontend/.github/agents/task-planner.agent.md +375 -0
  123. package/templates/frontend/.github/agents/task-researcher.agent.md +255 -0
  124. package/templates/frontend/.github/agents/tdd-green.agent.md +60 -0
  125. package/templates/frontend/.github/agents/tdd-red.agent.md +60 -0
  126. package/templates/frontend/.github/agents/tdd-refactor.agent.md +85 -0
  127. package/templates/frontend/.github/agents/tech-debt-remediation-plan.agent.md +50 -0
  128. package/templates/frontend/.github/agents/typescript-mcp-expert.agent.md +91 -0
  129. package/templates/frontend/.github/agents/ultimate-thinking-beastmode.agent.md +644 -0
  130. package/templates/frontend/.github/agents//360/237/216/255 generator.agent.md" +264 -0
  131. package/templates/frontend/.github/agents//360/237/216/255 healer.agent.md" +44 -0
  132. package/templates/frontend/.github/agents//360/237/216/255 pom.agent.md" +308 -0
  133. package/templates/frontend/.github/instructions/a11y.instructions.md +369 -0
  134. package/templates/frontend/.github/instructions/ms-sql-dba.instructions.md +25 -0
  135. package/templates/frontend/.github/instructions/object-calisthenics.instructions.md +302 -0
  136. package/templates/frontend/.github/instructions/performance-optimization.instructions.md +420 -0
  137. package/templates/frontend/.github/instructions/playwright-python.instructions.md +62 -0
  138. package/templates/frontend/.github/instructions/playwright-typescript.instructions.md +86 -0
  139. package/templates/frontend/.github/instructions/security-and-owasp.instructions.md +51 -0
  140. package/templates/frontend/.github/instructions/self-explanatory-code-commenting.instructions.md +162 -0
  141. package/templates/frontend/.github/instructions/spec-driven-workflow-v1.instructions.md +323 -0
  142. package/templates/frontend/.github/instructions/sql-sp-generation.instructions.md +74 -0
  143. package/templates/frontend/.github/instructions/task-implementation.instructions.md +190 -0
  144. package/templates/frontend/.github/instructions/typescript-mcp-server.instructions.md +228 -0
  145. package/templates/frontend/.github/prompts/ai-prompt-engineering-safety-review.prompt.md +229 -0
  146. package/templates/frontend/.github/prompts/architecture-blueprint-generator.prompt.md +321 -0
  147. package/templates/frontend/.github/prompts/breakdown-epic-arch.prompt.md +65 -0
  148. package/templates/frontend/.github/prompts/breakdown-epic-pm.prompt.md +57 -0
  149. package/templates/frontend/.github/prompts/breakdown-feature-implementation.prompt.md +127 -0
  150. package/templates/frontend/.github/prompts/breakdown-feature-prd.prompt.md +60 -0
  151. package/templates/frontend/.github/prompts/breakdown-plan.prompt.md +508 -0
  152. package/templates/frontend/.github/prompts/copilot-instructions-blueprint-generator.prompt.md +293 -0
  153. package/templates/frontend/.github/prompts/create-agentsmd.prompt.md +248 -0
  154. package/templates/frontend/.github/prompts/create-github-issue-feature-from-specification.prompt.md +27 -0
  155. package/templates/frontend/.github/prompts/create-github-issues-feature-from-implementation-plan.prompt.md +27 -0
  156. package/templates/frontend/.github/prompts/create-github-issues-for-unmet-specification-requirements.prompt.md +35 -0
  157. package/templates/frontend/.github/prompts/create-implementation-plan.prompt.md +156 -0
  158. package/templates/frontend/.github/prompts/create-llms.prompt.md +209 -0
  159. package/templates/frontend/.github/prompts/create-specification.prompt.md +126 -0
  160. package/templates/frontend/.github/prompts/create-technical-spike.prompt.md +230 -0
  161. package/templates/frontend/.github/prompts/csharp-nunit.prompt.md +71 -0
  162. package/templates/frontend/.github/prompts/ef-core.prompt.md +76 -0
  163. package/templates/frontend/.github/prompts/folder-structure-blueprint-generator.prompt.md +404 -0
  164. package/templates/frontend/.github/prompts/gen-specs-as-issues.prompt.md +165 -0
  165. package/templates/frontend/.github/prompts/generate-custom-instructions-from-codebase.prompt.md +239 -0
  166. package/templates/frontend/.github/prompts/java-junit.prompt.md +64 -0
  167. package/templates/frontend/.github/prompts/memory-merger.prompt.md +107 -0
  168. package/templates/frontend/.github/prompts/multi-stage-dockerfile.prompt.md +46 -0
  169. package/templates/frontend/.github/prompts/playwright-automation-fill-in-form.prompt.md +29 -0
  170. package/templates/frontend/.github/prompts/playwright-explore-website.prompt.md +19 -0
  171. package/templates/frontend/.github/prompts/playwright-generate-test.prompt.md +19 -0
  172. package/templates/frontend/.github/prompts/postgresql-code-review.prompt.md +214 -0
  173. package/templates/frontend/.github/prompts/postgresql-optimization.prompt.md +406 -0
  174. package/templates/frontend/.github/prompts/project-workflow-analysis-blueprint-generator.prompt.md +294 -0
  175. package/templates/frontend/.github/prompts/prompt-builder.prompt.md +142 -0
  176. package/templates/frontend/.github/prompts/remember.prompt.md +125 -0
  177. package/templates/frontend/.github/prompts/review-and-refactor.prompt.md +15 -0
  178. package/templates/frontend/.github/prompts/sql-code-review.prompt.md +303 -0
  179. package/templates/frontend/.github/prompts/sql-optimization.prompt.md +298 -0
  180. package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-agents.prompt.md +72 -0
  181. package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-chatmodes.prompt.md +71 -0
  182. package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-collections.prompt.md +149 -0
  183. package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-instructions.prompt.md +88 -0
  184. package/templates/frontend/.github/prompts/suggest-awesome-github-copilot-prompts.prompt.md +71 -0
  185. package/templates/frontend/.github/prompts/technology-stack-blueprint-generator.prompt.md +242 -0
  186. package/templates/frontend/.github/prompts/typescript-mcp-server-generator.prompt.md +90 -0
  187. package/templates/frontend/.github/prompts/update-implementation-plan.prompt.md +157 -0
  188. package/templates/frontend/.github/prompts/update-markdown-file-index.prompt.md +76 -0
  189. package/templates/frontend/README.md +199 -0
  190. package/templates/frontend/biome.json +45 -0
  191. package/templates/frontend/components.json +22 -0
  192. package/templates/frontend/index.html +13 -0
  193. package/templates/frontend/package.json +44 -0
  194. package/templates/frontend/pnpm-lock.yaml +2011 -0
  195. package/templates/frontend/postcss.config.js +6 -0
  196. package/templates/frontend/public/vite.svg +1 -0
  197. package/templates/frontend/src/App.css +42 -0
  198. package/templates/frontend/src/App.tsx +17 -0
  199. package/templates/frontend/src/assets/react.svg +1 -0
  200. package/templates/frontend/src/components/layout/layout.component.tsx +31 -0
  201. package/templates/frontend/src/components/menu-toggle-icon.tsx +53 -0
  202. package/templates/frontend/src/components/ui/button.tsx +57 -0
  203. package/templates/frontend/src/docs/RECOMMENDED_LIBRARIES.md +226 -0
  204. package/templates/frontend/src/docs/SETUP_SUMMARY.md +162 -0
  205. package/templates/frontend/src/hooks/use-scroll.ts +21 -0
  206. package/templates/frontend/src/index.css +121 -0
  207. package/templates/frontend/src/lib/api-client.ts +46 -0
  208. package/templates/frontend/src/lib/utils.ts +6 -0
  209. package/templates/frontend/src/main.tsx +30 -0
  210. package/templates/frontend/src/pages/about/about.page.tsx +50 -0
  211. package/templates/frontend/src/pages/home/home.page.tsx +43 -0
  212. package/templates/frontend/tailwind.config.js +59 -0
  213. package/templates/frontend/tsconfig.app.json +41 -0
  214. package/templates/frontend/tsconfig.json +13 -0
  215. package/templates/frontend/tsconfig.node.json +26 -0
  216. package/templates/frontend/vite.config.ts +14 -0
  217. package/template/.env.example +0 -8
  218. package/template/AGENTS.md +0 -23
  219. package/template/ARCHITECTURE.md +0 -53
  220. package/template/ORDER_SYSTEM.md +0 -93
  221. package/template/biome.json +0 -3
  222. package/template/src/features/orders/controller.ts +0 -13
  223. package/template/src/features/orders/index.ts +0 -7
  224. /package/{template → templates/backend}/knip.json +0 -0
  225. /package/{template → templates/backend}/playwright.config.ts +0 -0
  226. /package/{template → templates/backend}/pnpm-workspace.yaml +0 -0
  227. /package/{template → templates/backend}/src/features/health/controller.ts +0 -0
  228. /package/{template → templates/backend}/tsconfig.build.json +0 -0
@@ -0,0 +1,302 @@
1
+ ---
2
+ applyTo: '**/*.{cs,ts,java}'
3
+ description: Enforces Object Calisthenics principles for business domain code to ensure clean, maintainable, and robust code
4
+ ---
5
+ # Object Calisthenics Rules
6
+
7
+ > ⚠️ **Warning:** This file contains the 9 original Object Calisthenics rules. No additional rules must be added, and none of these rules should be replaced or removed.
8
+ > Examples may be added later if needed.
9
+
10
+ ## Objective
11
+ This rule enforces the principles of Object Calisthenics to ensure clean, maintainable, and robust code in the backend, **primarily for business domain code**.
12
+
13
+ ## Scope and Application
14
+ - **Primary focus**: Business domain classes (aggregates, entities, value objects, domain services)
15
+ - **Secondary focus**: Application layer services and use case handlers
16
+ - **Exemptions**:
17
+ - DTOs (Data Transfer Objects)
18
+ - API models/contracts
19
+ - Configuration classes
20
+ - Simple data containers without business logic
21
+ - Infrastructure code where flexibility is needed
22
+
23
+ ## Key Principles
24
+
25
+
26
+ 1. **One Level of Indentation per Method**:
27
+ - Ensure methods are simple and do not exceed one level of indentation.
28
+
29
+ ```csharp
30
+ // Bad Example - this method has multiple levels of indentation
31
+ public void SendNewsletter() {
32
+ foreach (var user in users) {
33
+ if (user.IsActive) {
34
+ // Do something
35
+ mailer.Send(user.Email);
36
+ }
37
+ }
38
+ }
39
+ // Good Example - Extracted method to reduce indentation
40
+ public void SendNewsletter() {
41
+ foreach (var user in users) {
42
+ SendEmail(user);
43
+ }
44
+ }
45
+ private void SendEmail(User user) {
46
+ if (user.IsActive) {
47
+ mailer.Send(user.Email);
48
+ }
49
+ }
50
+
51
+ // Good Example - Filtering users before sending emails
52
+ public void SendNewsletter() {
53
+ var activeUsers = users.Where(user => user.IsActive);
54
+
55
+ foreach (var user in activeUsers) {
56
+ mailer.Send(user.Email);
57
+ }
58
+ }
59
+ ```
60
+ 2. **Don't Use the ELSE Keyword**:
61
+
62
+ - Avoid using the `else` keyword to reduce complexity and improve readability.
63
+ - Use early returns to handle conditions instead.
64
+ - Use Fail Fast principle
65
+ - Use Guard Clauses to validate inputs and conditions at the beginning of methods.
66
+
67
+ ```csharp
68
+ // Bad Example - Using else
69
+ public void ProcessOrder(Order order) {
70
+ if (order.IsValid) {
71
+ // Process order
72
+ } else {
73
+ // Handle invalid order
74
+ }
75
+ }
76
+ // Good Example - Avoiding else
77
+ public void ProcessOrder(Order order) {
78
+ if (!order.IsValid) return;
79
+ // Process order
80
+ }
81
+ ```
82
+
83
+ Sample Fail fast principle:
84
+ ```csharp
85
+ public void ProcessOrder(Order order) {
86
+ if (order == null) throw new ArgumentNullException(nameof(order));
87
+ if (!order.IsValid) throw new InvalidOperationException("Invalid order");
88
+ // Process order
89
+ }
90
+ ```
91
+
92
+ 3. **Wrapping All Primitives and Strings**:
93
+ - Avoid using primitive types directly in your code.
94
+ - Wrap them in classes to provide meaningful context and behavior.
95
+
96
+ ```csharp
97
+ // Bad Example - Using primitive types directly
98
+ public class User {
99
+ public string Name { get; set; }
100
+ public int Age { get; set; }
101
+ }
102
+ // Good Example - Wrapping primitives
103
+ public class User {
104
+ private string name;
105
+ private Age age;
106
+ public User(string name, Age age) {
107
+ this.name = name;
108
+ this.age = age;
109
+ }
110
+ }
111
+ public class Age {
112
+ private int value;
113
+ public Age(int value) {
114
+ if (value < 0) throw new ArgumentOutOfRangeException(nameof(value), "Age cannot be negative");
115
+ this.value = value;
116
+ }
117
+ }
118
+ ```
119
+
120
+ 4. **First Class Collections**:
121
+ - Use collections to encapsulate data and behavior, rather than exposing raw data structures.
122
+ First Class Collections: a class that contains an array as an attribute should not contain any other attributes
123
+
124
+ ```csharp
125
+ // Bad Example - Exposing raw collection
126
+ public class Group {
127
+ public int Id { get; private set; }
128
+ public string Name { get; private set; }
129
+ public List<User> Users { get; private set; }
130
+
131
+ public int GetNumberOfUsersIsActive() {
132
+ return Users
133
+ .Where(user => user.IsActive)
134
+ .Count();
135
+ }
136
+ }
137
+
138
+ // Good Example - Encapsulating collection behavior
139
+ public class Group {
140
+ public int Id { get; private set; }
141
+ public string Name { get; private set; }
142
+
143
+ public GroupUserCollection userCollection { get; private set; } // The list of users is encapsulated in a class
144
+
145
+ public int GetNumberOfUsersIsActive() {
146
+ return userCollection
147
+ .GetActiveUsers()
148
+ .Count();
149
+ }
150
+ }
151
+ ```
152
+
153
+ 5. **One Dot per Line**:
154
+ - Limit the number of method calls in a single line to improve readability and maintainability.
155
+
156
+ ```csharp
157
+ // Bad Example - Multiple dots in a single line
158
+ public void ProcessOrder(Order order) {
159
+ var userEmail = order.User.GetEmail().ToUpper().Trim();
160
+ // Do something with userEmail
161
+ }
162
+ // Good Example - One dot per line
163
+ public void ProcessOrder(Order order) {
164
+ var user = order.User;
165
+ var email = user.GetEmail();
166
+ var userEmail = email.ToUpper().Trim();
167
+ // Do something with userEmail
168
+ }
169
+ ```
170
+
171
+ 6. **Don't abbreviate**:
172
+ - Use meaningful names for classes, methods, and variables.
173
+ - Avoid abbreviations that can lead to confusion.
174
+
175
+ ```csharp
176
+ // Bad Example - Abbreviated names
177
+ public class U {
178
+ public string N { get; set; }
179
+ }
180
+ // Good Example - Meaningful names
181
+ public class User {
182
+ public string Name { get; set; }
183
+ }
184
+ ```
185
+
186
+ 7. **Keep entities small (Class, method, namespace or package)**:
187
+ - Limit the size of classes and methods to improve code readability and maintainability.
188
+ - Each class should have a single responsibility and be as small as possible.
189
+
190
+ Constraints:
191
+ - Maximum 10 methods per class
192
+ - Maximum 50 lines per class
193
+ - Maximum 10 classes per package or namespace
194
+
195
+ ```csharp
196
+ // Bad Example - Large class with multiple responsibilities
197
+ public class UserManager {
198
+ public void CreateUser(string name) { /*...*/ }
199
+ public void DeleteUser(int id) { /*...*/ }
200
+ public void SendEmail(string email) { /*...*/ }
201
+ }
202
+
203
+ // Good Example - Small classes with single responsibility
204
+ public class UserCreator {
205
+ public void CreateUser(string name) { /*...*/ }
206
+ }
207
+ public class UserDeleter {
208
+ public void DeleteUser(int id) { /*...*/ }
209
+ }
210
+
211
+ public class UserUpdater {
212
+ public void UpdateUser(int id, string name) { /*...*/ }
213
+ }
214
+ ```
215
+
216
+
217
+ 8. **No Classes with More Than Two Instance Variables**:
218
+ - Encourage classes to have a single responsibility by limiting the number of instance variables.
219
+ - Limit the number of instance variables to two to maintain simplicity.
220
+ - Do not count ILogger or any other logger as instance variable.
221
+
222
+ ```csharp
223
+ // Bad Example - Class with multiple instance variables
224
+ public class UserCreateCommandHandler {
225
+ // Bad: Too many instance variables
226
+ private readonly IUserRepository userRepository;
227
+ private readonly IEmailService emailService;
228
+ private readonly ILogger logger;
229
+ private readonly ISmsService smsService;
230
+
231
+ public UserCreateCommandHandler(IUserRepository userRepository, IEmailService emailService, ILogger logger, ISmsService smsService) {
232
+ this.userRepository = userRepository;
233
+ this.emailService = emailService;
234
+ this.logger = logger;
235
+ this.smsService = smsService;
236
+ }
237
+ }
238
+
239
+ // Good: Class with two instance variables
240
+ public class UserCreateCommandHandler {
241
+ private readonly IUserRepository userRepository;
242
+ private readonly INotificationService notificationService;
243
+ private readonly ILogger logger; // This is not counted as instance variable
244
+
245
+ public UserCreateCommandHandler(IUserRepository userRepository, INotificationService notificationService, ILogger logger) {
246
+ this.userRepository = userRepository;
247
+ this.notificationService = notificationService;
248
+ this.logger = logger;
249
+ }
250
+ }
251
+ ```
252
+
253
+ 9. **No Getters/Setters in Domain Classes**:
254
+ - Avoid exposing setters for properties in domain classes.
255
+ - Use private constructors and static factory methods for object creation.
256
+ - **Note**: This rule applies primarily to domain classes, not DTOs or data transfer objects.
257
+
258
+ ```csharp
259
+ // Bad Example - Domain class with public setters
260
+ public class User { // Domain class
261
+ public string Name { get; set; } // Avoid this in domain classes
262
+ }
263
+
264
+ // Good Example - Domain class with encapsulation
265
+ public class User { // Domain class
266
+ private string name;
267
+ private User(string name) { this.name = name; }
268
+ public static User Create(string name) => new User(name);
269
+ }
270
+
271
+ // Acceptable Example - DTO with public setters
272
+ public class UserDto { // DTO - exemption applies
273
+ public string Name { get; set; } // Acceptable for DTOs
274
+ }
275
+ ```
276
+
277
+ ## Implementation Guidelines
278
+ - **Domain Classes**:
279
+ - Use private constructors and static factory methods for creating instances.
280
+ - Avoid exposing setters for properties.
281
+ - Apply all 9 rules strictly for business domain code.
282
+
283
+ - **Application Layer**:
284
+ - Apply these rules to use case handlers and application services.
285
+ - Focus on maintaining single responsibility and clean abstractions.
286
+
287
+ - **DTOs and Data Objects**:
288
+ - Rules 3 (wrapping primitives), 8 (two instance variables), and 9 (no getters/setters) may be relaxed for DTOs.
289
+ - Public properties with getters/setters are acceptable for data transfer objects.
290
+
291
+ - **Testing**:
292
+ - Ensure tests validate the behavior of objects rather than their state.
293
+ - Test classes may have relaxed rules for readability and maintainability.
294
+
295
+ - **Code Reviews**:
296
+ - Enforce these rules during code reviews for domain and application code.
297
+ - Be pragmatic about infrastructure and DTO code.
298
+
299
+ ## References
300
+ - [Object Calisthenics - Original 9 Rules by Jeff Bay](https://www.cs.helsinki.fi/u/luontola/tdd-2009/ext/ObjectCalisthenics.pdf)
301
+ - [ThoughtWorks - Object Calisthenics](https://www.thoughtworks.com/insights/blog/object-calisthenics)
302
+ - [Clean Code: A Handbook of Agile Software Craftsmanship - Robert C. Martin](https://www.oreilly.com/library/view/clean-code-a/9780136083238/)