J
Joe Van Dyk
I'm certain that there's some type of a design pattern that neatly
solves my problem, but I dunno what it is.
I need to create Message objects based on on the contents of a string
(that's actually in xml format, but it doesn't really matter).
So, here's an example string (totally unrelated to the actual problem
domain):
Message Type: Dinner
Main Course: Rib Eye Steak
Wine: Red
Another message:
Message Type: Breakfast
Main Course: Eggs
Juice: Orange
So, the structure of each message string contains some similarities and
some differences.
Based on the string, I'd like to create objects that represent each
message. I'm guessing that I'd want some base Message (or, in this
case, Meal) object, and then have classes inherit from that base class
that have their own specific data members.
Would I have some type of a factory that takes a string and returns a
pointer to a Meal object? How could I properly examine the string and
create the proper object inside that factory?
I'm used to Ruby, where this type of thing is fairly easy. But no Ruby
for me.
solves my problem, but I dunno what it is.
I need to create Message objects based on on the contents of a string
(that's actually in xml format, but it doesn't really matter).
So, here's an example string (totally unrelated to the actual problem
domain):
Message Type: Dinner
Main Course: Rib Eye Steak
Wine: Red
Another message:
Message Type: Breakfast
Main Course: Eggs
Juice: Orange
So, the structure of each message string contains some similarities and
some differences.
Based on the string, I'd like to create objects that represent each
message. I'm guessing that I'd want some base Message (or, in this
case, Meal) object, and then have classes inherit from that base class
that have their own specific data members.
Would I have some type of a factory that takes a string and returns a
pointer to a Meal object? How could I properly examine the string and
create the proper object inside that factory?
I'm used to Ruby, where this type of thing is fairly easy. But no Ruby
for me.