开发者

OOP : Naming a class [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜