Pseudocode is a description of a program's implementation set out as code without needing to adhere to any formal syntax of a language. It is often used for a programmer's own benefit to plan what they are going to do and make sure their ideas seem doable, but is also highly useful for explaining a piece of code or your intentions to others, or teaching.
This example of a median filter algorithm allows you to follow the idea without needing to understand the specifics [Image credit Angela0130 ]
Pseudocode can be as detailed as laying out each step in an algorithm in words and involving basic, compact mathematical notation (such as matrix or set notation for mathematically-based algorithms), or as high-level as sorts the items, selects the highest priority one, processes it
- there is no set syntax. The formality of it will depend upon the intended audience, as will certain stylistic choices - for example, among Java programmers you might note that an array should be declared by writing foo = {1,2,3}
whereas Python programmers may more naturally write foo = [1, 2, 3]
. Similarly, staunch C programmers may still end their lines with semi-colons, though pseudocode cannot be expected to run as written. Good pseudocode is written to avoid details that are unnecessary for human understanding in order to make it as accessible as possible.
Pseudocode has a further use as serving as the 'dummy code' for a project. Programmers can type it directly from their plan into a comment in their chosen language so they know all the parts of the program that are left to code fully. From pseudocode such as this, the next step is often skeleton code which does not have all the features the end product will have, but allows other parts of the program in development to compile. An advantage of psedocode, as it is not in any formal language, is that it can be used as a framework to implement the idea in any suitable language without having to change any punctuation or phrasing.
Graphical alternatives to pseudocode that serve the same purposes include flowcharts and unified modelling language charts.
© BrainMass Inc. brainmass.com March 31, 2023, 4:44 am ad1c9bdddf