Skip to content

Commit

Permalink
Merge pull request #6271 from HSLdevcom/factory-method-naming
Browse files Browse the repository at this point in the history
Update method naming conventions
  • Loading branch information
optionsome authored Nov 27, 2024
2 parents 48fa3f3 + bbcac59 commit 211aafb
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion doc/dev/decisionrecords/NamingConventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,16 @@ Here is a list of common prefixes used and what to expect.
| `findStop(Criteria criteria) : Optional<Stop>` | Find one or zero stops; return `Optional`. |
| `findStops(Criteria criteria) : List/Stream<Stop>` | Find 0, 1, or many stops; return a Collection or Stream (List is preferred). |
| `listStops() : List/Stream<Stop>` | List ALL stops in context; return a Collection or Stream (List is preferred). |
| `withStop(Stop stop) : Builder` | Set Stop in builder, replacing existing value; return `this` builder. |
| `initStop(Stop stop) : void` | Set property _once_; a second call throws an exception. |
| `createStop(String name, ...) : Stop` | Factory methods for creating objects should start with `create` prefix. |
| | See (Builder Conventions)[RecordsPOJOsBuilders.md#builder-conventions] for creating objects with builders. |
| `addStop(Stop stop) : void/Builder` | Add a Stop to a collection of Stops. |
| `addStops(Collection<Stop> stops) : void/Builder` | Add set of Stops to existing set. |
| `withBike(Consumer<BikePref.Builder> body) : Builder` | For nested builders, use lambdas. |
| `withStop(Stop stop) : Builder` | Set Stop in builder, replacing existing value; return `this` builder. |
| `of(FeedScopedId id) : Builder` | Create new builder instance from `Stop` class. |
| `copyOf() : Builder` | Initialize a new builder instance from `Stop` instance with identical values. |
| `build() : Stop` | Finish building stop with a builder. |

These prefixes are also "allowed" but not preferred; they have some kind of negative "force" to
them.
Expand Down

0 comments on commit 211aafb

Please sign in to comment.