Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > How create algorithms

Reply
Thread Tools

How create algorithms

 
 
Mabden
Guest
Posts: n/a
 
      09-07-2004
"FloWo3" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
>
> how do you create (design) algorithms.
> I'm talking about thinking about it and come to an idea.
>


Examine the problem in small steps. Break down each little piece into
baby steps.

Contrary to other posts, I don't use paper and pen unless I'm trying to
visualize the actions of a loop of something like that.

I start in with an editor (not necessarily an IDE, Notepad works fine)
and start by just typing in comments of the steps I think I need, like
this:
---------------------------------------
// allocate variables

// open input file

// read data from file (into struct, line at a time, or whatever)
---------------------------------------

As I'm working I fill in things I find I need, like this:
---------------------------------------
// allocate variables
// loop counter, if necc.
// line buffer
// struct for file data, or alloc as needed

// open input file

// loop to read data from file into struct one line at a time
// read a line into line buffer
// parse line buffer into struct

// close file

// do something with data struct

// deallocate as necc.
---------------------------------------

The above is more C-like than C++, but you get the idea.

I try get the full problem scoped out before writing any real code, and
if some step is very complicated I just open another notepad for that
function or class. Eventually, I find things that I can fill in as real
code, but I try to resist that as long as possible.

Some will say that you have to use paper for this process, but editors
work for me. YMMV. On the plus side of this method you end up with fully
commented code at the end. And the comments are sometimes more correct,
since they change as the design is fleshed out - before the code is
written.

--
Mabden


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
real-time compression algorithms on fpga Melanie Nasic VHDL 19 01-01-2006 06:00 AM
Routines and algorithms for DRM/SBR Soenke VHDL 0 12-28-2005 10:02 AM
encryption algorithms abhinav VHDL 2 12-29-2004 12:08 PM
Map n algorithms to m functional units Andreas VHDL 0 12-02-2003 02:34 PM



Advertisments