Delphi: Transporting Objects to remote computers
- by pr0wl
Hallo.
I am writing a tier2 ordering software for network usage. So we have client and server.
On the client I create Objects of TBest in which the Product ID, the amount and the user who orders it are saved. (So this is a item of an Order).
An order can have multiple items and those are saved in an array to later send the created order to the server. The class that holds the array is called TBestellung.
So i created both
TBest.toString: string;
and
TBest.fromString(source: string): TBest;
Now, I send the toString result to the server via socket and on the server I create the object using fromString (its parsing the attributes received). This works as intended.
Question:
Is there a better and more elegant way to do that? Serialisation is a keyword, yes, but isn't that awful / difficult when you serialize an object (TBestellung in this case) that contains an Array of other Objects (TBest in this case)?
//Small amendment: Before it gets asked. Yes I should create an extra (static) class for toString and fromString because otherwise the server needs to create an "empty" TBest in order to be able to use fromString.