Logical Operators in JavaScript

Logical operators in JavaScript can be a clean and simple way to return or set values without introducing extra if statements.

console.log(true || false);                //true
console.log(true && false);                //false
console.log(true && 0 && false);           //0
console.log(true && 'string' && 1);        //1
console.log(false || 'string' || false);   //string
console.log(false || 0 || 'string');       //string
console.log(false || 1 && 'string');       //string
console.log(false || 1 && 0 && 'string');  //0
console.log(false || 1 && 0 || 'string');  //string

This comes in hand when you want to make sure a variable has a value. This can be a concise way of preventing errors.

var persons = [
    {id: 1, name: 'joe', age: 22},
    {id: 2, name: 'harry', age: 59},
    {id: 3, name: 'will', age: 30}
];
var index = 19;
var person = persons[index];
console.log(person.name); //error

Well that’s no good. Let’s say index is derived from user input and you don’t want it to error if the index is out of bounds:

console.log(person && person.name); //undefined

Much better. You could also test index. If it’s not a valid value, then set it to a default.

index = index < persons.length || 0; //0
var person = persons[index];
console.log(person && person.name); //joe

This is a very contrived example, but hopefully you get the idea.

Arguably, adding logical operators on the same line doesn’t always make for the most readable code, but with practice I’ve found it to be quite readable and concise, as long as you don’t pack too many operations on one line.

That said, it’s not always easily tested. Each line of code performs multiple functions, so you can’t put break points right where you want them.

More JavaScript

Double Equals Comparison Operator in JavaScript

I’ve been doing a lot of development in JavaScript lately. I’ve found that evaluating values using the double equals comparison operator in JavaScript can produce some intriguing results.

First, I want to clarify the difference between double equals (==) and triple equals (===) in JavaScript. Double equals evaluates equality WITH type coercion while triple equals evaluates equality WITHOUT type coercion. Thus:

0 == false     //true
0 === false    //false

Double Equals (==)

Now for some more examples. For starters, when comparing '0' and '' to false, both evaluate to true:

'0' == false    //true
'' == false     //true

However, when we compare them against each other:

'0' == ''   //false

Interesting. Why is that? This is how the double equals works:

Equal (==)

If the two operands are not of the same type, JavaScript converts the operands then applies strict comparison. If either operand is a number or a boolean, the operands are converted to numbers if possible; else if either operand is a string, the other operand is converted to a string if possible. If both operands are objects, then JavaScript compares internal references which are equal when operands refer to the same object in memory (Comparison Operators, Mozilla Developer Network).

So, with the example at hand, JS evaluates the operand type first. Since neither operand is a number or boolean and at least one of the operands is a string, they are evaluated as strings. (In this case, just so happens both operands are strings.) Next JS evaluates the values, which are different. Despite the “falsey” nature of both zero and the empty string, as string types they are altogether different values and therefore not equal.

Let’s take a look at a couple other intriguing examples.

'' == '0'           // false
0 == ''             // true
0 == '0'            // true
false == 'false'    // false
false == '0'        // true
false == undefined  // false
false == null       // false
null == undefined   // true
' \t\r\n ' == 0     // true

To explain some of these examples that were perplexing to me the first time I examined them…

When comparing false == 'false', JS tries to convert both to numbers. The result is 0 === NaN, which is of course false. This also explains why false == '0' is true–because it boils down to 0 === 0.

It appears that when ' \t\r\n ' is converted to a number, JS converts it to 0. At any rate isNaN(' \t\r\n ') results in false, which tells me that when converted to a number, ' \t\r\n ' does NOT result in NaN. Therefore ' \t\r\n ' must boil down to 0 since ' \t\r\n ' == 0 is true.

For further reading and in depth analysis with helpful tables, I highly suggest reading Truth, Equality and JavaScript by Angus Croll.

Final Thoughts

Some developers avoid using == in their code because they don’t understand it and it’s confusing. I think it’s important to understand how == works since this will lead to language mastery. Furthermore, if you don’t use ==, your colleagues or 3rd party libraries will, and if you don’t understand it, then you are disempowered. After you understand ==, I see no problem with not using it. But simply avoiding it because it’s confusing and you don’t understand it seems unwise.

If you’re interested in the actual specification: Abstract Equality Comparison Algorithm

If performance is of concern when using == vs ===, these may be worth perusing:

More JavaScript

Block Scope and Function Scope in JavaScript

Block Scope

JavaScript does NOT have block scope (think if blocks and the like). Variables used before assignment will be undefined and variables used after assignment will yield the expected value.

function a() {
    var hi = 'hi';
    console.log(hi);  //hi
    console.log(bye); //undefined

    if (true) {
        var bye = 'bye';
        console.log(hi);  //hi
        console.log(bye); //bye
    }
    console.log(hi);  //hi
    console.log(bye); //bye
}

Why? Because JavaScript hoists all variable declarations to the top of the function upon rendering the code. So effectively it is interpreted like this:

function a() {
    var hi, bye;    
    hi = 'hi';
    console.log(hi);  //hi
    console.log(bye); //undefined

    if (true) {
        bye = 'bye';
        console.log(hi);  //hi
        console.log(bye); //bye
    }
    console.log(hi);  //hi
    console.log(bye); //bye
}

The variable declarations hi and bye are hoisted to the top of the function and assigned as you would expect. As a result, bye is undefined when it is first referenced outside the if block and we don’t get an error. However, the second time it is referenced outside the if block, it has the appropriately assigned value, even though it is out of block scope.

Function Scope

JavaScript DOES have function scope. Variables defined in inner function scope and used in outer function scope will result in an error because the variable has not been defined in scope.

function a() {
    var hi = 'hi';
    console.log(hi);  //hi
    console.log(bye); //error

    function b() {
        var bye = 'bye';
        console.log(hi);
        console.log(bye);
    }
    b();
    console.log(hi);
    console.log(bye);
}

Variables used in outer function scope even after inner function scope assignment will result in error as well; however, if a variable has been defined in outer function scope, JavaScript will reach those variables and refer to their values within inner function scope.

function a() {
    var hi = 'hi';
    function b() {
        var bye = 'bye';
        console.log(hi);  //hi
        console.log(bye); //bye
    }
    b();
    console.log(hi);  //hi
    console.log(bye); //error
}

What about functions defined in inner scope and referenced in outer scope?

function a() {
    var hi = 'hi';
    function b() {
        var bye = 'bye';
        console.log(hi);  //hi
        console.log(bye); //bye
    }
    b();
}
b(); //error

The same holds true for them as well. Function scope is strict.

More JavaScript

Sublime Text Tricks – Code Efficiently

tl;dr

  1. Know functionality & memorize hotkeys–dig through the Sublime docs or menus to see what’s possible
  2. Isolate significant code snippets–copy/paste into separate documents to prevent interference with other code
  3. Leverage ‘Quick Find All’ hotkey–A faster way to find all
  4. Leverage multiple cursors–Type it once in multiple places at the same time
  5. Convert case automatically–Use hotkeys
  6. Leverage column selection
  7. Leverage multi-selection
  8. Leverage ‘Quick Add Next’ hotkey
  9. Sort lines alphabetically–Case sensitivity optional
  10. Leverage find and replace with regex (sparingly)

Column Selection or Multi-Selection combined with Ctrl+Click and Copy/Paste is king.

Preface

More recently, I’ve realized the benefits and efficiency of a powerful text/code editor. For my purposes, I want to focus on how to code efficiently with some Sublime Text tricks. It’s taken me some extra time to figure out how to leverage Sublime as a code editor, but it has paid off tremendously. I want to share some tricks that have made code editing fun, fast and easy.

As I was coding at work the other day, creating JS models for some new tables in the database, I found myself in a predicament. I had this database table with roughly 55 columns of attributes, a massive table relevant to our other tables. And I knew immediately that I was going to have to code all 55 columns into a JS model. I started to sigh, but then I got really excited because I knew I could find some incredible ways to do this really fast using Sublime.

Trick #1 – Know functionality & memorize hotkeys

Hotkeys are a fundamental of fast computing. I probably don’t have to mention this but I will anyway because I know how lazy some of us are, myself in included. Some times when you pick up a new program it can feel like a lot of work to learn all the new hot keys, especially when they’re different from another program or, in this case, when you’re talking about a really powerful text editor with lots of tricks up its sleeves. Put in the time sooner than later. It will pay off. Peruse (peruse |pəˈro͞oz|, verb – to read through with thoroughness or care) the menus and digest all the possibilities. Memorize the hotkeys of the actions you know you’ll use, then just remember the other actions so you can think to use them later. Memorize the latter hotkeys once you find yourself leveraging their respective actions regularly.

Trick #2 – Isolate significant code snippets–copy/paste into separate documents

Back to my story. I was at work and I needed to code this new model. First, I dug into our backend and found that the table had already been replicated into a C# model. Score! No tedious typing necessary. Below is some pseudo code similar to the code just mentioned. I’ve inserted it here so you can use it to try some of the Sublime functionality I’ll be discussing.

public int LoremIpsum
public boolean Dolor
public int Sit
public int Amet
public string Consectetur
public string Adipisicing
public string elitElit
public int Quidem
public boolean CulpaNobis
public int Exercitationem
public string Repellendus
public int Aliquam
public string Perspiciatis
public int Placeat
public string Ad
public int Laborum
public int Deserunt
public DateTime Soluta
public DateTime Cumque
public int Doloremque
public int Ipsa
public string Cupiditate
public boolean Provident
public int Incidunt
public int In
public string Quasi
public string Repudiandae
public int Quidem
public int Ab
public boolean Iusto
public int Commodi
public string Natus
public DateTime Minima
public int Atque
public int Molestiae
public string HicTemporibus
public string UllamLabore
public string Facere
public boolean Obcaecati
public int Sed
public int Excepturi
public int Distinctio
public boolean Similique
public int AdipisciVeritatis
public int QuoSequi
public DateTime Velit
public int A
public int Est
public int Necessitatibus
public string UtLiberoInventore
public string IpsaDicta
public int VoluptatumSimiliqueMagni
public boolean ImpeditDelectusFacilisNatus
public DateTime Labore
public string Corrupti

I copied all the properties from that model into an empty Sublime document. I recommend you copy and paste significant code change snippets into separate documents because it allows you to leverage the power of commands like find/replace without interfering with existing code. (Obviously, for simple things, this is too much work.) This is another reason why I always have Sublime open on the side. If I’m using an IDE like Visual Studio, Eclipse or Xcode, it’s a pain to create a new document because you usually have to go through the process of adding it to your project (wait for the modal to load, select a doc type, give it a name, hit next, then finish, etc.). That’s a such a hassle. Sublime is light weight and fast so I can open a new document in a second and paste in the code I’m working with. Easy as Ctrl+C >> Alt+Tab to Sublime >> Ctrl+N >> Ctrl+V >> Make modifications >> Ctrl+A >> Ctrl+C >> Alt+Tab to IDE >> Ctrl+V. And if you use Alt+Tab, the selection you made in the IDE remains when you switch to Sublime, so when you return, all you have to do is press Ctrl+V to replace the existing selection.

Trick #3 – Leverage ‘Quick Find All’ hotkey
Trick #4 – Leverage multiple cursors

Next, I stripped off the unnecessary C# keywords (i.e. ‘public’ and types like ‘int’, ‘string’, etc.) using find and replace…with a twist. Instead of using Ctrl+F, I double-clicked the word ‘public’ with the mouse (this highlights all matches) and keyed Alt+F3 (Cmd+Ctrl+G in Mac), the shortcut to Quick Find All. Alternatively, you may want the options of the Find toolbar (case sensitive or whole word), in which case you can click the word >> Ctrl+F >> Alt+Enter to Find All. With all the same words selected, I pressed Delete/Backspace.

One of the most powerful features of Sublime (or other text editors) is multiple cursors. You’ll notice when you do a Quick Find All you’re not just highlighting all occurrences, but actually selecting all occurrences. You have individual cursors for all your selections.

Next I wanted to clear out the value types, so I just pressed Ctrl+Delete (Fn+Alt+Delete) to delete the entire next word followed by Delete once more to delete the final space. I successfully narrowed down my properties with a few quick key strokes, which took literally a few seconds. If this seems slow to you now, with practice it will become second nature. You start my recognizing when you can/cannot leverage the tools available and then when you should/shouldn’t. You shouldn’t leverage these tools when it will take you longer to use them than just sticking to the basics, even after it becomes natural and fast.

This is what my code looks like after a few key strokes and seconds later (remember these are just the pseudo names of my model’s properties):

LoremIpsum
Dolor
Sit
Amet
Consectetur
...
IpsaDicta
VoluptatumSimiliqueMagni
ImpeditDelectusFacilisNatus
Labore
Corrupti

Trick #5 – Convert case automatically
Trick #6 – Leverage column selection

You’ll notice all my properties are PascalCase according to C# convention. But in JS we use camelCase, so I needed to convert case on these properties. I could have simply keyed Ctrl+A to Select All >> Ctrl+K >> Ctrl+L to Convert Lowercase. However, there are some property names listed here that consist of more than one word and I didn’t want to lose their case. So instead I used column selection by middle clicking on my mouse (alternatively Shift+RightMouseButton for Windows and Alt+LeftMouseButton for Mac) in between the first and second letters of the first line and dragging all the way to the last line and to the left so that we highlight only the first letter of every line and then release the button. Now press Ctrl+K >> Ctrl+L to Convert Lowercase. That does it.

Next there were a number of things I needed to do to construct my model. I’d like to touch on one of those things that I think illustrates another powerful case for column selection. As part of our web app we are using Knockout.js and we use the KO observables in our models. In one portion of the model, I needed to assign the value of each property to a KO observable. Before I started using Sublime, I probably would have just copy/pasted the ‘ = ko.observable();’ onto each…and every…line. But with column selection I can simply middle click on the first line way out to the right of all the properties and just drag down to the last line and release. This effectively places a cursor at the end of every line. Now I simply type (or paste) ‘ = ko.observable();’. Then let’s say I hadn’t declared these variables yet so with all my existing cursors, I press Home >> type ‘var ‘. Except that looks kinda ugly and redundant so let’s undo that so we only have one variable declaration:

Ctrl+Z to delete ‘var ‘ >> End >> Backspace ‘;’ >> Type ‘,’ >> Esc >> Click end of last line >> Backspace ‘,’ >> Type ‘;’ >> Click beginning of first line >> Type ‘var ‘.

My code now looked something like this:

var loremIpsum = ko.observable(),
	dolor = ko.observable(),
	sit = ko.observable(),
	amet = ko.observable(),
	consectetur = ko.observable(),
	...
	ipsaDicta = ko.observable(),
	voluptatumSimiliqueMagni = ko.observable(),
	impeditDelectusFacilisNatus = ko.observable(),
	labore = ko.observable(),
	corrupti = ko.observable();

Trick #7 – Leverage discrete mutli-selection
Trick #8 – Leverage ‘Quick Add Next’ hotkey

As I continued down my path, I noticed there were a few assignments that needed changing. Some of them needed default values and some were actually supposed to be observable arrays. Once again, before Sublime I probably would have just typed out the changes on the respective lines. However, instead I leveraged multi-selection like so:

DoubleClick ‘observable’ in the first line >> Ctrl+D 5x to Quick Add Next >> Ctrl+DoubleClick ‘observable’ every other line 5x >> Press RightArrow to go to the end of the selection >> Type ‘Array’ to change them all at once to ‘observableArray’. Then press Esc >> Ctrl+Click inside at least 5 sets of parenthesis >> Type ‘false’ to set the default observable value. My code now looked something like this:

var loremIpsum = ko.observableArray(),
    dolor = ko.observableArray(),
    sit = ko.observableArray(),
    amet = ko.observableArray(),
    consectetur = ko.observableArray(),
    adipisicing = ko.observableArray(),
    elitElit = ko.observable(),
    quidem = ko.observableArray(),
    culpaNobis = ko.observable(),
    exercitationem = ko.observableArray(),
    repellendus = ko.observable(),
    aliquam = ko.observableArray(),
    perspiciatis = ko.observable(),
    placeat = ko.observableArray(),
    ad = ko.observable(),
    laborum = ko.observableArray(),
    deserunt = ko.observable(),
    soluta = ko.observable(),
    cumque = ko.observable(),
    doloremque = ko.observable(false),
    ipsa = ko.observable(),
    cupiditate = ko.observable(),
    provident = ko.observable(),
    incidunt = ko.observable(),
    in = ko.observable(),
    quasi = ko.observable(),
    repudiandae = ko.observable(false),
    quidem = ko.observable(),
    ab = ko.observable(),
    iusto = ko.observable(),
    commodi = ko.observable(),
    natus = ko.observable(),
    minima = ko.observable(false),
    atque = ko.observable(),
    molestiae = ko.observable(),
    hicTemporibus = ko.observable(),
    ullamLabore = ko.observable(),
    facere = ko.observable(),
    obcaecati = ko.observable(),
    sed = ko.observable(),
    excepturi = ko.observable(false),
    distinctio = ko.observable(),
    similique = ko.observable(),
    adipisciVeritatis = ko.observable(),
    quoSequi = ko.observable(),
    velit = ko.observable(),
    a = ko.observable(),
    est = ko.observable(),
    necessitatibus = ko.observable(false),
    utLiberoInventore = ko.observable(),
    ipsaDicta = ko.observable(),
    voluptatumSimiliqueMagni = ko.observable(),
    impeditDelectusFacilisNatus = ko.observable(),
    labore = ko.observable(),
    corrupti = ko.observable();

Obviously, based on the types in my original C# model, the model I’ve created won’t work too well (I didn’t actually need arrays). So before I move on, I’d like to show you something I did have to do that may be more applicable. I had to set the default values for my properties based on their respective types (number, boolean, date, etc.). I went back to the original C# properties which I left isolated in a separate document and leveraged column selection to grab the types. This is what I started with:

var loremIpsum = ,
    dolor = ,
    sit = ,
    amet = ,
    consectetur = ,
    adipisicing = ,
    elitElit = ,
    quidem = ,
    culpaNobis = ,
    exercitationem = ,
    ...

I used column selection to place a cursor on the end of every line >> Ctrl+LeftArrow (2x) >> Ctrl+Shift+RightArrow to select the types on every line >> Ctrl+C >> Ctrl+Tab to previous file with JS properties >> Column select end of every line >> Ctrl+V. This is how it looked when I was done.

var loremIpsum = int,
    dolor = boolean,
    sit = int,
    amet = int,
    consectetur = string,
    adipisicing = string,
    elitElit = string,
    quidem = int,
    culpaNobis = boolean,
    exercitationem = int,
    ...

I next used Quick Find All on each type to replace each type with the desired default value. DoubleClick ‘int’ >> Alt+F3 or Cmd+Ctrl+G >> Type ‘0’ >> Repeat with different type. When all was said and done this was the product:

var loremIpsum = 0,
    dolor = false,
    sit = 0,
    amet = 0,
    consectetur = '',
    adipisicing = '',
    elitElit = '',
    quidem = 0,
    culpaNobis = false,
    exercitationem = 0,
    ...

Trick #9 – Sort lines alphabetically

It’s nice to have all your model’s properties (or CSS attributes) alphabetized. Simply select all the relative lines and choose F9 to Sort Lines or Ctrl+F9 to Sort Lines (Case Sensitive). Don’t forget to readjust any line beginnings or endings after sorting (i.e. commas, semicolons, var declarations, etc.).

var a = 0,
    ab = 0,
    ad = '',
    adipisciVeritatis = 0,
    adipisicing = '',
    aliquam = 0,
    amet = 0,
    atque = 0,
    commodi = 0,
    consectetur = '',
    corrupti = '',
    culpaNobis = false,
    cumque = new Date(),
    cupiditate = '',
    deserunt = 0,
    distinctio = 0,
    dolor = false,
    doloremque = 0,
    elitElit = '',
    est = 0,
    excepturi = 0,
    exercitationem = 0,
    facere = '',
    hicTemporibus = '',
    impeditDelectusFacilisNatus = false,
    in = 0,
    incidunt = 0,
    ipsa = 0,
    ipsaDicta = '',
    iusto = false,
    labore = new Date(),
    laborum = 0,
    loremIpsum = 0,
    minima = new Date(),
    molestiae = 0,
    natus = '',
    necessitatibus = 0,
    obcaecati = false,
    perspiciatis = '',
    placeat = 0,
    provident = false,
    quasi = '',
    quidem = 0,
    quidem = 0,
    quoSequi = 0,
    repellendus = '',
    repudiandae = '',
    sed = 0,
    similique = false,
    sit = 0,
    soluta = new Date(),
    ullamLabore = '',
    utLiberoInventore = '',
    velit = new Date(),
    voluptatumSimiliqueMagni = 0;

Trick #10 – Leverage find/replace with regex (sparingly)

As a final example, I’d like to show you how I used regex, specifically regex groups, to solve a text editing predicament in one fell swoop. However, I’ve found that regex can be overused, therefore I caution to use it sparingly. Even for the example at hand, I didn’t need to use regex (I could have used a combination of column selection and copy/paste), but I quickly saw an opportunity that wouldn’t take very much extra time. However, in the past, mostly school projects, I have wasted plenty of time trying use regex for simple problems. Don’t fall into the trap of over-engineering.

Let’s say I had a code snippet that looked something like this where I was chaining a bunch of properties together to change some values:

var thing = thing.loremIpsum(item.)
    .dolor(item.)
    .sit(item.)
    .amet(item.)
    ...
    .voluptatumSimiliqueMagni(item.)
    .impeditDelectusFacilisNatus(item.)
    .labore(item.)
    .corrupti(item.);

I want to copy the name after the first period on each line and paste it after the second period. First, I would isolate the significant code snippet into a separate Sublime Text document–everything starting after ‘var thing = thing’ at the first ‘.loremIpsum(item.)’ to the last ‘.corrupti(item.)’. Then I would press Ctrl+H or Cmd+Alt+F to bring up the Find/Replace toolbar (from the menu Find >> Replace…). Enable both ‘Regular Expression’ and ‘Wrap’ options, type in the text below in the appropriate boxes and click Replace All.

Find What:        \.(\w+)\(item.\)
Replace With:     \.$1\(item.$1\)

My final product would be this:

var thing = thing.loremIpsum(item.loremIpsum)
    .dolor(item.dolor)
    .sit(item.sit)
    .amet(item.amet)
    ...
    .voluptatumSimiliqueMagni(item.voluptatumSimiliqueMagni)
    .impeditDelectusFacilisNatus(item.impeditDelectusFacilisNatus)
    .labore(item.labore)
    .corrupti(item.corrupti);

As a second example, let’s say I was not chaining and did not have just ‘thing’ and ‘item’ but wanted to swap some properties around–I needed to convert something bizarre like this:

.loremIpsum(est.)
.dolor(necessitatibus.)
.sit(utLiberoInventore.)
.amet(ipsaDicta.)
...
.voluptatumSimiliqueMagni(exercitationem.)
.impeditDelectusFacilisNatus(repellendus.)
.labore(perspiciatis.)
.corrupti(placeat.)

to this:

est.loremIpsum(loremIpsum.est)
necessitatibus.dolor(dolor.necessitatibus)
utLiberoInventore.sit(sit.utLiberoInventore)
ipsaDicta.amet(amet.ipsaDicta)
...
exercitationem.voluptatumSimiliqueMagni(voluptatumSimiliqueMagni.exercitationem)
repellendus.impeditDelectusFacilisNatus(impeditDelectusFacilisNatus.repellendus)
perspiciatis.labore(labore.perspiciatis)
placeat.corrupti(corrupti.placeat)

The regex would be something like:

Find What:        \.(\w+)\((\w+)\.\)
Replace With:     $2.$1($1.$2)

Final Thoughts

There are lots of other cool possibilities with a powerful text editor like Sublime Text. Something I didn’t address here that I may in a future post is leveraging the sublime package manager to install plugins. Also, customizing your hotkeys and adding new ones. If you frequently use similar tricks, share them in the comments.

Column Selection or Multi-Selection combined with Ctrl+Click and Copy/Paste is probably one of the most powerful tricks you can use. Most code is not random enough to overcome these trios. You often have variable property name lengths, but Ctrl+LeftArrow or Ctrl+RightArrow overcomes that by skipping over phrase chunks. This only starts to break down when you have dashes (-) in your names like ‘some-css-class’. That’s usually not a problem for most languages though since convention calls for PascalCase or camelCase combined with underscore (_) for some variable names (e.g. SOME_STATIC_VAR), but underscores are considered part of the phrase.

Ideally I would have had a tool or script that simply looked at my database table and would have pumped out the model for me. Alas, that would have taken more time to script out or investigate. The methods I used here have significantly reduced the time it takes me to code lengthy, repetitive, pattern-prone snippets.

Day One: Journaling Made Easy

Day One

I don’t buy apps very often. Probably because I can usually find a free alternative that works. However, every now and again the free alternatives are not what I’m looking for and the paid alternatives look fabulously well developed–great UI, great UX–so I take the leap and buy.

Day One is one of those apps.

Probably about a year ago I went ahead and bought it and I’ve never missed the money or regretted it. ($5 really isn’t that much money, it just seems like a lot relative to all those free apps we download. It’s probably cheaper than buying a physical journal!) I’ve always struggled to keep a memoir of my life, but Day One makes it easy because not only are their reminders, but I can take pictures along the way. One of the reasons I don’t write in a journal regularly is because it takes time to describe what I did that day or I’d have to bring the journal with me everywhere I went just to capture a moment in the moment. With Day One, I can capture moments in the moment and all I have to do is take a picture.

While pictures are awesome, words are the essence of any true journal or diary. A photo journal without words is more of a photo album. It can tell a story, but words can add a lot of depth to a picture, much like sound to a motion picture. If typing on the phone sounds ‘no bueno’ to you then just speak into your phone and let it transcribe your voice because Day One supports that too! Brilliant! My greatest entries are probably those that combine pictures with words.

Once again though, writing a long, reflective entry can take time. I’ve found that some times all I need is the time it takes me to get to work on public transit or waiting in the airport for a flight.

Writing in a journal is often more about reflection and meditation than anything. This is one of the keys to relaxation and greater happiness. This is one of the biggest reasons why I write in my journal. Furthermore, I want people to know what my life is about on the day to day, what I think about, what I notice, what’s important to me. I want to go back and remember what I did 10 years ago. I want others to do be able to do that too, if they wish.

In summary these are the reasons why I love Day One:

  • Photos
  • Tags
  • Reminders
  • Varied journal views (i.e. timeline, calendar, photos, year, etc.)
  • Geolocation data
  • Weather conditions
  • Cloud backup via Dropbox
  • Digital

Day One: journaling made easy.

Is Getting a University Degree Worth It

After reading Jake’s post (2013-04-23) about being a university graduate, I felt inspired to write my own. I’ve thought a lot about why I initially chose to go to college, why I stuck around instead of dropping out and what it means to me now that I’m a university graduate. To some people it might sound crazy to drop out of college when it seems practically required you have a college degree to get a job these days. However, I’m assuming many of my readers could understand the appeal given the largely technical audience of my blog and my technical background. So is getting a university degree worth it?

Introduction

Over the last several years, app development and entrepreneurship have exploded. The demand for developers of all kinds, including designers, programmers and testers, has skyrocketed. Furthermore, the push for smarter entrepreneurship and more efficient means of finding potentially successful products and exceptional talent has increased. As a result, many would-be college graduates have dropped out and started their own companies. Some have been successful; others not so much. Instead of starting companies, others have found they don’t need a diploma to find a high paying job, as long as they have the sought after skills. Still others are attracted by the potential to fund their their dream jobs and ideas with the money of VCs and angel investors, not to mention friends, family and fools.

The point is, young twenty somethings are finding ways to make a living without obtaining a university degree and, from what I’ve seen, primarily by leveraging technology. We hear about successful blogs, YouTube channels, Kick Starter projects, mobile startups, work-from-home entrepreneurs, sell-it-on-ebay-ers, etc. every day. Furthermore, with the advent of free online college courses (e.g. Udacity, Coursera, MIT Open Courseware, Stanford iOS Development Lectures and others) there’s more incentive than ever to NOT go to a traditional university and pay tuition (read Reinventing College & Education). While many college graduates are anxious to find jobs, technologists are making it big. That’s not true for the majority probably, but it seems like it’s become much more prevalent.

So now that I’m a university graduate, how do I feel about it? Do I have any regrets? Do I wish I would have done things differently? Do I have a job?

Open Doors and Career Decisions

When I applied to BYU, I declared my major as biophysics. It sounded prestigious and exciting. I loved physics and I loved biology. This would be the perfect major for me. I never once looked at the required coursework. A couple months into school, I realized I needed to start planning my major and the classes looked unappealing. Furthermore, people told me the career options, and I wasn’t really interested. The only thing that sounded cool was being a doctor, “cuz doctors make lots of money” (Obamacare didn’t exist yet). That was when I realized I had no idea what I wanted to be “when I grew up.” I realized for the first time that classes don’t determine what you do for your career necessarily. In other words, I liked biology, but did I want to be a doctor for the next 30 years? Did I want to go to med school? I really had to check my motivations.

In the meantime, I left to serve as a volunteer missionary for two years and I thought that would give me plenty of time to figure it all out (false). When I got back, I decided to follow in my brother’s footsteps and give Information Systems a try. It just so happened I loved it, just like most of my brother’s interests.

Then it came again. I knew that information systems was the major I wanted to commit myself to because the coursework was interesting, the jobs were interesting, the jobs paid well and the jobs were in high demand, but I didn’t know which company I wanted to work for or which field of technology I wanted to dedicate myself to. Therefore, I chose to apply to the Masters of Information Systems Management (MISM) program, which would give me another year to think about career and company and another shot at an internship. In retrospect this worked out perfectly because it gave me an extra summer to take an internship, more time to try different part-time jobs and more time to delve into all sorts of tech on personal projects.

My first internship opened my eyes to what kind of company I wanted to work for and also what kind of work I didn’t want to do (among many other invaluable experiences, skills, etc.). Then by the time I got through my second internship I figured out what interested me most and what I saw myself doing full-time for the next 30 years (or so) of my life. And that’s when I started focusing my efforts into developing a master’s capstone project that would really help me obtain skills revolving around designing and coding.

The university setting provided all these open doors to me. It seems to me that if I had gone straight to work after high school or dropped out of college to jump on some big idea I would have felt almost forced to take the path that I had chosen without more time to explore other opportunities. I know that’s how I felt when I was faced with company offers: it felt like the end of career exploration, like I’d never switch jobs once I signed one of those contracts. While that may not be likely these days, a full-time job will consume most of your time to explore other opportunities, not to mention present other potential side effects like the ‘golden handcuffs.’

To put it differently, I needed a good 3 years trying different things (internships, personal projects, part-time jobs, even just interviewing lots) to figure out my career. I don’t think I could have done that as well any other way, even traveling the world and just taking time off to think. It’s possible I could have dropped out my last year to try and launch a startup, but until then I didn’t even know what I wanted to do! Regardless, I was at the end of the university race. Why drop out during the final sprint? Alternatively, I could have skipped college and gone straight to work and figured it out that way, but I didn’t have enough experience to get me anything more than a fast food job or maybe some personal assistant work. So maybe a university degree and experience isn’t for everyone but it was perfect for me, for someone who didn’t know what they wanted to do or be. And what’s more is that the open doors and opportunities not only provided a path for my career but gave me other life experiences. The opportunities, experiences, people and time helped me find myself.

An Experience, Not Just Education

Attending a university is more of an experience than just an education. There’s so much happening at a university that if you go just to get an education and do nothing else but school school school, then you’re missing out. That should be obvious to most if not all college graduates (I hope). Even aspiring high school students know there’s more to school than grades and test scores. What about the extra curricular activities?

For me BYU was an experience and I had a blast. During my first semester, I slept an average of 3 hours a night (class at 7am every day; I took 3 hour day naps). I went to dance parties, went on road trips, went sledding at 2am and stayed up late just to stay up late. That’s what you do when you’re in college, right? Toward the end, I got more involved in clubs, service organizations, dance classes, an occasional intramural sport team and business competitions, many with the intent of not only building a résumé but building my character and enjoying life.

Being involved in so many things and meeting so many different people helped me see the world through an ever changing lens, something of a kaleidoscope, but more organized and meaningful. College is a unique experience that can’t quite be replicated and I’m glad I lived it. I’m also glad it’s over. No more homework and no more tests.

Education Is What You Make of It

Parallel to the idea that attending university should be an experience is the idea that education is what you make of it. As a masters student studying information systems (IS), I had the opportunity to take MBA classes in addition to my IS coursework and electives. One of my MBA professors started one of our many lectures by referencing an article that supported the claim that going back to school for an MBA is an economically sound choice based on the average salary of MBA grads in the US. However, he disagreed with the article and provided this insight: You don’t go back to school to earn an MBA just because it will increase your salary by maybe $10k more than other university graduates. Based on how much tuition you’re paying, you probably won’t break even for a number of years, not to mention the opportunity cost of leaving the work force for two years and the time you give up. You go back to school for whatever it is that you need and want to get out of it. In other words, an MBA is one of many ways to increase your wealth, but don’t go back to school for just that one reason.

There are so many other things to get out of a university education. Perhaps more importantly you could create an extensive network of connections among your professors and peers to land a prestigious job. Chances are if those connections don’t help now, they will in the future. Or perhaps you could seek co-founders for the new venture you’ve launched or are preparing to launch. Or perhaps you could enter a competition and pitch your big idea to judges and investors to refine your idea, get noticed and maybe win $50k of crucial seed capital.

I witnessed a number of my peers just sorta go to class without really learning anything valuable. For them, a degree in information systems was just the key to a job. They worked hard in the classes they enjoyed, but sorta just shrugged their shoulders in the classes they didn’t care about or didn’t perceive as valuable. Maybe for them it wasn’t valuable. Maybe they will never use the material. Maybe they are happy with their job and skills and that’s all they want. I’m sure some of them spent their time working more hours in part-time jobs. Money isn’t a bad trade-off. Others were probably trying to launch start-ups or push ideas through entrepreneurship competitions. Not a bad trade off either.

I don’t have any regrets about obtaining a university degree. I believe I did pretty well for myself. If I could go back and do it over knowing what I know now, I’d probably change a few things, but that’s typical of knowledge and experience. If I could do it over again, I’d probably spend less time as an underclassman having fun just hanging out and spending more time having fun building my career and skills. Additionally, I’d maybe take a year off or attend classes part-time and see if I could launch a startup. At BYU I had a number of free resources right at my fingertips that I could have utilized more than I did including professors, experienced entrepreneurs, career services, students with similar interests, the Crocker fellowship and the Center for Entrepreneurship and Technology just to name a few. Regardless, I have a job, I have a degree and I have developed the skills to do what I want and become what I want to become. I made the most of my education.

Trade Schools

One thing I want to draw attention to separately is the focus of general education classes. GE classes at BYU were often a pain because they were just that–general. This is something I would change and do differently.

A friend of mine attended the LDS Business College and took the same required GEs but got so much more out of his classes because they looked at history, economics, writing, math and even science through the lens of business. Everything was applied to business from what he told me. I think I’d much rather enroll in a business college from the beginning, knock out my GEs, get my AA and then transfer to a B-school like the Marriott School of Management. While many of my peers successfully knocked out their GEs with AP or IB credit in high school, I don’t think this is the necessarily the best route either. Most of us are too immature and inexperienced in high school to get significant value out of the classes we test out of. Even though they are more than sufficient introductory courses, they’re not applied. In my mind, application and contextual understanding is one of greatest keys to mental persistence and creating value.

I’ve never been to a trade school but from what I’ve heard, they sound like a brilliant alternative to a traditional university education, assuming they are accredited and you come out with a recognized diploma/degree. Personally, I think our society places too much emphasis on traditional kinds of degrees and credentials. We’ve overshot the goal, which I believe was to create a means of more easily identifying the individuals with the desired skills and abilities. It seems to me some jobs require advanced degrees, when in reality what the employer needs is a person with a specific skill set. Degrees are supposed to guarantee that skill set (though some times they don’t even do that); they shouldn’t act as barriers to people who have the necessary skills even if those skills were gained through experiences outside of an academic institution. In my field (and perhaps in others as well), it’s not uncommon to hire a technologist without a degree. What matters is if they can get the job done as expected. Usually this is validated through a résumé, references and targeted interviews. Naturally many companies simply require degrees to make the process easier on them by filtering out potentially unqualified candidates. This is one of the very reasons I got a master’s degree–to minimize the chance of facing job barriers, even red tape when looking for a promotion or career advancement. That said, some of the smartest, most capable people I’ve worked with don’t have have advanced degrees let alone college degrees.

Quality of Education vs. Cost of Education

The Information Systems program at BYU has consistently ranked as a top 10 program. Based on the tuition I paid at BYU, I’d say I got a steal of a deal. Furthermore, I was fortunate enough to graduate debt free. I don’t think that’s something every university graduate can say, especially those who pay top dollar at some universities. At the end of the day, IS grads from the Marriott School of Management get offered the same exceptional job opportunities from companies that recruit at other top ten schools.

There are a number of opposing arguments that could be made here, such as differences in starting salary, etc. I haven’t done enough research to really look at the various arguments, nor have I the experience or knowledge or wherewithal to make any judgments. The point of my post isn’t really to compare universities either, but I’d like to reply to the argument that the cost of a university education these days really isn’t worth it. For who I am and where I’m at today, I feel competent and competitive with those in the work place. I got what I paid for and I feel good about it. Like I said, I have no debts and I have a full-time job. Not everyone can say that, but I can. If I were thousands of dollars in debt and jobless, I don’t think I’d feel the same way. Not every degree can get you a job or put money in your pocket.

Closing Thoughts

If you know your end goal and you have an idea on how you want to get there or if you’ve found yourself, you may not need a university degree, especially if your field is technology related. If you know your end goal, maybe free online classes are the way to go. Maybe running a startup is the right choice, especially if you’ve already validated your idea, have potential customers and/or have interested investors. Diving in and getting to work can be some of the best education. It’s real, it’s valuable and it forces you to stay afloat or drown. If you have the drive to succeed, the proverbial leap of faith may lead you to success–you won’t stop fighting until your survival is made sure.

I’ve toyed a lot with the idea of founding tech startup and seeking funding. From one angle, it sounds like an amazing experience: someone else pays you to build your dream product. And it seems like that’s how a lot of the startup founders I’ve met feel about it. More power to them. It’s a pretty enticing opportunity, especially if it takes you where you want to go. From another angle, I’d rather start a business without funding. Why would I want an investor or venture fund for my boss? I mean in a lot of ways, that’s what investors and VCs are, your boss. At the end of the day, they are the people you report and answer to. I’d rather start a business to be my own boss. Isn’t that why most people start a business, for autonomy?

I’m happy where I’m at. I’m learning, I’m growing, I’m making money, I’m enjoying life both in and out of work. And it just so happens I’m a university graduate with two degrees and I have no regrets. Is getting a university degree worth it? For me, yes. Ask me what I think in ten years.

Creative Commons Licenses

I’ve been working on a platform to publish photos from my travels. As part of my research, I read up on Creative Commons (CC) licenses. The Creative Commons website was extremely helpful; very clean website, great UI/UX and clear explanations of the licenses. I’ll summarize the six main CC licenses here; however, I suggest you navigate to the Create Commons website for specifics and the actual licenses.

There are four main characteristics of the CC licenses:

  • Attribution: Giving the creator due credit for works. All CC licenses require attribution.
  • Distribution: Dissemination of works. All CC licenses allow for redistribution (sharing) of works.
  • Derivatives: Creating modifications of original works. Some licenses prohibit derivative works while others only allow for ShareAlike, which means others must license their new creations under the identical terms.
  • Commerciality: Making profit from original or modified works. Some licenses allow works to be used for commercial purposes while others do not.

Therefore, the six licenses are as follows:

  • Attribution (CC BY)
  • Attribution-ShareAlike (CC BY-SA)
  • Attribution-NoDerivs (CC BY-ND)
  • Attribution-NonCommercial (CC BY-NC)
  • Attribution-NonCommercial-ShareAlike (CC BY-NC-SA)
  • Attribution-NonCommercial-NoDerivs (CC BY-NC-ND)

See the About The Licenses page on the Creative Commons website for details.