Jump to content

Logic Tree Example


G+_Darryl Medley
 Share

Recommended Posts

Logic Tree Example. In Episode 37 they talked about creating a logic tree (what I call a Program Outline) as part of the design process of creating an app. While the show notes present the tree as a list of functions I don't remember them actually showing the tree during the show so I thought it would be good to have another example. There are different formats you can use, graphical (flowcharts), text, etc. I personally like to sketch out the logic on a sheet of paper in pseudocode.  Pseudocode is just whatever makes sense to you. Mine looks a lot like my favorite language from the 80's - HP Business Basic. Here's an example:

Main block:

while hamster is alive

   Clean_Cage

   Check_Food_and_Water

endwhile

// end main block

 

func Clean_Cage

   if 7 days have passed

      replace_bedding

   endif

end func

 

Anyway, you get the idea. It's just an easy to read format that shows the logic and structure of the program. When I start writing the actual code, I'll create the main block with just comments or placeholder functions for the various subroutines. I'll then create each subroutine and carefully test it. This method works well for me but I'd like to hear what others do.

Link to comment
Share on other sites

That's an excellent example!

This is how I usually do it, except I write actual functions that do nothing, and once I'm satisfied with the "skeleton" structure of the program, then I'll start filling in the blanks.

 

A great feature of Visual Studio is that it can generate stub functions for you.

If you type this:

 

    bool hamster_is_alive = my_hamster.does_it_move();

 

a small button will appear when you move the mouse over "does_it_move". Pressing that button will add this to your Hamster class:

 

    public bool does_it_move()

    {

        throw new NotImplementedException();

    }

 

Raising "NotImplementedException" will ensure that your code compiles and runs so you can continue building the rest of the program.

Then you can fill in this method whenever you get around to it.

Link to comment
Share on other sites

 Share

×
×
  • Create New...