Serialization is the process of converting an object into a stream of bytes in order to persist it to memory, a database, or a file. Its main purpose is to save the state of an object in order to be able to recreate it when needed.
Questions tagged [serialization]
140 questions
31
votes
2 answers
Best practices for serialization of DDD aggregates
According to DDD domain logic should not be polluted with technical concerns like serialization, object-relational mapping, etc.
So how do you serialize or map the aggregates' state without publicly exposing it via getters and setters? I have seen…
EagleBeak
- 527
26
votes
6 answers
Java serialization - advantages and disadvantages, use or avoid?
Serialization is used for persistence in Java. It may be okay to persist a few objects using serialization. But, for a large number of objects, ORM, Database etc might be better. It seems that serialization is useful only for small jobs. May be I am…
sky scraper
- 361
26
votes
2 answers
Move from JSON to Protobuf. Is it worth it?
We have REST webservices that can serve XML or JSON (WCF). I'm toying with idea of implementing Protobufs. Why?
PROS
Less load on servers.
Smaller message size - less traffic.
It is easier to switch now than later.
CONS
Need to be…
katit
- 681
- 1
- 7
- 14
24
votes
2 answers
Protobuf design patterns
I am evaluating Google Protocol Buffers for a Java based service (but am expecting language agnostic patterns). I have two questions:
The first is a broad general question:
What patterns are we seeing people use? Said patterns being related to…
Apoorv
- 1,128
21
votes
5 answers
Why should I never ever ever use Java serialization?
I've heard that I should never use Java serialization (Serializable/ObjectInputStream/ObjectOutputStream) because of security. What's the problem?
21
votes
2 answers
Should serialization and deserialization be the responsibility of the class being serialized?
I'm currently in the (re)design phase of several model classes of a C# .NET application. (Model as in M of MVC). The model classes already have plenty of well-designed data, behaviors, and interrelationships. I am rewriting the model from Python…
kdbanman
- 1,447
17
votes
10 answers
Should serialization and deserialization be "atomic" transactions?
I am wondering if serialization and deserialization of classes should always be treated as an "atomic transaction?"
What I mean is, if an error were to occur during the process of serializing or deserializing a member of an object, should the whole…
Patrick Wright
- 789
- 4
- 12
17
votes
2 answers
What happens if we serialize and deserialize two objects which references to each other?
To make it more clear, this is a quick example:
class A implements Serializable { public B b; }
class B implements Serializable { public A a; }
A a = new A();
B b = new B();
a.b = b;
b.a = a;
So what happens if we serialize a and b objects into a…
Seregwethrin
- 353
14
votes
2 answers
Comparing TCP/IP applications vs HTTP applications
I'm interested in developing a large-scale user-facing website that is written in Java.
As for design, I'm thinking of developing independent, modular services that can act as data providers to my main web application.
As for writing these modular…
HiChews123
- 1,123
13
votes
3 answers
Are we queueing and serializing properly?
We process messages through a variety of services (one message will touch probably 9 services before it's done, each doing a specific IO-related function). Right now we have a combination of the worst-case (XML data contract serialization) and…
Bryan B
- 2,814
12
votes
2 answers
Does Serialization preclude the use of Dependency Injection?
Simple question: I understand that Serialization in C# requires default constructors. This would eliminate the possibility of using Constructor injected DI (which is generally the favored style of DI, in my reading[citation needed]). So is it really…
kmote
- 3,372
11
votes
5 answers
How do you fix the wrong-case-sensitivity dictionary setting bug-pattern?
There is a coding anti-pattern I've noticed (while using .Net). You declare a data class, which is supposed to have a dictionary field (or get/set Property), and lets call it 'Properties', for the sake of example. It has a string key type.
…
Tim Lovell-Smith
- 399
10
votes
3 answers
JSON without quotes for keys
I need a textual human readable format which is reasonably compact and version-control friendly to serialize a persistent memory heap. My Bismon system (GPLv3) has such a format (it is textual, human-readable, git-friendly, occasionally editable…
Basile Starynkevitch
- 32,862
9
votes
3 answers
Compatibility of Enum Vs. string constants
I was recently told that using Enum:
public enum TaskEndState { Error, Completed, Running }
may have compatibility/serialization issues, and thus sometimes it's better to use const string:
public const string TASK_END_STATE = "END_STATE";
public…
Yosi Dahari
- 612
8
votes
3 answers
Serializing an object in different ways
It is usual for me, when doing web development, to copy attributes from my model classes to the other class that will be sent to the client. Usually, with a class that accepts a model and extracts the necessary information this is sufficient…
Fernando
- 277