Saturday, June 20, 2009

AS-MVC: Hot From the Geekery

In the world of code development, stuff changes all of the time. And when a programming language makes a big change everyone using that language suddenly gets reduced from being fluent to, say, a seven-year-old who is recovering from having just fallen from a tree. You brain hurts all of the time and you can't remember where you left your shoes or how to tie them.

In the Adobe Flash world I have lived through a few of these large changes. For example, Flash used to have a coding language under it that was, well, fairly silly at best. But it was the most interactive language for client-side web development and so I learned it. From that language (I believe this would be back in Flash 3 or maybe 4) ActionScript was born. ActionScript (later referred to as ActionScript 1) added some standardization but also let you write code the older, sillier way. But it was a syntax move in the right direction (they added something called "dot notation" which pretended to be object oriented.) Then along came ActionScript 2.0 which was a move from "dot notation" to a slightly more "object oriented" reality.

Since ActionScript 2.0 a Flash Developer had the luxury of writing code that adhered (mostly) to object oriented development techniques but could also write completely valid AS 2.0 code that had far less to do with Object Oriented Programming (OOP.)

Now we are in ActionScript version 3.0 and that is also quite similar to AS 2.0 but the OOP-side of AS 3.0 is far closer to OOP than flash has ever been. As a result, people attempting to learn AS 3.0 are searching the web for examples of how to build Flash content using AS 3.0 and are running into a mix of OOP techniques and non-OOP approaches. I say OOP approached because Object Oriented Programming to many people comes down to meaning "I built a bunch of classes" but that is a very rudimentary understanding of what OOP is. Saying OOP is "building a bunch of classes" is like saying web accessibility is "adding ALT properties to IMG tags in HTML." To a degree that is true, but that doesn't begin to come close to explaining what 508 web accessibility really is, how it works and all that it encompasses.

If you have made the jump from "timeline" code in flash to "class-based" code then you have surmounted the first hurdle. Again, because you could write non-OOP code in AS 2.0 making the jump into AS 3.0 was like pulling off a motorcycle trick across the wide side of the Grand Canyon. Having at least created classes in AS 2.0 is like having a bigger more powerful bike and simply jumping across, say, the Mississippi River: still scary but you can at least see the other side without squinting.

So, if you have made the first jump (building classes) then here is a hint to understanding some of the rest of the jump.

Now, I don't have the time to help outline all of the new classes or any new syntax here. That is an unavoidable effort at scratching around and memorizing a new framework / code-base. There are no shortcuts to that, but I can say that tools like FlashDevelop can help you find your way much faster since FlashDevelop will add your import statements to your custom classes. The bigger (or at least equally as large) hurdle in making the AS 3.0 jump is understanding the most appropriate approach to coding your classes and how the timeline (or visuals) relates to that code. Most folks don't know how to avoid writing code in the timeline and are searching desperately for what the right best approach might be.

The amazing part about OOP is that there are a number of excellent approaches to organizing your coding effort, but I am going to briefly explain one of the older techniques that remain valid to this day.

Let's look at the Model-View-Controller (MVC) approach to development.

Model-View-Controller is about cleanly separating the three parts of a software development experience: The interface (View), the common utility logic (Model), and the instance of the application and it's controlling of the interface and the utility logic (Controller.) Let's go through each of the three parts.

The View:
In the Flash world, the View is the "front-end" interface where the user is listening, watching, talking, typing and clicking. In the MVC approach the interface would be planned appropriately to break apart the interface into various logical parts: video player, audio player, text presentation, lists, editing forms, common game controls, etc.

In the various Views you might create animations that are completely controlled in code by class utilities like "Tweener" which can be told to animate something from one frame to another specific frame and notify you when that animation is complete. That sort of "control" code is written into the Controller to manipulate various states of a View.
The Model:
The Model is where we put the logic of the application. I previously referred to it as common utility logic because I want to separate in your mind the code that animates the state of an application and the code that provides common services in a very interface-agnostic utilitarian manner. Said another way, you might create a rich internet application (RIA) in flash that retrieves information from an RSS feed for displaying in the browser. In this architecture and approach you would write an interface-agnostic utilitarian class that simply gets that data and hands it over as a result. If you write a class to retrieve RSS feed data (XML) and hand back the results and you keep that separate from any interaction with the presentation / interface / View then you can reuse that code (Model utility class) in future projects that implement different interfaces.

Your custom common utility classes, any other classes you are using in Flash, or classes from some third party are typically referred to as part of the Model part of the MVC approach.
The Controller:
The Controller as you can imagine is also comprised of code. In the AS 2.0 world the controller was typically just a number of functions in the lowest level "_root" timeline in flash. In the AS 3.0 world inside the Flash paradigm of development, the Controller is the Document Class associated with the lowest level timeline FLA. Inside the Flash project properties you can now assign a class to basically be the code that the SWF calls first before anything else. It is inside the Document Class where all of the action starts.
The document class could create an instance from the View (some interface, possibly a login), animate it into visibility and link up code that "Controls" (or watches) for clicks from that Interface, which might create instances of common utility classes from the Model to perform some function. Let's look at one example of what that interaction might look like.

Going back to the previous example, let's imagine someone arrives at your RSS Viewer RIA. Once the SWF loads it would call the code in your Controller (Document class.) The Controller would animate in a presentation of the RSS List View (an Interface element from the library) and then wire-up the list to code, in real time (animate and setup the View for interaction): The Controller might use a class from the Model to get the list of RSS Feeds and then populate the View with that information. The Controller might dynamically associate a mouse-click event with the list.

Let's imagine that the user mouse-clicks on an RSS Feed item presented in the RSS list View. The Controller would be notified of that click (because it wired it up a moment ago) and would then need to present the RSS Feed Reader View (yet another View inside the View part of the MVC approach.) Before it does this you might have written the Controller to clean up the List View by unloading arrays or removing event watchers that are no longer needed.

Once the RSS Reader View was ready, the Controller would wire up that view for scrolling and various kinds of mouse-click interactions.

This is the basic MVC approach to OOP in AS 3.0 under Flash CS3 and CS4. As you can see, it is all about events managed by the Controller resulting in the presentation of new Views and the Controller management of their interactions via Controller code as well as the Controller using other utility classes from the Model but it is all about events.

Naturally you are going to want to get really familiar with the ActionScript 3.0 event model: how do you code for events, how do you handle asynchronous events, how do you author asynchronous events in your custom classes, what are the more common View related events that the Controller needs to manager (for example: setting up a View, managing interactions a user experiences with a View, cleaning up after a View no longer needed in that moment, etc.)

Well, that is MVC and I hope it wraps some context around knowing how to explore AS 3.0 and what sort of architecture and approach decisions you might want to make inyour new coding projects. Have fun and build cool stuff!

Wednesday, June 10, 2009

America is a Democrazy

Many terms get tossed around today as if we know what we are talking about, “America is becoming socialist,” or “What that guy said is communist,” or “America is a Democracy”… on and on, yet I would be curious if people really understood the meaning or ideas behind those concepts or ideologies or political types of government.

Then out come the old quotes that defend our personal perspective. It is funny how quotations work. In my mind, quotations are symbolism. They remind us of perspectives. Now, unless you are quoting from an academic study, you are likely dealing with a conversational quote. And like I said, those quotes are just symbolic. For example, for a while now I had heard about a quote from someone named Alexander Tytler, who was said to say that democracies only last about 200 years at which point voters vote themselves generous gifts from the public treasury. Well, if you are a fiscal conservative (like me) then you look at that statement and you want to quote the piss out of it like you are naming something from the periodic table of elements. The trouble is, while the statement was first well circulated in the 1970s, nobody knows where that really came from. It could have been my grandma. We will never know. My point is, just because it is an old statement doesn’t make it significant or profound, but everybody pulls out their quotes. What is more interesting is history and the symbolism of quotation to provoke thought. If we abandon either of those, then we go brain dead.

So for a bit of history, here is the first of 6 blog-posts that will investigate the history of 4 different forms of political government: Democracy, Socialism, Communism and Republic. I will identify the major ideological perspective of that form of government and suggest how I think America is either like or not like those forms. I will also see if I can find out the state of those forms of government (do they work; are they successful; what makes them successful.)

Here is a video to get you interested in the topic:


This will be pretty therapeutic for me because I have been thinking that America is moving toward a Socialist form of government and feel that has proved to be a poor decision in the history of our Earth. You can help me keep it honest by not allowing me to turn this into a propaganda piece (which will admittedly be difficult… but we will see.)

I am going to try and keep this pretty short (I know, not my usual thing) so each post will be easier to digest. Hopefully that won’t result in an over simplification of the facts and symbols. All of the following blog posts will link to each other so that it is easy to read through the full thread when I am done. As I write these blogs posts I will go back and update the links.

Here are the links to the blog posts:
  1. America is a Democrazy: Intro
  2. What is Democracy
  3. What is Socialism
  4. What is Communism
  5. What is a Republic
  6. What is a Democrazy - Afterward

Sunday, June 7, 2009

Leftist Ideological Spying


Just when you think you’ve heard it all. In the news at the moment is a recent revelation that Walter K. Myers, a State Department intelligence analyst, is defending himself in a court of law for spying, a.k.a. sharing intelligence secrets, for Cuba against the United States of America. As we know spying for Cuba means spying for the Soviet Union since they back the Cuban Government politically speaking.

So what is the key defense that Mr. Myers is using? Well, it has been reported that he has grown frustrated with U.S. Policies. What does that mean exactly? Well, he used to complain to his politically liberal neighbors who would agree with him about feeling appalled by “the Bush years.” This is crazy talk since G.W. Bush was only President for the last eight years in his 30 year spying spree. So what does that mean?

Probably no surprise to anyone at this point, Myers complained to his diary about “greedy oil companies”, inadequate healthcare and “complacency of the oppressed” in the United States. Does any of this sound at all familiar? Wow, that sounds like the Democrat Political platform… literally.

So what happened to Myer in the 1970s? He made a two week trip to Cuba where he was supposed to be making an academic trip as a part of a United Nations effort. Interesting. Once he arrived for this little United Nations trip he was met and led around by a Cuban Intelligence Officer. The story spins out into a series of moves where he was recruited and eventually joined the State Department Intelligence community explicitly to spy for Cuba. Myers says that his growing frustration on the above mentioned points culminated in his eventual inspiration for a new American revolution: Communism.

Let me say that again. His liberal ideals leading him to buy into the typical Democrat talking-points eventually brought him to the ideological conclusion that America needs a revolutionary move toward those ideals, and the government-type that most well embodied those ideals was… communism.

I am not remotely surprised that this definitive example of such an ideological connection now has a walking-talking face. The closer we get to over-simplified political arguments that demonize the concept of democracy, or free markets, or that value a social ideology over personal freedom, the easier it is to see how a country under pressure can move toward Marxist ideals. The biggest tell-tale in a move toward a Marxist ideal is when people who are already empowered to make a difference hand over their power to a leader that will now advocate for the general welfare for the betterment of all. Go back and read about the history of Russia, the communist revolution or the short book “Animal Farm.”

This is why it is so important that we don’t just look at where we are but where we have been and where we are going.

Thursday, June 4, 2009

Climate Change Legislation from 2002

If you'll read anything I write this year, definitely read this...

As the recorded averages reveal more and more that we are in a planetary cooling trend, the new ECOconomy is changing the term from "Global Warming" to "Climate Change," or so I've been told. At least guys like Michael Crichton have said stuff like that (in his book, State of Fear, and in speeches before Congress.) But is it true? Have "they" now traded in the phrase "global warming" for the phrase "climate change" in hopes that people won't deny the reality of it, even if the world isn't really getting hotter?

In recent videos published on youtube by the State Department, you can observe their use of phrases like "climate change" and refer vaguely to it's challenges as they enter into international talks on "clean energy." There are so many buzzwords and nearly all of them are being used in a pseudo-scientific manner, including "clean energy," and we have yet to cleanly define those terms. In fact millions of dollars are spent internationally to create talking points like these even before experts have fully qualified what the standards are. I digress.

The fact is, if we are "we" then who is "they?" And if there is a "they," are they really coordinating a phrase change. Well, no not really. The fact is that there is a movement and phrases catch on here and there and we go with the most simple, memorable explanation whether it is true or not. My sisters and I used to joke about "respecting movie knowledge," meaning if we can't remember where we heard something, from a book or in a movie, well - that's OK, we respect movie knowledge so share your thought anyway. I think many Americans often feel the same way. This is how slogans and facts get handed around. And in this information age we forget that this is happening and that not all facts are equal (said another way, not all facts are either the whole truth or the truth at all.) So why do we refer to Climate Change? Is this really a new face on Global Warming? The answer: not really. Here is one way to know this is true... let's look at the past.

Here is part of a speech from G.W. Bush back in 2002. he was giving this speech about a new "Blue Sky" legislation that was drafted under his administration:

"America and the world share this common goal: we must foster economic growth in ways that protect our environment. We must encourage growth that will provide a better life for citizens, while protecting the land, the water, and the air that sustain life.

In pursuit of this goal, my government has set two priorities: we must clean our air, and we must address the issue of global climate change. We must also act in a serious and responsible way, given the scientific uncertainties. While these uncertainties remain, we can begin now to address the human factors that contribute to climate change. Wise action now is an insurance policy against future risks.

I have been working with my Cabinet to meet these challenges with forward and creative thinking. I said, if need be, let's challenge the status quo. But let's always remember, let's do what is in the interest of the American people.

Today, I'm confident that the environmental path that I announce will benefit the entire world. This new approach is based on this common-sense idea: that economic growth is key to environmental progress, because it is growth that provides the resources for investment in clean technologies.

This new approach will harness the power of markets, the creativity of entrepreneurs, and draw upon the best scientific research. And it will make possible a new partnership with the developing world to meet our common environmental and economic goals.

We will apply this approach first to the challenge of cleaning the air that Americans breathe. Today, I call for new Clean Skies legislation that sets tough new standards to dramatically reduce the three most significant forms of pollution from power plants, sulfur dioxide, nitrogen oxides and mercury.

We will cut sulfur dioxide emissions by 73 percent from current levels. We will cut nitrogen oxide emissions by 67 percent. And, for the first time ever, we will cap emissions of mercury, cutting them by 69 percent. These cuts will be completed over two measured phases, with one set of emission limits for 2010 and for the other for 2018.

This legislation will constitute the most significant step America has ever taken -- has ever taken -- to cut power plant emissions that contribute to urban smog, acid rain and numerous health problems for our citizens.

So as you can see here the phrase "climate change" was used all the way back in 2002. And in this case, Bush was honestly saying that we could get behind certain changes with regard to this issue because, well hey, it can actually bolster the economy. He made the direct connection and spoke about it honestly.

So, what happened to the plan. Here is an amazing bit of history:

Most Americans share this view, according to a new poll released by the nonprofit Clean Air Trust. The survey of registered and likely voters, conducted for the Clean Air Trust, found that, by almost a three to one margin, voters reject the notion that electric power companies should be able to buy pollution credits from another company rather than clean up their own emissions.

That result held true even when the Bush cap and trade plan was described in the White House's own terms, claiming that the proposal would "lead to faster reductions in air pollution at less cost by relying on the efficiency of the market."

"If it were up to the voting public, the Bush plan would be dead on arrival," said Frank O'Donnell, executive director of the Clean Air Trust.

O'Donnell noted that the survey questions were worded carefully in order not to load the results.

"The truth is, once the voting public understands what the Bush plan is all about, they flatly reject it, even if we don't point out that it will encourage irresponsible corporate behavior," added O'Donnell.

O'Donnell noted that 53 percent of surveyed Republicans, 69 percent of Independents, and 70 percent of Democrats oppose the cap and trade proposal. However, 70 percent of voters said they supported tougher enforcement of existing clean air laws.

Voters also said they would be less likely, by a 45 percent to 10 percent margin, to vote for a candidate who supports the cap and trade proposal.

Here is a link to that full article:

http://www.air-pollution.net/clearskies.htm

So, how is what Bush wanted to do any better? Well, we have studied the affect of mercury and the two other elements and we are seeing the practical nature of those changes today. Mercury has almost been completely removed from computer manufacturing and if we would implement the other restraints we would actually see a reduction of smog in our cities. So one difference would be the actual science involved. At the same time, there is an admitting of what we do not know and a reasonable restraint with regard to it. That is very different than our current President calling skeptical people "climate change deniers." In fact, back in 2005 when it was time to vote on Clear Skies Legislation, Obama voted against it. Historically, Obama also funneled $9 Billion to the coal industry at around the same political timeframe. Hmmmm?

So, what can we learn from this? That only a few years ago Congress as well as the public thought that CAP N TRADE was a crock and that it did not work! And so now this is (again) what is the LARGEST HOPE for Climate Change!?!?!?!?!

You tell me... what has changed?

Tuesday, June 2, 2009

Supreme Court Criteria, Sonia Sotomayor

Is there a difference between prejudice (pre-judgment) and racism (pre-judgment with regard to race-based stereotypes)? I think there is. Many people can be legally prejudiced against a certain perspective without it making them into a racist. This happens as a result of various life experiences. Being a racist might have nothing to do with experience but rather indoctrination into a set of perspectives. Am I splitting hairs? Maybe.

In the press right now is the possibility of seating a Supreme Court justice who has made a few statements that could quite possibly be found somewhere between legally prejudiced and possibly racist. I will go out of my way and expose myself as someone who doesn’t think this potential S.C. justice is a racist. Let’s quickly examine this.

Here is the context of what has been asked that created the questionable response:

In our private conversations, Judge Cedarbaum has pointed out to me that seminal decisions in race and sex discrimination cases have come from Supreme Courts composed exclusively of white males. I agree that this is significant but I also choose to emphasize that the people who argued those cases before the Supreme Court which changed the legal landscape ultimately were largely people of color and women. I recall that Justice Thurgood Marshall, Judge Connie Baker Motley, the first black woman appointed to the federal bench, and others of the NAACP argued Brown v. Board of Education. Similarly, Justice Ginsburg, with other women attorneys, was instrumental in advocating and convincing the Court that equality of work required equality in terms and conditions of employment.

Whether born from experience or inherent physiological or cultural differences, a possibility I abhor less or discount less than my colleague Judge Cedarbaum, our gender and national origins may and will make a difference in our judging. Justice O'Connor has often been cited as saying that a wise old man and wise old woman will reach the same conclusion in deciding cases. I am not so sure Justice O'Connor is the author of that line since Professor Resnik attributes that line to Supreme Court Justice Coyle. I am also not so sure that I agree with the statement. First, as Professor Martha Minnow has noted, there can never be a universal definition of wise. Second, I would hope that a wise Latina woman with the richness of her experiences would more often than not reach a better conclusion than a white male who hasn't lived that life.

The full context of the speech can be found here:

http://www.nytimes.com/2009/05/15/us/politics/15judge.text.html?pagewanted=1&_r=1

So was she contextual legally prejudiced in the scenario she was speaking to, is she a racist or none of the above?

Well, I don’t believe she is being a racist. She is basically saying that she feels that perspective is a byproduct of life and in certain circumstances having a particular perspective will offer greater insight for the purpose of rendering better decisions. In fact, some might ask the question, shouldn’t we want diverse experience within the Supreme Court? Wouldn’t having diverse experiences benefit the court’s decisions?

In the legal system this is unfortunately the wrong question, and Obama being a lawyer won’t likely be promoting this perspective (unless he is hoping to persuade the approval of Congress by creating public pressure to do so.) If it were the right question then she gave the exact wrong answer.

Our judges should be experienced in parsing the law, not in empathizing with the experience of others. If we are looking for criteria for seating people on the Supreme Court then we are looking for people who have the strength to measure out legal judgments that value our laws more than a biased perspective outweighing our understanding of those laws. Perspective should be wrought from having an ability to identify truth, justice, and compliance based on facts with regard to the law and not based on who makes the more compelling emotive argument or worse yet, who is willing to render a “better judgment” simply by their historical or stereotypical vantage point.

Now, imagine the court system!

Let’s imagine you were going to court and the evidence is in your favor. But imagine the prosecutor is amazing at weaving a very relationally emotive message that connects with a jury in such a way as to help bring convictions. You would want lawyers defending you that could dismantle emotive arguments and focus on the facts and the law. Only in the case where the evidence didn’t support you, would you want a jury emoting in your favor. This is why jury selection is so tedious a process. Juries aren’t typically selected because they are diverse (diversity can't be confused with being "representative"... there is a big difference.) They are selected because they have the capacity to understand the issues and do not carry any pre-judgment. If the defense or prosecutor can identify legal pre-judgment (prejudice) then you can be removed from the jury.

Again, if the case is a shaky one then the lawyer might try to find jury members who could be emotionally manipulated by their perspective and experience.

The same is even more true of judges. If prejudice or racism is in question then naturally the people (Congress) who select the grandest “jury” (the Supreme Court) will and should be allowed to ask refining questions. Moreover, judges are not considered "peers" like a jury is considered "peers" to the defendant. This means that "peer" criteria is flat out of the equation for judges. Electing judges on such criteria reduces S.C. justice criteria to political criteria and works against the very nature of the system that has been established.

I say, ask a few more questions and then move on. I don't think she is a racist. She might be biases based on legal pre-judgment and then should be disqualified (even at a more local level.) I can't believe we are suddenly out of good candidate who are both qualified and untainted.

I encourage you to keep watching this case.

Based on the above here is my short of list of unacceptable explanations (if they are offered):

  • The court needs my diverse perspective.
  • Sure, I think that my demographic stereotype is uniquely special. Here are a few more demographic stereotypes that are now also special and should make me seem less like a racist.
  • I am not a racist.
Even if all of these items were true (well, except the second one) none of them would bring us any closer to gaining an understanding of better Supreme Court justice selection criteria in the context of the aforementioned goofy statements we already know about.

Update:

It is almost entirely true now.

Politico is reporting that some Dems in Congress are pressing for an unprecedentedly quick confirmation of Sotomayor while others are saying, "There is no need to be in a rush."

At the same time Sotomayor is saying that she also supports her friends counterargument with regard to white male stereotypes (i.e. she said that in the speech she made reference to the fact that white male Supreme Court justices were a part of most of the larger civil rights laws of the previous century, but she still gives the majority credit to female lawyers.) This is just her justifying her stereotype by validating another friends stereotype.

(That is like my above second point of unwelcome excuses.)

Someone recently reminded me that if what she said had been spoken by a white person, it would surely be called racist. Let's see how that looks:

I would hope that a wise white man with the richness of his experiences would more often than not reach a better conclusion than a Latina woman who hasn't lived that life.

You decide if the above statement would be called racist or prejudice. Feel free to leave a response here.

UPDATED AGAIN:

Ends up that 60% of Sotomayors decisions were overturned by a higher court. Forgetting about stereotypes based on race and gender, that means that the legal system thinks that this particular (specific) Latina woman does not "more often than not reach a better conclusion"... than her peers. So fundamentally her words are at best a sideshow to the fact that she is not qualified to sit on the Supreme Court.

Now, mind you, she is an appeals judge. This means that she doesn't have to sit through long presented cases and come to a decision. She only has to look at the appeal criteria. And so, a lower court would say, "No, you can't," and she would review that and say, "Yes, you can," which would be appealed to a higher court in which six out of every ten appeal decisions would then be overturned by saying, "Ah, no, you can't" and inevitably that would be the outcome. So, fundamentally that might be a measure of poor "judgement."