Mongo Magic

I really like the idea of MongoDB.  As a format, JSON can sometimes be a hassle (it really doesn’t like single quotes, or commenting), but because I started learning programming with Javascript, the notion of objects as storage just makes sense to me.

When you layer Mongoose on top of it, you end up with (basically) all you need for working with a simple database.  And you can write it all in JS!

So, this isn’t an ad for Mongo/Mongoose – it’s just an appreciation for some technologies that have made my life easier the past week.  The presentation site I’ve been working on (with login and backend in Node) is just about up and running.  It’s responsive and fairly fast, and also fairly secure (no tls yet, but given a little more time, and authorization, we would add that next).

On other topics that totally sound like ads but aren’t, I’ve been working through Wes Bos’ latest course covering ES6.  It’s really great- he starts with background and simple examples and works up to more complex stuff.  My observations of ES6 so far:

  1. String templating looks a lot like Angular2 templates mixed with concepts from other languages.  It was an eye opener to see how you can replace content within a string using the familiar old ${var} replacement option (like I was looking at PHP!).
  2. ‘Fat arrow’ or lambda functions do seem cool, but should be used with caution.  And this is the reason.  No, seriously- the ‘this’ keyword is the driving factor behind the addition of these functions, but it does add some complexity.  ‘This’ has always been a bit tricky- but the new thing to remember is that a lambda will not bind to the context of the enclosing function.  So, if you use a fat arrow, expect ‘this’ to bind to the outer function scope (or global, or undefined).  However, this can be useful if you’re nested inside a couple functions and want to pass down the context (it will work if you used a ‘traditional’ function structure to bind the context you do want!).
  3. Destructuring seemed complicated at first glance.  So much so that I avoided checking into it for quite a while.  But it does seem like it will be useful.  Grabbing each item out of an array and assigning it to its own variable (without explicitly looping the whole array) is something I can apply to code I write often.  That, combined with the ‘rest’ operator, can make for some powerful array manipulation patterns.

So, if you haven’t checked into ES6 too much, check out the course.  Or, if you have but, like me, avoided the ‘scary’ stuff, give it a shot- it really does make sense!  As you watch, follow along in an editor.  I like using for the simple examples running in the console, and for ones that require the dom – both are no setup and following along on my own and experimenting as we go really does help.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s