Wednesday, August 5, 2009

Flex and Pure MVC

I learned PureMVC for Flex about a month ago, and was able to successfully migrate all of my Flex projects at work to this new framework. Of course, these projects are relatively small (appx 5000 lines of code at best) but it was the best move I could have made.

Though PureMVC doesn't necessarily guarantee good design and separation of concerns in a project, it certainly provides a nicely decoupled way of utilizing the MVC design scheme.

PureMVC uses what's called a Facade to act as a broker for forwarding notifications from various components. View components (MXML and the ActionScript needed to drive them) are provided to "Mediators" which communicate via the Facade. These mediators translate any events from the UI (e.g. users clicking buttons to load information from a server) into "notifications" which are sent via the Facade to the respective Controller objects.

These Controller objects are known as "Commands". Commands receive the notification from the Facade (and any data passed from the View components) and then use "Proxies" to request data and perform the majority of the business logic for the application.

Sound complicated? It's really not. The typical project may be organized like this:

src
|- controller
|- model
|_ view

Under the "controller" directory, Commands are kept which receive notifications. These commands invoke "Proxies" which are stored in the "model" directory. These proxies request information from remote objects (e.g. servers) and relay data back to the appropriate location. The "view" folder contains two different types of objects: view components and mediators. The view components are simply the user-visible forms and controls in which the user interacts. These have absolutely no connection to any PureMVC components; rather, they are passed (at runtime) to a "Mediator". The mediator listens for events from the view components and then relays the event to the Facade as a notification.

Frankly, it sounds a lot more complicated than it is. Future posts should have some examples for how to assemble a simple User-form in PureMVC

Saturday, June 20, 2009

Conky version 1.0


It's finished! I'm still working on some details: the icons are ok, but I wonder if I could cut this down a bit. I also want to divide this up to all 4 corners of my screen.

Anyway, this is the conky in #! on my laptop. The smudged content in the top is my hostname 'on' my ESSID. If the ESSID isn't available (e.g. no wireless connection), it prints " is disconnected"

Friday, June 19, 2009

Nuts, Conky isn't working right


Here's a snippet of a Conky config I've been working on.

Friday, June 12, 2009

Dependency Injection and Flex

So, a quick note on the progress I've made with Flex. First of all, I wanted a tool to highlight text. So...I spent 3 weeks working through tutorials and examples from some brilliant coders who have already paved this way, worked with several different libraries, and finally found that all my work was for naught; enter, FlexLib. It not only had a great highlighting class, but also contained some moveable Panels, and a nice extensible Tab Navigator...sigh..all that work down the drain.

Anyway, I've heard about Dependency Injections a lot lately, and I finally decided to research what it's about. Wow, I never realized how simple a concept it would be. Having been exposed to different design patterns like Factory Method, this was extremely easy to assimilate.

Dependency Injection works very well with Flex interfaces, and particularly well with Factories. If I have an object A which depends on object B, I could have A instantiate B and maintain a reference to it. Unfortunately, this creates a dependency within A upon B:

private var bInstance:B;
...
bInstance = new B();
bInstance.foo();


In this case, A has a definite dependency upon B's implementation. If B changes 'foo()' to anything else, A will break.

We can partially solve this via a interface, in which A and B agree on B's required methods. In this case, B utilizes an interface, BI, which instructs B to always implement 'foo()'. Thus, A can access B via its instance:

private var bInstance:BI;
...
bInstance = new B();
bInstance.foo(); //guaranteed since bInstance is an instance of type BI


But we still have a problem: A is still relying on the base class of B. What if we wanted to break B into different objects, and 'B' was no longer a valid name? Moreover, what if we moved B to a different library? Enter a factory.

Rather than A creating B, even via its interface, what if the code calling A passed in a reference to B, via its interface? For this, we'll add two new classes. 'Factory' has a 'createBI' function that returns a reference to B via its interface, BI. FooBar is a class which creates A. In this class, the code to create A might look something like this:

a = new A(Factory.createBI());


Whereas the constructor for A might look like this:

private bInst:BI;
public function A(bInst:BI):void {
  this.bInst = bInst;
}


From this point, we've broken the dependency of A to B, and created a new dependency from A to BI. This is a better design and is more extensible: should we need to have different variations of B, as long as they implement the BI interface, A can utilize them.

What's more, 'FooBar' injected the dependencies into A.

That's all there is to it.

Now...my question is...how far can you take this??

Sunday, April 12, 2009

Happy Easter -- Christ is risen indeed!

What a wonderful time of the year for us, as Christians, to remember the glorious resurrection! We worship on Sundays because this was the day of Christ's resurrection from the dead, but it's also, in my mind, important to set time aside on the anniversary of our blessed hope.

I've been thinking about the resurrection more this past year, and I have a thought: one of the strongest proofs of Christ's resurrection lies in the changes the Holy Spirit wrought in the lives of His disciples and those who lived in the ancient world.

At the time of Christ's death, His disciples had fled. The oligarchical religious authorities had, it seemed, succeeded in squelching what they viewed as a blasphemous trend and an affront to their authority. Jesus' friends had abandoned Him immediately after His arrest, and, on that Sunday so long ago, were in hiding. They feared the reprisal of the authorities against those Jesus had taken into His "inner circle," so they sat in their rooms, cowardly and afraid for their own lives.

Don't get me wrong -- I would have done the same...we all would have.

But, within a very short amount of time, these men swept through Israel, Palestine, Asia Minor and to even farther reaches of the known world, spreading the glorious news of Christ's death and resurrection and forgiveness for sin. They baptized and made disciples wherever they went, turning the Jewish society completely on its head. Those who had lived and breathed a fiercely xenophobic and merit-based religious lifestyle were now proclaiming the forgiveness of sins fully apart from works to those outside their respective society. Faith and belief were no longer restricted to a few select practitioners, men, women, soldiers, etc. Instead, all, even small children, were welcomed into the Church.

For those who would purport the existence of explicit "misogynism" in the early church, I would ask they read the New Testament and consider the words of Christ, Who, in a strictly patristic society, reached out to women with His teachings; as well as the apostle Paul, who, though recognizing the difference in role and responsibility between the sexes, also acclaims specific women working alongside men in the church. I would also encourage them to compare Christianity in its day to the other religious institutions at the time: it stands apart in its acceptance of all from different walks of life, and its claims of the abject uselessness of meritorious acts.

In a very short amount of time, the world was drastically and fundamentally changed. No longer basing their religious standing on their capacity to keep Law, give charitably, or act in accordance with goodness, Christians were, rather, displaying chartity and good deeds stemming from an inward change. Rather than working to earn merit, their focus was on being thankful for a gift given while they were still sinners (Romans 3:8), and spreading this good news to everyone they came near.

Christianity spread like a wild fire in its early days, in the face of the most perverse and grotesque persecution and opposition known to man. Under the reign of Domitian, Christian persecution became a matter of state policy; under the reign of Nero, Christians were tortured and ravished as a matter of entertainment. The Jewish religious authorities persecuted and murdered early leaders of the Christian church, casting others into jail.

We know the tomb is empty. Christ rose from the grave (halleluiah!) and we in Him we have a blessed hope. But we need remember one thing: no explanation, no physical evidence, no arguments are sufficient to explain this unprecedented phenomenon. It's not enough for the world to present Jesus' bones and say, "here he is!" Such an occurrence falls drastically short of the historical evidence we have of such a massive personal transformation on behalf of His followers.

What more can we ask for? The proof of Jesus' resurrection and His sending the Holy Spirit need not lie in manifestations of "spiritual gifts;" it need not be sought in an "experience" or a "feeling" or emotion; it need not be based upon the display of miraculous "healings" during televangelist gatherings. Though I don't discount gifts, feelings, or the power of the Lord to heal, we far too often seek for reassurance of His reality in things which focus us inward:
  1. I have this gift
  2. I feel this feeling/sensation
  3. I was healed
Instead, let us turn to the real and historical Jesus as our reassurance and hope. We have the ultimate proof of His resurrection: an empty grave, a missing body, 500+ witnesses, and the greatest spiritual conversion mankind could ever witness.

He has risen indeed!! Happy Easter!!

Wednesday, April 8, 2009

Issues Etc -- Does Satan Exist?

I listened to a great review of the ABC Panel which discussed the existence of Satan. It's in two parts:






These are well worth listening to.

Sunday, April 5, 2009

A few Ofelia Pics

Ok, I wanted to post a few pictures of my kiddo:

She's just so friggin' cute!















She's trying to read like her daddy. Her mommy is also now reading too!















We had a little date to the library on Saturday--she was ready for the blustery weather:















Here she is, trying to distract her daddy while he's sick and working from home: