1

I have a conceptual problem that I want feedback on. First and foremost, the layout of my system. It contains a server, with many clients connected to it.

The clients get fed data from the server at variable intervals. At the moment, this data contains: Faults, Warnings and Locations. Faults, Warnings and Locations all contain a variable for "Terminal". The terminal being a PC which may have a fault or warning attached to it.

Now. The admin console wishes to see how many terminals are on the system (essentially in the database) in total. Not a problem! I'm already sending information about all terminals in "Locations". This number is 2 for-loops and a count away (about 7 LOC).

However, here is my conundrum. Is it better to make the server do, essentially "return Terminals COUNT" and send it as part of the payload with Warnings, Errors and Locations, than have the client iterate through some arrays to get the information?

I've been thinking for a while, and while I'm of the impression the server should carry the work, it is some data being sent that is technically "unnecessary".

Is this correct?

5
  • Are these mobile devices? The more logic you can put on the server, the fewer changes you'll need to make to the mobile app which may require approval by your app store.
    – JeffO
    Commented Aug 26, 2015 at 12:29
  • There's a desktop application, and a web portal, so not explicit mobile applications. Commented Aug 26, 2015 at 13:09
  • So the conundrum is lumping necessary information in the same request as your Faults, Warnings and Locations or having a separate request for that information even if you'll need both?
    – Neil
    Commented Aug 26, 2015 at 13:16
  • Not exactly. All the data can be extracted from the current request, but with a bit of processing on the client side. It's about adding another field to the request for easier access/better performance client-side Commented Aug 26, 2015 at 13:24
  • How large are these arrays? If it's under 200 in most instances, let the client do it. A minor optimization isn't worth the increase in program complexity.
    – Neil
    Commented Aug 26, 2015 at 14:05

1 Answer 1

1

How much space would this count take? 10 bytes?

Unless you're trying to compress your payload to an absolute minimum, I would do calculations on a server, and keep logic that can be executed on a server on a server. Makes it a bit easier to maintain, less strain on client devices if it matters, etc.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.