On Glenn Beck and Global Warming and the Danger of Fox News

I am so glad Glenn Beck is off the air. That man was an absolute cancer to American politics. The irresponsibility of his claim there was no evidence of global warming has set back the movement to help heal our planet for years (I won’t even touch on his negative influence on controlling Wall Street). I started getting clued in on his negative influence when a very close friend and I had a heated debate about global warming. As a faithful watcher and listener of Glenn Beck, he just spouted back what Beck said: There was no evidence of global warming. I was amazed by that claim, after having read scientific evidence to the contrary! My friend challenged me to provide evidence right then and there – and as we were on the phone, he knew it wasn’t possible. In any case, he was so firm in his position, that nothing I said would make him even consider the possibility.

It completely amazed me that my friend, whom I believed to be reasonable could be utterly and complete brainwashed by a known “shock jock” who was hired by Fox News Channel simply to incite the angst and anger of people. Way to go Fox, mission accomplished! You managed to drive a wedge into US politics where we’ll be cleaning up the mess for years to come, as this article from the Huffington Post relates.

I read that article last year and wanted to throw it into the face of my friend; tell him that his devotion to this wacko was dangerous, and that following the advice of someone who didn’t even believe this stuff he was saying would simply create a greater divide between conservatives and liberals. Okay, deep breath… Circling back to the issue of global warming, what really set me on the edge was what that article said about Glenn Beck’s personal position on global warming vs. what he actually said on his show,

Let’s take the example of climate change. There was a time when mainstream Republicans like John McCain, Lindsey Graham and Tim Pawlenty thought that man-made climate change was a real problem and that government had a role in fixing it. Then Beck and friends on Fox News Channel and talk radio in went to work. Beck’s role in all this is remarkably cynical, as he told USA Today Weekend that he personally believed in climate change — “you’d have to be an idiot not to notice the temperature change,” he said — but said the complete opposite on the air. “Americans know this global warming thing is a scam,” he proclaimed on the radio.

When I read that, I just about screamed out in rage! Here was a man who single-handedly defeated any kind of measure to control a serious problem by getting his listeners and viewers to follow what he said on his shows and put pressure on their representatives such that Republicans who were once in favor of global warming legislation completely turned their backs on it!

Months ago a study was released that Fox News viewers were less informed than those who don’t watch the news. I don’t think it suggests anything about their level of intelligence, but to me, it suggests that Fox News isn’t really focused on news, but on commentary and opinion on a a narrow set of issues that they know will incite the anger of their viewers. Rather amazing, but I believe the net effect coming from this type of “journalism” is that it has completely changed the face of American politics from open debate on issues to arguing on whose ideology is better. Throughout history, we’ve seen what governance through ideology gets us: pre-WWII Germany and Russia.

The thing that is very frightening to me is the Republican fixation on ideology. It is turning people who I have known to be great debaters and political conversationalists – such as my close friend whom I mentioned above – into ideologues. No longer do they try to get their news from a variety of sources; no, they get their news from sources that simply fit their ideology. Worse yet, they’re unabashed about regurgitating everything they read.

Another person whom I know well is particularly prolific at ideological regurgitation. I used to have a lot of respect for him, as he is a very successful attorney, and one with whom I used to have intelligent conversations on various issues. But now, he has been reduced to yet another Obama-hater, using Facebook to post link after link on why “Obama is this…” or why “Obama is that…” What a waste of a brain.

You’ve got to hand it to Fox and their ilk: They’re powerful enough to sway people – super-smart people – away from intelligent and respectful debate. But that’s where the danger lies. If we allow emotion – especially anger – affect our thinking, we’ll never come together as a country. But this seems to be Fox’s goal. Appeal to the angst and you can get millions to move. Fox gets ratings that drives in revenue. But the losers are the people. It’s saddening to see what’s unfolding before our very eyes.

A Particular Caveat About Backbone.js Development

I’ve been developing an MVC application using Backbone.js as my MVC engine. This is a very powerful framework and its capabilities extend beyond a proprietary MVC engine that I helped develop in a previous company. One thing that I absolutely love about Backbone.js is how you can use a third party DOM library such as jQuery. With the proprietary MVC engine I helped develop, we actually stringified our HTML and wrote it all out with innerHTML, and DOM operations were performed with DOM scripting. You might think this is screwy, but it ensured that we followed a fundamental rule: No component could know about another component’s DOM. The net result is that all view objects were completely encapsulated and their DOM’s protected from other objects.

With jQuery and other DOM-scripting libraries, all you need is a selector, and that sort of opens up your views’ DOM’s to be open to manipulation. I even found myself starting to do this in a module that I built where a two-column informational table was actually constructed from four different data sources and four different views. Luckily, I fell back on my old experience and made the conscious decision that my individual views would only know about the specific section of HTML for which they were responsible. But I could’ve easily broken the rule that a component only knows about its DOM and its DOM only.

You might ask, “So what? What’s the harm in that?” There’s actually not much harm of that, but if you have two components competing for the same patch of HTML, you could have some deleterious results. So my advice here is relegate your views to specific sections of HTML on they and only they act upon. This will ensure that you won’t stepping all over yourself and having to deal with resource contention.

If You Adopt a Pattern, Stick with the Damn Pattern!

This is a bit of rant, but something that I’ve seen time and again in development groups that I’ve worked with over the years: Engineers adopting a design pattern then falling out of the pattern when it’s convenient. The most egregious is breaking out of the MVC pattern when the interaction gets difficult. Don’t get me wrong, there will always be exceptions; but especially in UI engineering, I see a lot of “falling back” on the tried and true DOM-based operations before adequately exploring whether or not it can be done within the context of the particular MVC engine that is being used.

There are several reasons for breaking from the pattern:

  • JavaScript is wide open, and there are lots of ways to skin a cat, so if you hit a bit of a roadblock, there are lots of tools available to solve the problem. But in rebuttal to that, just because you can do something, should you?
  • Because JavaScript is not strongly typed, enforcing patterns is difficult at best. Everyone has to buy into it.

What I see a lot of is falling back on DOM-based libraries such as jQuery. For instance, if you want to show a popup window to display some information from the server when a user clicks a link, the MVC way would be that the view that holds the link intercepts the click, triggers an “action” event of some sort which is intercepted by a controller that would then tell a DAO that would retrieve the information from the server. When the data is available, the DAO would fire a “data available” event that a model is listening to; the model in turn would update itself, trigger a “change” event to which a view is listening. The view updates itself, then displays the results.

This seems a little convoluted and complex but what it ensures is that you have proper separation of concerns; each different component is responsible for only what it was intended to do. The anti-pattern to this is just call a function and use jQuery or another DOM-based library to handle it all, which is totally easy. You make the call, use jQuery’s AJAX method, then display the message with a jQuery modal dialog. Simple.

But here’s the problem with that: Once you go that route, you’re using an external entity outside of your MVC system that acts completely independently of your system. That entity combines MVC and DAO operations. You could argue that that makes it a self-contained MVC. But that would be wrong because there is no separation of concerns, which is what MVC is all about. If you’re going to follow the pattern, there are no multi-roled objects.

Furthermore, the approach that is commonly taken is to make that function globally available because “Hey! It’s a cool function that we could use everywhere!,” which usually means polluting the global namespace. That has some serious security implications when you do that because you’re exposing the function to the world, and because that function is making an open server call, it is possible to expose it to CSRF attacks. Not good.

You see this behavior mostly from developers who are new to MVC. So how do you teach them? Simple. You have to get team buy-in to specific rules:

1. Obey the knowledge barrier. Look at the diagram below:

The solid lines represent direct knowledge from one entity to another. From that we can see that the controller knows about both the view and the model, and the view also has direct knowledge of the model. The dashed lines represent an implicit knowledge in that the only way for those entities to communicate with the destination object is via messages/events.

2. I mentioned this above: No multi-role objects.

3. DOM-based libraries should only be used to interact with the DOM; that is, they’re mostly used as helpers for the views. However, since they also have AJAX capabilities, they can also be consumed for use with DAO operations, but a DAO object should always be relegated to that whether the DAO is explicitly or implicitly declared. For instance, Backbone.js utilizes jQuery’s AJAX for CRUD operations. In that case, the DAO is implicit, and actually obfuscated from the developer as the models and collections interact with the Backbone.sync object which is itself a DAO.

4. Finally, to mitigate shortcuts, developers have to learn and practice good architecture and design; that is, they need to start using some sort of class and object interaction description methodology such as UML.

Those are four simple rules. Having taught this over several years, I know how difficult it can be to enforce and have developers obey them because the temptation is to always go the easy route. But great programs can only be created with a thoughtful approach to building them. Just as in construction, you wouldn’t build a house without a blueprint, and when you’re building you wouldn’t use construction methods that don’t follow the standards. Why would you do this in software?

Wednesday JavaScript Meanderings

On JavaScript Parasitic Inheritance

Hmmm…. Not sure that I really buy into all the craze in Parasitic Inheritance the last couple of years. Perhaps I’d buy into it if I heard a really great technical explanation, but thus far, all I’ve heard and read about the virtues of Parasitic Inheritance center around not having to use “this” and “new.” My reaction to that line of reasoning is “So what?” “this” and “new” are artifacts of the JavaScript language. Deal with it. Another line of reasoning used to justify the use of Parasitic Inheritance is the concept of the durable object, which is defined as “A durable object contains no visible data members, and its methods use neither this nor that. Again we return to the non-use of “this.” And again, “So what?” You can achieve something similar this using while defining a custom object in the traditional way:

function myObj() {}

myObj.prototype = (function() {
    function myPrivFunction(myArg) {
       return ...do something with myArg...
    }
    return {
        myMethod : function(param) {
            return myPrivFunction(param);
        }
    };
})();

You can have a whole set of private functions defined above the return that will not be changeable to the outside world. Furthermore, one of my biggest problems with Parasitic Inheritance is that you lose instanceof. Yes, there are ways to deal with it, but most of the examples I’ve seen deal with overriding Object and Function prototypes, or creating some intermediary “helper” function to enable instanceof with Parasitic Inheritance. My thought about this is if you have to make changes to the core of the language, then the “solution” you’re providing is simply an interesting engineering exercise.

On MVC: Put the DOM in Its Place, Dammit!

One of the things I see quite a bit of when working with JavaScript developers who are relatively new to using MVC frameworks such as Backbone.js is that their thinking is very DOM-focused. And while MVC in JavaScript does mean interaction with the DOM through the View, most developers focus their thinking around the View. As a result, their programming is all about direct references. But MVC is about separation of concerns, and each part of the MVC has an important role to play. As such, one of things that I do my best to help “teach” is having developers divorce themselves from DOM-based thinking, and start thinking at a much higher level; specifically, the system or application; breaking the application or system into constituent MVC parts.

Admittedly, it’s difficult for many to make the conceptual leap into MVC thinking because what we as UI Engineers produce ultimately shows up on the DOM. But the DOM is a by-product of MVC interaction. Once you get that concept down, then thinking with a perspective of MVC becomes quite easy.

It doesn’t help matters much when you have examples that are very DOM-focused, as many developers that move over to MVC are expert in jQuery or YUI or prototype.js, what have you. As a result, these developers provide examples that lean heavily on that previous experience. It’s a bit of vicious cycle.

A Republican’s View of Why Obama Is Likely to Win the Election…

…and How Several Years of Successful Coaching Shows Me Why Republicans Will Lose in the Election

I’ve been a Republican since I registered to vote 32 years ago, and though I’ve had my ups and downs with political involvement over the years, I always have been an apt observer. This coming presidential election has especially piqued my interest because it has been amazing – and horrifying and even a bit amusing – to observe the Republican strategy in the race up to the election. This amazement comes from having been a coach of various sports over the years. I have a winning record in all the sports I’ve coached, and have four championships under my belt for my high school roller hockey team.

Not to say that I’m a great coach – everyone has room to improve – but I did learn quite a bit from studying successful and arguably great coaches such as Bill Walsh and Herb Brooks. From what I observed, a huge part of their success was simply teaching what it takes to develop a team with a winning attitude. We could talk about collaboration and cooperation and such, but there’s one thing that I learned as a coach that you never do: Ever mention or plan my game around the word “lose.”

And from that, I don’t mean don’t play the game to not lose, but also don’t play the game to make the other team lose. What? Not play the game to make the other team lose? What’s THAT about, you might say. Basically it’s this: If you plan your game around the mindset of making the other team lose, what you’re doing is projecting onto the other team your own idea of what it means to lose. Ultimately, your mindset will be your undoing. We can’t possibly know what the other team thinks with respect to losing, so if we project our sense of losing onto the other team, we essentially end up focusing on what will make us lose, and ultimately play a game of “not-losing vs. losing” as opposed to winning vs. losing. The best we can hope for in that scenario is a draw.

A good example of this comes from a Star Trek: The Next Generation episode “Peak Performance” where Data plays a rather arrogant opponent in a game of Stratagema.

When I saw this years ago, the one thing that struck me in Data’s explanation of beating Kolrami was that he was playing to a draw. But I looked at it the other way. Kolrami had projected what his “values” of he believed would make his opponent lose onto Data. Data didn’t just didn’t play the game that way, and though he technically did not win the game, he played it in such a way to force Kolrami to withdraw.

And this is EXACTLY what I’m observing in the GOP right now. They’re playing the election game very much like Kolrami, and frankly, with all the absolutely STUPID stuff the leadership is spouting, such as John Boehner’s repeated claims of the “unconstituionality of Obama-care” though the US Supreme Court ruling completely blows that out of the water, they’re doing a great job of it. We have also had to hear every single Republican representative say in the press, “Our goal is to make Obama a one-term president.” Every time I hear that I have to laugh because that is exactly the kind of rhetoric Obama wants to hear. The GOP has essentially stated their entire strategy, and it’s working in Obama’s favor. His job approval ratings (Gallup) are starting to trend upward. The GOP will state that his job approval ratings are historically low as compared to other presidencies. But the only thing that matters is where they’re at in this current election year, and should they press above the 50% mark, the GOP can kiss the election goodbye.

The net result for the GOP? Since they’re all partaking in the same strategy, the GOP presidential nomination is frankly, still up in the air. Though Romney won Florida, his lead of 31% vs. Gingrich’s 26% isn’t significant enough for him to claim victory. Plus, 31% is not really a number about which to be ecstatic. If the numbers were in the 40’s that would be a different story, but as the numbers don’t lie, it is easy to interpolate that the Republican Party is generally fractured on who to follow. Not good.

And based upon those numbers, I’m apt to yet again vote outside the party. I have zero confidence in Romney, whom I see as simply buying the election with his riches and well-funded super-PACs. I was hopeful that Gingrich would fare better, but he has his own skeletons in the closet to deal with, and makes me seriously doubt his ability to lead the country. As such, there’s really no one in the GOP race that appears to me to be an outright leader. I realize that the number will go up as more candidates leave the race. But I also see that as those supporters settling for the remaining candidate(s). I would much rather see someone who’s garnering support organically rather than through inheritance.

Obama, on the other hand, has been quietly going about his business, and no matter what the hyperbole of the GOP may state, his policies have had success. Do I like the fact that he didn’t act much stronger on the Wall Street executives? Not at all. Do I like Obama-care? I’m a bit on the fence with that, but it has not killed jobs as the GOP keeps touting, and it has cost FAR LESS than what idiots like Michell Bachmann, Glenn Beck and Sarah Palin have made so many believe.

I never did dig the bailout, but understand why it had to happen, though I’m hopeful that legislation will pass that will prevent institutions from growing too big to fail. And mind you, those institutions were allowed to grow that big due to the rescinding of regulations under the Clinton and Bush administrations. Obama inherited a shit sandwich, and though I’m a Republican, I have to say that he’s done okay given the circumstances under which he took the presidency.

In any case, I believe that the only way for a true GOP leader to surface among the mediocrity that’s present in the race right now is for one of the candidates – and perhaps the party as a whole – to stop playing the game of “not losing.” They need to start volunteering their leadership on issues that are important to americans – all americans – and not just the financial elite and lobbies. Until they stop playing the game the way they’re playing, Obama has nothing to worry about.