Tech Talk: NBAA

Recently, I began preparing a session for the NBAA conference in Orlando targeted at the aviation industry. I struggled identifying the needs of the audience since they were a bit different than I usually have the opportunity to speak to. The following article was not the presentation I gave, but an early direction to introduce several technology concepts to the group and help them understand how these topics could improve their business processes and general operations. The primary topics included:

  • Electronic Data
  • Specialized Software (and SaaS)
  • The Cloud
  • Mobile
  • Security Tips

Though I ultimately presented a slightly different direction for this material, I think it still has some value to be presented here.

Migrating from paper to electronic systems is a challenge. Technically, the data needs to be structured in a way that computer systems understand, but the real challenge comes from user adoption. Paper let’s you write anything you want, change workflow however you need at that moment, and is comfortable to some workforces that are still not yet at ease with computers.

However, the move to electronic data allows for real time validation of the data to significantly reduce mistakes, gives us visibility into trends that may be occurring, and allows us to access the information by several people at a time.

Take reporting aviation discrepancies for example; at Flightdocs, we have seen a number of operators switch from a paper based write-up to electronic. Images and video can be captured and attached to the discrepancy for later evaluation and over time, we can begin to track trends in part failure or unexpected use.

As you begin to move your data to electronic systems you may be tempted to move to Excel or other similar general use software. This is a great start, but it has many drawbacks. Data is typically not validated and doesn’t reflect the real use of the data such as proper tolerances or required fields.

Collaboration becomes a real issue as emailing files back and forth is fraught with errors and typically if the file exists on a network it can only be in use by one person at a time.

Look for specific software that solves an important problem for you. Whether it is maintenance, flight scheduling, inventory, or accounting — find an expert company that can help you tackle these problems in a purpose driven way.

In most cases, I advise against buying on-premise software if possible. This is software that you have to install and maintain at your company and comes with all kinds of hidden costs and complexity. At Flightdocs, we both use software as a service as customers, and providers as our business. This is software that is hosted by someone else, often in a cloud, and is accessed by the internet for a monthly or yearly fee.

The cloud, at it’s simplest form is a way of renting servers from another company with quite a bit of magic thrown in to handle massive scaling. However, this over simplification shouldn’t belittle how important this shift in technology is and all of the tremendous opportunities it now gives us.

In the past, it was incredibly difficult to scale quickly and across continents. It meant purchasing servers, setting up data centers, staffing the appropriate IT resources to manage the hardware and software, and keeping everything up to date and running smoothly.

The cloud allows all of that scale and complexity to disappear and you to simply use or develop applications and has led to more innovation in mobile device software and internet enabled embedded devices.

Now that you’ve moved from paper to electronic, selected the right targeted software for your operations, and have access to that data anywhere through the internet, look to mobile for access away from your desktop.

Imagine each leg of your flight updating compliance metrics and aircraft times in real time to help keep your due list in check or notify home base of necessary maintenance or inventory orders.

You could even dispatch work to individuals who can follow up with their mobile devices and keep getting the latest information throughout the day.

Now that we’ve built up this discussion with all of the good things you can do with technology, let’s share a couple of important drawbacks.

When you go to software as a service or to the cloud, you intentionally give up a lot of responsibility. This can also work against you in that you may not have as much control if there is an issue. In computers, we all know that things aren’t perfect. Outages do happen, hardware does fail, and mistakes are made. If you are already outfitted with the best experts in supporting a production quality network and application, then it may not make sense for you to give over this control.

Security is a double edged topic. If the data that you are storing is of significantly high security, such as weapons systems, or medical patient information, then you may want to reconsider a cloud provider. This is not to say that a cloud provider is going to be necessarily less secure, but you have less direct oversight and therefore are unable to answer some specific security requirements for certain certifications.

  • Home Depot — 56m credit cards potentially stolen through installed malware on cash register machines.
  • JP Morgan — Month long attack stealing 76m names, email addresses, addresses, and phone numbers of account holders.
  • Ebay — 145m user accounts potentially compromised by hackers stealing employee accounts.
  • Adobe — 152m credentials accessed and sensitive information erased.
  • Target — 70m records stolen from compromised magnetic strips on card readers.

When you opt to start moving more and more data to the cloud, you’re making your information more accessible. This is a good thing, but it needs to be controlled for the right people. There are several steps that you can take to further protect yourself and your data.

Here are a few helpful tips:

  • Always use a strong password. These are passwords that can be harder to remember but provide much better security.
  • Never use the same password on more than one system. By enforcing this, you limit your exposure if by some chance a password is compromised.
  • Always ensure you are connecting over secure traffic, look for sites that show a lock in the address bar.
  • Ask for and setup multi-factor authentication to help protect you, even if your password is stolen. Multi-factor authentication also called 2-factor authentication is when you have a username and password and a second factor such as your phone to confirm login attempts.
  • When using a software as a service company, ensure your password is hashed when stored. Flightdocs uses one way hashing to prevent decryption attacks.
  • Ask about encrypted data practices when moving data to the cloud. Not all data needs to be encrypted, but data that you consider sensitive should be.
  • Keep computers and browsers up to date with the latest patches.
  • Install virus and malware scanning software on your computer to help prevent attacks.
  • Always set a pin or login for your mobile phone. Phones are easy to steal and provide lots of information as we adopt mobile access strategies.
  • Be careful with roaming settings on your phone due to wireless hijacking.
  • Backup your data, but also be careful to encrypt and protect backups as they can become vulnerable sources of data.

Conway’s Game of Life in Angular.js

I know there are a lot of posts for Angular, so I will spare everyone a rehash of setup and Hello World. Instead, I thought it would be fun to show a simple example of Angular recreating Conway’s Game of Life.

This example will use the following technologies:

  • HTML
  • CSS
  • Angular.js
  • Bootstrap

If you would like to see a sample of the working application, click here: http://www.nicholasbarger.com/demos/conways-game-of-life.

What is Conway’s Game of Life

Check out Wikipedia: http://en.wikipedia.org/wiki/Conway%27s_Game_of_Lifefor a more in depth definition and origin of the game, but in short, it’s a simulation that allows you to observe evolutions based on an initial starting configuration while applying the following four basic rules at each round:

  1. Any live cell with fewer than two live neighbors dies, as if caused by under-population.
  2. Any live cell with two or three live neighbors lives on to the next generation.
  3. Any live cell with more than three live neighbors dies, as if by overcrowding.
  4. Any dead cell with exactly three live neighbors becomes a live cell, as if by reproduction.

The game can continue indefinitely resulting in either a repeating pattern or a “still life” where no more moves can occur.

Since this article is more about Angular, I’ve simplified the game a bit as well to randomly select the starting positions and limited the board to 30 by 30 cells, but feel free to improve the code to allow the gamer to specify starting positions or infinite space. All source code can be found here: https://github.com/nicholasbarger/conways-game-of-life.

Let’s set up the UI

To start, let’s set up a form and board to play on. The form is pretty straightforward and allows you to specify the number of starting life forms, how many generations to simulate and finally, a button to start the game.


            Enter the number of spontaneous lifeforms:
            
            Enter the number of generations to simulate:
            
            Start

Notice, that we’re using a few Angular tags to collect the data and fire off the game.

First, the data to interact with is wrapped with a div that specifies an ng-controllerattribute. This attribute is used to specify what controller will be used to execute logic against the HTML DOM elements. It is common to place this controller logic in another Javascript file.

Next, ng-submitis used to specify what function will be called on the controller when the form is submitted. When we wire up the controller, this is the method that will start iterating over generations in the game.

Finally, ng-modelis used to bind data values from the input form fields into variables that can be accessed in the controller. When the values on the form are changed, the variables backing them are automatically notified of the change and updated.

Now that we have a form created to gather some basic information about starting the game, let’s create the board that the game will actually play on.

<strong ng-show="rows.length > 0">Generation </strong>
        <table id="board" class="table table-bordered">
            <tr ng-repeat="row in rows">
                <td ng-repeat="cell in row">
                    <i class="glyphicon glyphicon-fire" ng-show="cell.isAlive == true"></i>
                    
                </td>
            </tr>
        </table>

In this code snippet, we see a few new Angular components used for controlling presentation of data.

First, ng-showallows us to toggle the visibility of DOM elements by evaluating a true/false statement. Essentially, when the expression is true, we’re setting a CSS style “display: block”, and when false, setting “display: none”.

Next, we get our first look at the mustache-inspired template rendering (http://mustache.github.io) used by Angular. Notice the double curly braces surrounding the variable name in . This allows rendering of this variable and is automatically updated whenever the value of the variable changes.

The Angular control we have not yet covered is ng-repeatand is used when building out the table as we create rows and cells based on the number of items in the “rows” variable. This simply iterates over the collection and continues to generate the content where the attribute is specified and all information that is a child within it.

Finally, we revisit the ng-show attribute to show a small icon in the cell based on whether it is alive or dead. The “== true” is a bit redundant (and admittedly, should be “===” if used anyway to strictly check the value).

Wire up the Controller to Play

The controller is just a function that sets up all of the code to interact with the UI and exposes the necessary variables through a special parameter called $scope. You can read quite a bit more on $scope through the Angular documentation https://docs.angularjs.org/guide/scopebut for simplicity, it’s a way to expose variables to binding in the UI.

If the UI is going to use a variable or call a function, it must be attached to $scope through the following syntax:

$scope.myVariable = ‘Some value’;
$scope.myFunction = function(param1, param2) { return param1 + param2; };

For brevity sake, I will just link to the file hosted on Github since its code is not truly Angular specific and mostly controls running the game. I’ve attempted to comment the rules fairly well so it is evident what is happening in each “generation” of the game. https://github.com/nicholasbarger/conways-game-of-life/blob/master/game.html

Take Away

At my company, we’ve adopted Angular to use every day in production development and haven’t looked back. The benefits of creating a single page applications (SPA) which limits full trips back and forth on the server has allowed us to provide a more native experience over the web while reducing our server load by pushing some of the processing back onto the client.

The example shown in this article is by no means production code and is structured all in one file, which is usually not appropriate for production use. Enterprise level applications need to fully utilize separation into various modules that are comprised of controllers, views, partials, directives, services, and so on.

I’ve learned to stop promising future blog posts since I tend to write in short waves and then neglect my blog for months at a time; however, I think it would be great to write several posts on architecting large Angular web applications and some of the challenges we have faced. Stay tuned (but don’t hold your breath)!