Sunday, June 11, 2017

Learning MongoDB from MySQL Background




Until this point, I've only had experience with using MySQL databases, but I've been wanting to try MongoDB because it has a funny name and also because it's widely praised.

The truth is, if you're skeptical there are many reasons to give MongoDB a shot:
  • Its JSON-like syntax and ability to chain commands is pretty sweet!
  • It can make your web app/website more efficient in the right circumstances
  • If you're using node, you've got access to some nice Mongo drivers

Now I know there are a billion better articles out there about using Mongo, this article is my experience as a self-taught mysql guy, and I hope I can provide a general outline and some useful resources so you, too can start Mongoing around.

As usual, I decided to learn by doing, so I've started a new project. I call it "scorecard". It's a simple application for score-keeping (mind... blown. I know.) To do this, my first step was to understand what the heck all this "mongo" stuff was about.

Step 1 - Understanding MongoDB in MySQL terms

It took me a little while to fully wrap my head around the structure of MongoDB and it wasn't until I started comparing it to MySQL that I full understood. Here's my way of understanding it:

Just like MySQL, you can host multiple databases on your machine. Within those databases, MongoDB stores things in collections, which are basically like tables in MySQL. Within each collection is a document, which can be thought of as each row in MySQL, as it stores all the values of a particular record.

So in summary:
  • database = database
  • collection = table
  • document = row

The difference of course is that MongoDB is far more flexible. Each document could look entirely different from others within the same collection. This is the key to understanding when MongoDB may be more efficient, or more cumbersome for your application.

For my application, in each scorecard collection, there will be 0-100 players, a title, some meta information, and possibly extra data if say the scorecard is for a golf game where the score should be kept differently.

In this case, if I were using MySQL I would need to create columns for all this data, likely on several different related tables, and it would add a lot of complexity to a rather simple application. Using MongoDB, I can nest each player within each scorecard document, and have any unique number of attributes that define settings for each unique scorecard. Later on, I may want to add complexity to my players, and break them out into a related collection, but for now I'm keeping it simple.

 

Step 2 - Installation

The simplest way to install MongoDB on a Mac is to use Homebrew. The MongoDB Docs actually provide a very easy to use, step by step instruction of how to install on both Mac and PC.

 

Step 3 - Running Mongo Daemon and Mongo Shell 

To start using mongo, you have to first run Mongo Daemon in the background by typing mongod into your command-line.

Mongo Daemon looks like a bunch of jibberish, and talks about itself a lot. Basically, it's your mongo server that makes the magic happen, just let it talk to itself in another terminal window.

Next you can start playing with mongo in your command-line by typing mongo. (Note, if you've manually installed mongo (like, not with homebrew), you may need to do this while in the directory you downloaded the files to).

Step 4 - Using Mongo Shell Commands To Create Test Data

Let's go over some basic commands to get you started, but you know the MongoDB docs are great for this.

These are the commands that have been useful for me so far. There's so much more to learn, I recommend doing some tutorials and going through the docs to keep playing around.

Now that I've got my database setup, I've started to create a node/express backend API, and a React front end for my scorecard app. I'll post about that stuff next time!

Happy coding y'all!

Tuesday, May 2, 2017

The Future Of JavaScript, AND BEYOND!


Yesterday evening I had the privilege of attending a talk by Kyle Simpson about the Future Of Javascript. Kyle is a renowned author, teacher, and speaker. His works include the You Don't Know JS book series and Frontend Masters courses.

I committed my bugs to GitHub, checked out of my Star Wars themed tech play pin at Capital Factory, and mozied on over to the Google Fiber event space in downtown Austin – a really nice stage for talks like this if you haven’t been yet. We had free Topo Chico! I was happy.

Kyle opened his talk yesterday with a bit about the importance of communication. He talked about how we will never be as good at speaking in code as a computer, and will inherently always be better at communicating with other humans. Therefor, instead of focusing all our energy on code optimization, we should focus more on human communication (the worst fear of over a million computer geeks).

Then we covered a lot of ground when it comes to the latest and greatest in the JS/ES2017 world. I think the top three things I am eager to dive deeper into and experiment with are Rest/Spread Properties, Async Iteration, and Do Expressions.

I’ll try my best to stumble through my naive interpretation of these features, hopefully to the extent that you smarter people will be able to understand what I’m trying to say and giggle a bit.

Rest/Spread Properties

I find that many times I’ll try to re-use a function, but with each use case comes new parameters to pass in, and more complexity. It’s manageable, but can be cumbersome when faced with the task of managing all those properties on both function calls and function declarations.

As Kyle explained, with the latest and greatest from ECMAScript, we can use rest/spread properties to solve this problem. Using spread expressions basically allows you to say: "if there's anything else I didn't account for, gather all those up into an object called ‘otherProps'".

Example:


Async Iteration

Say I’m in a conversation with some friends. One of them is telling me their story about their vacation to Thailand, and they say “let me show you some pictures!” They fumble through their phone to find them.

If I was a JavaScript robot, I would now wait until I receive those photos before proceeding with the conversation. This is socially awkward, and not cool man.

Instead, it would be best to continue making small talk while my friend looks for the photos.

With Async Iteration, you can be a more socially adept robot by awaiting for data to come in while simultaneously yielding to send data out in same function.


Example:
 

Do Expressions

Kyle made a really great case for the new Do Expressions support. He explained that wherever JS expects a statement, you can also write an expression, however where JS expects an expression, you cannot write a statement. This makes some programmers cranky, and a do expression can fix that, plus help to clean up your code.

Example:



If you’re interested in reading more about upcoming javascript functionality, checkout this list of ECMAScript proposals: http://github.com/tc39/proposals

Kyle closed his presentation with something that really hit home for me, was a huge wakeup call and an inspiration. I obviously would never put it as well as he did, but I did my best to jot down what he said:

He talked about how he understands that some folks feel overwhelmed about such a quickly changing ecosystem, and that it can feel like we don’t have the bandwidth to keep up with our work on top of learning all these new things. His answer: Don’t do that.

His point was simply, don’t try to understand all of it, just understand where all these things fit in to the big picture, and focus on the things that you think will really help YOU personally in your work. He suggests picking one thing on the long list of upcoming features and really deep dive into it. Bookmark the other stuff to skim over it later.

In addition to this, he was sure to teach what you’ve learned, and you will understand it better. Thus, here I am again.

Back when I was a cinematographer, I blogged on my spare time, both on a personal blog and http://www.scriptmag.com. I didn’t have a huge audience, but I found that it helped me to collect my thoughts into learning teaching points when reflecting on my previous projects. I learned more from my experiences even after it was over just by writing about it.

It took me too long to start this blogging habit back up, but I am thankful for Kyle’s inspiration to wipe the dust off that writer’s cap and get to work.

Happy coding y’all!

Tuesday, October 6, 2015

ES6


Now that I’ve settled in Austin, I was excited to be able to attend my first Austin tech event. Hosted by the Google Developer and Javascript Austin meetup groups, the event focused on ways developers can begin learning and experimenting with the up-and-coming JavaScript standards, EcmaScript 6 & 7.

On the outside, I played it cool, but inside I couldn’t help my excitement as I entered the headquarters of Evernote (a very popular application on the market today). On top of that, not only was there free pizza, but also a selection of free local beers!? Austin rocks!

Ok so I was sure to take notes, and of course I will share:

Our presentation was hosted by Richard Anaya of ESO Solutions. He discussed the new features of ES6 and 7. All of which can be found at the Babel website.

If you visit https://babeljs.io , you can use their compiler tool to experiment with ES6, and compile regular old JavaScript code that works in similar fashions.

Some discussed features which stood out to me were:
  • Native support of Classes without prototyping!
  • Arrow Functions/Lambdas, which can replace the far too common anonymous function
  • Native support of default parameters
  • The new Operator :: can be used to bind handlers, like this::eventHandler
  • With Object Observation, you can watch for changes on an object
  • Class Decorators provide an easy way to add functionality across multiple class members by essentially adding a “tag” to a class
  • Async is made a lot easier with native support of promises
  • The new loop “For… of” will basically be an improvement of the “for” loop
  • Generators - Using a new "next" feature, these can return a different value each time a function is called based on a built-in iterator
Next week, I’ll be attending some events at Austin Startup Week.

Saturday, August 29, 2015

Making Contact




Recently I’ve been working on a design for Jenna Dioguardi's actor portfolio website. I’m building it as a custom template on the Wordpress platform so it’s easy for her to maintain without a development team.

Style guide for Jenna's site
Most of the work so far has been revising designs, and finally this week I’ve set out to code everything. It’s one of my first projects, so it will be a lesson in itself — learning as I go. My process has been “ok we’ve designed this really cool thing… now how do I make this?” Not the most time efficient process but one that definitely forces me to learn a lot!

My recent accomplishment has been designing a very simple contact form that integrates with the Wordpress admin panel.

I thought this was worth sharing, based on how it’s actually quite simple to code, and it’s a shame that developers so frequently rely on throwing a plugin into their website.

This article http://premium.wpmudev.org/blog/how-to-build-your-own-wordpress-contact-form-and-why/ by Harley Alexander was extremely helpful, not only in convincing me that I could feasibly accomplish this task on my own, but Harley is very thorough in his tutorials.

Honestly, before now, I’ve never really liked the PHP language. It always feels so messy: Mingling HTML, logic, and server requests all together into one messy script. There also seems to be an endless amount of functions that do such specific tasks, I find it tricky to work through when compared to other languages, but maybe that’s because I’m still a newbie.

Despite my grudge against PHP, Harley really kept his tutorial bare bones, yet included all the essentials necessary for a working contact form. If you’re looking for a nice breakdown on this topic, I highly recommend checking out his post.

Venturing onward, my task for today is to develop a portfolio page!

Monday, August 17, 2015

301 Redirect



In just two days I will be leaving New York and west-bound to Austin! The adventures just keep rolling in!

For the past two weeks, I’ve had the added challenge of balancing my coding studies with packing up everything in our house. Regardless, I’ve squeezed in bits of studying whenever possible and tried my hardest to keep up my track record on GitHub.

New York has been such a great community, I’m really going to miss it. On the other hand am I looking forward to exploring Austin and the tech community there.

Don’t worry, I’ll keep it weird.

Friday, June 26, 2015

Updates



Ok so I took a little hiatus from blogging, but I assure you I have not taken hiatus from coding!

I’ve been busy while I was gone…
  • I’ve been putting painstaking hours into trying to understand EmberJS.
  • I’ve been taking courses on how to draw and animate with JavaScript (so fun!)
  • I’ve finally learned Bootstrap.
  • I’ve been finalizing designs for two actor portfolio websites.

Now that my summer vacations are over, I’m ready to get serious with my career-changing plans again. I’ll be posting more of my findings very soon.

Wednesday, June 3, 2015

Enter the JS Universe



Last night I managed to get out to another tech meetup to learn about various front-end development tools and techniques. It was really awesome to sit in a room with a bunch of coders, and listen to them discuss things that I have so far only been reading on forums. It really pumped me up, and I just can’t wait to be a part of a team!

I am baffled by how expansive the universe of JavaScript really is. Lately in my studies it seems that I open door after door to new concepts… new frameworks… new techniques. Last night, I found myself just writing terms in my notebook which I didn’t understand at all.

The page is covered with notes like “What does .map() do?”, “What’s NPM?”, and “splats??”

I learned last night that JavaScript can now be used to make installable iPhone applications via JSX – This was very encouraging to me, as that only opens up more options to where I might land at the end of all this hustle.

It’s really exciting to dive into a new world like this. It’s like exploring a different world that’s inhabited by this thriving and complex civilization who call themselves “developers”. I’ve still got a lot to learn!

Learning MongoDB from MySQL Background

Until this point, I've only had experience with using MySQL databases, but I've been wanting to try MongoDB because it has a fu...