Java – When to Use Pseudocode Instead of Flowchart

flowchartjavapseudocode

I'm a student working with various techniques of programming, and I've come across pseudocode and flowchart. I know that these are both used in order to think through the problem before actually programming, but I have a few questions with this.

  1. When would I use pseudocode to plan out and when would I use flowcharts? Or is it better to do both before actually programming. Particularly for a small arcade sort of game in JAVA since that is my next project.
  2. I've noticed that pseudocode is very similar to the actual code rather than flowcharts. Would this make pseudocoding better because you essentially copy/paste the pseudocode into your program (of course, you have to change it to fit the language. I understand that part).
  3. Is it practical to use both of these while programming? Particularly the same game mentioned earlier.
    Thanks.

Best Answer

Flowcharts and pseudocode often have the same level of expressiveness, but differ in linearization. Pseudocode is linear (i.e. a sequence of lines with instructions), a flowchart is not. Therefore, flowcharts are a higher abstraction level, used before writing pseudocode or for documentation.

Flowcharts have, in my opinion, two strong advantages over pseudocode: Firstly, they are graphical. Many non-technical people have a strong fear of structured text, but not of graphical descriptions, so flowcharts will sit much nicer with them. Secondly, flowcharts are much better at expressing meta-considerations such as showing the main line of execution as opposed to branches.

Your questions in detail:

  1. For a really complicated problem, you would use flowcharts first, then pseudocode. Both are optional when you feel secure enough.
  2. Yes, pseudocode has the advantage of being mergeable with real code. Steve McConnell, for example, strongly recommends writing methods in pseudocode first and then leaving the pseudocode in the code as comments.
  3. I always felt that the need to draw a flowchart during design shows insufficient partition of your problem. Non-trivial flowcharts indicate convoluted logic, which should be avoided at great costs.