So in this section of the course we're going to take a look at the flyway design pattern and this design
pattern is concerned with space optimization.
So what is it all about.
Well the one thing that we want to do if we're storing lots of data is we want to avoid any redundancy
it's kind of like compression in images or films if you have the same block repeating over and over
again you probably want to actually avoid having that block take up memory.
But instead you just write it and say how many times it repeats so if you imagine an online game like
massively multiplayer online RPG for example you're going to have lots of users with identical first
and last names you're going to have lots of people called John Smith but you're also going to have lots
of people called John and lots of people whose last name is Smith and there is no point in actually
storing the same first and last name combinations over and over again because you are simply wasting
memory.
So what you would do instead is you would store a list of names somewhere else and then you would keep
the pointers to those names and by pointers I mean virtually anything.
I don't mean actual physical memory pointers I mean you can keep indices for example if we talking about
a database you can keep all the names first and last names in one table and then you can have the index
as a number pointing you to that table.
Another example is let's suppose you work with text and you have some form of outputting text and you
want to format the individual characters so you want to make some words for example Balderrama time
that got capitalized or whatever.
You don't really want to store additional information per character because typically what you want
to do is you don't want to just format individual characters you want to format whole words or whole
sentences or whole paragraphs whatever.
So for this you would do something else you would introduce this idea of ranges where you define a range
as you know in terms of taxes the line number that you could be on or the starting and ending position
of the text and then you would apply the flyway pattern to actually decorate this with some additional
meaning.
So the flyway design pattern is quite simply a space optimization technique that allows you to use less
memory by storing some of the common data data that is common to several items or several data objects.
You allow yourself to store it externally and then simply reference to it when you actually need it.