User Tools

Site Tools


When writing a set of programs as in Project 1, it helps to apply some basic software development principles:

  • Throwing a bunch of poorly-thought-out code at a problem to see what sticks almost never works, especially with a deadline.
  • This, like most projects in upper-level courses, is impossible if you start the night before it's due. Break it into pieces, and work on a piece every so often.
  • The outline is easy. You can write and test the code to load message, image, and loop though characters (like, to just print them each out) in 15 minutes. Then fill in the guts.
  • Your solution should be general, that is, it should work no matter what size message you read. Most messages will be small enough to fit in a reasonably sized image - your solution should work for all of them.
  • Do you remember how to get the next character in a String? Do you have an idea where to look if you don't remember?
  • Think about or write down a narrative of how the program will go. Something like this for Encode (incomplete, but the main scheme is there):
   load the message 
   load the image
   determine message length
   "hide" length in first pixel
   for each character in the message
       extract the bit patterns to hide
       get the next pixel from pixel array
       extract RGB components from the pixel
      "hide" bit patterns in each component
       stuff pixel back into pixel array
  • Design first, then code. How might we break the problem down into useful functions? (Hint: some of the tasks in the outline above could be functions). Which tasks should occur in setup(), which in draw(), and which in your own functions? Should draw to run continuously, or just once?
  • Designed properly, both programs are surprisingly short.
  • Write short functions to test your understanding of the bit-twiddling operations, such as extract a set of bits, changing just a few bits to new values, etc. Test these with multiple test cases to make sure they work before using them in the larger program. When you know they work on simple numbers, it's much easier to trust they work with pixels and characters.
cs276/project1tips.txt · Last modified: 2013/10/11 11:19 by scarl