Thread: Transient variable

Results 1 to 7 of 7
  1. #1 Transient variable 
    Sexy boi <3

    ByteValue's Avatar
    Join Date
    May 2012
    Age
    28
    Posts
    829
    Thanks given
    11
    Thanks received
    80
    Rep Power
    80
    This thread will be explaining what is a transient variable for those who are wondering. It will be separated in 2, the 'real definition' and my explanation.

    Part 1 (Serialization):

    In computer science, in the context of data storage and transmission, serialization is the process of converting a data structure or object state into a format that can be stored (for example, in a file or memory buffer, or transmitted across a network connection link) and "resurrected" later in the same or another computer environment.[1] When the resulting series of bits is reread according to the serialization format, it can be used to create a semantically identical clone of the original object. For many complex objects, such as those that make extensive use of references, this process is not straightforward. Serialization of object-oriented objects does not include any of their associated methods with which they were previously inextricably linked.
    This process of serializing an object is also called deflating or marshalling an object.[2] The opposite operation, extracting a data structure from a series of bytes, is deserialization (which is also called inflating or unmarshalling).

    Source: Serialization - Wikipedia, the free encyclopedia


    Part 2:

    Some of you may not have understand the part 1, which is normal. I will explain the purpose of the transient variable for RSPSs in the following text.


    I will take example on player loading here since it is the easier to understand from my point of view.
    When you log in, your player loads some information like your username, password, rights, equipment, bank, etc. This is here that comes the transient. When you declare a variable like the delay every time you take a sip of your potion, you don't want it to be saved for next time you log in since it's only about 3 seconds. So you want this information to be lost the next time your player will be loaded. That's where you call your variable transient. When you do it, every transient variables that are declared will be reset to default every time you will load your player.

    If you look in Player class, you will notice that Bank class instance or Equipment class instance aren't transient. That's because every time that your player will save, these variables will be saved for next time you will load your player, like when you log in. If they've would been transient, every time you would log in, your bank and equipment would be reset to default, which means empty.

    So, when you declare a variable, think if either you will need it to be saved for later use or no. I hope you liked it, and if you have any questions or comments, feel free to post below!
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Feb 2012
    Posts
    141
    Thanks given
    16
    Thanks received
    15
    Rep Power
    40
    TL;DR

    Transient: keyword used in Java so that if the class it's encapsulated in is serialized, that it should be skipped (not saved)

    In all fairness, this isn't really a hard concept

    Oh, and it's used in plenty of other languages, too, e.g. C#. It's called transient because of the actual definition, which basically says that it doesn't last a very long time (when compared to non-transient variables in the class.)
    Thanks for reading I'm new to this community and to RSPS, so if I ask a silly question here and there, please forgive me!
    Reply With Quote  
     

  3. #3  
    Sexy boi <3

    ByteValue's Avatar
    Join Date
    May 2012
    Age
    28
    Posts
    829
    Thanks given
    11
    Thanks received
    80
    Rep Power
    80
    Quote Originally Posted by Cajun Fries View Post
    TL;DR

    Transient: keyword used in Java so that if the class it's encapsulated in is serialized, that it should be skipped (not saved)

    In all fairness, this isn't really a hard concept

    Oh, and it's used in plenty of other languages, too, e.g. C#. It's called transient because of the actual definition, which basically says that it doesn't last a very long time (when compared to non-transient variables in the class.)
    Yea, but many beginners often need the thing to be clearly explained to understand it.
    Reply With Quote  
     

  4. #4  
    Member Transient variable Market Banned


    Luke132's Avatar
    Join Date
    Dec 2007
    Age
    35
    Posts
    12,574
    Thanks given
    199
    Thanks received
    7,106
    Rep Power
    5000
    not rly used in rsps :\

    Attached imageAttached image
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Feb 2012
    Posts
    141
    Thanks given
    16
    Thanks received
    15
    Rep Power
    40
    Quote Originally Posted by Luke132 View Post
    not rly used in rsps :\
    Are you sure? Rs2hd, for example, used XStream, which is just serialization but in XML format, so Graham had to make some variables there as transient.

    It's not directly applicable to RSPS, but since serialization is one variant of player saving/loading that works decently, it is somewhat important to know how to use transient
    Thanks for reading I'm new to this community and to RSPS, so if I ask a silly question here and there, please forgive me!
    Reply With Quote  
     

  6. #6  
    Sexy boi <3

    ByteValue's Avatar
    Join Date
    May 2012
    Age
    28
    Posts
    829
    Thanks given
    11
    Thanks received
    80
    Rep Power
    80
    Yea, exactly since it avoids saving useless data and then making the saving better.
    Reply With Quote  
     

  7. #7  
    Banned
    Join Date
    Jul 2011
    Posts
    138
    Thanks given
    26
    Thanks received
    28
    Rep Power
    0
    Quote Originally Posted by Luke132 View Post
    not rly used in rsps :\
    We use serialization :L.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Variable O
    By Mark in forum Help
    Replies: 1
    Last Post: 11-26-2010, 10:39 PM
  2. some variable help
    By Lord Military in forum Help
    Replies: 3
    Last Post: 05-17-2010, 10:26 PM
  3. Variable
    By Byakuya Kuchiki in forum Help
    Replies: 5
    Last Post: 03-21-2010, 11:04 PM
  4. Local variable Stat, Local variable lvl
    By Moarte in forum Help
    Replies: 5
    Last Post: 11-19-2009, 05:25 AM
  5. Variable p?
    By Enjoi in forum Help
    Replies: 3
    Last Post: 05-10-2009, 02:48 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •