liveBook · Manning

Pseudocode

As explained in Learn Go with Pocket-Sized Projects

Pseudocode is an informal, language-independent notation for expressing an algorithm's logic.

Pseudocode is an informal, language-independent representation of an algorithm’s logic. It uses readable sentences and words instead of executable instructions, allowing you to reason about a solution before implementing it. It has no official grammar: choose notation that makes your own logic as clear as code. section 5.2.2

Use pseudocode to turn a tricky problem into explicit, testable steps:

  • Step away from the screen and describe the desired behavior before choosing implementation details. section 5.2.2
  • State the rules and edge cases, such as correctly placed letters, misplaced letters, and repeated characters. section 5.2.2
  • Write ordered passes, conditions, loops, and temporary state using readable notation and placeholder operations when needed. section 5.2.2
  • Try concrete inputs against the pseudocode, then identify what each placeholder must do in the target language. section 5.2.2
  • Convert the checked logic into code and test it with nominal, duplicate-character, and wrong-answer cases. section 5.2.2

Repeated-letter feedback

For a word game comparing SMALL with HELLO, pseudocode first marks every guess character absent, marks exact matches, then scans unmatched characters for valid misplaced matches. A fictional operation such as mark can express intent before it is replaced by Go code. section 5.2.2

Listing 5.27 Pseudo-code of computeFeedback()
func computeFeedback(guess, solution) feedback {

   for all characters of the guess { #1
      mark character absent          
   }

   for each character of the attempt {                  #2
      if the character in solution and guess the same { 
         mark character as seen in the solution         
         mark character with correct position status    
      }
   }

   for each character of the guess {                     #3
      if current character already has a hint {          
         skip to the next character                      
      }                                                  

      if character is in the solution and not yet seen { 
         mark character as seen in the solution          
         mark character with correct position status     
      }
   }

   return the hints
}

Inspect the complete computeFeedback() pseudocode, including initialization, exact-position matching, unmatched-character handling, and returning hints. section 5.2.2

How Learn Go with Pocket-Sized Projects covers it

How deep it goes
Works through ordered passes and edge cases, then stops short of specifying final language syntax and helper implementations.
Examples
Uses repeated-letter word feedback, the SMALL-versus-HELLO case, placeholder operations, and table-driven tests.
What it assumes
Assumes programming familiarity while teaching the planning notation and its use from the problem’s behavior upward.
What you can do after
Build it from scratch by drafting, checking, and translating algorithmic logic into tested code.
How it connects
Connects algorithms with implementation planning, edge-case analysis, testing, and diagrams.

Also explained in

Compare how 6 books explain pseudocode →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn Go with Pocket-Sized Projects. The section links point to the parts of the book it draws on.