Back in Action

I think that taking a break from things every so often is absolutely necessary to maintaining sanity and motivation. The past 2 weeks, I took a break from my 100 days of web projects. I spent that time camping with my family in New Mexico. It was really nice and we had a ton of fun.

Now it’s back to work. I finished the lesson on SQLAlchemy this evening. Wow, lot’s of information, and I don’t know how much I really understood. I definitely don’t feel like I could reproduce the application without re-watching the entire video series. As this 100 days of web program goes farther and farther, I feel like I am retaining less and less information. I think it’s mostly because it’s outside of my comfort zone. I really want to find a project to work on to hone my skills, but I’m hesitant to get involved with anything until after the full 100 days.

As for my curriculum plans, well I took a break from that as well. I’m still not sure how I’m going to do things with my CS 1 class this year. I got an e-mail from CodeHS about a new CS 1 for Texas course they’re rolling out. I want to take a look at it to see what they think CS 1 looks like. I may end up using their stuff which is in Javascript. My biggest problem with Javascript for new programmers is it seems to severely lack in the debugging feedback loop. Also, I really really like Python. I need to keep an open mind though. I suppose I could use Javascript in CS 1, then Python in Advanced CS, Java in AP CS, and then let students choose their language for CS 3? It’s worth exploring.

I received a nice binder from College Board with their new AP CS framework. It’s nice to see that they are going to have online resources for teachers/students to use including multiple choice practice sets. I haven’t done a deep dive into the curriculum yet, but what I have looked at seems promising. I’m not terribly worried about my AP CS class. The students in there will be motivated and hard working for the most part. It will be their 3rd or 4th year programming (all but 2), so picking up Java should be pretty straightforward for most of them. I think the hardest part will be keeping them challenged so they don’t get lazy. That’s where UIL problems come in I think!

My “Advanced CS” classes (2nd year) will be modified from last year. I don’t think I’m going to start off with circuits this year, though I’m not sure what we will start with. Probably a bit more time on Git/Github. I need some offline ideas though, so probably some flowcharting.

The next month is going to fly by, so I hope to use that time to relax but also get a little bit of work/planning done. I don’t want to burn out before the school year starts, but I also don’t want to lose all of the great things I’ve picked up over the past few months.

What is this CRUD?

I just finished day 11 of 100 days of Web with Python and am pretty pleased with how it went. The past 2 days were following along as the instructor setup an API using API Star. While overall I was able to follow along with the tutorial, there were a couple of instances where Bob (the instructor) jumped to the next step with little or no explanation and I was playing catch up. In particular, since I had never used “breakpoint()” before, when he ran the application and there was suddenly a “pdb” prompt I was very confused. I got it figured out, but I probably re-watched that part of the video 10 times trying to figure out where the “pdb” was coming from.

breakpoint() is pretty slick!

That being said, I think that “breakpoint()” is one of my new favorite functions. Apparently it was added in Python 3.7, and implements PEP553. Basically it gives you a prompt at that point in your program so you can check variable states and test functions, etc. For more information about the breakpoint() function, see this quick tutorial on Hackernoon. I can definitely see using this in class next year. Unfortunately, Kubuntu 18.04 is still on Python 3.6. I guess that means I’ll be upgrading to 19.04 in the Fall. That’s ok, I was already thinking about switching the class to Xubuntu.

CRUD Operations

Back to APIs…I actually had my 2nd year classes do some work with open-notify.org, an API for checking the whereabouts of the International Space Station, so it’s pretty neat to see how to develop the API itself.

This was my first experience with CRUD operations since my databases class in college. CRUD is an acronym that stands for Create, Read, Update, and Delete. These are the primary operations you do on elements in a database. For this particular project, we used a dictionary instead of a database, but I can see where (probably) with a few minor changes to the code, we could be using an actual database back end.

Where’s the data?

An important part of building the API is getting the data. But finding data for testing things can be difficult. I mean, it’s EVERYWHERE, but in my experience it’s often behind a pay-wall or isn’t in a very usable format for testing things. That is where Mockaroo comes in. I hadn’t seen this tool before. Basically, it lets you get up to 1000 randomly generated rows of data in JSON, csv, xls, or SQL. That’s really cool. I think we may use this next year for some practice processing csv files.

Pytest

Another major part of the past two days was using Pytest for testing the functions. In class, I have my students use the doctest module, so I don’t have any experience with Pytest. I’m looking forward to diving in tomorrow to see what is involved and may consider using it instead next year. A big advantage to doctests is they can be inserted in as documentation in the code itself. The downside to this is it (in opinion) potentially makes the program much more difficult to read. It might be nice to just have a separate .py file with a bunch of tests that I can put in the starter repo. I know you can do the same thing with doctests basically, so I’ll have to weigh the advantages and disadvantages of each a bit more.

Reinventing Google…am I doing it right?

Days 6-7 of the 100 Days of Web with Python involve recreating Google’s search page from 1998 (the logo belongs to Google, of course). It was a pretty fun exercise but didn’t take me very long. I did cheat a little (I looked at the HTML file on Google’s page in 1998 to see how they did their tables). Once I stopped thinking of a table as an Excel spreadsheet-like thing, it really made recreating the page much easier. Since it didn’t take me very long to get the basic page recreated, I decided to go ahead and work ahead. Here is my Github repo for this project.

Day 8 asks you to create a simple form for someone to register on Google (or something like that) and not worrying about style too much. Here is my form:

©2018 Google LLC All rights reserved. Google and the Google logo are registered trademarks of Google LLC.

As you can see, it’s pretty basic. I think it’s really nifty that the input field can auto validate different types, including e-mail and date. Of course the form looks kind of ugly right now. I don’t particularly like how the date input is clearly a different size from the others. So after a quick Google search, I came across the style=”width:” and set each of the input boxes to the same width:

©2018 Google LLC All rights reserved. Google and the Google logo are registered trademarks of Google LLC.

Still not perfect, but better. That’s one of the things I love about this stuff. If I don’t know how to do something, I can just look it up and generally find an acceptable way. What I don’t like is always wondering if the way I did it is the ideal way or the industry standard. That second one in particular really matters to me as a teacher. I do my best to teach my students in industry standard ways, or at least what I think they are. Sometimes a solution on Stack Exchange may just be a hack, and not really the right way of doing something.

This dilemma of industry standard practices has to be one of my constant struggles. Since I have 0 experience in industry, I’m never 100% sure what I’m teaching is a best practice. I base most of what I teach on blogs, online tutorials, and books, so I would like to think the people who write these things know how programs are written in the industry, but maybe they don’t. I mean, they have to at least know more about it than me right? But then again, here I am blogging and some new person might see my code and think I know what I’m doing. I wonder if everyone feels this way. I’ve heard it called “imposter syndrome”. Maybe I’ll do another post about that another time.

Getting the hang of HTML

Just finished day 5 of 100 Days of Web with Python. I’ve always wanted to learn HTML, or at least enough to make decent web pages. Oddly enough, by working through this one lesson, I learned more than I ever have. Michael Kennedy does such a great job of explaining things, and I’m really enjoying working through the exercises with him. Here is my Github repo for today’s stuff. It’s basically the same as the one on their site. Days 6-8 involve remaking Google’s page, then making a submission form page. I’ll put them in that repo as I work through them as well.

I decided to make a list of a few of the things I’ve learned so far:

VS Code Tricks:

  • ctrl-shift-alt-numpad down = duplicate current line (or selection)
  • VSCode has a ton of autocomplete stuff for style=
  • VSCode will auto-complete images if they are there…very cool.

HTML Stuff:

  • I understand <div> tags now! Wow, how simple. I see <div> everywhere on web pages and now I understand why.
  • Use <strong> for bold.
  • Use <input type=password> for password field
  • There are quite a few input “types” and VS Code will auto-complete
  • Add the `required` keyword to an input if it is required

After completing this lesson, I began wondering what is being taught in the high school web design course. I need to go take a look at the curriculum. This is pretty simple to get going it seems like.

After 5 days, I’m extremely pleased with my purchase, and am very much looking forward to the next 95 days!

100 Days of Web with Python

I decided to go ahead and spend some real money and finally learn some web technologies. 100 Days of Web with Python is pretty interesting so far. I’ve finished the first 3 days (1 lab) and can now create a basic web page template using Flask. Since I don’t know HTML or CSS (very well) I haven’t done much customizing. Here is my Github repo with my site so far.

My super basic Flask page

The video lectures are well paced and chunked really well. I never felt overwhelmed and was easily able to follow the instructions (even though the first instructor is using Windows 10 and I’m on Linux). He made a point of giving instructions for Windows, Mac, and Linux, and I could follow along no problem. I’m already comfortable with Vim, so that part was easy enough. When I went back today for day 3, which is basically to redo the whole process on your own without looking at the instructions (as much as possible), I used VS Code (my normal editor for Python). I was able to do about half of the process without looking at the instructions. I did forget a few little things:

  • The specific modules to import from flask haven’t sunk in completely. They’re logical enough, but I still need to connect the dots in my head completely.
  • For some reason, I keep forgetting that the templates folder has to be inside of the program folder.
  • I had to look up how to setup the virtual environment again.

One big thing that I’ve already learned which now seems so simple and obvious is virtual environments in Python. There have been so many times that I have read about using virtual environments, only to get confused about how to set them up or use them. If I had known it’s as simple as python -m venv venv, I would have started using them a LONG time ago (I don’t know how many modules I have pip-installed for a one off project that I never used again!) I will definitely have my Advanced CS courses use virtual environments next year!

Even 3 days in, I think I’m going to be very happy with my choice to start 100 days of programming. If nothing else, I’m looking forward to the journey.