Re: Document A Project
- Posted by Greg Haberek <ghaberek at gmail.com> Feb 19, 2005
- 568 views
> Perhaps I was not clear on what I said. If you were writing down code on paper > how would you write it down? Well, there's two different ways I've used: Flow-charts and Pseudo code. Flow charts are fun. I had a whole 1 year class on flowcharting in high school. Flow charts are better for languages like COBOL, RPG and BASIC. I haven't had much luck with flowcharting in Euphoria, and I don't even know if anyone uses flowcharts any more. But whatever you do, don't lose your flow chart stencil!! (They won't give you another one.) Pseudocode is a way of "talking-while-programming" as one of my professors once put it. This allows you to be fairly generic while still hold the form and logic of programming. Its also how I jot down code if I'm sitting in class and something comes to me. I also draw out window layouts on blank paper first, *in pencil*. Its a lot easier to have a visual reference when you're building a window. this: <pseudocode> -- generic file input routine Declare 'data' as a sequence Declare 'line' as an object Declare 'fn' as an integer Open 'fn' for reading If fn is -1 then Die. Intialize data to an empty sequence. Read a 'line' from 'fn' While 'line' is a sequence Append 'line' to 'data' Read another 'line' from 'fn' Close 'fn' Output 'data' </pseudocode> turns to this:
-- generic file input routine --Declare 'data' as a sequence sequence data --Declare 'line' as an object object line --Declare 'fn' as an integer integer fn --Open 'fn' for reading fn = open( "somefile", "r" ) --If fn is -1 then if fn = -1 then -- Die. puts(1, "could not read somefile\n") abort(1) end if --Initialize data to an empty sequence. data = {} --Read a 'line' from 'fn' line = gets( fn ) --While 'line' is a sequence while sequence( line ) do -- Append 'line' to 'data' data = append( data, line ) -- Read another 'line' from 'fn' line = gets( fn ) end while --Close 'fn' close( fn ) --Output 'data' pretty_print(1, data, {})