Skip to content

Commit

Permalink
rule updates for CTF (#9612)
Browse files Browse the repository at this point in the history
Update rule.md
  • Loading branch information
sethdaily authored Nov 28, 2024
1 parent 98b25f9 commit 2542f1e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions rules/avoid-generic-names/rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Generic names like “manager”, "helper", “processor”, “data”, and “

## Why generic names are problematic

Words like "manager" and "processor" imply something that handles various tasks, which can make it tempting to pile unrelated responsibilities into one class. "Helper" makes this worse as it becomes a catch-all for a collection of disorganized functionality.Names like "data" or "info" are similarly ambiguous, as they could apply to nearly anything, from a database connection to a simple string. Specific names are always preferable, as they make the code easier to understand and prevent code bloat from accumulating unrelated functionality.
Words like "manager" and "processor" imply something that handles various tasks, which can make it tempting to pile unrelated responsibilities into one class. "Helper" makes this worse as it becomes a catch-all for a collection of disorganized functionality. Names like "data" or "info" are similarly ambiguous, as they could apply to nearly anything, from a database connection to a simple string. Specific names are always preferable, as they make the code easier to understand and prevent code bloat from accumulating unrelated functionality.

:::greybox
`OrderManager` - a class to handle orders in an e-commerce system
Expand All @@ -41,12 +41,14 @@ Bad example - while this name suggests that it might have something to do with o
:::

:::greybox
`OrderCreator` - specifically creating orders
`OrderCreator` - specifically creating orders

`ShippingOrderHandler` or `OrderShipmentService` - specifically handles only one aspect - sending orders for shipment
:::
:::good
Good example - This name directly reflects its purpose, making it immediately clear what the class is responsible for
:::
:::


:::greybox
`UserData` - tracking the data for each user account
Expand Down

0 comments on commit 2542f1e

Please sign in to comment.