404 Tech Support

Everybody should know psuedocode

Coding and writing scripts, like most things, gets better with practice and experience. To improve communication between developers and others, everybody should understand psuedocode as a middle ground communication means. Psuedocode is also great for beginning programmers to understand so that they can focus on the concepts and building blocks of good programming or a particular language, rather than the specific syntax.

What is Psuedocode?

Your regular, every day, proper grammar English is a high level language. Programming languages have been getting closer and closer to a high level language over time. Progressing from binary with 1s and 0s to assembly with short codes to our modern languages with full-word terms and variables that are quite understandable on their own, programming languages have gotten easier to understand on their own.

Psuedocode is an abstraction of actual code to outline what function you want performed. Psuedocode uses full words or even descriptive phrases to make the intended function clear. For example, we might have a script that creates a new employee account, adds them to the correct groups, and changes their permission. The psuedocode could be simply written as

:CreateUserAccount
//Pull name from ERP db
//Use first initial, last name, and employee code to make unique
Acct[] = ERP fi,lname,ecode

:AddUserToGroups
//Add newly created account to groups based on role

Case LineWorker
//Added to groups employees
AcctAdd $acctname employees

Case Executive
//Added to groups employees and executives
AcctAdd $acctname employees
AcctAdd $acctname executives

Case IT
//Added to groups employees and IT
AcctAdd $acctname employees
AcctAdd $acctname IT

:ChangePermissions
RemoveDefaultPermissions $acctname
SetStandardPermissions $acctname

What we have is a simple procedural set of instructions that illustrates the steps of the process that needs performed. This allows a non-technical person that owns the process to mostly translate the steps into a clear case. It removes the high level language things that get in the way like long paragraphs that describe the process and different scenarios. Without the psuedocode, you’d have something like the following:

First, we look up the new user in our ERP database. We then create the account using their first initial, last name, and their employee code all concatenated together in order to make their account name. Once the account is created, we are going to add them to their appropriate groups. If they are a line worker, we will add them to just the ’employees’ group. If they are an executive, meaning a VP or higher, we will add them to the ’employees’ group and the ‘executives’ group. Lastly, if they are a systems administrator, we will add them to the ’employees’ group and the ‘IT’ group. These different cases can be determined by the role listed for their account in the ERP system. The last step of the process is to update their permissions. We just remove the default permissions that the system sets up and apply our boilerplate permissions so they have access to what they need.

Given the psuedocode and the above paragraph, which would you rather be provided with to translate this simple process into an automated process? Given a more complicated process or a more verbose person, the paragraph could only grow in complexity and unneeded information.

You may also notice that the above psuedocode example is procedural, meaning it just runs from top-to-bottom, one step after the previous. There is nothing stopping you from making the psuedocode object-oriented. In fact, an object-oriented layout may help you make the process more efficient and further abstract some of the more complex code to a function that the technical person can fill-in.

For beginning scripters and coders, psuedocode can help break down the problem into solvable chunks and organize the problem into the right order. It may also be easier to spot any dependencies or race conditions before the problem gets too technical or before a prototype wastes its time in testing. Non-coders should be able to write and understand psuedocode as a means to improve communicating their needs and expectations to the technical personnel they are working with. Programmers should already be very familiar with psuedocode and they should know it because it can help them when they encounter a complex task to break it down and find the right order in which to process.

Psuedocode is not really that special. It won’t compile and it won’t solve the problem but it can provide a framework for writing the code in an actual programming language. It can also cut a lot of wasteful fluff out of communication to clear up any misconceptions.