Tuesday, March 19, 2024 08:43

Archive for the ‘Functions’ Category

Recursive functions

Thursday, April 20th, 2017

Recursion is a mathematical concept that defines any object that is contained or defined by itself. That should be the official, academic definition. In simple words, recursive functions are functions that make a call to themselves from within their own body, in order to solve a problem.… Read more

Best practices when using methods and functions

Wednesday, April 19th, 2017

There are two main reasons why methods and functions are even used. First one, which I already mentioned in a few of the previous posts, is code re-usability. The second is modularization of the code, splitting of complex tasks into smaller sub-tasks, which can offer us a better overview of the entire functionality.… Read more

Return operator

Tuesday, April 18th, 2017

In few of our previous lessons, we used functions – methods that not only can be called, perform some action, but also return a value to the caller – the piece of code that called them. You can imagine this as placing the returned value in the place where the function was invoked from.… Read more

Methods and functions signature

Monday, April 17th, 2017

I talked in the previous lesson about methods and functions signatures, and I offered there a brief explanation on the topic. It is time to explain this new concept in more detail. At a basic level, there are only two things that are mandatory to specify a method or function signature: the parameters type and the order in which the parameters are listed.… Read more

Functions and methods overloading

Monday, April 17th, 2017

There are times when we have functions or methods that perform basically the same thing, but use different kind of parameters. So, in other words, there are cases when we have methods with the same name, but with different signatures.… Read more

Optional parameters

Sunday, April 16th, 2017

When I explained functions and methods parameters, I said that we can use them to send different values that our methods and functions can use in their calculations. You should also know that methods and functions can have optional parameters, parameters with a default value, which can be skipped when calling a method or function.… Read more

Execution workflow

Saturday, April 15th, 2017

Whenever a method executes, it takes control over execution workflow of the program. However, if in the caller method we call yet another method, the execution is transferred to this new method, until it’s code is executed, and when that finishes, the execution control is returned to the first calling method.… Read more

Variable Scope

Saturday, April 15th, 2017

A very important concept in programming is what we call variable scope. Though this concept should have been explained when I explained variables, it wouldn’t have made much sense back then, because it was relying on stuff we did not yet explain.… Read more

Methods and functions parameters

Tuesday, April 11th, 2017

Our methods and functions can perform different actions, but sometimes, we need to offer them certain relevant data to process. We do this by using methods and functions parameters.

One of the primary goals of methods and functions is what we call code re-usability and this means we don’t have to copy and paste the same piece of code over and over, whenever we need that certain action to be performed.… Read more

Methods and functions declaration

Sunday, April 9th, 2017

Methods and functions declarations is actually a three step process: declaration, implementation, call  of our method or function.

  • Declaration is the process of writing the method type, name and eventual parameters, so the program can successfully identify it.
  • Implementation of a method is writing the actual code that will be executed when the method is executed.
Read more

Follow the white rabbit