Skip to main content

Mobomo webinars-now on demand! | learn more.

In this day and age, transparency is a necessity for every business—distributed or not. When more than 1,700 chief executive officers were surveyed for an IBM Global CEO Study, the majority agreed that openness and transparency are key to a company’s success.

Transparency breeds trust—and research reveals a definitive link between organizational trust and overall business performance. According to Building Trust in Business, an annual survey conducted by Interaction Associates, high-performing organizations have consistently placed more value on customer and employee relationships than lower-performing businesses. As a result, workers at high-performing firms are better at retaining key employees. "High levels of trust equals high performance," Linda Stewart, CEO of Interaction Associates, told Entrepreneur magazine. “If you look at the lower-performing companies, in all cases they had lower levels of trust."

I Can See Clearly Now

Because remote workers literally cannot see their managers, distributed businesses are inherently opaque. Distributed team members often feel disconnected from the business, which can promulgate paranoia and suspicion. This leads to a distrustful work culture and lower productivity.

This is why it’s so important for distributed team leaders to pull back the curtain and give their employees a clear view of the company’s day-to-day business. If you don’t want to leave your distributed team in the dark, take these six simple steps to make your business more transparent:

Step 1: Bulldoze silos

At Intridea, we believe it’s important not to build communication “silos,” which essentially lock up information in private emails or individual conversations. Unless there’s a good reason not to broadcast certain sensitive details, we ensure company communications and information are easily accessible to the entire team. After all, knowledge is power; but valuable information is useless to the company if you don’t share it with your team.

When you depend on communication silos, important information gets bottled up in individual inboxes, chat accounts or even inside employees’ heads. Break down these barriers by using technology that allows your team to easily share information with each other. Which leads us to the next step…

Step 2: Use transparent collaboration tools

Without open communication and the tools to support it, ideas and information will end up trapped in a silo where only a few people can access it. This is why it’s important for distributed businesses to use collaborative technology tools that make information readily available to the entire team.

When we at Intridea have a project involving more than one person, we typically use a group chat tool instead of multi-person emails. This opens up project information, ensuring that everyone involved with the project is fully aware of the current status. It also gives the added advantage of providing a searchable, archived history of the project.

Step 3: Encourage open communication across the board

Here at Intridea, we try to cultivate a culture of openness and trust by maintaining clear and truthful communication with employees. The lines of communication work both ways. Not only should distributed workers remain in constant communication with their managers—but managers should also be open and frank with their team members.

When you communicate with your team, don’t mince words. You should always be forthright in your communications with teammates and clearly explain the motives and thinking behind your opinions and decisions. Help your colleagues understand your position by providing them with all the information—not just bits and pieces. This preserves trust and boosts group decision making.

Above all else, be honest. When you communicate with your employees, make sure they know exactly what’s in store for their career and the company in general.

Step 4: Curb back-channel chatter

As with any organization, rumors can spread rapidly in a distributed company. Since distributed managers aren’t in the same physical location as their employees, they don’t have an opportunity to hear the hushed whispers in the hallway. Unfortunately, many remote team leaders don’t learn about rumors until after they’ve taken a toll on the organization.

This is why it’s important to be proactive when it comes to curtailing rumors. How do you accomplish this? By making your company as transparent as possible. In the absence of information, your team members will dream up their own reasons for unexplained happenings—and these reasons can sometimes be uncharitable, inaccurate or downright ludicrous.

“Rumors arise in situations that are ambiguous,” writes author and psychology professor Nicholas DiFonzo in his book The Watercooler Effect: A Psychologist Explores the Extraordinary Power of Rumors. “Rumor is primarily what people do together when they are trying to make sense and manage threat in an ambiguous context.”

Imagine a key employee leaves a company. Of course, your distributed team will realize the employee is gone—but without any details about what happened, they might assume the worst and start wondering if they’ll be on the chopping block next. Rather than pretend the employee never existed, address the situation head-on with the rest of the team. First communicate the details to the team members most directly affected, and then send a clear message to the rest of the company.

DiFonzo points out that transparency is the best way to squelch rumors. “Developing a norm of transparency and reducing uncertainty may be as simple as periodically posing the question, ‘Has anybody heard any rumors lately?’—and then being sure to respond honestly, quickly and convincingly,” he suggests.

Step 5: Share job openings with the team

In the spirit of transparency, be sure to share new job openings with team members before you post these positions publicly. This ensures your employees aren’t taken by surprise, which may make them question their job security. Plus, when you inform your team about a new position in advance, they can contribute to the recruitment process through referrals and social or professional networks.

Step 6: Realize transparency doesn’t equal micromanagement

Although it’s important to embrace transparency and ensure distributed employees maintain communication with their managers, this isn’t an excuse to micromanage. Numerous studies have proven that micromanagement can result in serious consequences, including disenchanted employees and inefficient teams. In fact, employees have singled out micromanagement as the most significant barrier to their productivity, according to a survey by office products manufacturers FranklinCovey.

It’s important to maintain a healthy balance between communicating with team members and giving them space to accomplish their job as they see fit.

Keep the conversation going! We'd love to hear from you.

Categories
Author

We were particularly proud to see one of our favorite clients, Peter Dewar, Chief Technology Officer at the District of Columbia Retirement Board (DCRB), participate in a thought-provoking panel on Wearables and the Internet of Things. The session's description as a “visionary panel” proved to be true, as all of the participants outlined the groundbreaking mobile capabilities they foresaw as feasible within the next five years.

Dan Mintz introduces Peter Dewar and other panelists

Mr. Dewar described his vision for implementing Google Glass in the office, at conferences—even for pension fund participants, staff, and Board members. Taking the idea of “smart rooms” even further, he also described a futuristic conference room, which would be able to set up a meeting’s required media (think dial-ins, projectors, etc.) upon the meeting organizer’s entrance or (biometric) authentication.

We from Mobomo were on the edge of our seats thinking about the possibilities, and excited about building them—especially for our government clients. Congrats to Peter Dewar for a great panel session, and thanks to Tom Suder for hosting yet another fantastic summit. We’re looking forward to next year’s—and to the future of mobile (in the government!).

Categories
Author

distributedteams

For countless decades, psychologists, geneticists and armchair scientists have debated about the impact of nature vs. nurture on human behavior. Although some research suggests characteristics like self-motivation and ambition are strictly inherited, we believe environment can also play a significant role in these traits. So while you may not be able to teach self-motivation to your team members, you can take steps to light the spark that already lies within...

“Ambition is energy and determination,” Dean Simonton, a psychologist at the University of California, Davis said in a TIME article. “But it calls for goals too. People with energy but no clear goals just dissipate themselves in one desultory project after the next.”

Light That Fire

We’ll be the first to admit that some employees just aren’t as driven as others. But when a remote worker seems to be completely unmotivated, it’s not necessarily his fault. He may be waning because his manager has failed to set clear expectations and deadlines for him. Often times, a little guidance is just the spark that an employee needs to light his fire.

Here at Intridea, if we notice a team member is fading, we make sure to give them explicit instructions and explain they’ll be held accountable for the quality of their work. By the same token, when an employee produces top-notch work, we shower them with praise.

We also ensure our employees understand their performance is measured by the actual work they produce; not the number of hours they work. We’ve found that newbie remote employees are often accustomed to the brick-and-mortar style of work, where clocking in and clocking out each day is good enough. Since there’s no need for a distributed worker to “show up” at an office, it’s all about the results they produce.

This is yet another reason to hire plenty of SMAIPs (Self-Motivated, Autonomous, Inquisitive People) for your team. (We discussed these highly desirable employees in our last two blogs.) These go-getters often serve as an inspiration for seemingly apathetic co-workers. No matter how indifferent they may seem, unmotivated employees will sit up and take notice when SMAIPs are consistently praised for their superior work—and this could be just what it takes to kindle their self-motivation.

Reignite Workers with Motivational Phrases

Whether you’re trying to motivate or congratulate employees, it’s important to choose your words wisely. Here are a few phrases we at Intridea use to push team members to try harder or praise them for a job well done:

  • “I know you’re capable of more than this.”
  • “I’ve noticed you haven’t been turning in your projects on time. Are you having any issues outside of work?”
  • “In the past month, your work hasn’t been as high quality as what I usually see from you. Is there something blocking your way?”
  • “I’ve noticed you’re falling behind on your projects. Can I help you prioritize?”
  • “I can see you’re swamped. How can I help?”
  • “The work you turned in on Monday was spot-on. Great job!”
  • “I’m proud of you. Keep up the good work!”
  • “Thanks for all your hard work. I really appreciate your efforts.”
  • “We couldn’t have done it without you!”
  • “Awesome job on that project! How did you do it?”

With the right words, plenty of encouragement and a clear set of goals, we believe you can inspire self-motivation in virtually any employee—even those who work from home in their PJ’s and fuzzy slippers.

Categories
Author

weird marketing

How do you get noticed when money is tight and the bigwig is who you’re after?

By talking to them in big bold letters. Add a fuchsia backdrop, plaster it on a board, throw in a few GIFS, and put it in the center of NYC---directly across from their window. That’s how!

Last Monday, Intridea launched our first billboard experiment; talking to a hopeful client through the art of bright banners and GIFS. It's unlike anything we've done before and completely out of the norm, but sometimes that's what it's all about...

As entrepreneurs, we have to get creative to stand out these days. Marketing is crazy competitive and long gone are the days of mere emailing, phone calls, and Google search.

So what’s a young business to do? Get weird, that's what.

If you want someone’s attention, reach out to them in any way possible. Don’t be timid and don’t second guess yourself. Market in an unconventional way and you’ll get unconventional (and more often than not) - positive responses. Don’t believe me? Keep reading.

Uber | Kittens + Cupcakes

Uber is great. Add kittens and cupcakes to the mix and you’ve just made a friend for life. On National Cat Day, Uber went out of their way to celebrate their feline loving fans. On this day, NYC, San Fran, and Seattle Uber users could “request a kitten” and enjoy a cupcake --- all because Uber said so! Talk about odd, out-of-the-box, and interesting.

Airbnb | Hollywood + Vines

Back in 2013, after a series of renter mishaps, Airbnb turned its focus to user experience. With their campaign, titled Hollywood & Vines, Airbnb created a four minute short film utilizing six second Vine videos from users all over the world. It was an uncommon route, but excellent platform for partnering with Airbnb users and capturing their adventurous spirits.

Ben & Jerry’s | Tweet for Ice Cream

I love B&J’s CORE ice cream campaign. Traveling around the US and setting up shop in various cities, BJ is giving out free ice cream to anyone who tweets them. Its awesome, fun, and super convenient for their lovely fans. Plus not only is it free, but they hand deliver them to your specific location - talk about customer loyalty!

Don’t get wrapped up in the details. Go out there and do something crazy; it's the only way to succeed as an entrepreneur. Too much thinking wastes too much valuable time.

Drops mic.

Keep the conversation going! We'd love to hear from you.

Categories
Author

In our last blog, we pointed out the three most important traits for successful remote workers: self-motivation, autonomy and curiosity. We call these highly desirable employees SMAIPs (Self-Motivated, Autonomous, Inquisitive People).

So once you’ve built a killer distributed team of productive SMAIPs, you can just let them do their thing right? Not so fast. Even if you’ve populated your team with the most self-motivated, autonomous and inquisitive employees known to mankind, you have to consistently nurture these traits.

Here are five do’s and don’ts we at Intridea follow to keep our distributed employees motivated, engaged and happy:

1: Don’t Micromanage. Do Give Guidance.

Because SMAIPs require very little direction, they absolutely detest micromanagement. That’s why we try to foster self-directed behavior by giving our team members plenty of independence and elbow room to get the job done.

If you hover over your employees, get involved with every small task and nit-pick every detail, you’ll stifle their creativity and send their confidence into a tail spin. In fact, people who believe they are being watched perform at a lower level, according to a study in the Journal of Experimental Psychology. So, back off. The more you micromanage, the less productive your team will be.

When leaders expect remote employees to follow overly complicated processes, this can also crush self-motivation. After all, enforcing inflexible rules and procedures is really just another form of micromanagement. We’ve found that if employees have to jump through hoops to get something done, they're less likely to try.

2: Don’t Play It Safe. Do Embrace Failure.

If you punish your team members for each and every failure, you’re going to end up with overly cautious employees who do the bare minimum. And who could blame them? They’d rather play it safe than face your dreadful wrath.

Far too many remote managers paralyze their teams with the fear of failure. Not only does this suffocate their inquisitive and self-driven behavior—it eventually transforms employees into brainless automatons.

At Intridea, we think it’s important to embrace failure and turn each botched attempt into an important lesson. In his book, Adapt: Why Success Always Starts with Failure, economic journalist Tim Harford writes, “Biologists have a word for the way in which solutions emerge from failure: evolution.” Harford says we need to learn to accept failure and constantly adapt, which involves lots of improvising. “Success comes through rapidly fixing our mistakes rather than getting things right first time.”

In fact, some research shows that failure is often the quickest path to success. People and organizations that disastrously miss their goals perform much better in the long-run, according to a University of Colorado Denver Business School study.

“We found that the knowledge gained from success was often fleeting while knowledge from failure stuck around for years,” Professor Vinit Desai, the leader of the study, wrote in the Academy of Management Journal. “Organizational leaders should neither ignore failures nor stigmatize those involved with them. Rather leaders should treat failures as invaluable learning opportunities, encouraging the open sharing of information about them.”

3: Don’t Overburden Them. Do Enforce Work-Life Balance.

SMAIPs are often prodigious in their output—which can be both a blessing and a curse. While leaders may be tempted to let highly driven team members pull long hours and work their fingers to the bone, this will quickly lead to employee burnout.

As we mentioned in a previous blog, it’s important to ensure your employees achieve a healthy balance between their work life and personal life. In the long run, work-life balance leads to happier, more productive employees.

“The business climate has become so fiery and competitive that leaders are focused on competition and getting the most out of their people,” John Izzo, author of Values-Shift: The New Work Ethic and What It Means for Business, told CNNMoney. “Everyone's working to their max.” This extreme pressure will quickly derail even your most productive and driven SMAIPs.

Izzo warns that an employee suffering from burnout becomes part of the “working wounded.” Because they’ve lost all of their motivation, they apathetically limp along through their work day. “Ultimately the biggest price companies pay for burnout is a loss of talented people,” he adds.

Because we realize SMAIPs will create Intridea’s most innovative work, we make a point to nurture these employees—not work them to death.

4: Don’t Dishearten Them. Do Give Positive Feedback.

Distributed leaders have to be careful about demoralizing SMAIPs with too much negative feedback. If you only offer a worker feedback when he does something wrong, you’ll quickly crush that employee’s spirit and deflate his motivation.

It’s important to give distributed employees positive feedback, even for normal day-to-day work. When you reward your team members for a job well-done, this will encourage further self-driven behavior. It also ensures they’ll sit up and listen in the instances when you need to offer them negative feedback.

Warren Greshes, author of The Best Damn Management Book Ever has also emphasized the importance of positive feedback. “If you want to point out the mistakes people make, get them to listen to you and fix those mistakes, you better be ready to recognize them when they do something right,” he writes. “Employee recognition is one of the greatest drivers of employee motivation in the workplace. Do you know anyone who doesn’t like to be recognized when they’ve done something right or achieved something special?”

If you only speak up when an employee has done something wrong, they won't bother to take risks that could turn into big wins for the company. In the end, your employees will stop caring because they know no matter what they do, you’re going to criticize them.

5: Don’t Dismiss Their Ideas. Do Set Expectations.

SMAIPs often formulate groundbreaking ideas, and they’re usually bursting with excitement to share these ideas with their manager. So when a self-motivated employee comes to you with her latest brain child, it’s important to give the idea the thought and consideration it deserves.

If you ignore or constantly shoot down an employee’s ideas, she’ll more than likely stop sharing altogether. In fact, more than a third of U.S. workers don’t speak up for fear of retribution, according to a DecisionWise Benchmark study. “These perceptions typically stem from a culture that stifles the free expression of ideas, and from leaders who contribute to or create that culture,” points out Paul Warner, Director of Consulting Services at DecisionWise. “Fear of speaking up is extremely detrimental to organizations, often causing an escalation of dissatisfaction among employees leading to absenteeism, non-productive work behaviors, low team identification, and eventually reduced performance and turnover.”

We’ve found that while it’s critical to listen to our team members’ new ideas, it also helps to set expectations upfront—even before the employee’s idea is hatched. For example, we encourage our team members to use a program called sparktime—an Intridea initiative to encourage side projects and exploration. When one of our employees submits an idea for a side project, our “approval” is contingent on a well-defined plan as well as good timing with other projects. This helps focus our employees and also teaches them how to set themselves up for success.

Check out our next to blog to learn how to spark self-motivation in distributed employees.

Categories
Author

clean code

Programs must be written for people to read, and only incidentally for machines to execute. - Abelson / Sussman

I like my code so clean you could eat off of it (if you could eat off of code). When working on a codebase I'm ruthless about deleting unused code, unnecessary comments, debugging statements, etc. Yes, it may be painstakingly detailed, but this is all a benefit to my future self, my coworkers and anyone who reviews my code in the future.

When doing a code review of a pull request, I make notes of all the places where code could be cleaner; I also expect the same to be done for me. If I'm pairing, I make sure we do code reviews of every line of a commit before making the commit. I run a tight ship, and I appreciate when my coworkers do the same.

It's just common sense; a clean codebase, free of cruft, is easier to read and understand. A codebase that is easy to read and understand is easier to debug, extend, and modify. Ultimately, a clean codebase makes for happy developers.

What is "clean" code?

Code that is "clean" is code that is written to be read and understood with relative ease. You could say this is code written with the reader in mind. Every person and every organization has their own definition for what exactly clean code is, so I won't be giving explicit examples. What is important is to find some common ground on a project and all stick to it.

Every developer has heard the old saying that goes something like "Always code as if the person maintaining it is a maniac serial killer and knows where you live". With respect to that, clean code is code that keeps you safe.

Rules for organization

Everyone in an organization has their own rules for how code should be organized. It doesn't matter all that much what these rules are, so long as everyone in the organization can agree on some set of rules and everyone follows them.

If you do not have some rules I suggest listening to the ruby rogues podcast episode in which Sandi Metz discussed some rules for keeping code clean.

They are:

  • Your class can be no longer than 100 lines of code.
  • Your methods can be no longer than five lines of code.
  • You can pass no more than four parameters and you can’t just make it one big hash.
  • Your controller (in a Rails app, when a call comes into your controller) can only instantiate one object to do whatever it is that needs to be done.

Note that these rules are not really rules but more like guidelines. They are there to guide you when you don't know where to begin with writing clean code; they are there if you have no rules; they are there as a conversation starter within your organization.

To quote Charles Max Wood from the Ruby Rogues episode regarding the rules:

So, one thing that really strikes me with these rules is that for the most part, if you really try, you should be able to follow them. [If you say] “Oh well, I’m sure I can find an instance that breaks this rule.” The whole point is when you break the rule, you should be able to explain exactly why you need to break the rule. In that way, then you can justify what you’re doing. But otherwise, you’re not forced to think about what you’re coding and that’s really what the issue is.

Style Guide

A style guide goes hand in hand with code rules, such as those defined above. A style guide, however, covers a much greater set of situations. I think the guidelines defined in a style guide are just as important. If everyone codes using their own style (say 4 space or hard tabs instead of 2 space tabs) on a project, it makes the cognitive overhead that much greater from file to file. If I have a standard style that I know the code will conform to, it makes it that much easier to scan the code and figure out what is going on.

Ruby style guide

At Intridea, we have a Ruby style guide that we follow to make sure that the code we write all follows the same convention. (you can find it at Ruby Style Guide). This is a non-confrontational way to let your developers know there is a standard for the way their code should look when they are writing it, you are reviewing it, or you are both writing it via pairing.

Rspec style guide

It is not only important to keep your ruby and rails code adhering to a consistent style, but also it is important that everyone write their specs in a consistent way. I suggest using a resource like betterspecs.org as a starting point for a conversation about how you want tests to be written.

If you want to differ from what is proposed on that page, it is open source on github here. So you can fork it for your organization and make any changes you would like.

Humbleness and code reviews

The best way to fight against spaghetti code, or a big ball of mud, is to have someone review your code, whether through pair programming or an explicit code review (a git pull request being most common these days).

It's important to remember, don't take comments personally, criticisms of code are not criticisms of the person. Critiques of code logic or style should be looked at as a moment in which you can grow as a developer. You may not agree with the examination of your code, but it will at least spark a conversation in which case all parties can see each others viewpoints and come to a consensus of what the end result should be.

On more than one occasion I have come across a piece of code that I thought could have been a bit cleaner, or refactored differently, and thought "oh man, I get to correct someone!" Only to then check the author through git blame, and realize it was written by me. My point is that no one is perfect and change isn't going to happen overnight; it takes time and deliberate effort. You should look at comments regarding code organization or style not as an attack, but as an effort to make the end result better for everyone.

Keep the conversation going! We'd love to hear from you.

Categories
Author

There’s no question, our awesome team of employees is what makes Intridea tick. Of course, any company could say the same, but being fully distributed takes a truly unique individual and it’s definitely not for everyone.

That’s why during Intridea’s hiring process, we keep an eye out for professionals with three essential traits: self-motivation, autonomy and curiosity. We call these highly desirable candidates SMAIPs (Self-Motivated, Autonomous, Inquisitive People).

In fact although we’re a technical company, we value these three employee characteristics even more than a specific set of programming skills. That’s because SMAIPs seek out and learn new technologies on their own, inspire other employees and produce killer work.

A Remote Chance

In addition to the top three critical traits, we also seek out employees who are most likely to work well in a remote setting. Okay, we know what you’re thinking. Wouldn’t a self-motivated person naturally be a kick-ass remote worker? Believe it or not, the two don’t always go hand-in-hand.

This is especially true for certain extroverts. While an extroverted worker might be extremely self-motivated and independent, he may also need to be around others to thrive. Many of these super-outgoing types will shrivel up and wither away in a secluded work environment.

So we’ve found the most desirable candidate for a distributed workforce is not only self-motivated; she also has the ability to remain engaged and inspired in spatial isolation. That’s why we look for team members who are content working in solitude for long stretches of time.

Slacker Alert

Of course, traditional brick-and-mortar companies also strive to hire self-motivated, autonomous and inquisitive employees—but these traits are particularly important for distributed team members. Because non-distributed supervisors share a physical space with their team, they can easily spot when employees are slacking off. This breathing-down-the-neck supervision is not possible when your employees are spread out across the nation or even the globe.

As a result, unproductive remote employees often fly under the radar. This slacker-effect is one the greatest dangers—and sometimes the ultimate demise—for many distributed businesses. To make matters worse, the unmotivated remote worker may not even realize that his status quo is disappointing his boss. It could take weeks before he’s called out on it, and by then a lot of damage could already be done. This is why it’s vital for distributed teams to hire self-motivated, autonomous, inquisitive people.

“The challenges of identifying candidates who will perform at a high level in office jobs are multiplied exponentially when hiring for home-based jobs,” writes Brent Holland, Vice President of Research & Consulting at FurstPerson, in an ERE article. “Regardless of the job or corporate culture, remote workers must be independent, self-motivated, conscientious, comfortable working in social isolation, and capable of solving problems.”

Tracking Down a SMAIP

When it comes to building a distributed team, the old cliché is absolutely true: One bad apple spoils the entire barrel. That’s why it’s essential to hunt down SMAIPs (Self-Motivated, Autonomous, Inquisitive People) when you’re hiring for a remote position.

Here at Intridea, we use rigorous interview and screening techniques. Throughout the interviewing process, we look for clues that the candidate is self-motivated, autonomous and inquisitive and will thrive in a remote work setting.

So how do you pinpoint a SMAIP? In our experience, a candidate might be the right guy or gal for the job if he/she:

  • Contributes to side projects, either in his/her field or outside of it.
  • Attends or hosts events or meet-ups.
  • Founded a start-up in the past.
  • Actively blogs or publishes in other formats, such as books, podcasts, etc.
  • Pursues passions outside of work (rock-climbing, cooking, carpentry, etc).
  • Freelances, either on the side or as a full-time job.
  • Learns for learning’s sake and take classes for fun.

Take Them for a Spin

Still not sure if that candidate is a SMAIP? Take him for a test drive! We’ve found it’s extremely beneficial to arrange a trial run with a potential hire whenever possible. When a prospect is willing to work a one-month trial gig on evenings and weekends before she comes on full-time, this in itself is a sign that she’s a SMAIP.

A trial run gives us a chance to assess the employee’s quality of work, communication skills and reliability. It also helps us determine whether or not the candidate is the right fit for our team.

Every now and then, a candidate’s personality simply doesn’t harmonize with the rest of our employees. In some instances, these trial runs have helped us rule out candidates who are not respectful of their teammates’ time or who don’t effectively communicate their progress.

It’s always better to discover these issues during a trial run than to hire an employee and realize it when it’s too late to pull the plug. And you don’t want a bad apple spoiling your beautiful bunch of SMAIPs.

Once you’ve built a powerhouse of SMAIPs, how do you keep these awesome remote employees happy? Find out in our next blog. In the meantime, got any tips for hiring remote employees? Keep the conversation going! We'd love to hear from you.

Categories
Author

javascript

One of the most utilized, but not fully understood features of JavaScript is that, with a couple of exceptions, everything that you interact within the language behaves like an object.

This functionality can be seen most easily with Arrays and Functions. For example, the simple primitive version of Array (var arr = [1,2,3] for example) has object methods that can be used:

var arr = [1, 2, 3]; arr.indexOf(2); // >> 1 

Can I Use This Anywhere?

Before we get much further, let’s cover the things that aren’t objects. Simple primitives (boolean values (true and false), undefined, numbers, and strings) and null (which is it’s own type) are not objects. Numbers, Strings, and Booleans can act like objects, in that they have methods, but these types are immutable. True objects are changeable (mutable), and their properties are a collection key/value pairs, expressed as {key: value}, or accessed through dot or array notation: key.value or key[‘value’].

Here is an example of how Strings are not objects, but they are object-like:

var twoCities = "It was the best of times, it was the worst of times" twoCities.split(','); // >> ["It was the best of times", "it was the worst of times"]  // You can't add properties to Strings, but it acts like it's stored twoCities._author = "Charles Dickens"; // >> "Charles Dickens" twoCities._author // >> undefined 

This last case is important, because that aspect of mutable objects is what enables things like very simple caching on functions that perform complex tasks:

function renderTemplate (path) {   if (!renderTemplate.templates) {     renderTemplates.templates = {};   }    if (renderTemplate.templates[path] != null) {     return renderTemplate.templates[path];   }   var template = openAndReadFile(path);   return renderTemplate.templates[path] = template; } 

Because Functions are Objects, we can do this. If we wanted to do something similar with Strings, we cannot (and really, there’s not much need for it).

Leveraging Object-like Behavior to Your Advantage

Let’s walk through our caching example in more detail to see how it helps us run more efficient code.

The renderTemplate Function

Here we have a function named renderTemplate, which returns an HTML fragment that’s read from a file stored on the file system. Since we’re not focusing on how that’s done, but rather on how Functions being Objects is helpful, we are delegating the heavy lifting to a different method named openAndReadFile which handles the actual finding and opening of files. However, reading a file can be expensive and potentially redundant work, especially if you’re looping through a large list of items that all use the same template.

Here’s the function again, for reference:

function renderTemplate (path) {   if (!renderTemplate.templates) {     renderTemplates.templates = {};   }    if (renderTemplate.templates[path] != null) {     return renderTemplate.templates[path];   }   var template = openAndReadFile(path);   return renderTemplate.templates[path] = template; } 

The first two lines, if (!renderTemplate.templates) { renderTemplates.templates = {}; } put this “everything is object-like” concept right in the forefront. First, the function is checking to see if it has a property named templates (note that you can reference named functions from within themselves, which is what we’re doing here). If that property doesn’t exist, it creates it, and stores an empty Object primitive as the initial value.

The function then checks the templates Object to see if there’s a reference to the template stored in the cache, and returns it if it’s there. Then, if the template isn’t stored in the cache, the openAndReadFile function is called and then simultaneously stored in the cache and returned to the context from which it was called.

Actually, Everything isn’t an Object

This is a common misconception. JavaScript has six primary types: string, number, boolean, null, undefined, and object. Arrays and Functions are actually a variant of object, with Array being a sorted Object (and with it’s own sub-set of rules) and Function a callable Object.

Further Reading

This is a topic that’s been covered in greater depth by other authors, and I highly recommend that you check out the following (and not just for this specific topic, either!)

Categories
Author
Subscribe to