Link to home
Start Free TrialLog in
Avatar of codequest
codequest

asked on

c# ado list vs dictionary

This is asking for some general feedback and suggestions on a code architecture question.  Part of this is me writing it out to make better sense of it.

Starting with the context:

Using VS2013 and SQL 2012, I'm redesigning an app from vb.net / webforms / tableadapters to c# / MVC / "raw" ado (no tableadapters, no Linq, no EntityFramework).   Those design choices are locked.  

The application purpose is to support interactive group collaboration sessions.

I've figured out most of the new technology and I've passed the last major review on the DB redesign.

The Data Access architecture:

The application is going to use a complex "Group Session Data Object" (GSDO).  The GSDO will keep all the "files" for a single group session in one large class object in memory for the duration of the session, along with a lot of control variables.  The "files" will be several collections of objects, logically equivalent to tables and rows.

A largish total data content of a GSDO might be 1MB and a largish number of records in the file with the most records might be 2000, the other main files maybe 200 records.   Since participants will be refreshing the entire collaborative content view frequently, there will be maybe 20 to 100 times more reads than writes.

I've prototyped this in the earlier version, thought it through a dozen times with respect to performance, server capacity cost etc.

One last point that is somewhat relevant:  this version will be one step past the prototype.  I'm not able to carry it into full volume use without partnering or contracting with professional developers.  This version needs to be able to support maybe 1000 active group sessions of 10 people each.   I'd like to write it to be as expandable and performant as possible, however, I only really have to get it to be "good enough".

The complication starts here:

I'm looking at using Codetrigger to generate dataobject layer and business object layer.  Codetrigger can be found in the VS Tools offerings and at codetrigger.com.

The generated code looks good, much more thorough and sophisticated than I would do on my own.

I've got one major question remaining.

Codetrigger (CT) generates business objects that are based on typed Lists.

Everything I read says that I can get much better performance by using Dictionaries.

So, I've got a few alternatives:

Option 1)  Just use Lists
     > Dictionaries are way faster.  Most the content display will be via display work files json'd to the client.  The work files are created via specialized data-structuring indexes of record IDs.  So the display fetch will be "read the index, and give me the associated dictionary entries".  This should be very fast compared to using a List to find the record by ID.  Building the indexes will require looking up parent ids and related record ids, again, direct id fetches, good for dictionaries.  Only occasionally will there be a complex search on the content of the dictionaries (i.e. "where this1 = that1 and this2=that2").
 
Option 2)  write my own BO layer, i.e. just use the CT DAO layer.
    >  way lot of work compared to using the CT BO layer.

Option 3)  Write a utility program to diddle the generated code BO layer to have it use dictionaries instead of lists.
     >  undermines the purpose of the generated code, if I modify the DB
     >  could spend a lot of time fooling around with this
     >  seems feasible technically

Option 4)  Write an extra data access "layer" in the code to convert the Lists to Dictionaries and visa versa.
    > disk reads (DB > CT DAO > CT BO > Convert List to Dictionary) will be almost exclusively during loading the GSDOs.  Again, sequence will be determined by the specialized indexes that will be built on demand, so the List objects and their IDs can just be tossed into the Dictionary in a single pass.
    > disk writes will be only occasional compared to the screen refresh reads from the GSDO.  Disk writes will involve taking a "row" object from the dictionary and handing it to the chain of  CT BO > CT DAO > DB.   CT BO is set up to accept those row objects for all I/O functions.
    >  building, manipulating and using the individual row content within the business logic won't be affected;  I'll use the provided CT BO classes without any changes or workarounds.

Option 5)  start with option 4 and then convert it to option 3 later.

Option 6)  find another ADO generator that creates BO dictionaries
     >  Codetrigger is free, has about 5000 downloads from VS Tools, and is part of what appears to be a healthy company
     >  I have not located a comparable product that was free or even close to free.

If I had to decide right now, I'd probably go with option 4, because it seems easier and less likely to break.

Any thoughts about these options would be appreciated.

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of AndyAinscow
AndyAinscow
Flag of Switzerland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of codequest
codequest

ASKER

Good point, thanks.