Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 760531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:43:45+00:00 2026-05-14T15:43:45+00:00

I have a modeled a set of objects that correspond with some real world

  • 0

I have a modeled a set of objects that correspond with some real world
concepts.

TradeDrug, GenericDrug, TradePackage, DrugForm

Underlying the simple object model I am trying to provide is a complex
medical terminology that uses numeric codes to represent relationships
and concepts, all accessible via a REST service – I am trying to
hide away some of that complexity with an object wrapper.

To give a concrete example

I can call

TradeDrug d = Searcher.FindTradeDrug("Zoloft")    or
TradeDrug d = new TradeDrug(34)  

where 34 might be the code for Zoloft. This will consult a remote
server to find out some details about Zoloft. I might then call

GenericDrug generic = d.EquivalentGeneric()
System.Out.WriteLine(generic.ActiveIngredient().Name)

in order to get back the generic drug sertraline as an object (again via a
background REST call to the remote server that has all these drug
details), and then perhaps find its ingredient.

This model works fine and is being used in some applications
that involve data processing.

Recently however I wanted to do
a silverlight application that used and displayed these
objects. The silverlight environment only allows asynchronous
REST/web service calls. I have no problems with how to make the
asychhronous calls – but I am having trouble with what
the design should be for my object construction.

Currently the constructors for my objects do some
REST calls sychronously.

 public TradeDrug(int code)
 {
     form = restclient.FetchForm(code)
     name = restclient.FetchName(code)
     etc..
 }

If I have to use async ‘events’ or ‘actions’ in order to use
the Silverlight web client (I know silverlight can be
forced to be a synchronous client but I am interested in
asychronous approaches), does anyone have an guidance
or best practice for how to structure my objects.

I can pass in an action callback to the constructor

 public TradeDrug(int code, Action<TradeDrug> constructCompleted)
 {

 }

but this then allows the user to have a TradeDrug
object instance before what I want to construct
is actually finished. It also doesn’t support an
‘event’ async pattern because the object doesn’t exist
to add the event to until it is constructed.

Extending that approach might be a factory object that itself
has an asynchronous interface to objects

 factory.GetTradeDrugAsync(code, completedaction)

or with a GetTradeDrugCompleted event?

Does anyone have any recommendations? Does anyone know
how the new Reactive framework might fit in with any
solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:43:45+00:00Added an answer on May 14, 2026 at 3:43 pm

    I would ditch the public constructors and go with async factory methods. It need not be a separate factory object, it could just be static methods on TradeDrug itself, something like:

    public static void LoadByIdAsync(int id) { ... }
    public static void LoadByIdAsync(int id, object userState) { ... }
    public static event LoadByIdCompletedEventHandler LoadByIdCompleted;
    

    The event-based async pattern is described here: http://msdn.microsoft.com/en-us/library/wewwczdw.aspx

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The application that I help support has no real business objects to speak of,
Lets say we have a sql relationship that can be modeled like this using
I have a database application in which a group is modeled like this: TABLE
I have this scenario and I'm not sure exactly how it should be modeled
Working on an app where I have a large collections of managed objects against
I have two entities, projects and users. These are modeled in Rails using Mongoid
I have modeled an AJAX search after this example a long time ago. I
Here is my problem with simplified example. I have two entities modeled from SQL
Well, I have been beating my head over this one for some time now,
I have a one-to-many relationship modeled using join table: create table t1 (id int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.