Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Who should implement the concurrency - the client or the server  RSS feed

 
Jake Kowalski
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application I have the following potentially long running classes:

  • ScheduleLocalNotificationsOperation
  • UnScheduleLocalNotificationsOperation
  • SyncEventsToDeviceCalendarOperation
  • UnSyncEventsToDeviceCalendarOperation
  • ScheduleLocalNotificationsOperation
  • SaveProductsToLocalStorageImpl


  • and so on.

    Most of these are structured this way:



    Ideally, I would like to design my Operation classes to be concurrency agnostic, and to be able to impose some multithreading policy on them from the outside, like so:



    But this way I should implement some concurrency policy in every client, every time I call those classes.

    On the other hand, I dont want to interrupt the pure logic in those operations by adding concurrency to them, so my question is basically, from design stand point what is the better way to do this, if there is a clearly defined one?

    Can I create an OperationsRunner class that will be called by any client and will execute any Operation using polymorphism and make that class be the only one that deals with concurrency?
     
    Simon Roberts
    Author
    Ranch Hand
    Posts: 176
    9
    Java Linux Netbeans IDE
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Too much code, sorry, I haven't read it. However, purely from a design standpoint, I'd say there are two ways to address this question in general.

    If doing any kind of work in one place results in better responsiveness to the user, then do it wherever that is.

    Otherwise, if all else is equal from a responsiveness perspective, but one location or the other results in fewer network roundtrips and/or less bandwidth use, then do it there.

    If neither of those issues guide you, then if the work being threaded is related to presentation, do it on the client. If it's to do with computing the raw data, do it on the server.

    HTH
     
    • Post Reply Bookmark Topic Watch Topic
    • New Topic
    Boost this thread!