MudBytes
» MUDBytes Community » Coding Discussions » Coding and Design » data structures in C
Pages: << prev 1, 2 next >>
data structures in C, prototype stuctures
Tyche
Wizard






Group: Members
Posts: 1,059
Joined: May 23, 2006

Go to the bottom of the page Go to the top of the page
#16 Posted Jul 1, 2009, 6:38 pm

In Murk++, I renamed them to Object and ObjectPrototype.  ObjectPrototype does indeed also serve as an object factory.
You'll notice that the state in ObjectPrototype is the initial state (or a seed for the initial state) of an Object. 
While modifying your area files or using OLC changes ObjectPrototype, Objects can be changed by a number of explicit commands like
sset, oset, mset, etc.  And Objects state is also changed by the operation of code, like movement between rooms and containers.
Objects minus the differences between the ObjectPrototype is what is stored in Player files.  Otherwise Objects are destroyed when the
game goes down or reboots. 

That's in the original code mind you, (Murk++ is mostly functionally unchanged Merc 2.2). 
Various other derivatives of Merc/Rom may have modifications.



.........................
http://jlsysinc.gotdns.com/ladybug_laugh2.jpghttp://jlsysinc.gotdns.com/teensymud_250x80.pnghttp://jlsysinc.gotdns.com/palin_calendar.jpg
For now we see through a glass, darkly; but then face to face: now I know in part; but then shall I know even as also I am known.


Justice
Sorcerer




Group: Members
Posts: 310
Joined: May 14, 2006

Go to the bottom of the page Go to the top of the page
#17 Posted Jul 1, 2009, 6:50 pm

There is a reason why I stated quite clearly that what DIKU/Merc (being the code in question) uses is somewhere between a prototype and a factory.  Then later expanded on what exactly both of these design patterns really are.  Which btw, also answers why someone may need a "meta" class.  I also explained that obj_index_data performs other roles than simply object instantiation.  It also provides a single point of access to centralized data.

What I don't understand is... why do you feel the need to repeat exactly what you've said in post #6?

Runter said:
It's already been made clear by 4 or 5 different people what the prototype code is.  I'm pointing out there are other options--and you can still write some function to transfer fields.  Yes, diku does a lot of things a certain way.  That doesn't discount other options.


Runter said:
Just thought I would point out It would have also been fairly easy to simply use obj_data for both prototypes and instantiated objects from those prototypes.  Depending on how your own personal implementation it could mean having useless fields in both but not necessarily.  I think someone, like David pointed out, wanted a metaclass.  And it made sense to create a physical separation of (meta)class from instance.
.........................
In any sufficiently complex system, no one is smart enough to predict every consequence of a seemingly minor change.

Justice
Sorcerer




Group: Members
Posts: 310
Joined: May 14, 2006

Go to the bottom of the page Go to the top of the page
#18 Posted Jul 1, 2009, 7:06 pm

Tyche said:
In Murk++, I renamed them to Object and ObjectPrototype.  ObjectPrototype does indeed also serve as an object factory.
You'll notice that the state in ObjectPrototype is the initial state (or a seed for the initial state) of an Object. 


That's an interesting way to view things that the prototype is a seed for the initial state.  Heh, in my mud I called it item to avoid confusion in what "object" meant in an object oriented language.
.........................
In any sufficiently complex system, no one is smart enough to predict every consequence of a seemingly minor change.

Pages:<< prev 1, 2 next >>

Valid XHTML 1.1! Valid CSS!