JavaScript: What are Closures?

So maybe you’ve heard of JavaScript closures before but you’re wondering, what exactly are they? Well, when it comes to JavaScript, you can have variables that belong to a local (a variable declared within a specific function) or global scope (variables that are accessible from anywhere in the code). You can make variables private by using closures.

Take a look at the following example:

var countUp = (function () {
var count = 0;
return function () {return count += 1;}
})();

countUp();

Now, let’s break it down:

  • The variable countUp is assigned the value of a self-invoking function.
  • It sets the count to 0 and returns a value that adds 1 to the current count.
  • It has access to the count in the parent scope.
  • The variable count is protected by the scope of the anonymous function, and can only be changed using the countUp function.

Software Design Styles and the Cycle of Software Design

Recently I did some document diving to find out more about different styles of software design. When it comes to building software, I’m someone who is more familiar with getting things to work, and I haven’t focused too much attention on discussing my approaches. So in an effort to become more eloquent about the way I describe my work, I thought I’d share an overview on software design styles and the cycle of software design:

Service-oriented architecture (SOA): a style of software design where services are provided with application components through a communication protocol over a network. The elements of SOA include:

  1. Application frontend, service, service repository, service bus
  2. Contract, implementation, interface
  3. Business logic, data

A web service is an example of an SOA with a well-defined set of implementation choices.

Representational state transfer (RESTful): RESTful web services allow systems to access and manipulate web resources by using a predefined set of operations. RESTful includes the HTTP methods get, put, post, and delete. More information on what these mean include the following:

  • Get: retrieves a representation of the collection
  • Put: replaces the addressed item of a collection, or if it doesn’t exist, it creates it
  • Post: create a new entry in the collection
  • Delete: delete the item in a collection

Model-view-controller (MVC): a pattern for implementing user interfaces. It’s broken down into three components:

  • Model: directly manages the data and logic of the application
  • View: the output of the information, how the information is presented to the user
  • Controller: uses input from the user to make changes to the model or view

Software development life cycle (SDLC): a structured sequence of stages in developing a software product. These steps include: communication, requirement gathering, feasibility study, system analysis, software design, coding, testing, integration, implementation, operations & maintenance, and disposition.

EDGE Website

Project Details:

edge.gbci.org
EDGE started out as a simple site created on Drupal. I worked on styling the overall website as well as selecting banner images for different pages and creating icons to add more interest to text-heavy pages. I also added JavaScript functionality to make different sections more interactive.

Programs Used:

  • Photoshop
  • Illustrator
  • Drupal (CMS)

EDGE Website

New Video Background for USGBC

Every now and then I get design-related projects with my work at USGBC. The other day I worked on cutting together videos of buildings for a new video background on USGBC’s main website. I added a consistent filter so the videos would look somewhat similar. I haven’t worked too much with video before, so it was interesting putting together something with iMovie. It’s inspired me to make a few videos for my studio art-related work sometime in the future.

USGBC building

USGBC building

PEER Website

Project Details:

peer.gbci.org
PEER was in need of an full website redesign. I began the process by creating wireframes for the user experience. Next, I developed and designed the website in Drupal. Images were Photoshopped and added to the necessary pages. I also designed icons in Illustrator to use on a couple of the pages. CSS and Javascript were used to make the website more interactive as well as responsive.

Programs Used:

  • Photoshop
  • Illustrator
  • Drupal (CMS)

PEER Website

Yoda Speak

I can’t believe it’s been nearly three weeks since I completed the WDI course. In an effort to make sure I’m staying sharp with my coding skills, I’m going to try to complete coding challenges every week and create a new app every month. Will I succeed with living up to those goals? I sure hope so!

I am also combing through my previous class assignments from WDI to try to find ways to refactor my code or polish existing work into more functional applications. So recently I decided to revisit a Yoda exercise we did. Using vanilla JavaScript, I created an application that utilizes the Yoda Mashape API for translating text into Yoda speak.

You can view the live app here and see the Github repo over here.

Yoda Speak

Redesigning USGBC.org’s Homepage

Earlier this year, I worked on reworking USGBC.org’s homepage. The main navigation was also reworked and was launched in conjunction with the homepage redesign project.

Previously, the homepage looked like this:

USGBC's website

As you can see, the logo and search box appeared right below the main navigation on every page. Thus the header took up quite a bit of real estate. The homepage itself had a carousel with banner images that were swapped out every few months.

I worked on redesigning the header so that the logo, search box, and navigational links all existed on the same line. For the homepage, instead of using a carousel, I worked on adding a video background with a text overlay and a call-to-action button. Here’s the final look:

USGBC's website

Overall, it was very exciting to refresh the look and feel of the website by making a few enhancements to the homepage, as well as the overall website layout.

WDI Day Fifty-Eight: Project 4 Presentations and the Last Day of WDI

I can’t believe that three months have already gone by, and that WDI is over. It was a wonderful experience and I’m glad I decided to go through it. Today we had a chance to work on our projects in the morning, and in the afternoon we presented our project 4. I was pleasantly surprised that a lot of people enjoyed my application. I thought it was a rough project that wasn’t fully complete, but it was great seeing that others thought it was good.

After our presentations, we did a few group activities to close off our experience at WDI. We did an exercise where we had a piece of paper taped to our back and everyone walked around writing things we liked about other people so they were receiving anonymous compliments. A couple of the students in the class created certificates for everyone that were pretty humorous. We also received GA backpacks and did a toast at the end of class.

Overall, the experience has been a really positive one. I doubted myself a lot at times towards the end of the course, but overall I did indeed learn a lot. I also met such a wonderful group of people who I hope I can stay in touch with for years.

WDI Day Fifty-Seven: Project Week 4, Part 5

Using Rails and JavaScript for my project has proved to be a good move. Instead of struggling with the technology and building out an application, I have been able to focus on building out my app.

Today was a pretty successful day – I created icons for all of the different sections of the site. I also found a fix for the weird offset issue I was running into. I also added the ability for users to change the difficulty level of the puzzles they created. Overall, things are slowly falling into place, and I’ve successfully launched all changes to the deployed app on Heroku.

puzzle-me-pictures-screenshot

WDI Day Fifty-Six: Project Week 4, Part 4

My project is gradually coming together, and I’m feeling much better about things now that I’ve changed gears. I’ll definitely need to revisit front-end frameworks next week so I can feel more confident with them.

After spending a few hours working on my app, we had a break in the afternoon where the Outcomes team had a former instructor review the technical interview process that developers often go through. Since I’m not at all familiar with that process, it was pretty insightful to get a taste of what happens.

Later I played around with adding animations to my app, and discovered how fun SVG animations are. I’ll need to look into those more in-depth since they seem to be pretty powerful. Overall, today had several wins. I managed to set up user logins, deploy my app, add image uploading with AWS, spiced up the homepage with an animation, and looked into a few other ways to fine-tune the app. For tomorrow, I hope to work on the following:

  • Adding icons to each landing page
  • Rethink the puzzle index page
  • Rework the styling
  • Try to resolve the offset issue that makes the JavaScript puzzle act weird in Chrome and Firefox
  • Add seed data
  • Fine-tune the user experience for user logins