OOP : Naming a class [closed]
In my application I have a Market with a bunch of Levels. Each level开发者_StackOverflow has Goods and Supply Chain Operations. Now, I'm stuck figuring out how to name a family of classes that populate Levels with these entities. I know that a name is important in a sesnse that a proper one makes code self-commented. Since stuff like Builder, Creator, Factory, Provider is more of a wiring classes, I'm out of ideas. Right now I use Market_Level_Goods_Filler, but it feels odd. Any suggestions? Thanks
Personally I like to use the Command/Query pattern as a way of dividing and managing these types of classes.
In this context your class would be a command. Either way I'd be naming my classes to describe what they actually do.
What does your class do?
Perhaps PopulateLevelsForMarket
or PopulateMarketLevels
? (PopulateLevelsForMarketCommand if using the Command/Query paradigm).
If you're finding it hard to name your class because it does a variety of different things you'll want to start thinking about breaking up the class so that the focus is one a single set of operations.
Think SRP at the class level.
Your description makes me think that Market
and Level
make up a Gang of Four Composite pattern. Is that correct?
I would say that a LevelBuilder
or LevelLoader
would be appropriate. I don't understand your "more of a wiring classes" [sic] objection. Populate sounds like a creation verb to me.
精彩评论