Why is WordPress so easy to install, so painful to update?

I don’t think there is a better open-source blog engine on the market than WordPress, but why is it so painful to update it? You have to back up the database, download the files, copy over the config file, themes, uploads, and any other stuff you need to the new installation, and then rename the folders quickly so the new one fills the space of the old one.

Why can’t we just get the files that have changed downloaded and the database updated by pressing a big blue “Update” button?

How to Roll Back Changes using Subversion

A question I’ve often gotten is “How do I roll back some changes I made in Subversion?” I’m the company expert in Subversion here at mediaRAIN (another one of my hats) so I thought I’d answer the question one more time.

Subversion is great as it allows you to track every change you’ve made and go back to a previous version if needed. Sometimes you only need to go back to an earlier revision temporarily (for example to tag the project at that point). But other times you (or that lousy co-worker who left on vacation yesterday!) have introduced bugs or committed something you shouldn’t have. Now you need to roll back the broken revision(s). Looking at TortoiseSVN’s menu or going through the list of command-line options you’ll see … gasp! … subversion forgot a roll-back feature! How could they do that?! Isn’t that one of the main reasons for using a versioning system like Subversion?

Never fear, Subversion can roll back changes made, it’s just not labeled “Roll Back” and it doesn’t quite undo those changes. See, it is Subversion’s job to track every revision of a document whether good or bad. What if you rolled back the lousy co-worker’s changes and after he gets back from holiday he shoots you to death with his flying-ninja gun because you destroyed all that code he worked on for days? Not good, Subversion needs to remember even the bad times.

So if Subversion won’t go back, it must go forward, and what you really need is the merge feature. Merge let’s you take a collective group of changes between two places (two separate files or two separate revisions, or both) and merge them into your working copy. Why doesn’t it just merge it into the head revision? Well, you’ve got to TEST it first of course! Merge is also used to get changes from a branch to the trunk and visa-versa, so we need to use it the right way for roll-backs.

Because Merge will “apply the differences between two sources to a working copy path.” (command line help `svn help merge`) it takes three parameters: the first source, the second source, and the working copy path. Since you are rolling back changes the first source and second source will be the same path but different revisions. Make sure to use the HEAD revision (or later revision) first and the starting of the bad-news revision second since you are rolling BACK and not forward. Then you’ll set the working copy path (if you’re using TortoiseSVN that will just be the folder you right-clicked on) to the corresponding folder in your working copy.

Command-line Example:

merge svn://domain.com/repo/trunk/folder/changedFile.txt@HEAD svn://domain.com/repo/trunk/folder/changedFile.txt@215 ./folder/changedFile.txt

When using TortoiseSVN you can hit that “Show Log” button to find the revision easily. Command-line users will have to find it first, remember it (yeah, painful ;), and then use it.

You’re not done yet. Now you’ve removed those changes made from your working copy you still need to test your code and the commit the files back to the repository. This will create a new revision that is now fixed, but leaves the broken one in the repo still in case you ever want to “roll back your roll back.”

How to listen to Flash events that don’t bubble

I learned a little trick the other week and thought I’d share. Sometimes you might need to listen to a non-bubbling event “up the chain” somewhere, but of course, since it is not bubbling, that can be hard. The trick is that event events that don’t have bubbling still have the capture phase, so if you flip that capture flag to true in the event listener then you can now listen to any events dispatched by any child views whether they are bubbling or not. Example:

 // listen for some event (this one is even custom) that does not bubble // make sure to set true on capture stage.addEventListener("customNonBubbling", myListener, true); ...
<mx:Button id="myButton" click="dispatchEvent(new Event('customNonBubbling'))"/> 

Note: this only works on display objects as far as I know. Capture and bubbling don’t apply to objects that are not on the display list.

Hacking the Flex SDK

The Flex SDK is finally fully open-source. So I thought I’d have a little fun and implement my own Binding classes to be used when using the [Bindable] metadata tag in an ActionScript 3 project.

The first thing I did of course was to checkout the Flex SDK from subversion. They’ve got instructions on doing all that in their wiki. The wiki also has some great instructions for downloading and installing ANT and the other things you’ll need to build the SDK. Look further down on the previously linked to page in the section “Building and testing.”

Once I had the project checked out I downloaded ANT per the Mac-specific instructions on the wiki. I the ran `source setup.sh` and then `ant -q main` just like they said and voila! I had built my own SDK. Of course, it was basically the same as the one already installed with Flex Builder.

I then started digging into the code and found in the sdk/modules/compiler/src/java/flex2/compiler/as3/binding/BindableProperty.vm template file that is used for the auto-generated binding code. I took out some of the imports, changed the [Bindable(event=”propertyChange”)] on line 62 to [Bindable(event=”${entry.propertyName}Change”)], and changed every place it had dispatchEvent(PropertyCha…. to dispatchEvent(new Event(“${entry.propertyName}Change”). This will allow my binding class that just looks for {propertyName}”Change” event for binding instead of using the expensive describeType function.

Next, I compiled the whole SDK and had issues, because the Flex framework needs to use the old binding. SO DON’T DO THAT. After backtracking and fixing things up I changed to the sdk/modules/compiler/ directory and THEN ran `ant -q main`. Now my mxmlc will use the new binding template but the old framework SWCs weren’t compiled wrong with it.

To check out the new generated classes compile your project using `mxmlc Main.as -keep`. That creates a folder called “generated” that has all those classes including your new bindable changes in it. Now in Flex Builder, you can add a your new SDK and compile your own projects. Haven’t had time to actually test this out yet and I’ve gotta run, but let me know if you get it working.

Flight Stealth, a Flex Component Alternative

The first question you probably have after seeing the title of this post is “why would you make an alternative to Flex?” Or perhaps, “how could you even think of competing with Flex?” Honestly, we aren’t trying to compete. This will be open source. And alternatives are always nice to have. We could talk about how difficult it can be to extend the Flex components, how limited the styling is, or how Flex makes complicated things easy and easy things complicated, but the fact of the matter is we just thought building an alternative would be fun.

Now, that being said, I think we’re going to have a KILLER alternative to Flex. We (Tyler Wright, my twin, and I) have been wanting to do something like this for awhile. After hearing Ely Greenfield’s Flex roadmap presentation at MAX we got all excited about it again. Much of what was presented there are things we’ve had in mind and wanting to build. I’ve been working on a proof-of-concept over the last few weeks, although we’ve worked on it off and on for a couple of years, and we are definitely headed in the right direction. I’ll list here a bunch of the stuff we’ve got worked out so far.

Features

Model View Controller Architecture

Flight’s components, code-named Stealth (because code names are cool!), are fully MVC show-off worthy. Each component (model) has a skin (view) and behaviors (controller) which are set at run-time. A component will have one skin, but could have many behaviors. User-input listeners only appear in the behaviors, databinding is used in the skin, and the component doesn’t have to worry about anything but it’s own logic. There is also a concept of “content” we are borrowing from (dun dun daaaaaa) Microsoft’s Blend. Content is data assigned to a component that can be displayed or used by the skin and covers anything from a Button’s label to a List’s dataProvider.

Stealth Pieces

Layout

Instead of having special components called containers that deal with laying out their children, every component has layout. That means you have a nice way to tell the icon in your button to be on the right or the left of your label. You can have somethings laid out horizontally in a panel and some things absolute positioned. Layout doesn’t just work horizontally, vertically, or absolute though. It uses concepts such as anchor, dock, and tile. These will be explained in detail at a later date. AND last but not least to me, when something turns visible=false it is removed from the layout. I’ve always used visible and includeInLayout together with Flex and it’s always bugged me that turning it invisible didn’t automatically remove it from the layout. Yay!!

State

Components always have state. You could consider all the data in a component its current state, however, lots of state is dependent on the behavior of a component. If a component behaves like a Button, for example, you’ll have mouseUp, mouseOver, and mouseDown states. If it is a toggle button you’ll also have selected state. And if it’s an application area you might give it state’s such as screen = “login”. So Stealth provides a state object that you can set mouse state, selected state, and any other state you might desire on it. This allows behaviors to add new types of state at run time.

Style

Stealth has full CSS selector support. This means you can parse a stylesheet at runtime and have “Application #loginScreen Form .inputs” styled just the way you need it. The styles also have state support using pseudo selectors. This would allow your application to show and hide different screens depending on their state like this “Application:login #loginScreen {visible: true;}”. Skins and behaviors are assigned via stylesheets at runtime as well: “Button { skin: ButtonSkin; behaviors: ButtonBehavior ToggleBehavior; }”.

Styles pull it all together like this:

How Stealth Pieces Fit

MXML Skinning

And finally, we’ve worked it out such that even though Stealth is not Flex, you can still use Flex Builder and MXML to create and define your skins and application. This was the “make it or break it” part of the deal for Stealth. Once we knew we could still use markup to define the layout and that we still had all the autocomplete and refactoring that Flex Builder provides, we were sold.

Right now Tyler, myself and hopefully soon Rob Taylor from flashextensions.com are working on it (I hope you don’t mind the mention Rob), but we hope to get the code public soon so that others can help and everyone can check in on the progress.

I really want to get a demo up that showcases the styling. That may or may not happen soon as I’m working on a project that may continue until April 15 (to pay off the government for all my contracting last year). :D I’ll stop procrastinating tomorrow.

Flex or the Server, What’s Your Focus?

I’ve been thinking deeply about how applications are architected. Tyler and I put together a MVC framework which we’ve been reluctant to release because he’s not sure if it’s quite right or if it’s different enough from other frameworks, and because I don’t have time to put it up and document it. So we’ve been brainstorming on how it might be better. I’ve decided that there are two main focuses when designing a Flex application, and it results in two different kinds of frameworks. There is Flex-focused applications and server-focused applications. The difference between these two applications is the location of the majority of domain logic. In Flex-focused applications you have a full domain model with methods and properties and relationships between the models. There is a lot of logic on the Flex side that is not presentation logic. In server-focused applications Flex takes on a view role. This is where value objects are used the most. More calls are probably made to the server because the Flex app needs to know what to do next or to display next. The Flex app contains mostly presentation logic. Right now I think most of the popular frameworks are server-focused. Value objects are abundantly used. A ModelLocator is used because the model on the Flex side is pretty flat. Right now I mostly do Flex-focused development. Not because I am not as comfortable on the server, but because the applications I make are things like image editors, document creators, etc. and not dashboards into server views. Right now I need a different kind of framework. Right now I need something other than Cairngorm or PureMVC.

« Previous Page — Next Page »