Thursday, February 4, 2016

w4d3 - Ironically, we built a blog using Django today. Also refactoring hell.

In our first day of working with Django, we built a blog.  It's not really useful, of course, and it just runs off a local host, but...it works!

Part of the project was learning the MVC (Model View Controller) scheme. We used some basic regex to detect the url request (/home, /about, /blog, /blog/page1, etc), served up an html template formatted with info pulled from a freshly-made sqlite database.

I won't lie - it's pretty exciting to see all the pieces I've been working on for months coming together.  I like seeing how a framework operates, too.  I want to dig into the django modules and see exactly what each piece is doing.

After working on the basic web stuff all day, though, (and building a blog once in code-along, and once from notes), I went back to refactor my blackjack game from last week.  I've added betting to the game, and greatly simplified the structure to make sure class instances are not interacting directly (i.e. the dealer's hand object had been passed from the game.play() method to each player in turn to evaluate win/loss/push).  Of course, changing so much broke a ton of things and I've been hours in fixing it.  I see why people hate refactoring.  It's just a few hundred lines long, but there's so much to keep track of.

In a side note, I've been working on learning shortcuts in the text editor to speed things up.  Today I figured out how to set bookmarks so I didn't have to scroll past walls of text every time I wanted to look another function up.  I find that using bookmarks keeps my attention focused much better.

Speaking of which, I failed, again, at an early bed time.  Soon, perhaps, I can port this blog to a site of my own devising.

No comments:

Post a Comment