What type of pattern would be used in this case

Posted by Admiral Kunkka on Programmers See other posts from Programmers or by Admiral Kunkka
Published on 2012-12-06T03:49:54Z Indexed on 2012/12/06 5:19 UTC
Read the original article Hit count: 238

Filed under:
|
|

I want to know how to tackle this type of scenario.

We are building a person's background, from scratch, and I want to know, conceptually, how to proceed with a secure object pattern in both design and execution...

I've been reading on Factory patterns, Model-View-Controller types, Dependency injection, Singleton approaches... and I can't seem to grasp or 'fit' these types of designs decisions into what I'm trying to do..

First and foremost, I started with having a big jack-of-all-trades class, then I read some more, and some tips were to make sure your classes only have a single purpose.. which makes sense and I started breaking down certain things into other classes. Okay, cool. Now I'm looking at dependency injection and kind of didn't really know what's going on.

Example/insight of what kind of heirarchy I need to accomplish...

  • class Person needs to access and build from a multitude of different classes.
    • class Culture needs to access a sub-class for culture benefits
    • class Social needs to access class Culture, and other sub-classes
    • class Birth needs to access Social, Culture, and other sub-classes
    • class Childhood/Adolescence/Adulthood need to access everything.

Also, depending on different rolls, this class heirarchy needs to create multiple people as well, such as Family, and their backgrounds using some, if not all, of these same classes. Think of it as a people generator, all random, with backgrounds and things that happen to them. Ageing, death of loved ones, military careers, e.t.c.

Most of the generation is done randomly, making calls to a mt_rand function to pick from most of the selections inside the classes, guaranteeing the data to be absolutely random.

I have most of the bulk-data down, and was looking for some insight from fellow programmers, what do you think?

© Programmers or respective owner

Related posts about design

Related posts about php