Men Are Definitely From Mars

Who doesn’t love coffee? Or should I say need coffee?

At least in America, coffee, especially that first cup in the morning, it’s practically a moral imperative. That first cup signals the start to our day; that first jolt that helps take the edge off our sleepiness. Ah! To me at least, it’s one of God’s greatest gifts to humankind. 

For coffee-drinkers, I think we can all agree that there really is nothing better than that first sip. But taking a more amusing perspective on it, what that first sip represents to women versus men wildly differs between the two sexes. Mind you, this isn’t something you’d find in the famous relationship book “Men Are from Mars, Women Are from Venus” but it does speak to a similar theme: If we understand each other better, we can have better relationships. Granted, it’s a much more colloquial perspective, but it’s yet another way of understanding how men and women differ.

Women are multi-taskers. I’m constantly amazed at how they can do so many things at once. I’ve been married almost 30 years and I can’t keep up with everything my wife is doing. I look at our online family calendar and it’s all her stuff! And having a central calendar like that isn’t unique to us. She got the idea from a group of moms she hangs out with; it makes my head spin.

So given that, that first cup of coffee for a woman is that spark that ignites her multi-tasking engine. She feels that caffeine coursing through her veins and she transforms into Super Woman, flitting about the house, getting the kids ready for school while negotiating a better rate on her credit card, and in my wife’s case as a teacher, getting her stuff ready for class. This is all before 7 am. I have nothing but admiration and appreciation for a woman’s ability to think and act upon many things at once.

But for a man, that first cup represents something totally different. We’re focused creatures. We live our lives one thing at a time. We roll out of bed, relieve ourselves, perform our morning ablutions, then head to the kitchen to have that first cup. Nothing else is on our minds. We take that first sip and unlike a woman who probably visualizes the things she’ll be doing for the day we, on the other hand, close our eyes and are instantly filled with anticipation. The anticipation that after we finish that cup, we are going to retire to the bathroom and unload a massive dump.

And it ain’t that ooey-gooey, runny stuff either. It’s a log made from all the compressed waste that has accumulated in our colon overnight, pressing in on itself and building up into one long piece. And it comes out like that, piling on the bottom of the toilet bowl, curling around like soft-serve ice cream, replete with the curly point on top when our sphincter finally pinches together, finally having had enough of the onslaught.

And, of course, men take great amusement and perhaps a bit of guilty pleasure in dropping a smelly turd in the toilet. The more creative ones don’t let it pile. They’ll scoot their ass forward to lay cable, then stand up and admire their handiwork. But it doesn’t end there. Not only will they be proud of their accomplishment, they’ll tell their friends!

Crude and rude? Maybe. But like I said above, it’s a colloquial perspective on just how different men and women are. Sure, I could have taken a more scholarly approach and delved into studies and analyses. But I’ll leave that for the experts. I can only write about what I’ve observed over the years.

Men are definitely from Mars!

Intermittent Fast: Day 1

Okay, made it through Day 1 and just finished my breakfast, so I thought I’d write a diary of my process.

I actually tried to start doing the fast last Friday. Big mistake, since I knew I was going out that night. I was good and didn’t eat a thing after 4pm. But ended up having three beers and most of a basket of garlic fries at Dave Fabian’s gig. 🙂 I was a little better Saturday, but realized I blew it when I had a cocktail at bedtime. On Sunday I was generally pretty good all day but had dinner after Mass and a cocktail before bed.

So yesterday was the first real day of my 8/16 IF. It was not nearly as hard as I thought it would be. I was starving all night last night, but I think once my body adjusts, I should be fine. The best thing about fasting the night before is that I noticed my stomach had shrunken. I normally like a pretty big breakfast, but the little sandwich I had this morning was more than enough to tide me over. I’m going to get my root canal finished up this morning, so snacking will NOT be an issue. 🙂

The big challenge for me will be snacking after lunch. I had a bag of Chili Cheese Fritos after my lunch yesterday. I’m going to have to forego all snacks like this. If I do need a bit of a snack, I’ll have some nuts, but no sugar.

Ugh! Another Resume Tip? This One Is Important

Having been a hiring manager on and off over the last 25 years, I’ve reviewed thousands of resumes. And I have to tell you that 95% of the resumes I see are – for lack of a better word – shit. This has never wavered whether I’ve looked to fill business positions or technical positions. Most resumes I get are crap.

I understand that I might be missing out on some potentially talented people, but the way I figure it, a resume gives me a first impression as to whether or not to talk to a candidate. And those whose resumes don’t possess a couple of critical traits will cause me to immediately pass on those candidates.

And when I say a “couple of traits,” I literally mean that I look at two traits, and no, unlike what seems to be popular these days with certain Mountain View, CA companies, one of those is NOT education.

Professional Summary

The first thing I look at is a professional summary or summary of qualifications. This is a simple paragraph that describes who you are and of what you’re capable. I really don’t care about an objective. After all, those are usually tailored to a specific position. Look, I know what you want to do. Your professional summary tells me why I should even take a closer look.

I’m not going to give examples here as there are plenty to be found online. So suffice it to say that your professional summary is your “elevator pitch.” In sales, this is your 10-15 seconds to catch the attention of your prospect, as if you were in an elevator and only had a little time to sell your product. In this case, the product is you, and the prospect is the hiring manager.

Employment

Here’s where I’m going to rant a bit because this is where so many resumes get thrown in the trash. I can’t tell you how many resumes I’ve seen where instead of describing what they did or accomplished in a company, they use that space to describe what the company does! When I see this, my immediate reaction is, So WHAT?!!! I don’t care what the company you worked for does, I care about what YOU did there! This is said while the crumpled resume sails through the air on its way to the trash.

For software engineers, you need to have the following:

  1. Projects you worked on and your role in said projects
  2. Any professional accomplishments/achievements while employed there
  3. Technologies, frameworks, libraries, and methodologies you employed.

For more experienced engineers, the lists might take up some space. You can keep to your top three for items 1 and 2, but you should list as many as you can remember for item 3.

I realize that you might be worried that your resume will take more than three printed pages when you do this. But I really don’t know who prints out resumes any longer. Besides, at least for me, I don’t mind scrolling if someone takes the time to describe what they’ve done and what they’ve accomplished.

And since employment history is in chronological order, it gives me a great picture of how an engineer has progressed in their career; not just from a technology perspective, but how they’ve grown professionally over time.

The reason I wrote this rant is that I saw the resume of a former employee who is looking for employment. They actually had a great professional summary, but when it got to their work history, they only described the companies for whom they previously worked! I, of course, sent feedback to them and shared – albeit in a much more gentle way than this – how they could improve their resume. Hopefully, they’ll heed the advice.

In any case, especially for those of you entering the workforce, even though you may not have much experience, you’ll raise eyebrows if you tell the hiring manager:

  • Who you are
  • What you’ve done
  • What you’ve accomplished

Simple, right? And no, it’s not “easier said than done.” We sell ourselves every day. A resume is just another form of expression.

Five Feet In Front

I’m sure you’ve heard of or read many inspirational sayings around being in the “NOW,” living in the present, etc. I myself as a former youth minister and career coach and mentor to many young people have given talks revolving around this subject.

One of my favorite sayings came from my own mentor who once told me, “Be clear about your goals, then give them up to the Universe, and the details will take care of themselves.” I know, it’s a real New Age-y thing to say, but it did strike home. What it told me was to stop focusing my attention on the little process details of achieving my goals. If I’m clear about what I wish to achieve and internalize what achievement of a goal means, I’ll naturally make the appropriate choices and changes in my life to achieve a goal.

That was advice I got literally thirty years ago. But let’s fast-forward to a conversation I recently had with my eldest son. He was lamenting the fact that he had studied a creative degree in college and couldn’t seem to find a job in his chosen field of study. He has been justifiably frustrated with this, and though he has gotten several side projects, he hasn’t been able to secure full-time employment in his field.

I empathized with him and told him I understood, but in addition, I happened to say this: “Son, you’re a dreamer like me. We look into the future and see all the possibilities the future has in store, and we want them now. But the reality is that we just can’t reach out to the future and grab our dreams and make them an instant reality. We have to deal with what we have – now – right in front of us. We have real issues that we need to face – now – right in front of us. This frustration you’re feeling is because you’ve got your eyes so fixed on the horizon that you’re stumbling on the obstacles that pop up right in front of you.’

‘Look, it’s not bad to have a dream, but there are more immediate things you need to take care of first to even start making your dreams a reality. For instance, you need to pay for your current life – food, rent, car, etc. So for now, instead of looking so far ahead that you miss what’s in front of you, put your focus five feet in front of you. You’ll still be able to see the future in the distance, but I guarantee you won’t trip on the obstacles that come your way.”

That was met with a little silence, and I realized that I had said something that hit home, something that he could conceptually work with. We’ve had these kinds of talks previously, but until that particular conversation, nothing really hit home.

After we hung up, I thought about what I had said and came up with a little mantra for myself that I’ll share here:

Focus five feet in front… (repeat)

As I said to my son if your focus is too far in the distance, you will stumble over the obstacles right in front of you. With a closer focus, you can avoid those obstacles.

The problem with focusing too far in the future is that just like looking out to the far horizon, you can’t make out any detail of objects, and by the time you reach that point in the distance, you oftentimes find that what you were looking at wasn’t at all what you thought.

For instance, one day recently, I was driving down the road and saw a shape in the distance. I immediately thought it was a dead animal, and it made me feel bad. But as I got closer, it turned out to be nothing but a brown piece of cloth that had bunched up. From a distance, it looked like a dead animal lying on its side. I laughed at my assumption. But that’s the point to this. Things far in the distance aren’t necessarily what they seem.

Another thing about our future is that it’s shaped like a funnel. We stand at the narrowest part of the funnel. As the funnel widens, so too do the number of different possibilities available to us. What causes so many of us so much anxiety is that when we place our focus into the wide-open spaces of the funnel, there are just too many possibilities to consider.

A common thing many of us do when faced with different possibilities is playing “what-if” games with ourselves. It’s fine to do with just a few possibilities, but imagine if there were lots of possibilities that we had to evaluate, which would be the case when we’re looking far into the future where there are several possibilities from which to choose. Add to that what I said about things in the distance not being what they seem from our current perspective – which means we’re also possibly playing what-if games with things that are not yet clear nor distinct. The net result is we become frozen because there are just too many factors we’re considering.

The way to overcome that is to bring our focus in where the number of possibilities is at an amount with which we can deal and the possibilities are things we can clearly identify. I use the “five feet in front” analogy to help drive that home. Now, some can handle more possibilities at once, but the point is to bring our focus back to where we can comfortably deal with the possibilities or issues within the limits of that focus.

Back in the early 90’s, I got into that “Personal Power” trend. I attended a different program, but it was similar to the Tony Robbins seminars. With those programs, one of the first things they’d drive home is that one of the ways to get yourself on a successful track was to start with achieving little goals first. Get the little wins to get you in the habit of achieving your goals.

The concept of focusing five feet in front plays nicely into that. When our focus is closer, it is easy to set easily achievable goals because the possibilities are right in front of us, and there are fewer possibilities to consider. As we learn to take care of those things and make them second-nature, we can start looking a bit further ahead at more distant goals. But our priority should be to take care of those things in front of us first.

Bear in mind, that this shouldn’t preclude us from looking to the future. But we should do it with the understanding that there are things that need our immediate attention first. So move your focus back, get the little wins first, and you’ll find that a whole new world may open up for you.

The Time Is NOW! Part 1

You’ve probably heard sayings like, “No time like the present,” or “You need to live in the Now.” I think it’s safe to say that we can all understand and comprehend the meaning behind those sayings, but how many of us actually make a practice of being fully in the present? On the other hand, how many of us are wont to fall into a pattern of putting it off till later, with the most common result of saying to ourselves, “I really should have…” once that “thing” has passed its expiration date?

Even as I write this, while I am so much better at living in the NOW than when I was younger, I still fall prey to the grim reaper of procrastination; not dealing with some very important things until it’s too late, and sometimes with some severe financial penalties.

Take, for instance, the time I signed up for a data service when I was in a fledgling startup. As a member of the technical advisory board, we were expected to pool our resources in coming up with a strategic plan to help guide the company’s technology path. As we were analyzing patterns and trends within the entertainment industry, I signed up for a data service to call into its API’s to run various studies. Unfortunately, the company eventually floundered before it could take off, and I no longer needed the service. I thought to myself at the time that I needed to cancel the service, and I did that at least once a month for a year until it was too late. I got charged for another year when the subscription renewed. It wasn’t cheap.

A friend of mine calls something like that a “learning tax.” And believe me, over the years, I’ve paid a lot of taxes! And I’m not alone in this. I’ve heard countless stories of people losing thousands or even hundreds of thousands putting off various things. It’s not pretty and can be seriously damaging.

In this series of articles, we’ll delve into procrastination and the things that can cause it, and I’ll provide you with tools I’ve learned either personally or through participation in professional seminars. Truth be told, I’m writing this as much as a reminder for myself as it is a way to reach others.

please Please PLEASE Make My Old Fashioned Right!

While the actual origin of the Old Fashioned is unclear, it was designated as an “Old Fashioned” in 1880 by the International Bartenders Association, and is one of the drinks that the IBA calls an “official cocktail.” Exact historical details aside. This is a drink that has been around a long time.

Now the thing about an Old Fashioned is that if you line ten people up who like Old Fashioneds and ask them their preferred recipe, you will get ten different answers. People will vary in the bourbon, whiskey or rye (perfectly okay, btw), what kind of fruit they prefer (some like the pulp, some like me, just like the zest of either a lemon or a lime – or both). However, there are a few things that seem to be common among Old Fashioned-lovers that almost all share – at least that has been my experience in speaking with people. So if you tend bar, or are making an Old Fashioned for other, you might think of the things I mention below:

  1. I want to taste my spirit. The reason I prefer an Old Fashioned over any other drink is for the whiskey I’m drinking; be it bourbon, rye or straight whiskey. Also, I don’t need a lot of sugar. A single lump, half a pack, or a teaspoon of simple syrup will do. But more importantly, I don’t need a full glass, so go easy on the water. In fact, don’t even bother with the water if you’re using simple syrup. But if you’re using a sugar cube or granulated suger, only use enough water to help melt the sugar during muddling. That means just a splash of water.
  2. Be generous with the bitters, please. I prefer a mix of Jerry Thomas bitters with orange bitters, but whatever bitters you use, please don’t skimp on the bitters. Remember, the Old Fashioned started out as a medicinal, and as such, much of its flavor comes from the botanicals in the bitters.
  3. Go easy on the ice! See the picture above? It’s a single large cube. That’s all you need, or a globe, if you don’t have a big cube. The point is that a large cube melts much slower and will thus not dilute the alcohol quickly. If you have neither a big cube or globe, please only fill the cocktail glass 1/4 full of ice; that is, just enough so the liquid covers the ice. That’s it. Remember item 1.? I want to taste my spirit!
  4. Please use a proper glass. An Old Fashioned should be served in a single Old Fashioned glass; that is, a glass that holds about 6-8oz. If you don’t have one on hand, it’s not a problem. Don’t think you have to have full glass, or think it’s weird that the glass is only 1/4 full. That said, back in May, when I went to move my daughter out of her dorm in Honolulu, at Champs in the Kaimuki district, the bartender only had double glasses, and it REALLY bugged him to see the glass only 1/4 full. So he gave me an extra shot to stop being weirded out. Not that I complained… 🙂
  5. Cherries are optional, and more importantly should only be garnish. Like item 3. above, I want to taste my spirit! I don’t need the extra sweetness imparted from the cherries (there should always be two, by the way), and I especially don’t want a bunch of cherry bits floating in my drink. For the record, I don’t mind citrus pulp, as some bartenders prefer muddling the pulp and leaving the rind alone. Personally, while I lean towards an Old Fashioned made with citrus zest, I absolutely don’t mind one made with muddled pulp, just so long as you don’t muddle the pith as well. As for the cherries, I like whole cherries to marinate in the liquid, and the dark Luxardo cherries are the best. But as I said, let them be garnish. Please do NOT muddle them.

I know… I’m sounding rather elitist, but to me the Old Fashioned is the pinnacle of cocktails. It’s so simple, but the slightest adjustment will make a world of difference in its flavor profile. Change the whiskey, change the citrus component, change the sugar, and it can have a dramatic effect on the outcome. That’s why I’ll never get tired of that drink!

On another note, I thought I’d try a “budget” bourbon, so I got a bottle of Rebel Yell for $9.99 at Trader Joe’s this evening. Wow! I’m amazed at just how delicious this bourbon is. While my go-to tends to be Bulleit Bourbon or Rye, Rebel Yell is a great budge alternative that will not disappoint. However, being a cheap bourbon, how I feel tomorrow after drinking a couple of rounds tonight will be the telling factor. Usually with cheap alcohol, cheaper can mean a bad hangover. We’ll just have to wait and see… 🙂

Surface Pro 4 vs. iPad Pro Comparisons Are Stupid!

Yes, both are tablets or at least take a tablet form, and I get that MS wants to take advantage of the tablet craze. But feature by feature comparisons of the hardware are completely useless to me. Why? Simply because the two machines are completely different animals.

The iPad Pro, even with the addition of a keyboard and stylus is still, well, and iPad. While you can do office productivity with the iPad, fuggettaboutit if you want to do more technical things like programming. Oh I’m sure that some Apple evangelist will read this, and retort that there are online programming editors available so this is a non-issue. I’m going to bullshit on that.

The Surface Pro 4 is a full-fledged computer housed in a tablet body. I have the modest version of the machine that sports an Intel i5 processor and only 8 GB of RAM. I also only have the 128 GB hard drive. But I can do all my software development on my Surface Pro 4, running IntelliJ, MS Word, Excel, browsers, email, and even a local web server, all at the same time. I couldn’t possibly do that with an iPad.

Furthermore, where I often have network connectivity problems with my iPad (admittedly, I have an older version), and even my brand new MacBook Pro, I’ve experienced nothing of the sort with my Surface Pro 4. Ever. For example, I have a wonky HP OfficeJet 6600 at my home that itself loses connectivity to my WiFi at times. It’s a simple matter of turning the printer off and on, and it reconnects. If I try to print from any of my Macs when I do this, they completely barf, and I have to reinstall the printer in my System Preferences! But with my Surface Pro 4, while it may take a little while to find it after the printer resets, it finds it.

Note that I’m not disparaging the iPad Pro at all. With the plethora of apps available for it, it’s hands-down the winner in the apps department; at least for the iPad ecosystem. But please spare me with the comparisons. The Surface Pro 4 is a laptop disguised as a tablet, and the iPad Pro, despite its accouterments is still a pure tablet. If you have the need for the computing power of a laptop, the Surface Pro 4 is the way to go. If not, either will do, but you’ll have the benefit of a huge application ecosystem with the iPad.

So… I guess I should just qualify that I think the head-to-head comparisons I’ve read thus far are stupid with respect to hardware. The more useful ones don’t take a stand and don’t rate one higher than the other, though most of the writers tend to favor the iPad Pro, but it’s easy to see that they’re not programmers.  For me, I just think it’s astounding that MS figured out how to hybridize the tablet and notebook computer. Software geek that I am, I enjoy the best of both worlds!

How Did Apple Miss This?

Look, I’ve been a faithful Mac user for over a decade, having been a PC/Windows user leading up to that point. No, I didn’t switch because I hated Windows. I’m not one to attach religious zeal to the computers I use. A company I joined happened to be a Mac shop, so I started using Macs.

Admittedly, Macs at the time were much easier to use than Windows. Windows was easy for me because I knew all the shortcuts. BUT the big issue with Windows at the time was that many things required manual intervention. Take software installation, for example. With Windows, it was a 50-50 proposition that a driver would be available for some software, and you’d end up having to download the correct driver from the manufacturer’s site. With the Mac, when you’d install software, it just installed. Any required driver was downloaded behind the scenes!

To say I was relieved not to have to think about drivers and the underlying system was an understatement. Some people might argue that if there are problems with the Mac, many things aren’t as accessible. Hogwash. You can open up Terminal, type in some commands, or you can reboot with certain key combinations, and many times, the problems would be resolved. It was much like troubleshoot stuff from the Command Prompt in Windows.

Usability-wise, at the time, the Mac definitely had an edge. Things were just so much easier to get at, and the UI promoted a certain flexibility to put things where you wanted to put them, and arrange them the way you wanted. That took a little time for me to adjust to that because I was so used to the hierarchical file system of Windows.

But Windows started to evolve… Over the years, I began to see a convergence – especially with respect to usability – between the two systems. It wasn’t enough to make me switch back to Windows, but I had to admit that I was pleasantly surprised by Microsoft’s movement toward better ease of use. Enter Windows 10 and the Surface Pro…

In my job, I work exclusively in the Web UI, building applications meant to be displayed in the browser. A few months ago, the question came up about our application’s performance in Windows, and I rather sheepishly said that we didn’t test on Windows as we didn’t have any Windows machines in-house. So I was given the permission to get a Windows notebook, and after doing a bit of research, decided upon the new Surface Pro 4. I got the mid-range model with 8GB RAM and 128GB storage. For what I do, that’s plenty, and I wasn’t going to fill up the machine with pictures, as this was to be a work machine.

To make a long story short, after using the machine for the last few months, I think I’m going to switch back over to Windows. For me, in the most meaningful ways (at least to me), Windows now is just as easy to use as the Mac. I have the exact same tools on Windows that I have on the Mac as far as desktop apps are concerned, and since all the services I use such as JIRA, GitHub and JSFiddle are all Web-based, there’s no difference.

Now all things being equal, if I was doing a head-to-head comparison between OSX and Windows 10, I’d probably not even consider making the switch. But with Windows, Microsoft has finally created an ecosystem of both hardware and software, where there is a seeming seamlessness between the two, much like we see with the Mac. Of course, it’s still Windows sitting on top of a machine, BUT it feels much more like a marriage as opposed to a simple pairing.

Still, that seamlessness wasn’t enough to compel me to make the move, because again, it just meant parity with the Mac. But what pushed me over the top was the touchscreen. Being able to click on links or buttons, and scroll windows by dragging directly on the screen are HUGE improvements in usability. While browsing, swiping back and forth between web pages makes the experience so much more enjoyable – you can’t even do that on the iPad! And the screen resolution simply rocks the house! Even my brother, who is a Mac addict commented on how good my screen looked with the pictures he had taken on a recent weekend get-together.

With the stylus and detachable keyboard, the conversion to a tablet is incredible, with the added advantage of that tablet being a full-blown computing device, with all the performance that you’d expect. Mind you, I love my iPad 2, but to me it’s more of an entertainment device that I keep by my bed, as opposed to a serious computing device.

And though it may seem like a small feature, Cortana rocks! Yeah, yeah, Apple folks will mention Siri – but where is Siri on the Mac? I use Cortana – A LOT – and she works great! I have her open apps, search for things – much like one would use Siri. It’s clear that Cortana needs to mature a bit more, but to have a speech interface on my computer is a real boon to my productivity.

And lest I forget about a HUGE feature, the weight of my Surface Pro 4, or should I say lack thereof is so nice. It’s hard to believe that I’m carrying a full-blown computing device that weighs as little as a tablet.

This brings me to the question I asked in the title of this article: How Did Apple Miss This? It’s clear that Microsoft saw that there was an opportunity to converge the notebook and the tablet and even features found on smart phones. Admittedly, that process of convergence wasn’t as smooth as it could have been, according to many reviews I read leading up to my purchase. But for Microsoft – who has traditionally been likened to a sloth with respect to innovation – to have executed on this innovation ahead of Apple is simply amazing.

It does seem apparent that the absence of Steve Jobs may have a lot to do with this lack of innovation agility. BUT, one would think that Jony Ive would’ve seen this coming. Maybe he did… who knows? But the plain fact of the matter is that if and when Apple does come out with a new notebook that has features comparable to the Surface Pro, for the first time in decades, they will be the one who’s late to the party.

In a way, I feel that it kind of serves them right. Since the passing of Steve Jobs, Apple’s well-known arrogance with its history of innovation has seemed to make it rest on its laurels, and let’s face it: Apple hasn’t come out with anything groundbreaking in the last few years. Though they’ve continued to produce new models of the iPhone, iPad, and the upcoming Macbook, and have made improvements with OSX, these changes have been much more evolutionary and frankly, pedestrian.

So kudos to Microsoft for recognizing the opportunity to converge computing platforms, and more importantly, executing on it in such an elegant way!

If MVC Is So Simple, Why Does It Get Screwed Up So Much?

Seems to me that there are lots of developers out there who have taken up the MVC banner, and charged forth into battle; silently crying out, “MVC! MVC! All apps should be MVC!” Or maybe it’s just me that did that… 🙂 Regardless, over the last few years, lots of people have adopted the MVC design pattern as their pattern of choice. But from what code I’ve seen, especially in the JavaScript world, most of it plain shit as far as following the pattern is concerned.

The most egregious guffaws are confusing object roles in an MVC system. I don’t know how many times I’ve seen objects that cross the Controller-Model or Model-View or View-Controller boundaries; intermingling roles within a single object. Other things I’ve seen are people defining objects to fill a particular role, then do all communication via two-way direct reference between objects. Or worse yet, I recently saw some code where the developer was having a controller make his view trigger an event to which the same view was the only listener! Yikes!

One could just call it stupidity on the part of the developers, but I’ll be more forgiving and say that all that boils down to simple ignorance of how the objects – and more importantly, how objects communicate in any MVC system – should work; or just plain ignorance of what MVC is all about.

The Model-View-Controller paradigm at its most pure is quite simple: It’s all about separation of concerns, and consigning “concerns” to three, specific classes of objects – Model, View and Controller objects. Each class has a specific purpose and role. In this installment, I’m going to talk about each of these classes, and how they should be used to build successful MVC applications.

Model

A Model is an application’s representation of the underlying data set; in other words, it’s data. It has accessor methods in the form of getters and setters to manipulate the data. It does not or should not contain business logic. Unfortunately, some 3rd-party libraries such as Backbone.js muddy the waters a bit by adding things like the “validate” method to allow data validation within the context of the model. I’ve always found this to be just plain wrong. While you certainly can put logic in the model by virtue of JavaScript not having any barriers to doing so, muddying the waters in the model’s role in this respect I believe does more harm than good.

To me validation is really the job of the controller, which should be the one that “owns” the business logic. However, I’m also in favor of placing validation logic in the view to encapsulate it and remove some of the burden from the controller, since validation is really view-specific.

A model’s role is simply to store runtime data. Consumers of the model can get or set attributes on the model. But when that data changes, the model is only responsible to notify listeners that it has changed. To me, that’s it.

View

To me, there are two types of Views: Smart Views and Dumb Views. Smart Views have a bit of logic in them, namely input and output validation logic to make them “smart” per se, but as the endpoint objects – that is, the objects that clients actually “see” – they should never contain core business logic. Actually Smart Views are simply Dumb Views with some validation. Some have argued that a Smart View could also be one that includes Model functionality, but I don’t subscribe to that at all. I think object roles should be distinct, and Views are responsible for presentation of data contained in their associated model. Period. As for “Dumb” views. They simply exist to display model data (and update the model if they’re used for input), and update themselves when the model changes. Pretty straight-forward.

But with any view, I found that following the following rule-of-thumb has saved me countless hours of anguish, and that is simply: A View knows about its DOM and its DOM only. It knows about no other View’s DOM. This is extremely important to consider, especially if you’re using Backbone.js whose views are normally attached to existing HTML elements, and not blitting out their own HTML. When you create a Backbone view and assign its “el,” you have to make sure that no other view – as you can potentially have several views on a page – can manipulate DOM represented by that “el.”

Admittedly, when I was new to Backbone, coming from a system I helped create whose views all contained their own HTML, I broke this rule because hey! jQuery lets you get the reference to any HTML element so long as it’s in the DOM tree. But I ran into a bit of trouble when I had multiple views on a page accessing the same region of the page and using the same el. It was a nightmare to try to maintain. I no longer do that, as I’ve learned that lesson, but mark my words: Your view should only be responsible for a distinct “el.”

Controller

Especially in JavaScript, a Controller is almost superfluous, as it is mostly used as an instantiation device for models and views. But it can carry “safe” business logic; that is, business logic specific to the operation of the application that doesn’t expose trade secrets. It is also used to control application flow. Circling back to Backbone.js, in earlier versions of Backbone, the “router” object was called controller, but was later renamed to router. I think this was a smart move because a router is simply a history manager wrapper. It doesn’t control application flow. That’s the controller’s job.

For instance, I’m currently building an application  where I have a master controller that instantiates several sub-controllers representing sub-modules of the application. Based upon user input (a click of a button or a link on a page), the controller decides that module to instantiate and display. It then tells the router to update the route to reflect the “destination” in the browser’s URL. In this respect, I’m using the router simply as a view, as all it does is update the URL, or on the reverse, tells the controller to display the right module or section depending upon what was entered in the URL.

In other words, a controller is responsible for controlling application flow. That’s all it does. It can listen and respond to events in the model and views. It can even trigger events to other controllers. But in no way should it contain data manipulation or view functionality. Leave that to the models and views of the system.

Look, MVC is not rocket science. But it may feel as if it is especially if you’re doing it wrong. And believe me, lots of people are doing it wrong.

Shut Up and Develop

In addition to writing this blog, I also write a fairly popular blog called GuitarGear. To write that blog, I interact a lot on various forums, and meet other guitarists. Especially in the forums, there’s lots of debate about which pedal or amp or guitar – what have you – works in a particular situation. Some of the threads go on for several pages. Invariably though, someone will pipe in and say something to the effect of, “Just shut up and play.”

Sometimes I feel like saying this when I’m in meetings with fellow geeks and a side debate starts on some topic; especially on the merits of one technical direction vs. another. In the best of cases, these discussions/debates yield a good direction; actually, in the end, they almost always yield a direction. But invariably, that direction could’ve been arrived at in a much shorter span of time. I think that part of the problem, especially with well-established teams is that everyone’s comfortable with each other. That’s both a good thing and a bad thing. It’s good that you can rely on your work mates, but that comfort can dangerously lead to losing “the edge” of urgency to deliver as you belabor points. The plain fact of the matter is that we have product to build; we shouldn’t be wasting time on trivialities. So shut up and develop!