DPS911 Release 6

The work for DPS911’s 6th release was already complete, I am just writing about it now. Release 6 was focused on implementing the command pattern and the undo manager, as discussed in bug 463.

I wrote about the progress made in my last release in the blog post, “Butter: Bug 463, the Undo Manager”.

Because this release was focused on architecture, I spent all of my time presenting and discussing the pattern being used, and the possible changes that need to be made. I was also active on GitHub and LightHouse, answering questions and concerns.

As a group, we went through code examples, what the pattern looks like when implemented in Butter, and how this will fit in with Butter’s current architecture. Although there was not much code added this release, there was a lot of discussion so that everyone is on the same page and understands the changes being made.

I also slightly changed the code, and submitted it in the pull request. The new commit introduced a makeCommand factory function, which must be called every time a new command is created. This factory function will automatically register the command with the UndoManager, and returns the command object to the caller, but without the undo function. Not returning the undo function as part of the command object to the caller is to ensure that undoing is only done through the UndoManager.

To summarize, to add a track event to Butter, and have undo and redo automatically done, the code within Butter would call butter.addTrackEvent. Behind the scenes, addTrackEvent will use a command and be registered with the UndoManager. If a button on the UI wants to add a track event, it will simply call execute on the command created by addTrackEventCommand. The key point here is that whether the command is being called from the UI or from Butter, there is only point of entry for the code.

In order to make everything more clear, a diagram needs to be created. I will be creating one as soon as I have a diagram of how Butter currently works. Additionally, the following items still need to be completed before this code lands in Butter

  • testing
  • putting the code in the right place
  • adding more commands
  • adding shortcuts to command objects
Advertisements
This entry was posted in Open Source. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s