Week 2 Almost Over!?

I can’t believe that tomorrow is the end of my second week of Fullstack. This week has especially flown by, partly because we have been busy working on stuff and partly because of the holiday on Monday. I have really enjoyed everything I have done so far and feel like I’ve learned a ton.

The first few days of the program went pretty fast with things like orientation, introductions, and review of our pre-work. We spent a good amount of time reviewing the TestFirst Javascript exercises we did as pre-work–– things like inheritance, prototypes, and functional programming. Since I had programmed before, I found these exercises fairly straightforward when I did the prework but I was fascinated to see the solutions we went over in class since they were generally a lot more elegant and interesting than mine. Prototypes were also a new topic for me and I found it interesting to compare object-oriented programming in Javascript with other languages I have used and in particular with C++. We spent a good amount of time refactoring the solutions- taking something that worked and improving it by making it more efficient or flexible. This really helped me learn about some of the useful things you can do in Javascript and some of its most useful functions. We also discussed TestFirst programming (basically what it sounds like- you write (or in our case for the program, receive) the tests your program should pass and then write a program that will pass them. This is different from how I have programmed in the past, but a great way of doing things because it makes it easy to test your code and also forces to think about interesting/“special” cases which may cause things to fail if you do not take them into account.

Towards the end of the week, we discussed data structures and implemented queues, stacks, linked lists, and binary trees from scratch. This was useful as it helped us practice our Javascript skills while also practicing object oriented programming. It was again interesting for me to compare this to how I have previously implemented these structures in C++ and Java. The great thing about Javascript (and other more “modern” languages like Ruby and Python) is that it doesn’t have set or pre-defined variable types so you don’t need to template your data structures. In other words, you can write the functionality for a Linked List and then someone can use your implementation to store whatever they want- integers, strings, objects, another class, whatever. This is very different from C++ and C#, the two languages I previously used the most, as those are strictly typed and you need to either declare the type of a variable in advance or template your functions. Long story short: I appreciate each new language I learn because I have done things “the other way.”

Last Friday, we worked in pairs to write a CSS selector called Selector.js- basically a version of the CSS selectors that JQuery uses (Sizzle). Our code allowed a user to submit a CSS selector such as “.hidden” and then the code would return all of the elements with the class “hidden” on the website the script was running on. We got this to work for IDs, tags, classes, multiple tags (a tag inside of a tag i.e. descendants), or tags with clases. I had not really used DOM functions such as element.getTagName before so it was pretty cool to be able to access and return elements from a web page. Chrome Dev Tools was super helpful because it allowed us to test our code and debug issues that came up. The most challenging part of the assignment was figuring out how to traverse the DOM- that is how to go through the webpage and access and return every element on it. We did this recursively using depth first search and it forced us to make sure we were actually visiting every node on the page and considering all possible scenarios.

This post has already gotten ridiculously long so I will quickly go through this week and in hopefully less detail. This week, we implemented sorting algorithms (bubble sort and merge sort) using Javascript. This time, we had to write our own tests using the Jasmine testing environment. I hadn’t done this before, but found that writing tests actually made writing the code easier because you knew exactly how your code should work.

We also worked on the “Game of Life” which helped us practice using Javascript to manipulate the content and CSS of a website. My Game of Life is actually running and can be found at http://seemaullal.github.io/game-of-life/ (there is more information there for those interested about how it works).

Finally yesterday and today, we went through an Intro to Node and in particular discussed asynchronous functions and how they differ from synchronous functions. We used several different node modules, including Socket.IO to read content from a file to a server and then automatically update the web page each time any of the files in the folder changed and display the new text. It was pretty exciting to run the program from one computer and access the server from another computer and see the file text displayed. If one computer modified the files, the other computer’s user saw those changes display almost instantly in their browser. It was exciting to see how something like this could power things like chat applications and one page apps like Gmail.

Super long post, but I guess I had a lot to say. I can’t wait to continue to see where this experience takes me and build bigger and more interesting projects.

Show Comments