## Fractal nature of computer programming

Have you ever felt like you are doing the same things over and over and over again? Your daily commute, your workday schedule or your programming pattern?

**Fractional capacity dimension**

Fractals possess the distinctive property of self similarity. They look the same when you zoom in and when you zoom out. Take a small part of a fractal, and it looks similar to another part of the fractal.

So how does programming come into the picture?

**A simple programming structure**

When you write a program, there are typically 3 sections to it:

- Declare variables
- Perform logic
- Obtain a result

In the program, you might write functions to help break up the program into smaller pieces. And in the function code, you

- Declare variables
- Perform logic
- Obtain a result

See any pattern yet? How about programs calling other programs? The caller program declares some variables, calls another program to perform logic, and obtain a result from that callee program.

**Self referential**

There’s a special type of function whose programming logic involves calling itself again. They are called recursive functions. An example is the function for calculating factorials. The factorial of 6 is the product of all positive integers less than or equal to 6. Or 1*2*3*4*5*6 = 720. The recursive function will be f(n) = n * f(n-1), where f(1) = 1. In code, it looks like

public int Factorial(int x)

{

if (x == 1) return 1;

else return x * Factorial(x - 1);

}

It is programmatically inefficient, but it *is *concise. (Math is like that sometimes…)

**Iterative process of software development**

The very cycle of software development is itself self similar. You develop, test, debug, roll out and get feedback from your users. Then based on the feedback, you develop again, test again, debug again, roll out the next version and get more feedback.

Sometimes, it’s even shorter. You write some code for a small part, test it until you’re satisfied with it. Then you write some code for another part and test *that *until you’re satisfied.

Can you give more programming examples with fractal properties?