Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating different POCO's from a single type
    primarykey
    data
    text
    <p>I'm writing a wrapping library around a <a href="http://en.wikipedia.org/wiki/SCADA" rel="nofollow">SCADA</a> database and I've got a small 'hippy-code-design' question. It involves how I'm converting the supplied DB objects into POCO's.</p> <p>I'm calling the DB using the vendors .NET libraries.</p> <p>When I make calls the DB, it passes back an object of type <code>DBObject</code>. This can represent anything in the database, and as such is quite generic in the information that it holds. Any custom information is accessed from the DB with a <code>DBObject.GetProperty()</code> method call, which requires the connection to the DB to be active.</p> <p>I'm looking to convert this basic <code>DBObject</code> into a variety of different POCO's so that I can pass them around via WCF and other tech.</p> <p>Currently I have a abstract base class called <code>ScadaObject</code> that has a number of base properties that I want all the POCO's to contain and a protected virtual method called <code>InternalFromDBObject(DBObject obj)</code> which performs this creating from the <code>DBObject</code> into the POCO.</p> <p>In my derived types I override this method, call <code>base.InternalFromDBObject(obj)</code> as the first call, then proceed to load any custom/specific information. I then have a static method on the POCO called <code>FromDBObject()</code> which returns a new instance of that POCO.</p> <p>Is this a good way to do things? I'm not hugely experienced in using factories so I'm not sure if they would fit. Is there any other design patterns I could use?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload