Serialize, then deserialize, vs. deserialize, then serialize: Which order and why?

Working for a new company and I'm learning how they do what they do and why they do it. I've noticed that when setting u the sorting for their grids, they sometimes DE-serialize then serialize, and sometimes they do the opposite. I have done sorting on grids before in C# but have not had to use serialization or DE-serialization so, I'm just trying to get a better understanding of when and why you would want to use this technique? If a brief summary of this can be given that will suffice, otherwise some links on why and why the order matters would be great. Thanks in advance.
LVL 1
Michael SterlingWeb Applications DeveloperAsked:
Who is Participating?
 
it_saigeConnect With a Mentor DeveloperCommented:
In general, Serialization is used when transmitting objects across application boundaries (a.k.a. application domains).  The recipient application is then responsible for Deserializing the object.  In most situations, the serializing application will provide a mapping of the serialized object (it is extremely rare for the serializing entity not to provide a mapping).  As I do not know the make-up of your code-base and/or network landscape, I can only guess as to their reasoning.  It is likely that the ui, api and service are separate application domains and are therefore serializing/deserializing as a matter of course.

-saige-
1
 
AndyAinscowFreelance programmer / ConsultantCommented:
I don't see why that should have anything to do with sorting.
1
 
it_saigeDeveloperCommented:
Neither do I Andy, but you never can tell, what if they sort in the db query rather than in the ui (silly, I know but stranger things have happened)...  ;)

-saige-
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
AndyAinscowFreelance programmer / ConsultantCommented:
Sorting in the DB query itself makes perfect sense.  DB's can index fields and sorting on an indexed field is very efficient (unlike sorting on unindexed fields).  But the DB drivers should take care of the grunt working in making any data available to the app in a suitable format.
1
 
Kyle AbrahamsConnect With a Mentor Senior .Net DeveloperCommented:
Serialization is just putting things into a pre-determined format so that it can be constructed and deconstructed as need be.  You serialize (pack) the object when you're sending information and you deserialize (unpack) the object when you receive data to use in your application.

Hope that makes sense.
1
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
I think I'm gonna close this question as I've gotten some good feedback, and thank you in advance to those who contributed. What I noticed (to your points Kyle & it_saige), is that, in the example that I've been given to model from, they are De-serializing the data into an object, and then, after sorting they serialize and put the same data into a session variable before continuing on to determine which direction to sort the column that has been clicked etc. So, Kyle/it_saige, by your explanation(s) above, they unpacked it into an object first, but then packed it [in]to a session variable which is "sending" the data to a different [storage] location. The utility that pulls the data is from a data access layer which, in this case,  is definitely a separate application domain. Would that be an accurate way to apply your explanation?
0
 
it_saigeConnect With a Mentor DeveloperCommented:
If they are in fact sending the serialized data/packed object to another destination outside of the realm of session then yes, this is normal and your explanation would accurately express this process.

-saige-
2
 
Kyle AbrahamsConnect With a Mentor Senior .Net DeveloperCommented:
Just to add a little more to the process:

Get data from the data layer.  Deserialze (unpack) the data so the program can sort it (the class handles how to sort its objects).  Could also work with the class as needed.  Then pack it up and throw it into memory this way the application can read it on the next post back.

FYI:  All session data must be serializable so that it can be stored in memory and re-read as needed.
1
 
Michael SterlingWeb Applications DeveloperAuthor Commented:
Thanks to all who contributed.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.