What is called the functions with no return value?

Understanding Procedures in Programming

Procedures, also known as subroutine, method, function, or routine, are a sequence of code that perform a specific task in a program. However, not all procedures return a value after their execution. A distinctive feature of a procedure is that it does not give back any value after it has finished executing. This characteristic is what makes procedures different from other types of functions or methods. In other words, the primary purpose of a procedure is to carry out an action rather than calculate and return a value.

An easy-to-understand example of a procedure can be seen in procedural languages like Python:

def print_hello():
    print('Hello, world!')

In the above example, print_hello() is a simple procedure that prints a string to the console. There is no returned value when this procedure is called, hence, it is considered a procedure.

This doesn't necessarily mean that procedures are always the best choice or that they are better than functions that do return a value (often called 'functions' in the strictest sense). It merely means they have a different use case.

Procedures are typically used for tasks that require actions rather than calculations. Furthermore, when writing code, it's useful to consider how the code can be split into smaller, self-contained chunks. If a chunk of code performs an action but doesn't need to return a value, then that's likely a good candidate to be a procedure.

Remember, when best practices are followed, procedures can greatly improve the readability and maintainability of code, especially in large codebases. They allow for code reusability and make it easier to manage and debug the code.

Do you find this helpful?