Misko has a great article about making sure that your constructors permit your class to be reasonably testable. Read the whole thing, his detailed examples are very informative.
Grogmaster Template Side
Being the blog of Pete Hopkins. This pirate kills fascists.
Wednesday, December 17
Flaw: Constructor does Real Work
Flaw: Constructor does Real Work: "Fundamentally, “Work in the Constructor” amounts to doing anything that makes instantiating your object difficult or introducing test-double objects difficult."
Monday, December 15
topgit Means Never Having to Wait for Reviews
I’ve been using git for a little while now at work. Some rather clever Googlers have rigged up a tool that syncs a local repository with Perforce, so I can do local development and version control with git and then check the final CL in to the depot.
Over the weekend I started using topgit (README), a git wrapper that takes most of the work out of managing dependent “topic branches.” The gist is that you mark branches as depending on one another. Then, when you modify a branch, you can use the
I’ve been doing a lot of large changes and refactorings recently, so what topgit really means for me is never having to wait for code reviews to keep working.
The basic workflow goes like this:
hack hack hack
mv mv mv
add add add
commit commit commit
now mail out the CL for review
In a pure Perforce environment, I couldn’t continue working on this code at all until the review came back and I could submit. With vanilla git, I can of course
Where it starts to get sticky is when my reviewer has comments. No big deal, though. I can just
Of course, I now need to update my
topgit supports exactly this pattern of development by automating the “update the
To continue, we have:
tweak tweak tweak
code code code
“All” is a very operative word in that last sentence. With topgit, a branch can have several dependencies, forming a DAG, and it will recursively update each one of them. This means that I can have several independent changes, with each out for review in parallel, but continue development on a new change that relies on all of them.
topgit works by keeping a separate reference branch for each topgit-managed branch. When you run
Over the weekend I started using topgit (README), a git wrapper that takes most of the work out of managing dependent “topic branches.” The gist is that you mark branches as depending on one another. Then, when you modify a branch, you can use the
tg update
command to propagate those changes to any branches that depend on it.I’ve been doing a lot of large changes and refactorings recently, so what topgit really means for me is never having to wait for code reviews to keep working.
The basic workflow goes like this:
“refactor” is the name of my new branch, “blogger” is the trunk
$ tg create refactor blogger
hack hack hack
mv mv mv
add add add
commit commit commit
now mail out the CL for review
$ gitwrapper mail -m reviewer
In a pure Perforce environment, I couldn’t continue working on this code at all until the review came back and I could submit. With vanilla git, I can of course
git checkout -b new-branch
and keep going, and this is fine most of the time.Where it starts to get sticky is when my reviewer has comments. No big deal, though. I can just
git checkout
back to the refactor
branch, make those changes, and commit them.Of course, I now need to update my
new-branch
so that I’m working from the latest intermediate state. git merge refactor
handles that fairly well (sometimes I get pedantic and use git rebase
) and I’m back to coding the new feature.topgit supports exactly this pattern of development by automating the “update the
new-branch
” step. If I created the new-branch
branch with tg create
, then I could run tg update
to merge in the latest versions of all of new-branch
’s dependencies.To continue, we have:
git checkout refactor
tweak tweak tweak
git commit -am "fixes from review"
git checkout new-branch
tg update
code code code
“All” is a very operative word in that last sentence. With topgit, a branch can have several dependencies, forming a DAG, and it will recursively update each one of them. This means that I can have several independent changes, with each out for review in parallel, but continue development on a new change that relies on all of them.
topgit works by keeping a separate reference branch for each topgit-managed branch. When you run
tg update
, it merges the dependencies into this branch, then merges that into the normal branch. This gives the added benefit that you can easily git rebase
against the reference branch to clean up your commit graph.
Monday, October 6
Palin Markov
Sean is back with more Markov: Sarah Palin
This seemed like an entirely plausible quote:
This seemed like an entirely plausible quote:
They cannot be allowed in their benefit, also, a mutually beneficial relationship for us to remind Russia that it's in their country and their parents give them a passport and give them a backpack and say never again will we be taken advantage of.
Tuesday, September 30
Word up in the House, &tc.: Another version of “Lukey”
Thanks to Lala.com, I found another Great Big Sea cut of “Lukey,” recorded with The Chieftains for their 1998 album Fire in the Kitchen (which is here attributed just to Chieftain Paddy Moloney). It’s appropriately raucous.
And now, a test of the emergency Canadian music
And now, a test of the emergency Canadian music
<embed>
system:Tuesday, September 16
CrossOver Chromium: Chrome (kinda) on a Mac
CrossOver Chromium runs the open-source build of Chrome with Wine to make it work (more-or-less) on an Intel Mac. It's very Windows-y, as one would expect (you'll need to use the Control key for keyboard shortcuts, for example) but it gets some amount of the job done. The visual display is a bit rough at items, with weird flashing as things get re-drawn.
But it's enough to write this post, at any rate, though it did crash once. I need to get the autosaving going in this new post editor...
Thx, Scudder!
But it's enough to write this post, at any rate, though it did crash once. I need to get the autosaving going in this new post editor...
Thx, Scudder!
Subscribe to:
Posts (Atom)