July 2nd 2022 - Day 2 of 3 day study bender
I'm happy to report day 2 was successful as well!
Start the day by watching CS50 Lecture number 5 titled 'Data Structures'. Key Takeaways:
1) Libraries are a collection of pre-written code to shorten your development time.
Framework includes a collection of libraries (among other things).
* Arrays have data in contiguous memory, this means if you need to extend an array but have the next memory location pre-allocated for something else, it causes an issue.
* When we dynamically allocate memory by declaring a variable, the memory is reserved from 'heap' whereas when we explicitly allocate memory for our variable, the memory allocated is from 'stack'.
2) There are 3 building blocks for data structures, first is the 'struct' keyword, second is the '*' operator for going to a memory address, & third is the '.' operator for getting the data at the address. '->' is used as an alternative to '* + .'.
* We can use a 'Linked List' as a better way to deal with adding data to an array. In a Linked List, you create a new data type, then store not only the value of the variable but also its memory address.
* We always have a tradeoff between memory and run-time, in the case of Linked Lists, we use more data to store the memory address (pointers). Pointers for newer computers are 8 bytes.
* Always make sure you release the address (pointer) before releasing the data (using the free operator)!
* We cannot use pointer arithmetic when using a Linked List and iterating through the list is a little more involved.
3) Trees are awesome! - The basic concept behind trees is to ensure that every child item on the left has a lower value than the parent, this enables the list to be sorted and gives us the ability to run binary search algorithms on Trees which result in O(log n) which is much more efficient than O(n).
* The downside to trees is that we use 2 pointers for all data since we store the location of the left and right child.
4) Hash tables - These are used to associate keys with values and how most of the data nowadays is stored.
* A 'hash function' takes an input as a string.
* Tries - Constant time lookup in massive data sets. O(1) notation. The downside is that it is a sparsely populated data structure that uses huge amounts of memory.
5) Queues -> These have FIFO property. Stacks -> These have LIFO property, this of a stack of trays in a dining hall.
---------------
After this lecture, I spent some time on a simple DevOps project, this one is for a simple 3 tier-web application automation.
Application architecture explained:
The end-users hit an NGINX Load Balancer that points to a Tomcat web server which sends requests to a queuing message broker, Rabbit MQ that forwards requests to Memcached which receives data from a MySQL database (PostgreSQL)
* Automation involved -> I first manually deployed the application which took a long time, then set up the application using a Vagrantfile. The next step to automate the applications installations was to list down all the commands entered into the terminal to set up the systems, write a bash script and run the bash script as a step in the Vagrantfile so that when the VMs are spun up, they are ready with all the packages installed.
* Vagrant is a tool by Hashicorp that is used for setting up developer environments whereas Terraform is a tool that is used for building out infrastructure. Vagrant is designed for working with local development environments.
Comments
Post a Comment