refactor writeObject, writeRef, writeDate
encode and decode enum
refactor readArray