Monday, November 30, 2015

Day 31

MEAN


Today was the first day of the MEAN stack. This stack is all in Javascript and we'll be learning technology such as AngularJS, NodeJS, Express and MongoDB. I somewhat regret not preparing more over the break since apparently half my class has already finished the first section! Luckily, the material isn't too hard because it was just the fundamentals. We learned basic data types of Javascript and prototypical inheritance. 

Most of our assignments have focused on OOP, or object oriented programming. That is, writing classes or constructor functions that in itself has different objects or methods that contain code that does something. One of the important parts of OOP that its a blueprint for whatever code thats going to be written and it helps layout all the attributes that the program might have. The assignments kind of eases us in with learning new concepts such as prototype and the different ways to write OOP (good and bad way). 

The big jump up was the Deck of Cards assignment. Because there weren't that many instructions, it was really hard to think how to create a random deck of 52 cards that can shuffle and deal out cards to individual players. Mike did a demo on it before I was able to finish the assignment and he made it look really easy. I'm sure a week from now, it will make more sense but it was definitely a big wake up call for me to not get behind. All the learning happens when you struggle through stuff instead of looking at the demo and pretending to know what's going on.

We are going to finish the JS Advanced Topics tomorrow..wish me luck!

Day 29 - 30

Thanksgiving Break!


Not much to report other than taking a small breather from programming!

Friday, November 27, 2015

Day 28

Presentation Day


So....unfortunately, we weren't able to fully flesh out our project. Turns out, I still have a lot to learn on GitHub and collaborating with developers on it. Merging conflicts were the death of me and when we finally figured out that binary files can't be merged, it already took away 2 hours of time. The presentation was originally set at 3 but was pushed forward to 2. We tried to add the bootstrap to make the website look nice but because I was working on the backend of the same file, Brian worked on the CSS so when we tried merging, it was either deleting the functionality of the website or the aesthetics. We stuck with functionality since that was more important but I was disappointed when all the other groups had pretty good CSS.

We weren't able to get to the random Santa generator so all in all our app was a bust but it was very cool working on a project with others and seeing how other people work out their code. I'll admit, I should've done more for the project and I got to cocky that I had everything all working only to find out that after merging all 3 of our codes, there were issues that had to be debugged. Since we didn't merge early enough, we spent the time to debug and that cost us the ability to add the random santa feature.

Other groups had similar ideas on the backend (movie watch list etc.) but the coolest one was the winning group and deservedly so. They created Thinder, where you can sign up and create an event on where and when to go eat. So if you're hypothetically alone on Thanksgiving, you can go on this app and see who else is doing what so you can join their event and everyone can share a meal together!

But thats the end of Python! Time went by really fast. We get the rest of the week off and starting Monday we'll be starting MEAN! Going to take this weekend to catch up with this blog and help with finishing my group project as well as look at the first couple things on the MEAN Stack. Happy Thanksgiving everybody!

Day 27

Secret Santa App


My group decided that our Python project is going to be a secret santa app. We learned about the AGILE system of development. Basically, have an overarching goal of what the end product is and divide into parts the different pieces of the project and its features and slowly implement and increment towards the goal. Eric has been a PM at Microsoft for the past 8 years so he was really well versed in AGILE and taught me and Brian on how to approach it.

We decided to do this app because of the holiday theme and also it kinda is something that we've done before. There will be a login/registration page with an OAuthr2 that will route to a dashboard page that will have the user's wish list and their friends' wish list in another table. You can add an item and also add an item on your friends wish list to your wish list. Now, when you add an item, it's not just a simple input form for the user to fill out but we'll use the Amazon Simple Product API that will give us a search bar that after inputting your item, will populate the top 5 most popular items and display them. From there, the user can then add that item to their wish list.

The last part of the app is to embed a clock that after it reaches a certain time, will generate a secret santa for all the users that are currently in the Django DB API. We divided our project and got to work and by the end of the day we got the Amazon API working as well as all the routes, databases and templates.

Day 26

End of Django


Today was a very chill day; finished the last 2 assignments for Django and just read on some new techniques of having custom queries. The last assignment of Django is a product catalog and I finished it relatively quickly. Since our 4th week is cut short, our project is a hackathon starting tomorrow! One of the things I'm trying to get better at is foresight in my building a project. Django is very unforgiving in the sense that if your urls don't have a method attach to the name, the page won't load at all even if the route isn't being used. It seems like Django is a perfectionist in the sense that it needs to know everything ahead of time. I think this feature is there so that traversing through different routes are faster and grabbing information from servers are faster that way too.

Anyways, I've gotten closer to the people at my table (whose name is not Maric's) and met Brian and Eric who sits next to me. The three of us has been partnering up for all the morning algorithms. I think we're gonna do our hackathon project together!

Day 25

More Django


Today Django got a bit harder because we focused on the Models. Something I should've mentioned in yesterday's post is that Django uses the MVC architecture, just in different names. Views in MVC are the Controllers in Django. And Templates from Django are the Views in MVC. Anyways, moving past that, one of the benefits of Django is that we do not need a MySQL DB; Django provides us with one! We set up the Model files with all of our tables and what we want on them and we migrate the changes. For each project that we start, there's a Django repository that gives us a DB to use. All we have to do is when we make our changes to our Models, we migrate them up to the Django DB and the changes will be set.

Unfortunately for the cohort, for the past 2 weeks, we've been doing roughly the same type of SQL queries to return what we want from the DBs. Django has its own syntax and queries of how to return information. In some ways, it's very straight forward but for newcomers it can be daunting. For example, usually we write "SELECT info, info etc. FROM table" and we populate the result that we want. Django's DB is an API, and as APIs go, it will return a JSON element. Since it's an object, we can't write in the way we have been for traversing through our information. We instead have to look at JSON in an OOP way to access the information (kind of like how we traversed through the Google Maps API to get the information we wanted). 

Another downside of Django's DB is that there are no visual representation of our data. When you have a query like Modelname.objects.get(id=1), it will return back an object. So thankfully, most of the assignments we've done require small bits of data although in the industry this is most definitely not the case since Python is known for being able to process through huge amounts of data quicker than other languages. Mike however, gave us a pretty print file that allows us to visually see what each object's keys and values are which makes things a bit easier.

Relationships between tables are written in the Models.py file and it's a bit different. In MySQL, when you have a many to many relationship, it will automatically populate a joiner table that has the foreign keys of the two tables it is joining. In Django, this is not the case and you write one line of many to many relationship code into ONE of the tables that you want to join. I like a different approach; creating a third table that acts as a joining table and use a foreign key of one to many relationship between the two tables. The assignments today weren't that hard as again, it was a repeat of what we've done before, just writing it in Django. Gonna relax a bit this weekend after the hard work I put it for the Red Belt!

Day 24

Django


The last thing we're learning in our Python stack is Django. Django is a high-level web framework that many app like Instagram and Pinterest uses. One of the cool things about Django is that it's very modular in the sense that you can quickly remove and input another application inside your project. However the con, for a developer building a project from scratch, is that there are many things to set up within your Django project. Such as:
  • Creating an application folder
  • Creating a url specifically for that app
  • Creating templates/static folders within that app
  • Add to projects urls routes that need to go thru each app
  • Add to settings the apps that are being used in the project.
Today was an easy day as we mostly just read through how Django works and did some basic routing and set up. Our last assignment of the day is the classic Disappearing Ninja where the primary goal is routing through all the different images on the urls page. Note, that Django does all of its variables in url with regex:
url(r'^(?P<question_id>\d+)/$', views.show, name='show')

Day 23

AJAX, API with Pylot


To give you guys an update; I passed my Red Belt Exam! Today is a retake day as well and I took the exam again just to get really confident in creating a web app with Pylot. I think it's important to write as much code as you can, that's the only way to solidify your skills. Anyways that was after doing AJAX with Pylot.

Today, we are going to use AJAX with databases. Meaning that we're going to employ the .post() function on our HTML. The first couple of assignments were creating a Wall-esque type of web app. Instead this time, when you post a message, the page will not reload and you can see the message show on the browser immediately after submitting the button. This first assignment was pretty straight forward although it took a bit of time to get used to having a partial HTML that will render the messages without loading. 

The structure of AJAX with Pylot is very similar to all Pylot assignment: 
  • Routes.py
  • Controller,py, Views.html, Models.py
Except that there will be an extra folder in the views folder that has a partial html (almost a blank html file but with pythonic code that goes through all the information being relayed.). Another exception is that most of the logic is going into the index.html jQuery script. The next assignment really challenged having multiple AJAX forms operate all at the same time. In the assignment Notes, we are told to create something similar to messages but when you create a note title, it pops out a new note that has the title and a note description (which was not on the page before and only appears when a new note title is being created). The note description will also have the ability to update via AJAX. So before, we would have a form input that has an update button that will update the database but now, has to update automatically. 

Here are the steps to creating an AJAX loaded webpage.
  1. Create the web app the same way you would without AJAX.
  2. Start incrementing features in script section (jQuery stuff)
  3. Create the partial html that will show AJAX loaded content.
  4. Remove update button
  5. Add AJAX feature with updates.
Our last assignment for the day was using the Google Maps API and creating a direction list. That was super cool. It was just getting the JSON from the .get() function and traversing through it and relaying the information into the HTML. I remember 10 years ago, I go on Yahoo or whatever site and printing out the directions list. Well, I created it this time!

Day 22

Pokemon AJAX APIs w/ jQuery


After taking the Red Belt Exam, we read on APIs which stands for Application Program Interface. APIs are the basis of modern application development. It is a set of rules that defines how a user interacts with a program. Think of a repository of information that you want and using jQuery to present this information on to the browser. We implement this feature by having this jQuery script tag in the HTML page:

<script src="https://code.jquery.com/jquery-2.1.3.js"></script>
Flowchart of AJAX Request
AJAX is Asynchronous Javascript and XML and is a web development technique that allows the user to not have to reload when sending and retrieving the data to the server or database. This is a departure from what we've done in all of our assignments so far since every time the user clicks a button or submits a form, the page reloads. Now, with AJAX, that won't be necessary.

Implementing AJAX is just writing Javascript functions in our script tags. The hard part of returning a JSON element from an AJAX request is traversing through all the information.
$.get("http://pokeapi.co/api/v1/pokemon/1/", function(res) {
    console.log(res.types[0].name);
    console.log(res.types[1].name);
}, "json");
Here's the breakdown of the API info request:
  • .get('url', function(data_name) {function code}, "return json or XML element")
  • .get is just to ask for the following API information, in this case the JSON of the pokemon API with the number 1 (bulbasaur!)
  • The console.log is the traversal of the object.
Anyways, these were the basic information to get us started with AJAX and APIs. The assignments were pretty fun! We made a Pokedex based off the information we traversed through with JSON we got from the Pokemon API. A hard lesson I learned early on is that you should console.log a bunch in different areas of your jQuery code so that you know which functions or part of your jQuery is being ran. This helps debugging and troubleshooting your code!

Thursday, November 26, 2015

Day 21

Red Belt Exam


I didn't finish the Red Belt Prep but I got most of everything working. There were some features that I just left out for the sake of simplicity; such as if the author is already added, just add him to a list of drop down menu that contains all the authors. But anyways felt pretty prepared for the exam.

I was pretty nervous and I didn't realize that when you enter the code to unlock the exam began. But I started my exam first. Just put on my earphones and got to work. We get 4 hours and 30 minutes to finish the exam. It seems like a long time but it actually goes by really fast. I did everything that I knew how to do first: set up my database, set up my HTMLs and setting up my routes using the RESTful method. I won't tell you the specific of my test since any future Dojo members might see this and it might give them an unfair advantage. Needless to say, it was much easier than the Red Belt Prep and most of the features on the tests were things we've done before with only one part a new feature. 

The exam was challenging but definitely manageable so I feel pretty good about being able to pass it the first time around. After the exam we were told to read up about AJAX and APIs as we're moving on from Pylot. Which again goes back to the point that we do not spend that much time on different technology...

Day 20

Red Belt Review


Oh boy, the Red Belt Prep was actually a lot harder than what I thought it'd be. It is basically the product catalog but has multiple catalogues on the dashboard. When you're on the dashboard, there is a book review table that reveals the most recent books that were reviewed but on the side it's a table of the most recent reviews of books. Only a few of my cohort members were working on the Red Belt Review as everyone else was reviewing past materials. I think the most draining thing about the prep is how long it is. I spent the first 2-3 hours just typing up and setting up all the HTML pages.

I've come to realize that truly everything that we do stacks on top of each other. And the order of the different frameworks that they taught us (Flask, then MySQL + Flask, then Pylot MVC) really matters. Taking a step back and kind of reviewing what I've learned so far; we began with basic Python syntax and we moved onto objects and classes with OOP. Flask is when we started putting all the algorithms together and started building basic web apps. With MySQL we can do even more with the information that user inputs into our site. Flask builds on routing knowledge. And finally with MVC, we're using an industry standard architecture albeit with a relatively unused framework in Pylot. 

By the time we get to the Red Belt Review, there really isn't anything new under the sun. Create the database of users with a one to many relationship to reviews, with a one to many relationships to books table and finally a one to one relationship with author. There is the login/registration which we've done to death. Then it's a product catalog-esque book reviews. Then build the link goes to the add a book review page. Again, using the RESTful routing. When you add a review/book, session the user id of the person who is logged in. 

I think Kris and Mike has done a pretty great job making sure we know everything and I'll be spending this weekend working away on this Red Belt Review!!

Day 19

Semi-RESTful Routes


Today was more Pylot and for us to starting using the RESTful method of routing. REST is a way to route server side code with the browser in a very coherent way and under 6 actions:
  1. New - routes to a new HTML for creation of product in database.
  2. Create - creates a new product.
  3. Show - routes to a new HTML for product info.
  4. Edit - routes to a new HTML for editing product info.
  5. Update - updates specific product info.
  6. Destroy - destroys specific product from database.
Note that these are in-built routes on Ruby on Rails. For Pylot we want to implement similar features because it will make the most sense in terms of code and file structure. The assignment for today is implementing these routes via a product catalog where the database reflects the products, and there are options to look at product info, edit then update the product, delete the product or add a new product.

It was a pretty fun assignment and wasn't too hard (even though I said I struggled with routes in the beginning). What I learned about setting up each project is to just take each thing step by step and make sure that the routes work before trying to do anything else. It sucks to write so much back-end code only to not see what is actually going on because you can't even go to the page. 

Note: It's announced that next Monday will be our Red Belt Exam! Thus tomorrow is just a full prep day.


Day 18

MVC Architecture


I think one of the hardest parts about the bootcamp so far is picking up new technology like every other day. Yesterday was the last day of using Flask and MySQL. And we were only on Flask and MySQL for two days. Now we're learning Pylot MVC to help us understand MVC architecture.
MVC is a way to organize server side information.

Here's a flowchart of how MVC works
  • M stands for Model and does all the data manipulation to and from the database.
  • V stands for View and is all the HTML templates or whatever the user sees.
  • C stands for Controller and is the director of where information goes.
I struggled with understanding the routes of MVC. Since in Flask, everything is done on one server-side file, you initialize the app.route('/name of route') and when you want to redirect you just write redirect('/name of route'). But in MVC, you have a specific routes file that handles all routing. Initially, I thought this was a waste of time but I quickly realized how useful it is. This is the progression of routing:
  1. Form action on html page is submitted
  2. Information is sent to the routes file
  3. If the action matches the route as well as route method (POST, GET etc.), it will go to whatever is after the hash in this example ('Controller_name#method_name')
  4. It will go that controller's method and execute whatever code is written in it.
The assignments were all assignments we've done before, except this time we're doing everything in MVC so all in all, wasn't too much of a struggle today.

Day 17

THE ****ING WALL


I've been pretty busy with all the coursework the past 2 weeks so I haven't been posting regularly...but here I am! At the beginning of week 2, we started on Flask + MySQL. For me, learning so much so quickly was a pretty big challenge. Now, in the beginning of using MySQL with Flask, it wasn't so bad. Everything is pretty straight forward because the query and the relationships between tables were very straight forward; 2 tables and either a one to one or a one to many relationship between them. Then came the Wall assignment. I think this is the first glimpse into future frustration with coding.

Wall wireframe:


Think of the Wall like a Facebook wall, you have a login/registration that goes into the user tables. When you log in, you can post multiple messages and on each message, you can post multiple comments. Here is the ERD:
So the login/registration part is straight forward because we've done it before. Having each user write messages is easy: you session the user id as they log in and input that user id into the messages table. So 80% of the assignment was basically done. All that was left was to get the comments. And this is the part where, looking back, I should've thought more about how to approach it rather than just start coding. I thought it'd be similar to the relationship between messages and users (and it is!) but I also had to pull out the message id so that the comments will display under the correct message.

That took me 4-5 hours to figure out. Looking back, I should've just tried to input an example comment with a message id that already exists and on MySQL, keep troubleshooting queries until I got the information that I wanted. So I began with getting all the comments with the message id;

  • SELECT comment, message FROM comments JOIN messages ON messages.id = comments.message_id WHERE messages.id = '{}'
This returns all comments for that message id. But name is also required! So we do another join.

  • SELECT name, comment, message FROM comments JOIN messages on messages.id = comments.message_id JOIN users ON users.id = comments.user_id WHERE messages.id = '{}'
By adding the second join, we're also asking for the user id which will give us the user name from the users table. After using that query to pull the information form the database, I was finally done...with the Wall.


ACE in Action

Tuesday, November 10, 2015

Day 16

Beginning of Week 2: MySQL +...Flask


I spent the majority of the weekend reviewing Flask and reading up ahead on setting up a database which is our next chapter. Our database is MySQL and installed a couple of connector programs on terminal. The assignments for this chapter are pretty straightforward: learning the syntax of SQL queries in Python code and how to use that to retrieve, receive and transmit code to and from the client side server.

Our class always begins with 20 minutes to an hour of algorithm challenges. I think this is one of my favorite part of the class because it really picks at your brain on how to accomplish a task. There's literally nothing else you need to know other than basic for, while, if else statements. So far the challenges aren't that bad and only uses basic algorithms. It's pretty cool to sometimes the wide variety of answers different groups come up with. I'm sure the challenges will get harder as time goes on but I'm pretty sure I'm up for the task.

We did Python Olympics again and...well PO is like Jeopardy and we guess the output of Python codes that Kris gives us. I know it's a good exercise to think like a machine but practically you can run the codes and see if it works and fix after whatever error pops up. Anyways, I didn't pay too much attention and I got caught using my computer...for fantasy football haha.

The rest of the class was spent doing the assignments, and in my opinion they were a great segway to learning the new material. The first being an email database where you enter a proper email (using if not email regex) and it will show up in the database on the index page ('/'). I built my HTML page based off of the Ninja Gold assignment where I had an activities box that displayed information from the server but this time, wrote code to display information from the database using (SELECT * FROM ...etc).

The next assignment was adding a friend that will be sent to a database that will also be sent back to the index page to the right of the input. The friends in the database can also be edited or deleted.
Very minimal design-wise, but the key was to be able to store, delete and edit databases through Flask.

Sunday, November 8, 2015

Day 15

End of Week 1


Today's the end of week! Honestly every day at the Dojo goes by really fast. The assignments don't really end and when you think you mastered everything you learn in one day, the next assignment or chapter will start barraging you with that much more information. The pace of the Dojo is honestly up to the individual. You can get a lot of things done, or you can fool around a bit and have to finish assignments longer. 

We're supposed to have finished Flask today and move onto MySQL + Flask. I kinda accomplished that, I got to the last assignment and got stumped (but eventually figured out! More on that later). The Ninja Gold assignment was pretty fun to do and I learned how to use datetime as a module. Ninja Gold is a basic app that allows you to click a button for 4 different buildings, each building giving you money or in one case, might also take away money. You have a gold counter at top and an activities log on the bottom. Tricky part about this assignment was to figure out how to create a message log for all activities, since showing one message is relatively easy. Maric recommended me to do a list or dictionary and I chose the former. Here is the result:


I didn't really do much CSS on this page since the main part of the project was to figure out how to create 4 inputs on the HTML that links to one app.route(using the hidden type) that puts out 4 different scenarios (all done with if and elif statements). I definitely should go back and make my projects more appealing for my GitHub account.

The last thing about Flask we learned today was validation and flashing messages and advanced routing. Validation is just having the server read what the user input is and comparing it with what is supposed to be; i.e. passwords must be longer than 8 characters, password must contain 1 uppercase etc. I tried to develop my own method outside of the password regex but alas Kris just told me to google regex since it's so much simpler.

Advanced routing was where I got stuck on, which is why I got stuck on the last assignment. Now, advanced routing is just using a variable and putting it as a parameter in our app.route() as well as our function within the route and the resulting render_template or redirect. I didn't really understand the assignment until I realized that the changes between pictures or HTML elements are due to the URL of the browser. 

Here's what I've learned in the past week:
  1. Basic Python syntax/algorithms.
  2. Python OOP including lambda functions.
  3. Flask fundamentals
Now this list doesn't seem like much but there's a lot of nuances and sub-sections in each of the bullet points but also, if you've read my previous blog posts, you'd know how much more. Anyways, gonna relax this weekend but also read into the next section of MySQL + Flask. See you guys next week!

Day 14

Seriously...what the flask?


After much confusion the day before, I'm starting to understand Flask a little bit better. There are some required syntax: 
  • Importing Flask and importing all the modules that is used in the server-side file. 
  • All of our assignments require us to have the app.run(debug=True) statement at the bottom on our server files so that if there were any issues with the code, the browser will give us error messages.
  • app = Flask(__name__)
  • app.secret_key = "your key", when you are passing POST info.
  • app.route(): are where you direct where client-side action goes.
App.route('.whatever is in here') - when using HTML elements such as form, writing in action="whatever is in here" will route whatever you write in that space into the same app.route that has the same parameter name. 
For example: <form action="/example"> will route to app.route('/example') and do whatever function you have written inside.
All app.route() must have a function inside it and that function must return something. Either a render_template('example.html') or a redirect('/example'). This is to ensure that whenever a button is pressed and the information is routed, there will be a page that exists. That last sentence probably doesn't make sense but that's the best that I can describe it.

We learned two main methods of passing information between client and server: POST and GET. Post is what you use during <input> elements and requires secret keys (see above) and is primarily used for private and sensitive information like passwords. GET is used to ask the server for information to display client-side.
  • GET allows us to request information from client side webpages. 
  • We can use session['example'] = request.form('name') to store the GET request of the form element with the name 'name' (think <input type="text" name="first_name">).
And the last topic of the day is how to represent python code in your HTML. For just printing something that is stored in the server via session, just write {{session['example']}}. If you want to use if else, for loops, use {% algorithm %} and also {% endalgorithm %}. Ending the algorithm is very important!! Going through the assignments and getting a lot of help from my classmates solidified the foundation of Flask so I'm pretty proud of being able to create a small web apps.

Thursday, November 5, 2015

Day 13

Advanced OOP and What the Flask??


The good part about today was that there weren't too many assignments. Unfortunately we also learned a lot in the process without too much practice on what we learned. We started with multiple arguments to pass through functions using the splat operator, which is just putting an asterisk next to the name of the parameter. This means that you don't know how many values will be passed but there will be multiple of the same values. Now splat operators only return tuples. 
  • So def function(*value), and if you call function(4,4), the splat operator will pass the parameters as (4,4). This includes any lists or even other tuples. i.e function((4,4),(4,4)) will return as ((4,4),(4,4)).  
  • A useful trick I learned from a classmate is to write print type(*value) to see what data type is being returned because with the assignment paired with splat operators, a lot of my compiling error was that I kept trying to put tuples with ints or lists with ints. Finding out exactly where the data types are coming from can help you figure out a code to change ints to tuples or vice versa.
After this we went over lambda functions, or the functionalities of lambdas. Lambdas are expressions, not statements so they don't have the same restrictions as statements. Lambdas are primarily used as a shorthand version to write a function with one method but allows for a multi-functional usage of that method.

For example: 
  • def map(self, myList, myLambda): 
  • returnList = []
  • for i in myList:
    • returnList.append(myLambda(i))
  • return returnList
  • print _.map([1,2,3], lambda x: x*x) 
  • This function and this print statement will cause all the values in the list to be squared. But by changing the x*x to other mathematical statements, you can manipulate the list further. We don't change the original function, but we change what we can do with that function in the lambda function. 
  • If it looks confusing, it's not as bad as it looks. myLambda(i) is a representation of the lambda function we write below (the x*x), the myList parameter is just the list we enter after print ([1,2,3]). 
We moved on to Flask really late in the day, much to the chagrin of the cohort. Flask is a framework used to build a single page webpage. I didn't get too much reading done unfortunately since it was so late in the day. Kris went into the lecture and it just kinda flew by my head. Fortunately Flask isn't as hard as I made it out to be although there is a lot of new syntax that I have to learn such as @app.route in my server file and {{session['name']}} in my html.

Wednesday, November 4, 2015

Day 12

Python OOP


Today's class started off sort of slow. We did an algorithm practice sheet for an hour and went through all the problems. I'm still getting used to writing in Python and these are some of the things I kept tripping up on:
  • for i in range (#, #): the upper limit is NOT inclusive. Meaning, if you want something from say, 1 to 10, you have to write (1, 11) because Python goes up to but not including 11.
  • When writing for i in list: this for loop runs all the values inside your list. I kept mixing that up as list[i] which is not the case, therefore if I wanted to change the actual values in the list at a certain index (list[i] = new_number), then I would either create another for loop for that purpose or, as Maric pointed out: create a counter variable outside of the for loop and do count += 1 inside the loop to note what index the for loop is on.
  • I need to get used to writing things in functions.
But we moved on to OOPs right after. For the readers who don't know, OOP stands for object-oriented programming and it's less of a Python thing than a programming paradigm across all languages. It allows for programmers to not have to re-write code and makes code a lot easier to read and follow. Michael Choi described OOP through Age of Empire barracks: 
  • A blueprint of a barrack (not an actual barrack) is the class.
    • Blueprint in the sense that the actual barrack doesn't exist but if it were to, it would come from the class of barracks.
  • Attributes like health of the building etc. are a part of the class.
  • Methods or functions of the building (like creating soldiers) are a part of the class.
  • This leads to the creation of the barracks (or an instance/object) and this barrack will inherit all the attributes or methods that the class of barrack has, but only if these attr/methods are public.
We then learned more about the syntax that sets up the class in Python like __init__. A tricky part about OOP is that when you first start learning it, a lot of the objects that are being passed in the parameters of classes or functions will make your head spin. It can get really confusing really easily as you stack more functions in a class and when you start creating more classes that use functions in another class. Here is an example:

Basic objects and classes
...lol doubly linked lists

Definitely the biggest head scratcher for today was the idea of singly and doubly linked lists.
Singly linked lists are nodes that have a head portion (that contains the value) and the tail portion (which points towards to another node). If there's only one node or if there is not another node to point to, the tail section will become null. Doubly linked lists are the same as a singly linked but has two tail portions which can point in a bidirectional manner instead of a single direction like singly linked lists. I won't focus too much on it since it's optional and is mostly to ready a person for a technical interview but it's definitely a CS theory that I should get down by the end of this bootcamp.

Monday, November 2, 2015

Day 11

First Day On-Site!


Woke up today pretty early at 6:30AM. Got a good amount of sleep last night and packed up all my food. Unfortunately by the time I got there, all the parking spots got taken up. The email wasn't kidding about no parking spaces. I parked with a friend at the nearby Toys 'R Us: there doesn't seem to be any rules about parking there for any length of hour so here's to hoping there's no ticket on my hood when I leave today.

This is what the setup is like for our cohort:

A good chunk of today was devoted to setting up Python on our laptops. Installed everything via terminal which was pretty cool. Kris went through the basic syntax of Python really quickly. I'm probably going back to the Dojo website to catch up on anything I didn't know. Python is really simple to learn yet tricky in a lot of ways since it does things differently than what I'm used to in Java/JavaScript.

In Java/JS you write for loops as 
  • for (var i = 0; i < #; i+#) {} 
But in Python, the syntax is 
  • for i in range (#, #):
  • And the fact that everything is differentiated by indentation.
The biggest difference for me in doing problems with arrays (or lists, as it's called in Python) is that in JS, all the for loops I've written to go through every array element is via 
  • for (var i = 0; i < array.length; i++) {some function with array[i]}
You can do for loops via the basic for i in range etc. but a TA showed me, in my opinion, a better way: for i in list_name:

Thats it! Another cool bit of code is that when you are in a for loop to look at each elements of a list, you can write i[#] to look at the specific characters in an element (that's a string) and pull that number out for use, which is what I had to do in an assignment. Also, a new conditional statement for Python: if type(i) is int: which is basically saying if the element of the array at i is an int, then...

I didn't expect this many students and with such diverse age and background. There was a lot of learning going on today especially with nested dictionaries which I still haven't fully comprehend but will try to do more on it at a later tie. A dictionary is essentially a library for all lists and touples (immutable lists) and can have another sub-dictionaries in them. The biggest pain of nested dictionaries is how to access the values as there are a lot of different ways to do it. Some easy, some way too complicated for our assignment. One way we learned was to use enumerate and the second is to create a 3rd nested for loop.

8 hours went by really quick today and I can definitely see how the pace can be very quick very fast.

Day 10

Last Weekend + Review


After finishing advanced jQuery, I decided to review a lot of what I've learned so far. I finished 1 or 2 optional assignments that I didn't get to finish although if I have time during the on-site days, I'll probably try to get around to it. I read up some python syntax to get a bit of a head start come Monday. I just finished paying off my tuition (or emptying my bank account) today and got to see the building. They told me that we will be located on the 3rd floor (originally 1st) and that it would be a lot bigger so I can't wait to see how it turns out because the original floor was already pretty big with 2 monitors per desk. I can't tell you guys how crappy it is to work on just one 13.3' monitor. Having multiple screens should make things move along a lot faster. Time for everything to start!

Day 9

Advanced jQuery


I went through advanced jQuery today as the last part of the web fundamentals course. On paper, dynamic content is simple; they're elements that are created after the page is loaded. You use the .append() function and whatever function is in the parameter is what will be executed after a certain event occurs. Now add in .on() which is a way to add event handlers. Event handlers are code that executes a function when an event happens (click a button, hover or something etc.). Make the selector as specific as possible so that the server doesn't take too much time finding all the elements.

Now for callbacks. Callbacks are just functions that causes other functions run after a certain event. Sound like the .on() function? It is similar, but callbacks allow for more precise coding. Write out a callback function outside the scope of $(document).ready, (this is to allow the callback to exist anywhere on jQuery) and plug whatever you dub the callback function into your jQuery scripts.

Anyways, it was pretty tough but I had a breakthrough late in the day. I kept thinking append() and on() methods as  really daunting tasks but once I started to little stuff by little stuff, it's essentially creating something in html but within the parameters of append. One thing that took me a while to get a hang of is that when you write .append('<div>' + [insert html elements] '</div'), you can STILL id/class whatever HTML elements you are putting in. Which makes customizing the element with CSS a breeze.

I think the hardest part about jQuery is learning which methods can stack with other methods so you don't have to write a lot of code. I guess that comes with practice and doing more problems. jQuery is super useful for the front-end side of things, and there are so many methods has been developed and I'm pretty sure will there will be more cool animations developed later!