Jump to content

code review request: serialization, bitwise ops

- - - - -

  • Please log in to reply
No replies to this topic

#1
existentialist

existentialist

    Newbie

  • Members
  • PipPip
  • 14 posts
I've tested the code and everything seems to work. I'm interested in hearing some criticisms on how I coded this. This project was for me to learn about bitwise operations and writing individual bytes to file. The source code is attached.

Main has 2 parameters. The first is "file"; you can supply your own output of linux "ps -e" command, but I've supplied my test output (processSnapshot.txt) in case you don't have access to linux. The second is optional, and is the number of lines in "file". Main creates a file "output04.dat" that stores the serialized data. Process is the primary object of this project, and holds an int pid (process ID) and 3 strings for TTY, time active, and the command that initiated the process. ProcessData handles writing bytes to file and all access to the output file. There are some methods in ProcessData that probably fit better in a separate class, but I'll leave that for the next bit manipulation project.

The output04.dat file was actually larger on my system (5.9KB), than the "ps -e" output (5.7KB). This was due to all the padding spaces I used to maintain a set record size. I am aware of the Serializable interface, but I wanted to write and decode individual bytes to better my byte manipulation skills. Later I'll try writing individual packets to a network stream, or making a very basic database program.

Edited by existentialist, 12 December 2010 - 12:12 AM.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users