Funky? Give up the func!

Kenji Daniel Akiba
2 min readFeb 27, 2021

Functions are a part of life one can agree without functioning, even without any substance, can lead to disaster.

If you are like me when it comes to coding or practicing coding I tend to like to listen to music, more specifically Lo-Fi hip-hop or funk.(depending on my mood) Planning ahead when creating functions is somewhat crucial. If you had followed along I wrote a while back I guess I sort of left a cliff hanger huh?

Remember the DRY principle, if you are starting out in your journey to code and interested to know what that is I’ll link it below 👇 after this conclusion! Functions are:

self-contained chunks of code that perform a specific task. You give a function a name that identifies what it does, and this name is used to “call” the function to perform its task when needed.

So, what is a function; what is considered a function? What can you do with them? Easy, you can do a lot of things for example:

Photo by Shahadat Rahman on Unsplash

contained within this picture example is a function you can put in variables and constants ‘if else’ statements what is called an, conditional statement. But why would you use functions? Reason being is ‘Don’t Repeat Yourself’. In Software development you will always ALWAYS have to write concise clear compact code. So that is where functional programming comes into play! Use it to prevent copied lines of code from what we call it ‘spaghetti’ code — where what you program is all over the place. Clear in a sense of what each function you write is readable, i.e.:

//func insert( coin with: String) -> Int{

//example var

//example let

//}else{

//Your code here

//} return statement

Whether you define a function you have the option to define a named type value that it can take in, they are also known as parameters. You may also have the option to have it return and pass back an output towards your function this is what is known as it’s return type. After it has been created you will, later on down the lines in your code, and if needed? To call your function. Once you hit the nail you will get used to writing functions along your journey and it will make life easier, trust me. I had to personally find out the hard way.

Thank you for reading!

--

--

Kenji Daniel Akiba

App developer, iOS; PC and avid comic enthusiast; always a student