Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Factory classes

Name: Anonymous 2005-11-17 4:09

Can somebody explain what are factory classes good for? As in, "why all this shit"? I have the impression factory classes are yet another suit in the Emperor's wardrobe. To me, they always looked like some bored programmer who needs to keep his job and hates the KISS principle decided to make our lives worse.

Name: Anonymous 2005-11-19 5:22

A real case that I have used factories for:

I have made a game engine that has map graphics and "things" that live within the map. Each thing, of course, is its own object instance, and probably from different classes. That's how it is during gameplay, that is. If I'm in a map editor, however, what I want is to start from a "pre-thing" that can be manipulated in a regular and predictable way, rather than having a lot of special cases and wastefully storing more info than necessary within the map.

Thus the factory concept naturally applies. I start from the standpoint of the predictable pre-object instances, then convert them one by one at runtime. This is a case where you really want additional data abstraction so as to ease the flow of the code handling it.

In a lot of cases zero abstractions(and therefore no new classes) are needed; one can adequately and concisely deal with lots of data kept in primitive types. this is my main beef with Java, because it forces on some potentially unnecessary abstraction.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List