There is More There Than Meets the Array
How data is structured matters. Efficiencies of both time and space can be significantly improved by using the correct data structure. In our fourth phase, the cohort was introduced to the concept of data structures. Throughout the course, we had been using a basic data structure in arrays. Luckily, most languages have a myriad of built in methods that perform time saving functionality on arrays. Our luck as web developers is elevated by the fact that Javascript is a very forgiving programming language. Javascript allows us build arrays of all sorts of different types. Not all programming languages are built this way. In fact, some languages require us to perform some memory management of our own. These same languages often don’t allow us the freedom to using varying data types in an array. What’s a programmer to do?
Luckily, there are a few tried and tested alternatives to arrays when it comes to using effective measures to structure data. In fact, some alternative data structures offer programmers creative solutions where arrays may be lacking. For example, believe it or not, in some languages the size of an array has to be decided at the time of declaration. This offers challenges if the programmer plans on having an array that is designed to grow in size. Now you’re probably thinking, “just redeclare another bigger array and move everything into that one”. Going that route, we start to run into inefficient practice with regards to time. We want our programs to be fast. A good solution around this is a linked list. There are three basic types of linked list: singly, doubly, and circular. They all take advantage of using a pointer variable that will reference the next node in the link. A doubly linked list uses two, the additional one often being declared a ‘head’ variable. A circular linked list allows all nodes in the list to be connected; there is no ending node.
Outside of these solutions to size defined arrays, there are more efficient solutions to small problems than what arrays provide. Stacks and queues are clever solutions to practical problems. Stacks abide by LIFO (Last In, First Out) and queues by FIFO (First In, First Out). They are oppositely ordered operations. Both of these data structures use similarly functioning methods: pop, push, peek. With only these methods, we can structure and manipulate data in a more efficient manner.
It is very important to at least be aware that these concepts exist, not only for interviews, but in case the plan is to get into additional languages down the line than the ones presented in the program. Keep in mind, with regards to lower level languages, a lot of the memory management is on the programmer to maintain. This presents unfamiliar issues not typically dealt with in Javascript.
I would like to briefly raise one’s awareness about CSS frameworks. We have only been exposed in those most minimal of instances throughout the program, but I feel taking the initiative to learn at least the basics of some of them can go a long way. Bootstrap is an extremely popular and easy to use framework. Their documentation is fantastic and easy to digest. There is also Tailwind CSS and Semantic UI. Starting with these will lay a good ground on which to develop further skills. Keep in mind, the way one introduces these frameworks into one’s program ought to vary. The basic options are twofold. You can either download the entity of the library as a dependency or similar reference the library in the parent html file. The latter, from my understanding, doesn’t overload your program with the full library, but it does allow you to select from the parts of the framework you need. This hopefully saves your program precious seconds from the user’s prospective.