<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Opower &#187; Opower Labs</title>
	<atom:link href="http://blog.opower.com/category/opower-labs/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.opower.com</link>
	<description>Blogs</description>
	<lastBuildDate>Thu, 23 May 2013 04:07:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>Innovation Days at Opower</title>
		<link>http://blog.opower.com/2012/11/innovation-days-at-opower/</link>
		<comments>http://blog.opower.com/2012/11/innovation-days-at-opower/#comments</comments>
		<pubDate>Thu, 15 Nov 2012 01:21:50 +0000</pubDate>
		<dc:creator>Stewart McCoy and Yoni Ben-Meshulam</dc:creator>
				<category><![CDATA[Opower Labs]]></category>
		<category><![CDATA[culture]]></category>
		<category><![CDATA[innovation]]></category>
		<category><![CDATA[organization]]></category>

		<guid isPermaLink="false">http://blog.opower.com/?p=2988</guid>
		<description><![CDATA[At Opower, we recognize that our team members are as complex as our customers, and our ability to create brilliant products depends on our ability to reimagine what&#8217;s possible. That’s why, twice a year, we&#8230;]]></description>
			<content:encoded><![CDATA[<p><iframe src="http://player.vimeo.com/video/59432655" width="500" height="281" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe></p>
<p>At Opower, we recognize that our team members are as complex as our customers, and our ability to create brilliant products depends on our ability to reimagine what&#8217;s possible. That’s why, twice a year, we shut out the world and focus on harnessing our collective talent to improve everything Opower—these are our Innovation Days. Similar to <a href="http://en.wikipedia.org/wiki/Hackathon">hackathons</a> and <a href="http://lifehacker.com/5932586/make-work-feel-less-like-work-with-the-8020-rule">20 percent time</a>, they go even further to promote community, creative thinking, and freedom from organizational hierarchy.</p>
<h3>Innovating, on the shoulders of giants</h3>
<p>In recent years a lot has been made over Google’s approach to innovation—20 percent time dedicated toward projects that further the company mission—which was similar to the approach 3M took as far back as 1948 with <a href="http://www.fastcodesign.com/1663137/how-3m-gave-everyone-days-off-and-created-an-innovation-dynamo">15 percent time</a>. Before Google, HP was encouraging employees to use 10 percent time—after lunch on Fridays—to work on whatever they wanted.</p>
<p>Some amazing products have come from those companies and their approach to innovation outside of normal product initiatives:</p>
<ul>
<li>Gmail, AdSense, and Google Earth</li>
<li>from 3M—a sandpaper with rearranged particles that easily cuts through metal, known as the <a href="http://solutions.3m.com/wps/portal/3M/en_US/Cubitron-II/Home/">Cubitron II</a></li>
<li><a href="http://en.wikipedia.org/wiki/Dave_Raggett">one HP employee</a> apparently used his 10 percent time to help invent HTML</li>
</ul>
<p>These products revolutionized how people around the world go about their work.</p>
<p><a href="http://blog.opower.com/wp-content/uploads/2012/11/id-blog-header-1800px.png"><img class="alignnone size-full wp-image-3069" title="Posters from Innovation Days past" src="http://blog.opower.com/wp-content/uploads/2012/11/id-blog-header-600px.png" alt="Posters from Innovation Days past" width="600" height="175" /></a></p>
<p>The format of those innovation initiatives was generally geared toward employees with technical abilities, and the actual percent time was not always formalized, either. At Google, if you wanted to work on something, you just did—there was no paperwork, no manager approval.</p>
<p>Many other companies take a different approach to innovation by hosting hackathons—companies like Yahoo!, Foursquare, Salesforce, and Yelp. This approach encourages public participation in a contest to build on top of a company&#8217;s platform. Many awesome products have come out of these events over the years, as well.</p>
<h3>What we&#8217;ve learned</h3>
<p>As we continue to improve on our Innovation Days, we&#8217;ve gleaned a couple key insights from these giants of innovation:</p>
<ul>
<li>innovation can come from anyone and anywhere, and it&#8217;s up to us to recognize opportunity and champion it</li>
<li>without facilitating a time and place for unconstrained work, it&#8217;s incredibly difficult for people to make innovation happen on their own time without support and encouragement</li>
</ul>
<p>As such, our guiding principles are simple: <strong>remove constraints and facilitate</strong>.</p>
<h3>Making time for what could be</h3>
<p>The only rule of Opower&#8217;s Innovation Day is that folks must present their projects at our Innovation Fair—a science-fair style event where everyone gets to share what they worked on and check out other folks&#8217; projects. The rationale, from a behavioral psychology perspective, is that when people publicly proclaim their intentions, they make themselves accountable to people who trust them to follow through. We want our team members to not only pursue their best ideas, but realize their ideas in ways that allow their projects to come to life for others.</p>
<p>To remove constraints:</p>
<ul>
<li>everybody is included, and people can work with whoever they wish on whatever they want</li>
<li>internal meetings, client meetings, or other regular commitments are not allowed</li>
</ul>
<p>And to facilitate:</p>
<ul>
<li>we’ve created a simple digital space for folks to share ideas and join in groups</li>
<li>about a week prior, we run Pitchathons in each office where anyone can propose and share ideas</li>
</ul>
<p>Working with participants across three offices in two countries has presented its share of challenges. For years, we tried coordinating the events so that kickoff and summary speeches coincided, but we realized that allowing each office to embrace its own time zone, location, and unique culture was the best way forward.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2012/11/innovation-days-at-opower/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Who&#8217;s Inhabiting Your Code?</title>
		<link>http://blog.opower.com/2012/04/whos-inhabiting-your-code/</link>
		<comments>http://blog.opower.com/2012/04/whos-inhabiting-your-code/#comments</comments>
		<pubDate>Thu, 12 Apr 2012 12:51:29 +0000</pubDate>
		<dc:creator>ed.peters</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=572</guid>
		<description><![CDATA[Lately I&#8217;ve been thinking about the notion of &#8220;beautiful code&#8221;, and finding it to be less and less satisfying as a goal. First off, beauty is elusive: everyone seems to have a different concept of&#8230;]]></description>
			<content:encoded><![CDATA[<p>Lately I&#8217;ve been thinking about the notion of &#8220;beautiful code&#8221;, and finding it to be less and less satisfying as a goal. First off, beauty is elusive: everyone seems to have a different concept of what it means (and except for mine, they&#8217;re all wrong). And second, even when you can label a piece of code as &#8220;beautiful&#8221;, it&#8217;s not at all clear how that translates into other desirable characteristics like performance, maintainability, and so forth.</p>
<p>In my reading, I came across a great article by Rebecca Wirfs-Brock <a href="#1">[1]</a> in which she discusses the notion of &#8220;habitable code&#8221;. This idea isn&#8217;t original to her (she credits Richard Gabriel in Patterns of Software <a href="#2">[2]</a>), but she provides a great explanation of the concept, and goes on to talk about its role in complex systems.</p>
<p>Paraphrasing some key points &#8230;</p>
<ul>
<li><em>Clarity for its own sake is an elusive goal</em>. In my own experience, if I strive really hard to make some aspect of my code crystal clear (say, a challenging algorithm or data structure), it&#8217;s at the expense of clarity in some other area. It&#8217;s a bit like a game of <a href="http://en.wikipedia.org/wiki/Whac-A-Mole">Whac-A-Mole</a>. Just as you can&#8217;t write code that&#8217;s infinitely flexible in the face of unknown future requirements, I don&#8217;t think you can write code that&#8217;s infinitely clear to an unknown future audience.</li>
<li><em>Beauty becomes a constraint for future authors</em>. It&#8217;s hard to extend or update excessively beautiful code without spoiling some of its inherent loveliness. An analogy to industrial design &#8212; the MacBook Air achieves a certain level of elegance by ruthlessly eliminating functionality like replaceable batteries, integrated ethernet or a DVD drive. How difficult would it be to add that stuff in later without compromising the original aesthetic? Probably very.</li>
<li><em>Habitable code makes its structure and intentions easy to understand</em>. Structure, sure, but as a professional developer, the &#8220;and intentions&#8221; part seems pretty important. You can read code to understand what it&#8217;s doing, but it&#8217;s not always obvious what problem the original author thought it was solving. This is a hard thing to do right &#8212; the best I&#8217;ve been able to do is document the problem being solved, and make the structure of the code appropriate to the solution. Code reviews are a huge help in identifying areas that need improvement in either direction.</li>
<li><em>Habitable code makes developers feel at home</em>. At <a href="http://www.opower.com">Opower</a> we have a pretty good-sized body of coding conventions, some of which are automatically enforced using tools like Checkstyle and PMD. To new hires, it sometimes seems totalitarian (it did to me). But once you&#8217;ve been around awhile, you notice a funny thing: you can go almost anywhere in our source base and see things done in a similar fashion. This helps us transition from artifact to artifact more easily, and reduces the overhead in sharing code. Habitable, indeed.</li>
</ul>
<p>Just like any other principles, these can be reduced to absurdity. Giving up completely on clarity is obviously not the answer, nor is making your code horribly ugly so that future maintainers don&#8217;t feel bad about rewriting it. But it&#8217;s interesting to think about where habitability differs from clarity and beauty, and what it demands of us as developers.</p>
<p>So &#8230; who&#8217;s inhabiting your code today? Whose code are you inhabiting? How is that going to change in a month? Six months? A year? And what are you doing to make each other feel welcome and at home?</p>
<p><strong>References</strong></p>
<p>[1] <a name="1"></a><a href="http://www.wirfs-brock.com/PDFs/DoesBeautifulCodeImply.pdf">http://www.wirfs-brock.com/PDFs/DoesBeautifulCodeImply.pdf</a><br />
[2] <a name="2"></a><a href="http://dreamsongs.net/Files/PatternsOfSoftware.pdf">http://dreamsongs.net/Files/PatternsOfSoftware.pdf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2012/04/whos-inhabiting-your-code/feed/</wfw:commentRss>
		<slash:comments>1326</slash:comments>
		</item>
		<item>
		<title>Spring Configuration and Library Decomposition</title>
		<link>http://blog.opower.com/2012/01/spring-configuration-and-library-decomposition/</link>
		<comments>http://blog.opower.com/2012/01/spring-configuration-and-library-decomposition/#comments</comments>
		<pubDate>Fri, 20 Jan 2012 17:26:07 +0000</pubDate>
		<dc:creator>Tom Vaughan</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=495</guid>
		<description><![CDATA[Opower&#8217;s evolved rapidly in the last 24 months and nowhere is that more true than in our code base.  Two years ago we had 2 flagship applications that shared model objects, DAOs and a handful&#8230;]]></description>
			<content:encoded><![CDATA[<p>Opower&#8217;s evolved rapidly in the last 24 months and nowhere is that more true than in our code base.  Two years ago we had 2 flagship applications that shared model objects, DAOs and a handful of utility classes with one common JAR.  Since then we&#8217;ve expanded to the point where (not even counting all the Ruby or Scala stuff) we&#8217;re managing:</p>
<ul>
<li>4 WAR applications</li>
<li>33 JAR libraries (1 open sourced @ <a href="https://github.com/opower/jpile">https://github.com/opower/jpile</a>)</li>
<li>14 &#8220;pom artifacts&#8221; that define groupings of projects and organize dependencies, versions, etc</li>
</ul>
<p>Not all of that growth was brand new, however.  As we expanded our product lines and thought more about the best way to scale our core features we invested heavily in the decomposition of existing WARs and improving the &#8220;librarification&#8221; of our code.  In addition to supporting scaling, improving the modularity of our code base also supports a move towards S.O.A. and improves the velocity of our scrum teams.  After all, it&#8217;s a lot easier to focus on developing the stories in your iteration if you don&#8217;t need to worry about stepping on another team&#8217;s toes.  That&#8217;s more easily achievable when your team aligns to one specific code artifact.</p>
<p>A problem we quickly ran in to as we started decomposing WARs and JARs was the creation of a lot of redundant spring configuration files&#8211; especially in an integration test context.  Here&#8217;s a crude picture of our initial state following some decomposition:</p>
<div id="attachment_506" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic11.png"><img class="size-medium wp-image-506" title="pic1" src="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic11-300x161.png" alt="One WAR depending on two JARs with duplicated spring bean configuration" width="300" height="161" /></a><p class="wp-caption-text">One WAR depending on two JARs with duplicated spring bean configuration</p></div>
<p>Note that the WAR includes the two JARs and wires together beans declared in the JARs with an applicationContext.xml defined in the WAR.  We thought it would be a good idea to adopt the policy of &#8220;keep the tests close to the code that they stress.&#8221;  That&#8217;s a sensible policy, but resulted in duplication of context configuration found in the WAR for the purposes of spinning up Spring contexts during integration tests.</p>
<p>Reducing that duplication was done by continuing the theme of decomposition and applying it to the Spring context as well.  For example, we adopted the policy that a JAR should export a sensible &#8220;default wiring&#8221; of the classes that it encapsulates.  We adopted naming conventions to facilitate the need to either explicitly or implicitly include a Spring context snippet.</p>
<ul>
<li>If a JAR includes a context file ending in &#8220;-spring.xml&#8221; then it&#8217;s automatically included by any WAR that declares a dependency on that JAR.</li>
<li>On the other hand, if a JAR includes a context file ending in &#8220;Context.xml&#8221; then it is only brought in to the WAR&#8217;s context with an explicitly declared inclusion of that file.</li>
</ul>
<p>Here&#8217;s what the picture looked like when we migrated to that model:</p>
<div id="attachment_507" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic21.png"><img class="size-medium wp-image-507" title="One WAR with two JARs, but no duplicated bean configuration" src="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic21-300x170.png" alt="One WAR with two JARs, but no duplicated bean configuration" width="300" height="170" /></a><p class="wp-caption-text">One WAR with two JARs, but no duplicated bean configuration</p></div>
<p>Integration tests that lived in our various JARs liked living in this model because they could always import &#8220;*-spring.xml&#8221; and their integration test context would come up and run just fine.</p>
<p>This worked well until we encountered some situations where one JAR started depending on another JAR.  We wanted to ship sensible Spring context defaults from both JARs, but because of the &#8220;*-spring.xml&#8221; rule we ended up needing to duplicate all of the application properties that were needed to wire up the beans in the depended artifact from within the src/test/resources directory of the dependent JAR.  Here&#8217;s a picture to explain what I mean:</p>
<div id="attachment_508" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic31.png"><img class="size-medium wp-image-508" title="Application properties starting to proliferate" src="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic31-300x184.png" alt="Application properties starting to proliferate" width="300" height="184" /></a><p class="wp-caption-text">Application properties starting to proliferate</p></div>
<p>This problem just got worse as you got more and more descended from a given library&#8211; for example, if jar-A depends on jar-B depends on jar-C and they all ship with their own &#8220;*-spring.xml&#8221; files we needed to define properties to configure C within jar-B <strong>and</strong> we needed to define properties to configure jar-B and jar-C within jar-A.  It was getting hairy.</p>
<p>To solve this we adopted a new standard that basically amounts to &#8220;provide sensible defaults for our sensible defaults&#8221;: any bean in a &#8220;*-spring.xml&#8221; snippet that can be configured with a PropertyPlaceholderConfigurer must provide a sensible default for that property.  So a bean definition might have looked like this before:</p>
<pre class="java">    &lt;bean name="foo" class="opower.Foo"&gt;
        &lt;property name="locale" value="${locale}"/&gt;
    &lt;/bean&gt;</pre>
<p>After:</p>
<pre class="java">    &lt;bean name="foo" class="opower.Foo"&gt;
        &lt;property name="locale" value="${locale:en_US}"/&gt;
    &lt;/bean&gt;</pre>
<p>The defaulting of application properties allowed us to eliminate 90% of the boilerplate test properties and code that we would have otherwise needed and allows for a greater abstraction of thought when a developer decides to pull in a library.  Thus, our current setup looks something like this:</p>
<div id="attachment_509" class="wp-caption aligncenter" style="width: 310px"><a href="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic41.png"><img class="size-medium wp-image-509" title="Defaulted properties eliminates almost all configuration" src="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2012/01/pic41-300x150.png" alt="Defaulted properties eliminates almost all configuration" width="300" height="150" /></a><p class="wp-caption-text">Defaulted properties eliminates almost all configuration</p></div>
<p>A couple of tricks to note when using this model:</p>
<ul>
<li>There&#8217;s a big difference in classpath context scanning between &#8220;classpath:/*-spring.xml&#8221; and &#8220;classpath*:/*-spring.xml&#8221;.  The first (with just one star) will pull in all the files that match &#8220;*-spring.xml&#8221; in the <em>first</em> directory on your classpath that contains any file matching that expression and then stop.  The second version (with classpath*) will do what you&#8217;d expect&#8230;.it pulls in all files that match &#8220;*-spring.xml&#8221; from every directory in scans in your classpath.</li>
<li>Application property defaulting accepts literals after the colon, so it&#8217;s safe to do something like &#8220;${path:file:///blah}&#8221; to default the property to the string &#8220;file:///blah&#8221;<br />
You can also change the default string separator in the PropertyPlaceholderConfigurer bean so your defaults look more like this: &#8220;${path?file:///blah}&#8221;  (using a &#8220;?&#8221; as a separator)</li>
<li>It&#8217;s tempting to eliminate application.properties wherever there&#8217;s a default, but we avoided that for documentation reasons&#8211; we wanted to provide the implementers and users of our software with a one-stop location to discover and understand the configurability of our applications.  Thus, we adopted a standard that even if an application property is defaulted in a JAR&#8217;s spring context snippet, we still explicitly declare that property in a WAR&#8217;s top-level application.property and document how that property affects the system.</li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2012/01/spring-configuration-and-library-decomposition/feed/</wfw:commentRss>
		<slash:comments>1430</slash:comments>
		</item>
		<item>
		<title>Our Scala DSL for testing our web product</title>
		<link>http://blog.opower.com/2011/09/our-scala-dsl-for-testing-our-web-product/</link>
		<comments>http://blog.opower.com/2011/09/our-scala-dsl-for-testing-our-web-product/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 14:34:57 +0000</pubDate>
		<dc:creator>Dave Copeland</dc:creator>
				<category><![CDATA[Opower Labs]]></category>
		<category><![CDATA[dsl]]></category>
		<category><![CDATA[scala]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=480</guid>
		<description><![CDATA[This is actually a fairly old bit of tech for us, but I&#8217;ve been reading Martin Fowler&#8217;s DSL Book, and thought it might be good to talk about what we&#8217;ve done. Our Domain-Specific Language is&#8230;]]></description>
			<content:encoded><![CDATA[<p>
This is actually a fairly old bit of tech for us, but I&#8217;ve been reading <a href="http://www.amazon.com/Domain-Specific-Languages-Addison-Wesley-Signature-Fowler/dp/0321712943">Martin Fowler&#8217;s DSL Book</a>, and thought it might be good to talk about what we&#8217;ve done.
</p>
<p>
Our Domain-Specific Language is probably more domain-specific than you might be used to.  Frameworks like Ruby-on-Rails or ScalaTest are DSLs for very broad domains (web-app development, and testing, respectively).  Our DSL&#8217;s domain is <em>our web product</em>.  Not any web product, not any Spring app, <em>our</em> web app.  This is important, as it allows us to creating something that is very focused and specific to what we&#8217;re doing.  In general, the more specific the domain, the more concise and powerful you can make your DSL.
</p>
<h2>The domain of application: its architecture</h2>
<p>
To understand how it works, you need to understand how the apppilcation is architected.  While it&#8217;s a Spring MVC web app, in the general sense, there&#8217;s a lot more convention around how it&#8217;s built.  If you&#8217;ve used a &#8220;web framework&#8221; like Spring MVC, you know that it&#8217;s really a giant library for responding to HTTP requests at its core, and that it&#8217;s not very opinionated; it&#8217;s generally just as easy to do things one way as it is another (check out <a href="http://static.springsource.org/spring/docs/3.0.x/javadoc-api/org/springframework/web/bind/annotation/RequestMapping.html">this</a> if you disgree).  As such, you need conventions around how to use it. Developers shouldn&#8217;t spend time asking how to wire up URLs, or where code should go; they should be getting to work and building features.
</p>
<p>
Our app is built along two main concepts: <em>pages</em>, and <em>modules</em>.  A Page is made up of one or more modules.  Each module contains a basic bit of information needed to display a page.  Think about websites that say &#8220;Hi, Dave!&#8221; in the upper corner; that &#8220;Hi, Dave&#8221; would be controlled by  a module.  Each page is backed by a controller whose job it is to expose <strong>only</strong> what&#8217;s needed to configure the modules on the page. All stateful information (e.g. &#8220;who&#8217;s logged in?&#8221;) is in these controllers.  Modules, on the other hand, are stateless; they get all the information they need to render from the URL and query parameters.  Modules are made up of two parts: a resource, which identies the data to display, and a view, which renders that data.  A single resource can have many views, and together, they form a module.
</p>
<p>
This is all glued together via a souped-up version of a <code>&lt;jsp:include&gt;</code> tag.  A page jsp-includes a bunch of urls, that happen to be modules, and conform to these conventions.  We have scaffolding scripts to generate the massive boilerplate required to make this happen.
</p>
<h2>Testing with Scala</h2>
<p>
Which brings us to our DSL for testing this stuff.  Essentially, a module&#8217;s url can be requested and tested independently of any page; we don&#8217;t need to navigate through the application to test modules, since they are almost entirely stateless (typically, they might require a login, but this a cross-cutting concern).  By requesting the module&#8217;s URL, and forcing it to render a view, we also get test coverage of our JSP pages, and can push our app to QA with high confidence that all pages will at least render, and that the correct information will be somewhere on the page.
</p>
<p>
This can all be tested with HTMLUnit, however the tests began to look like bloated assembly-language.  Enter Scala.  I started by writing out the ideal pattern of a test for a module.  Let&#8217;s consider a module that renders a person&#8217;s most recent bill.  Suppose we have two views of this module; in the &#8220;large&#8221; view, we want to see the bill&#8217;s cost, KWh used, and an account number.  In the &#8220;small&#8221; view (that we might use on a dashboard page), we want to see just the bill&#8217;s cost.  How might we test this?
</p>
<pre>
resource for bill 34 from customer 123:
  requires login as customer 123
  contains "45.67" as the cost
  has a view "small"
  has a view "large"
    that contains "156" as the kwh
    that contains "655321" as the account number
</pre>
<p>
I decided I wanted to write this in code, and have it work.  Not having time to write a parser (or invent a new language), I decided an internal DSL would be the way to go, and that Scala would let me get as close as possible to this:
</p>
<p><script src="https://gist.github.com/1226977.js?file=DSLSimple.scala"></script></p>
<p>
This code creates several data structures that our test can now walk.  Essentially, what this will test:</p>
<ul>
<li>That accessing the url without being logged in gets an error</li>
<li>That, once logged in, requesting a view named &#8220;small&#8221; will not generate an error</li>
<li>That, once logged in, requesting a view named &#8220;large&#8221; will not generate an error</li>
<li>That neither view has message properties that are missing their values (we aggresively use message properties to allow localization)</li>
<li>That both views contain a div with the id price that contains the text &#8220;45.67&#8243;</li>
<li>That the &#8220;large&#8221; view also contains a div with id kwh that contains &#8220;156&#8243; <strong>and</strong> a div with id &#8220;accountNumber&#8221; that contains &#8220;655321&#8243;</li>
</ul>
<h2>Getting fancy</h2>
<p>
Since this is just Scala code, you can use this to do more sophisitcated things:
</p>
<p><script src="https://gist.github.com/1226977.js?file=DSL.scala"></script></p>
<p>
I don&#8217;t know if the developers are totally in love with this DSL, but there&#8217;s so much you get for free, I&#8217;m certain they&#8217;d hate testing that by hand even more (or, worse, simply not test some of these things):</p>
<ul>
<li>You never have to remember to check for authentication requirements</li>
<li>You never have to remember to check for missing message properties</li>
<li>You can dynamically generates tests via test-data (as demonstrated above)</li>
<li>Because making a new data structure in Scala is so easy, you can make very fluent tests and test data.</li>
</ul>
<p>
Of course, this DSL is entirely useless to anyone but our web team.  It&#8217;s tailor-made to test our web product and our web product only.  The win, other than conciseness, readability, and brevity, was that this could be implemented and documented very quickly; I didn&#8217;t have to make the ultimate web-based tesitng DSL; just one that worked for our product.
</p>
<p>
If you are considering creating a DSL, keep this in mind: make it exactly right for you, and fight the urge to make it more general.  Also, don&#8217;t be afraid to use Scala for this; it&#8217;s much easier than Java, and you can fully type-check and document it very easily.  I should note that I intentionally used very few of Scala&#8217;s features to do this; developers only need to learn a few new concepts to understand what this code does.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/09/our-scala-dsl-for-testing-our-web-product/feed/</wfw:commentRss>
		<slash:comments>1363</slash:comments>
		</item>
		<item>
		<title>Attentive Programming</title>
		<link>http://blog.opower.com/2011/07/attentive-programming/</link>
		<comments>http://blog.opower.com/2011/07/attentive-programming/#comments</comments>
		<pubDate>Tue, 05 Jul 2011 15:00:34 +0000</pubDate>
		<dc:creator>paul.vancleave</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=471</guid>
		<description><![CDATA[Attentive Programming I’m currently reading Matthew Crawford’s Shop Class as Soulcraft who writes about how manual labor can make you spiritually whole. To get us to look at work in new ways, he describes work using&#8230;]]></description>
			<content:encoded><![CDATA[<p><strong>Attentive Programming</strong></p>
<p>I’m currently reading Matthew Crawford’s <strong>Shop Class as Soulcraft </strong>who writes about how manual labor can make you spiritually whole. To get us to look at work in new ways, he describes work using the categories: <em>assertiveness</em> and <em>attentiveness. </em>Crawford writes that work is not exclusively assertive or attentive and that to obtain the spiritualism that comes from manual work, you need balanced quantities of both. Too much assertiveness, and you may destroy your work, while too much attentiveness and you could go out of business. Soulcraft is being able to apply just the right amount of each.</p>
<p>I believe that Crawford’s categories can extend beyond the realm of manual labor. His descriptions really got me thinking about how they would apply to software engineering. What is “assertive” and “attentive” software engineering? I’ve always felt that programming brings with it a sort of spiritualistic satisfaction. Now Crawford gives me tools to examine programming in new ways.</p>
<p>The assertive programmer is one who makes new or improves features. In this case, the engineer is on the cutting edge of product development and essentially makes something out of nothing. He or she “asserts” him or herself by creating new code or by combining or expanding infrastructure in new ways to make new things.</p>
<p>This type of programming is fun and rewarding because you get to see something made. You also get a craftsman-level satisfaction and the pride of ownership knowing that the software is built well and that other people find it useful. Contrast this with the attentive programmer. The attentive programmer generally works with software that he or she didn’t make. And is given a problem which has perplexed others.</p>
<p>I think that I am more akin to this type of programmer. I am a Database Architect who works on the OPOWER Scale Team. On the Scale team, we handle problems that reflect scalability issues with the software. We also get a first crack at designing new features that are scalable out of the box, and I think that puts us firmly in the assertive camp.</p>
<p>I want to reflect more upon our reactive scalability work because I think this sort of work takes a different mindset and possibly a different software engineering approach. To be an attentive programmer you almost have to have a Zen-like disposition and “listen” to the information that you find. You may think that you understand the problem but you must verify if the hypothesis is true. And if it’s not, you must reexamine your assumptions, read the data again, and develop a new hypothesis to test.</p>
<p>The attentive programmer knows that truth is the path to the right solution, and that’s exactly how we approach problems on the Scale team. I think the key to a good scalability engineer is attentiveness and checking preconceived notions at the door. This type of programmer needs lots of experience and must be open to a wide range of ideas where hunches based upon past experiences or fresh perspectives can be quickly dismissed or followed based upon the facts.</p>
<p>To me probably nothing is more satisfying than taking a piece of code, no matter how complicated, that no one has been able to make go fast and making it fly. I’m always ready for the next problem and always wondering what I’m going to learn from that puzzle.</p>
<p>Are you an attentive or assertive programmer, or some combination of? Why? Thinking about how you approach software engineering may help you raise your game and bring with it the satisfaction of rising above the status quo.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/07/attentive-programming/feed/</wfw:commentRss>
		<slash:comments>1244</slash:comments>
		</item>
		<item>
		<title>Engineering&#8217;s Second Bottom Line</title>
		<link>http://blog.opower.com/2011/05/engineerings-second-bottom-line/</link>
		<comments>http://blog.opower.com/2011/05/engineerings-second-bottom-line/#comments</comments>
		<pubDate>Mon, 02 May 2011 10:27:07 +0000</pubDate>
		<dc:creator>Jeff Kolesky</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=446</guid>
		<description><![CDATA[OPOWER has a set of company values, the first of which is &#8220;We are double bottom line.&#8221; Our two bottom lines are the environment (we want to improve that) and money (we want to make&#8230;]]></description>
			<content:encoded><![CDATA[<p>OPOWER has a set of company values, the first of which is &#8220;We are double bottom line.&#8221;  Our two bottom lines are the environment (we want to improve that) and money (we want to make that).  Everyone in the company is fully bought in to the first bottom line.  Given our enterprisey business model, the engineering team cannot contribute directly to the company making money (accounting lingo deems us a liability, as does HR sometimes), so we have a slightly different second bottom line.</p>
<p>We focus on how we build the product to ensure it supports the business for the long haul.  We take this part of our job very seriously and are constantly working to improve how we work.  We use some of the obvious practices from agile like scrum teams, story pointing, and short-term iteration planning to keep ourselves on track with the functionality we need to build over a three iteration horizon.  A more out-of-the-ordinary practice is having test team members fully embedded on our scrum teams.  The software engineers in test work alongside software engineers building functionality, and a task is not considered finished until it is tested through our automated regression suite.</p>
<p>We do team retrospectives almost every iteration and keep a backlog of tasks to work on during regression weeks to keep improving our tools and process.  When it comes to coding, we have formal code reviews every three weeks as part of the iteration cycle, and ad hoc code reviews happen during the build.  Some of our reviews can get heated (though not personal), and everyone knows that the intent is to build the best product we can.  The reviews are also a lot of fun.</p>
<p>The point of all of this work is to get everyone in line with building a product for the future.  OPOWER is only four years old, and our product has been live and generating energy efficiency gains for over three years.  We are pushing ourselves to build new products to improve those efficiency gains and to positively impact the environment in other ways.  Our clients are pushing us to deliver more functionality to them faster and faster, and in the meantime, they keep giving us more and more data to learn from and use.  If we took a short-term approach to our jobs as engineers, the platform we are building would collapse in on itself, and that would do no one any good.</p>
<p>Wil Shipley, of Delicious Monster fame, wrote an <a href="http://blog.wilshipley.com/2011/04/success-and-farming-vs-mining.html">interesting article</a> recently, drawing an analogy comparing building software companies to either farming or mining.  When you mine, you take out a loan, purchase a ton of equipment, hire people to dig, strike gold, and profit.  When the gold runs out, you retire.  On the other hand, when you farm, you take out a loan, purchase some equipment and seed, and then you plant and tend.  If things go well, you reap some reward during the harvest season, after which you repeat the cycle, reinvesting your money back into your land.  If you are an adept farmer, you may figure out how to rotate crops and make the most of your land all year long, thus increasing profits.  In his analogy, farming is a long-term approach to building a company, and mining is what you do with a social network for dogs &#8212; build it to flip it.</p>
<p>At OPOWER, this analogy is particularly apropos, because of our first bottom line.  What is more sustainable &#8212; farming or mining?  Clearly, OPOWER is a farming company, and the engineering team is working to ensure the harvest comes in season after season.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/05/engineerings-second-bottom-line/feed/</wfw:commentRss>
		<slash:comments>1303</slash:comments>
		</item>
		<item>
		<title>Helping DC Area Agile Testers Help Themselves</title>
		<link>http://blog.opower.com/2011/03/helping-dc-area-agile-testers-help-themselves/</link>
		<comments>http://blog.opower.com/2011/03/helping-dc-area-agile-testers-help-themselves/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 10:55:43 +0000</pubDate>
		<dc:creator>rob.fagen</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=440</guid>
		<description><![CDATA[The DC Agile Software Testing MeetUp group met for the first time yesterday. Thanks to everyone that attended for contributing to a very positive experience. We&#8217;re looking for &#8220;Better Ways To Make Better Software&#8221;. Agile&#8230;]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.meetup.com/D-CAST/">DC Agile Software Testing MeetUp group</a> met for the <a href="http://www.meetup.com/D-CAST/events/16781293/">first time</a> yesterday. Thanks to everyone that attended for contributing to a very positive experience.</p>
<p>We&#8217;re looking for &#8220;Better Ways To Make Better Software&#8221;.</p>
<p>Agile software development is a great way to make good software that satisfies real needs and creates real value to those who build and use that software. Everyone on the team is concerned with the quality of the product. However, sometimes it can be an overwhelming task being the team member whose job it is to insure that the quality of the product is sufficient.</p>
<p>DCAST was created to develop a community of those interested in agile software testing who are also interested in testing agile products more effectively and more efficiently. By sharing our hard won knowledge we can all help make each other&#8217;s lives easier and more productive.</p>
<p>If you&#8217;re interested in sharing how you have raised the quality bar of your agile processes, we would love it if you were a part of this community. If you&#8217;re interested in learning (or want to all learn together), you&#8217;re even more welcome.</p>
<p>We&#8217;re going to be <a href="http://www.meetup.com/D-CAST/events/17021962/">meeting again in about a month</a>. Come check out the group if you&#8217;re in the DC area.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/03/helping-dc-area-agile-testers-help-themselves/feed/</wfw:commentRss>
		<slash:comments>1259</slash:comments>
		</item>
		<item>
		<title>Why Homework?</title>
		<link>http://blog.opower.com/2011/03/why-homework/</link>
		<comments>http://blog.opower.com/2011/03/why-homework/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 16:24:56 +0000</pubDate>
		<dc:creator>ed.peters</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=413</guid>
		<description><![CDATA[The Discovery Channel spends an entire week every year convincing us how incredibly awesome sharks are.  How do they do it?  Do they take a mako shark out of the ocean, squeeze it into a&#8230;]]></description>
			<content:encoded><![CDATA[<p>The Discovery Channel spends an entire week every year convincing us how incredibly awesome sharks are.  How do they do it?  Do they take a mako shark out of the ocean, squeeze it into a suit, and ask it questions about being a shark?  Not hardly.  They let us watch the thing cruising through the open ocean, chasing tuna and scaring the hell out of everyone.</p>
<p>When you apply to OPOWER, we want to see how awesome YOU are in your natural habitat.  Our homework helps us do that &#8212; by giving you a project that you can complete on your own schedule, in your own environment.  Maybe you&#8217;re a &#8220;early-morning coffee and Eclipse&#8221; person, or an &#8220;up-all-night with pizza and vim&#8221; type.  Whatever it is, we want to see THAT.</p>
<p>Yes, we also have a more conventional part of our interview process.  You&#8217;ll talk to us on the phone and in person.  We&#8217;ll ask you about your current projects, make you answer some tough technical questions, and write code together on a whiteboard.  But the homework is our way of asking you to show us what you&#8217;re like, on your own terms.</p>
<p>We take our homework pretty seriously, and hope you do, too.  Think carefully about the problems.  Explain what you did (and what you didn&#8217;t do) using comments and READMEs.  And give us your best code &#8212; polish counts more than features.  Code that&#8217;s lean, appropriately commented, and thoroughly tested is going to earn high marks, guaranteed.</p>
<p>Our application process is hard.  We know, because every single person in OPOWER&#8217;s engineering group has been through it.  We do it this way because we want a team full of great people that can produce reliable, real-world solutions.  It may be more work for everybody up front, but we think it&#8217;s produced great results.  And we think you&#8217;ll agree when you join us.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/03/why-homework/feed/</wfw:commentRss>
		<slash:comments>1579</slash:comments>
		</item>
		<item>
		<title>How One Line of Code Can Change the World</title>
		<link>http://blog.opower.com/2011/02/how-one-line-of-code-can-change-the-world/</link>
		<comments>http://blog.opower.com/2011/02/how-one-line-of-code-can-change-the-world/#comments</comments>
		<pubDate>Mon, 07 Feb 2011 14:18:00 +0000</pubDate>
		<dc:creator>Dave Copeland</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=405</guid>
		<description><![CDATA[From my recent talk at a recruiting event, a very quick Prezi: How One Line of Code Can Change The World on Prezi]]></description>
			<content:encoded><![CDATA[<p>From my recent talk at a recruiting event, a very quick <a href="www.prezi.com">Prezi</a>:</p>
<div class="prezi-player">
<style type="text/css" media="screen">.prezi-player { width: 550px; } .prezi-player-links { text-align: center; }</style>
<p><object id="prezi_5dpc5twja_kl" name="prezi_5dpc5twja_kl" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="550" height="400"><param name="movie" value="http://prezi.com/bin/preziloader.swf"/><param name="allowfullscreen" value="true"/><param name="allowscriptaccess" value="always"/><param name="bgcolor" value="#ffffff"/><param name="flashvars" value="prezi_id=5dpc5twja_kl&amp;lock_to_path=0&amp;color=ffffff&amp;autoplay=no&amp;autohide_ctrls=0"/><embed id="preziEmbed_5dpc5twja_kl" name="preziEmbed_5dpc5twja_kl" src="http://prezi.com/bin/preziloader.swf" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="550" height="400" bgcolor="#ffffff" flashvars="prezi_id=5dpc5twja_kl&amp;lock_to_path=0&amp;color=ffffff&amp;autoplay=no&amp;autohide_ctrls=0"></embed></object>
<div class="prezi-player-links">
<p><a title="" href="http://prezi.com/5dpc5twja_kl/how-one-line-of-code-can-change-the-world/">How One Line of Code Can Change The World</a> on <a href="http://prezi.com">Prezi</a></p>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/02/how-one-line-of-code-can-change-the-world/feed/</wfw:commentRss>
		<slash:comments>2006</slash:comments>
		</item>
		<item>
		<title>How to Get Hired: Polish</title>
		<link>http://blog.opower.com/2011/01/how-to-get-hired-polish/</link>
		<comments>http://blog.opower.com/2011/01/how-to-get-hired-polish/#comments</comments>
		<pubDate>Mon, 03 Jan 2011 17:51:54 +0000</pubDate>
		<dc:creator>Dave Copeland</dc:creator>
				<category><![CDATA[Opower Labs]]></category>

		<guid isPermaLink="false">http://www.heyitsopower.com/?p=386</guid>
		<description><![CDATA[It&#8217;s been several months, but we are still hiring like crazy, with no chance of stopping. We get a ton of résumés, and there are many internal hoops a candidate&#8217;s application package must jump through&#8230;]]></description>
			<content:encoded><![CDATA[<p>
It&#8217;s been several months, but we are still <a href="http://www.opowerjobs.com">hiring like crazy</a>, with no chance of stopping.  We get a ton of résumés, and there are many internal hoops a candidate&#8217;s application package must jump through before we bring someone in for an interview.  Our goal is for anyone who&#8217;s brought in for an in-person interview to have a very high likelihood of being extended an offer.  To that end, everything is reviewed by OPOWER developers directly.  Résumés go through an initial screening with our recruiters, but everything else goes straight to us, and we look at everything closely and carefully.
</p>
<p>
One thing I&#8217;ve noticed about successful candidates is <em>polish</em>.  This isn&#8217;t a word thrown around when discussing developers a whole lot, but I&#8217;ve found it to be a strong indicator of a true software professional.  The OPOWER application is more than just a résumé; it&#8217;s a written quiz and a coding assignment as well. Sloppiness at any point is a negative; it shows that the candidate just doesn&#8217;t give a shit about getting the job.  It&#8217;s not a deal-breaker, but it has a huge effect on how excited we get about a candidate, <strong>and</strong> it could be the deciding factor between two otherwise identical candidates.  It&#8217;s our version of <a href="http://gettingreal.37signals.com/ch08_Wordsmiths.php">&#8220;hire the better writer.&#8221;</a>
</p>
<p>
So, what do I mean by &#8220;polish&#8221;?  Here&#8217;s a few examples:</p>
<ul>
<li>Make your code <em>better</em> than you would &#8220;at work.&#8221;  Don&#8217;t make me download the JUnit jar and type <code>javac `find .  -name *.java`</code> to compile your code; give me a <code>pom.xml</code> or Ant file with Ivy support.</li>
<li>Send PDFs instead of MS-Word; they are so much easier on the eyes (and processor).  This is dead simple on OS X, <a href="http://www.cutepdf.com/products/cutepdf/writer.asp">there&#8217;s some free options for Windows</a>, and there&#8217;s always <a href="http://www.latex-project.org/">LaTeX</a> (which will definitely earn you some geek cred <img src='http://blog.opower.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </li>
<li>Don&#8217;t send me the functional spec of your last project and call it a résumé.  Use bullet lists, short sentences, and formatting to create an easy-to-scan CV.</li>
<li>Format your writing; compare <a href="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2011/01/sloppy.jpg">this</a>, to <a href="http://www.heyitsopower.com/wordpress/home/35481/domains/heyitsopower.com/html/wordpress/wp-content/uploads/2011/01/polished.jpg">this</a>.  Even though they both are excerpts from correctly-answered quizzes, which one is going to be easier and more engaging for me to read?</li>
<li>English: <a href="http://www.imdb.com/title/tt0110912/quotes">do you speak it?</a>.  Being able to communicate effectively using the written word is absolutely <strong>crucial</strong> for being a good developer, especially at OPOWER.  It doesn&#8217;t need to be your first, or even best, language; you just need to wield it as effectively as you do Java</li>
</ul>
<p>
A lack of polish won&#8217;t get you refused, but putting an extra shine on your application can make you stand out quite a bit&hellip;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.opower.com/2011/01/how-to-get-hired-polish/feed/</wfw:commentRss>
		<slash:comments>1354</slash:comments>
		</item>
	</channel>
</rss>
