Forums

Serialising cobra objects

General discussion about Cobra. Releases and general news will also be posted here.
Feel free to ask questions or just say "Hello".

Serialising cobra objects

Postby RIGHT_THEN » Fri Mar 11, 2011 10:08 am

Charles,

what are your thoughts on serialisation and why is cobra compiler itself not serialisable
i mean its classes dont seem to have serialise attribute on them.

2) do you have any objection if all the user classes/code that were produced by cobra were serialisable by default.instead of the user putting Serialise attribute on every thing himself.
ofcourse there could be a option to not serialise automatically.when we want to serialise our class and base class does not have that attribute on it it becomes a pain althou i dont know
for many things object being passed should be serialisable but why microsoft has not
implemented an automatic algorithm for users to just pass the object and rest is taken care
by the assembly itself like Serialise(myobject).Point is if the class for which i dont have the
source code is my base class or i am using its variables in my code i cannot do anything about it anyway. at best i can restrict certain things from being serialised but there should be a default algorithm for that. just like there is when you have specified Serialise attribute on your
class. having Serialise attribute on classes by default would save that pain. one can always
turn off that feature if one does not want to automate.

so i propose.

Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Serialising cobra objects

Postby Charles » Sat Mar 12, 2011 12:40 am

I haven't put Serializable on the classes that comprise the compiler because I have never needed to serialize them.

To my knowledge there is no appropriate automatic way to serialize an arbitrary object because there is no way to automatically know what references to follow. For example, if you serialize a "game object", you probably want to serialize its subobjects, but not its parent objects like a reference to the "game engine". And in general you don't want to serialize temporary items like database connections and open file streams.

By requiring the programmer to add the attribute, you are hopefully triggering him to think about the implications and then to do any additional work that is needed such as adding NonSerializable to some members and/or implementing ISerializable for even more control.

So it's doubtful that we would want such a feature turned on by default.

It might be interesting as an option though. And in that case, it might be interesting if the option were to add arbitrary attribute text to each class so that the option could find wider use:
Code: Select all
cobra -c -d -attributes-on-all-types:Serializable -t:lib MyLib.cobra



Interestingly, in this example, they serialize to XML without the attribute:
http://support.microsoft.com/kb/815813
Even though here they say that serializing without the attribute throws SerializationException:
http://msdn.microsoft.com/en-us/library/system.serializableattribute.aspx
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Serialising cobra objects

Postby RIGHT_THEN » Sat Mar 12, 2011 7:28 am

yes that compiler option would be good.BCL of microsoft has all its members
with Serialise attribute there would be very few if at all that dont.

now i dont say that i am good at knowing something about programming, but here is my observation
a while ago microsoft came up with a language called Axum for distributed and parallel programming
with channels and Actors. in that they say if an object has to travel boundaries like to another machine or to where ever they might be distributing it,it should be Serialisable.

Puts a dent right there.

it is now making me think what i can pass and what i can not.Hey it is everything that i cannot pass because none that i use outside my code is serialisable and is writing a Serialising routine
that simple!!!.So everytime i programm there comes something go on write a routine that would handle serialisation of a problem/code that i didnot create.it is a similar thing they say about memory mapped files(thou i have not investigatited it yet).Why this restriction. what special serialisiing attribute is going to do create some metadata for info.Data is allready there churn it out with reflection extend reflection if it is inadequate. and serialise the binary if text is not understood and leave it to the user to decide that if at all he does not provide with [Serialise] attribute or ISerialisable/se implementation then default would be to dump it all and
that might result in code bloat across boundaries and reduction in speed of execution.then if someone worries of that they could implement custom solution.

Or is it to say that there can be no default for serialisation.then it might be right to leave it to the user.but i think dump it all can be a default Serialisation and that should be implemented by microsoft or novell in some library for it to make easy for users to work


Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99

Re: Serialising cobra objects

Postby Charles » Sat Mar 12, 2011 11:40 pm

I had more trouble than usual understanding your last message due to the English. I don't think you have an outstanding question or suggestion for me, but if you do, please try again.
Charles
 
Posts: 2515
Location: Los Angeles, CA

Re: Serialising cobra objects

Postby RIGHT_THEN » Sun Mar 13, 2011 12:50 am

Charles wrote:I had more trouble than usual understanding your last message due to the English.



i think your english is just fine Charles ;)

Okay! i will formulate my sentences in future that are more english then gibberish.



Thanking_You
RIGHT_THEN
RIGHT_THEN
 
Posts: 99


Return to Discussion

Who is online

Users browsing this forum: No registered users and 76 guests