Greg Boone

How can I use PHP Namespaces in WordPress Plugins

PHP has long had a problem of naming collisions. Because older versions of PHP had no way of declaring methods outside the global space, developers came up with several different ways of preventing and checking for namespace collisions, none of which treated the underlying condition. These many and varied solutions begged for a unifying standard as they made things like autoloading and package management increasingly difficult. PHP 5.3 introduced a feature called ‘namespacing’ to solve this problem and WordPress developers should begin adopting. With proper namespacing, WordPress plugin and themes will become clearer, more stable, and more portable.
<!–more–>

Prior to PHP 5, if you tried to name a method or class foo it might conflict with another similarly nammed method elsewhere in the system. Developers came to terms with this by ‘namespacing’ methods with a prefix. With this standard, foo became my_foo or gb_foo where the my_ or gb_ corresponded to vendor prefixes (gb, being my initials). It also led to wrapping every method in a conditional to check for namespace collisions:

if ( !function_exists(gb_foo) ) {
    function gb_foo( $bar ) {
        echo $bar;
    }
}

gb_foo('bar');

Look familiar? The problem with this should be easy to see. If that conditional returns false, my method `gb_foo` will never be fired and any time it’s called, that other `gb_foo` method will. Imagine if `gb_foo` was something like this:

function gb_foo($bar) {
    mysql_query('DROP TABLES *');
}

I think we can all agree that would be bad.

Namespacing is a concept familiar to many other programming languages that isolates your application from others in a standardized way. The global space should be reserved for only those things that should be available at all times. There is typically a character or pair of characters which globally signifies a namespace separator. In PHP it’s the backslash .

If properly namespaced, you can name your method foo() without any possibility of your method conflicting with anything else (unless you declare it twice in the namespace).

Namespacing also alleviates your need to wrap your methods in that conditional. A properly namespaced foo() method would look like this:

namespace gb;

function foo($bar) {
    echo $bar;
}

Let’s take a look at what’s going on here. On the first line we declare the namespace we want to use, in this case my initials gb. We can then declare classes and methods without worrying about stepping on any other methods. This is sort of like putting things in classes, but it’s even more safe. To call that ‘foo’ method, just type gbfoo('baz'); which should output ‘baz’. You can also declare classes inside the namespace just like you would normally, the difference is that when these are called, the namespace must be too. There are a few different ways of approaching this:

Consider the application lives in a file called test.php and all our files are in the same directory.

// test.php
namespace gb;
class Bar {
    public static function foo($bar) {
        echo $bar;
    }
}

Example one: ‘Use’ the namespace, declared at the top of the second file.

require_once(DIR . '/test.php'); use gbBar;

Bar::foo('baz');

Example two: Call the method with the namespace and class prefixed.

require_once(DIR . '/test.php');</p>

gbBar::foo('baz');</p>

Example three: Instantiate the class as an object and declare the method from the object.

require_once(DIR . '/test.php');</p>

$object = new gbBar();

$object->foo('baz');

They’re all very similar and should look familiar. Again, all the namespace does is add a layer of abstraction away from the global space in order to prevent collisions. Where it becomes particularly useful is in autoloading with tools like composer. With namespaces autoloaded, developers do not even need to require the files where those classes exist. They only need to know the namespaces. Example one, then, becomes:

use gbBar;
Bar::foo('baz');

Pro tip: you can ‘use’ a namespace under another name. So if you have two classes Bar, you can redeclare them like this:

use namespaceBar as Bar;
use gbBar as Baz;

Baz::foo('bar');

You can also stack namespaces to isolate your individual plugins from each other: namespace gbmyAwesomePlugin; and namespace gbanotherAwesomePlugin serve as different namespaces for different plugins. It also keeps me safe from other ‘gb’s out there crowding my namespace.

Namespaces can also indicate where to find your application. With a fully namespaced plugin, you could even configure your WordPress install to use your plugin without ‘installing’ it. If you have composer doing that for you, you can autoload the plugin preconfigured the way you want it. WordPress is becoming an increasingly vibrant application development platform and namespacing will be key to it living in harmony with other PHP applications in complex systems.

Writing Unit Tests for WordPress

This post and others like it still get a strange amount of traffic. It’s worth noting the details here are out of date and I won’t be keeping it up. Use at your own risk!

In my last post I wrote about two testing libraries for WordPress and briefly discussed the difference between integration tests and unit tests. I also mentioned a concept called test driven development (TDD) and breifly explained how it might help write better code from the start. This post will expand on that and show how to write a simple WordPress plugin from a test-first approach. Since we’re writing unit tests, we’re going to use WP-Mock to create a test double for us and we’ll use PHPunit for our test runner.

TDD starts with a problem you want to solve—the same problem your plugin wants to solve. In this case, let’s say we have a plugin that will add some metadata to a post with the title “Test”. Since that’s going to require us to mock some WordPress core functionality, make sure WP-Mock is configured in your working environment. We’ll start by writing a test that verifies the metadata was attached to the post.

In order to write unit tests we first need to extend the base test suite:

Class OurTestSuite extends PHPUnit_Framework_TestCase {

}

Now that we have a class, we can call any of PHPunit’s methods for testing including all of its assertions. Inside OurTestSuite is where we will write all our testing methods. We start with setUp and tearDown, commonly named methods that instantiate some conditions we will want for all our classes. We’ll want to make sure our setUp and tearDown methods clean up our test environment as well as any mocks we create out of WP_Mock. So we’ll declare:

public function setUp() {
         parent::setUp();
     }
     public function tearDown() {
         parent::tearDown();
     }

If we had other objects, variables, or settings we wanted available throughout the test suite, etc., we could declare those too. If you run the test now you’ll get some output, but no tests will run because we haven’t written any. Every test is a method within this class. Let’s write one that will always pass just to see PHPunit give us something.

...
     public function testOneExpectsOneAdded() {
         // Arrange
         $foo = 1;
         // Act
         $bar = $foo + 1;
         // Assert
         $this->assertEquals(2, $bar, 'Variable $bar does not equal two.');
    }

If you run PHPunit on that test, you should get a dot. Congratulations!

Now let’s write our test for our save_meta method. There are three basic sections to our test: Arrange, Act, and Assert. The first section is for all the bits our method needs for input. In our case, we’ll need the post ID for a post called “Test” and a key and value pair to save as metadata. Since the ID could be any integer on a given system, we can arrange our test with any integer we like. The next piece, the key-value pair, will be set in the method, but we’ll want to decide now what they’ll be.

The “Act” section is where we call the method. In this case, we’re going to call a method called save_meta_data out of the MetaMethods object. Finally, the “Assert” section is where we decide what the method should expect to see at the end. This section might be empty depending on whether the method under test returns an output or calls some other method. In our case, it’s the latter. The test passes if update_post_meta is called exactly once. Right now our test is looking something like this:

...
     public function testTestPostExpectsMetaDataSaved(){
         // Arrange
         $post_id = 42;
         // Act
         $methods = new MetaMethods();
         $methods->save_meta_data($post_id);
         // Assert
    }
...

Not a bad looking test, but we have some mocking to do. We already know we’ll need to mock update_post_meta(), but we’re also going to need get_post() as well. In both cases, we’re going to make PHPunit handle calls to those methods and return what we want back. We know what to expect if we call update_post_meta: if all is well with our WordPress install, we expect it would add new information to the post object. So we don’t need to verify that, all we really need to do is verify it’s being called exactly once. So let’s add our mocks to the “Arrange” section.

Fully mocking a function like get_post() uses the static method wpFunction() from WPMock. We can call it with: `WPMock::wpFunciton(). We can also pass wpFunction some parameters like ‘times', for how many times we expect the mocked function to fire, and ‘parameters', and ‘return'. These help us create a fully function test double ofget_post`.

...
// Arrange
$post = WP_Mock::wpFunction('get_post');
...

Finally, we need to address update_post_meta, but since we don’t particularly care what we get back from this method, we can instead ‘stub’ it. WP_Mock has a wrapper for wpFunction that make this easy, it’s called wpPassthruFunction() and can take many of the same parameters, but fills in the return value for you. In our case, we want to know that update_post_meta fired once, so we can write something like:

...
// Arrange
WP_Mock::wpPassthruFunction('update_post_meta', array('times' => 1));
...

Now, if we run phpunit, we get a dot and an F, or maybe an E, since we haven’t written any code yet. Now we can write the actual code with the following workflow:

  1. Write some code
  2. Run the test
  3. Modify the test and code as necessary
  4. Repeat 2-3 until the test passes

A full example of our test is below:

Class OurTestSuite extends PHPUnit_Framework_TestCase {
     public function setUp() {
         parent::setUp();
     }
     public function tearDown() {
         parent::tearDown();
     }
     public function testOneExpectsOneAdded() {
         // Arrange
         $foo = 1;
         // Act
         $bar = $foo + 1;
         // Assert
         $this->assertEquals($bar, 2, 'Variable $bar does not equal two.');
    }

    public function testTestPostExpectsMetaDataSaved(){
        // Arrange
        $post_id = 42;
        $post = WP_Mock::wpFunction('get_post');
        WP_Mock::wpPassthruFunction('update_post_meta', array('times' => 1));
        // Act
        $methods = new MetaMethods();
        $methods->save_meta_data($post_id);

        // Assert
    }
}

Why Unit Testing in WordPress Matters

Testing WordPress has become a favorite topic of mine lately: moving away from hitting refresh and toward something more holistic, reliable, and automatable. I’ve written before about a testing method called called browser testing, which verifies a webpage has some expected behavior. These kinds of tests are great but they’re not perfect. They require a lot o dependencies and that someone else would need to verify your code. There is a better way, one that doesn’t require any of those dependencies and verfies the code down to the exact lines you wrote—it can even be independent of WordPress. It’s called unit testing and it will make you a better developer.

Continue reading “Why Unit Testing in WordPress Matters”

How can I use Feature Switches in WordPress

While a colleague and I were discussing the rollout of a new feature to our public facing website, he asked me if it would be possible to “hide” the new content behind a toggle. Effectively, he was asking me to write a feature switch, a best practice of continuous integration that allows you to push some source code while hiding future features. WordPress has some of this idea built into it’s core: plugins, for example, can be activated and deactivated to turn things on and off. Within plugins and themes, options pages can be used to turn on different features. SEO plugins, for example, let users turn on and off different optimizaiton tools. Feature switches are a little different, and in our case leverage the power of Apache environment variables to show and hide different parts of our site.

Continue reading “How can I use Feature Switches in WordPress”

How to Maybe Flush WordPress’s Rewrite Rules

Custom post types and taxonomies are one of the most powerful tools to transform WordPress from a blogging platform to a full CMS. One of the most common problems beginning developers have when starting to use them is understanding how they work. It’s easy to think that calling register_post_type is all it takes only to discover that their new post type archives are not working. This likely leads to a long dive into first (hopefully) the code to see if something was written incorrectly and then to the WordPress support forums to figure out what the problem is. 99% percent of the time I wager it’s because the developer forgot to flush WordPress’s rewrite rules.

Continue reading “How to Maybe Flush WordPress’s Rewrite Rules”

How can I do Browser Testing With WordPress

Browser testing is a basic component of a concept called behavior driven development (BDD), and one that has helped me become a better WordPress developer in the last few months. The concept of BDD is simple: test and develop around your software’s expected behavior. I recently wrote about BDD for Excella’s company blog, and this post will go a bit more technical than that. The upshot of behavior testing is you can find problems with both your code and your requirements. Before we get into that, a bit of background on the tools.

Continue reading “How can I do Browser Testing With WordPress”

How to Explain Git to Non-Developers

Since starting with Excella in January I’ve found myself explaining git and the underlying concept of version control to a lot of non-developers. People like to ask me what I’m doing at my job, what I’m learning, and git was a big one I had to learn early on. What I usually focus on when explaining git is how it is fundamentally different from revision history tools like those included with Google Documents and other word processors.

Continue reading “How to Explain Git to Non-Developers”

A week into Octopress

About a week ago I successfully migrated some of my posts from harmsboone.org to this blog, I also wrote a post about some things I learned about git that week. WordPress is great. I wouldn’t recommend it (and I almost always do) if it weren’t. For someone who wants to spin up a blog and maybe some day more in a pinch, WordPress is the go-to platform. In fact, the rest of harmsboone.org still runs it. Earlier this year, though, Danielle and I started talking about ditching the one-blog-for-both solution. When we were both living and teaching abroad sharing one blog made sense but now with the both of us starting different careers, we have different things to say.

We decided to keep HarmsBoone.org as an archive of the last four years and also create new blogs for the both of us. Since I was starting from scratch anyway, might as well strike out with something new.

Continue reading “A week into Octopress”

What I learned about git this week

I love hidden features in software. Whether it’s finding a konami code in unexpected places or that I can add or remove all the dots and underscores to my gmail address I want and I’ll still get the emails, something about them are great. That was what made Zach Holman’s presentation ‘More Git & GitHub Secrets’ such an enjoyable read this week.

Continue reading “What I learned about git this week”

Tussle over Technology: Controversy & the Patent Act

Abstract

The United States Constitution instructed the First Congress of the United States to enact laws “securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries.” This instruction, commonly referred to as the Intellectual Property Clause, demanded a set of laws based on the broad idea that inventors are best incentivized and remunerated for their works through a system of guaranteed exclusive rights. What exactly the scope of those rights were, who had authority to hand them out, and under what conditions they would be given, were all left to Congress to sort out; it was among the earliest controversies over science and technology in the United States of America. <!–more–>

Introduction

In the United States of America, the working definition of a patent is best encapsulated not in US Code, but from the United Nations’ World Intellectual Property Organization (WIPO). One of a handful of specialized UN agencies, WIPO’s mission is “to promote… a balanced and effective international intellectual property (IP) system.” Today, U.S. IP law is as much shaped by WIPO treaties and other international agreements as by the U.S. Congress. On its face a patent is nothing more than a legal document but the legal power endowed upon it is mighty. A patent grants to an inventor the power to exclude and determine who is allowed to ‘practice,’ or “make, use, or build,” an invention, in exchange the inventor must disclose in some detail how the technology could be made, used, and built (WIPO). A journey through time will show America’s first patent law respond to a specific set of concerns and gave society a way of answering the question: what is technology?

sThe United States Constitution empowered the United States Congress “to promote the Progress of Science and useful Arts, by securing for limited Times to Authors and Inventors the exclusive Right to their respective Writings and Discoveries” (US Constitution, Art. 1, §8, Cl. 8.). The exact scope of those rights, who administered them under what conditions and for how long were all left to Congress to sort out; it was among the earliest controversies over science and technology in the United States of America. The resulting law, the Patent Act of 1790, created a paradigm for how the United States understood the ideas of invention, technology, and science.

Intellectual Property Rights are not the only means of incentivizing creative work, but it had been the custom for many centuries before the Constitution was written. In his “Theories of Intellectual Property,” William Fisher argued for four broad ways of thinking about IP: utilitarian, natural rights, humanist, and desirable society perspectives. Thomas Jefferson reluctantly accepted IP rights as a desirable society utilitarian’s solution to the problem of incentivizing invention. To Jefferson’s (and, he would argue America’s) chagrin “the exclusive right to invention” is given “for the benefit of society,” at the risk of “embarrassment” from its unintended consequences (Jefferson 1813). As Edward Walterscheid tells in his 1997 article “Charting a Novel Course: The Creation of the Patent Act of 1790” there was robust debate in the late 18th Century. Input came from President Washington, Jefferson, inventors, and many others regarding what Congress should do.

The Patent Act of 1790 was a response to a specific set of problems unique to the early United States. It established a policy paradigm the legislation thereafter served to articulate in the same way that “normal science” did for Kuhn’s scientific paradigms (Kuhn 1970). Peter Hall called this “normal policymaking”, in which the established paradigm sets goals around which future policy will operate.

This paper is less concerned with the virtue of the law, about which a great deal has been written by legal scholars that will inform this work. Rather, it will examine the debate and proposals that interpreted the only precedent the US Congress had in its first three years—the Constitution—around the question of what constituted technology in the young republic. It holds that the Patent Act of 1790 was paradigmatic in the sense that Hall extrapolated “policy paradigms” from Kuhn’s scientific and technological paradigms (Hall1993, Kuhn 1970). The law settled a set of specific questions and problems and served as the answer to all disputes until such a time when the relevant parties no longer found the law adequate.

Intellectual Property Policy Paradigms

Peter Hall saw policymaking as essentially a process of social learning that “involves three central variables: the overarching goals that guide policy in a particular field, the techniques or policy instruments used to attain those goals, and the precise settings of these instruments.” Using British economic policy from 1970-89 as his object of inquiry, he illustrated a paradigm shift. He argued to think about three orders of policy change, the first and second of which he called “normal policymaking” [@Hall1993]. The third was “marked by the radical changes in the overarching terms of policy discourse” that sometimes led to paradigm shifts.

First and second order changes do not necessarily lead to third order changes. In Kuhn’s terms, normal policymaking has the effect of “further articulation and specification under new or more stringent conditions” (Kuhn 1970). First order change is characterized by “incrementalism, satisficing, and routinized decision making” (Hall 1993). Hall noted first order changes were made every year during the time period he studied. Second order changes happen less frequently; they “alter the instruments… without radically altering the hierarchy of goals behind [the] policy.” In British economic policies, these were changes to the controls on lending and monetary policy routinely made each year (Hall 1993).

A third order change is much more profound, and far rarer. In British economic policy it was a radical shift from the “Keynesian mode of policymaking to one based on monetarist economic theory” (Hall 1993). Third order changes are informed by “policy experimentation and policy failure” and can lead to “movement from one paradigm to another.” The United States Constitution’s Intellectual Property Clause prompted the First Congress to establish a paradigm for granting IP rights.

Pre-paradigmatic Environment: The Colonies Confederation, and the Constitution

Edward Walterscheid (1997), showed that IP rights derived from English law abounded in the American Colonies (Walterscheid 1997). Frank D. Prager, writing earlier than Walterscheid, showed that those laws were in turn inspired by even earlier Venetian laws protecting inventions and creative works (Prager 1944). A brief discussion of this custom is necessary to understand the controversy that shaped the first Patent Act.

By the time the American Colonies were legislating, intellectual property rights were generations old (Prager 1944). The Continental Congress, the legislative body under the Articles of Confederation, did not issue any patents or enact any laws establishing a patent system but “there was nonetheless a patent custom extant in both the infant United States and in Great Britain….” That custom, not operating through any formal mechanisms was, by 1787, “timeworn” and failing to address the technological needs of the American and English societies (Walterscheid 1997, emphasis added). The only explicit mention of inventions in law came from South Carolina’s copyright statute which extended the same rights to inventors of “useful machines” as authors had over their writings. It did not, however, create any kind of formal system by which those rights would be conferred. “Consequently, the granting of each patent… required a special act of the legislature” (Walterscheid 1997, Prager1944). This South Carolinian custom would be demonstrated by inventors in petitions to Congress.

What little policy made during the Colonial and Articles of Confederation eras was first and second order policy change. The aging custom of common law IP rights had yet to be replaced. The Constitution prompted a third order change to codify a uniform patent system across all the states in the union. After the constitution was adopted, inventors sought from Congress, a paradigm shift.

Building a Paradigm: Controversy in Congress

The First Congress’s goal was simple: grant IP rights. The Constitution said nothing about what those rights should look like or whether they should be create some kind of system or grant them individually as in colonial South Carolina. Walterscheid noted that the First Congress started receiving petitions from inventors waiting for legislation “almost immediately.” The petitioners wanted Congress to individually assign a unique right for each invention. Congress, overwhelmed with all the other obligations it had per the Constitution. The authors and inventors wanted answers from Congress about what they had in mind for a law: how generic it would be, whether one law would cover both inventors and authors, what would happen to them upon death, and how the assignment process would work. Congress did what it would probably do today on a question it had never before considered, “it appointed a committee” (Walterscheid 1997, 458).

Less than a month after Congress convened inventors David Rumsey and John Churchman’s petitions were heard in the House posing just these questions. The committee interviewed Churchman about how his navigational instruments worked and responded directly to him saying that he should be given some kind of exclusive right for a “term of years”, but stopped short of actually giving him one or any indication of how many years it had in mind. The committee’s report generated added controversy within Congress when it recommended giving Churchman “further encouragement to his ingenuity,” upon proof of his invention’s success. Another issue to consider: whether the power given to Congress was to reward or simply encourage inventors (Walterscheid1997, 456-459).

More petitions came from inventor Alexander Lewis claiming to have discovered a novel way of “impelling boats… through the water, against any current or stream,” and asking Congress to pass a law securing a twenty-one year exclusive right to “construct boats upon his model.” Inventor Arthur Greer, asked for the same term length, but specifically used the word patent, for his navigational discoveries, and a third, Englehart Cruse asked for an eight year term over his “improved steam engine.” All of these (and presumably more) were ordered to lie on the table [@Walterscheid1997, 459]. Finally, a petition from John Fitch asked for an exclusive right, not just to build, construct or use the invention, but to enjoin others, like Rumsey, from improving upon his steam boat invention. Fitch also claimed to have exclusive rights over his inventions in several states (Walterscheid 1997, 460-462).

To the extent these petitioners imagined a uniform system for applications, it was in wondering whether Congress might impose one. Each hoped congress would issue a special right over their unique inventions (Walterscheid 1997, Prager 1954). The issues raised nevertheless became central questions for a future patent system: what was a technology (or a Useful Art), and how long was sufficient enough time to protect it to promote their discovery? They were the issues the English system and common law traditions failed to address and were crucial for the First Congress in crafting legislation.

If Prager’s 1954 account is any indication, the public debate surrounding any patent legislation was a battle between Fitch and Rumsey over a perennial question of patent policy: what shall be done with simultaneous discovery? Rumsey wanted a public examination system like that in France, while Fitch wanted a jury mechanism to determine which invention came first similar to Webster’s proposal. On another level Fitch and his supporters also argued that any American system should be predicated on public declarations and disclosures of their inventions, rather than a more secretive but expedient system of closed examination favored by Rumsey. In the end both parties won some part of the argument in the final Patent Act (Prager 1954).

Walterscheid told the story more completely. While Rumsey and Fitch traded barbs, Congress attempted to make law. The first bill introduced built a system aimed at addressing the petitions and solving the many problems the English system faced. Patentability of improvements, for example, was a question for English courts, rather than Parliament, because England’s aging system had no mechanism to deal with them directly; Congress, however, had no system so it could take on that question (Walterscheid 1997).

The bill introduced on June 23, 1789 was ultimately ordered to lie on the table because Congress could not pass it and had other, more pressing things to consider by the session’s end (Walterscheid 1997).

By the opening of its second session, Congress was fully inundated with petitions asking for individual rights for inventions ranging from mills and sundry engines to lightning rods and wheeled boats. Added urgency came from President Washington who, in his 1790 address to a joint session, implored Congress to act on the Intellectual Property Clause and recommended that whatever legislation passed, it include some mechanism for importing useful inventions from abroad. The Senate, responded saying it would pass legislation when it deemed appropriate and the House appointed a committee “look into” his recommendations.[^1] Congress wanted the granting of exclusive rights to be handled in a system, rather than an arbitrary case-by-case basis (Walterscheid 1997, 492-498).

A new Technological Order

Finally, in 1790, a patent bill was introduced that eventually passed and settled all the controversy described supra. The Act was paradigmatic in that it established a system within which instruments of public policy could be created and predictably used to issue IP rights for technologies.

What did Congress Say?

Congress laid out some specifics based on the controversies identified by petitions sent between 1787 and 1790, though mostly these revolved around the formal operation of the system. Congress declared, for example, that inventions worthy of an exclusive right needed to be “sufficiently useful and important,” and would only be granted for a period of fourteen (14) years. Applications would be examined by a patent board within the State Department consisting of the Secretaries of State and War and the Attorney General. Inventors were required to provide a “specification in writing and a drawing, and a model if possible” (Federico 1936, 237). Many were rejected if they lacked a working model. Filing for a patent would cost about five dollars.[^2]

One concern of many petitioners regarded whether State patents would be honored as Federal patents. That answer was simply, no. All inventions would have to apply to the Patent Board—consisting of the Secretary of State (Thomas Jefferson), the Attorney General (Edmund Randolph), and the Secretary of War (Henry Knox)—and obtain an original patent. All those who petitioned Congress from 1787 through 1790 would have to file a patent like all other inventors. Rather than attempt to enumerate for the Board a list of criteria, Congress gave broad authority to these three to determine what constituted a “useful and important” invention “not before known or used” (Federico1936, Citing the Patent Act of 1790, p. 238).

Federico wrote that Jefferson was likely the most influential board member because of his many useful and important inventions, some of which earned him awards in France, none of which were patented.[^3] These three individuals would “meet from time to time and discussed the applications” pending before the Board. Jefferson elucidated the “rules and regulations ” by which these applications would be evaluated through various letters to citizens looking for guidance on licensing or patenting some invention. As legal scholar P.J. Federico wrote about the Act, “a personal letter form Jefferson probably represents an action on an application” (Federico 1936, 239-243).[^4]

Patentability quickly became shaped by what was technology. Jefferson was clear in his letter to Isaac McPherson that new uses for old technologies did not merit a patent, an improvement upon it, however, did (Jefferson 1813). In that same letter, Jefferson identified three rules the Board used that arose largely out of his desirable society view of intellectual property. Exclusive rights, monopolies as he called them, were granted not to protect a natural right, rather they are given for the benefit of society. Putting an old technology to new use did not bring enough benefit to merit a monopoly over that use. Neither did changing the material from which a machine was made: “Making a plowshare of cast rather than of wrought iron” was not sufficiently inventive because it was still a plowshare. His final rule said that “a change of form” was not an invention. A horseshoe was a horseshoe regardless of whether it was “high-quartered” or low (Jefferson1813, Federico 1936). These three rules were not, however, a complete or exhaustive list of the criteria used to judge applications. Federico notes that Jefferson had strong beliefs that “small devices, obvious improvements or…frivolous devices,” should not receive the protections of a patent (Federico 1936, 241). This system was not perfect, but did manage to give both Fitch and Rumsey patents for their respective steamboat inventions.

A report from the clerk’s office showed that of the 114 applications the Board received, only 49 patents were granted during the Act’s first three years [@Federico1936, 246]. As for the 14 steamboat or engine petitions, a Congressional hearing was held and ultimately determined that each invention was uniquely novel and could therefore be patented. Federico described the patent regime established as “conservative” with a keen attention to the scope of the rights being granted (Federico 1936). Jefferson wanted to hold ‘invention’ to a high standard. He worried that too many patents for too inconsequential of discoveries would be embarrassing to the young republic.

Conclusion: A return to normal science

Science and Technology Studies (STS) scholars have a history of analyzing the politics of techno-scientific events. Steven Epstein analyzed the politics of inclusion in clinical trials as well as the political transfer from lay person to expert in the controversies of the AIDS epidemic (Epstein 2009, Epstein 1995). More removed from politics, Bruno Latour’s Actor Network Theory is a suitable methodology for studying how a complicated system functions and produces knowledge (Latour 1988). Both Epstein and Latour’s methods could be useful frameworks for examining a lawmaking process; especially one with many nuanced actors like patent regime’s. Sheila Jasanoff wrote more specifically about the formal political process and the roles of STS in advising policymakers (Jasanoff 2011). Her perspective on the tension between highly technological societies and democracy are useful when thinking about passing a normative judgement on a set of policies, particularly if the rules a democracy sets up governing what is or is not technology are the object of study.

This essay, however, sought to understand how the United State’s first patent system came about and the controversies that informed it. To that end, Hall’s notions of policy paradigms were more useful because of its focus on policy being oriented toward goals based on a specific view of how a part of the world works. In Hall’s account of policy paradigms, the new economic order established was one that was “based on a fundamentally different conception of how the economy itself worked.” The shift in British Economics was a radical departure from Keynesian theory and fiscal tools to neoclassical economics and monetary policy tools [@Hall1993]. In the account here, the Americans saw a dramatic shift away from a custom to a codified system for intellectual property rights. The decay of the former and its failure to address new questions of patentability combined with a Constitutional call provoked a third order policy change that set a paradigm changing the fundamental goals of the State regarding the promotion of the “Useful Arts”.

Just as a Kuhnian scientific paradigm ushers in a new wave of “normal science,” (Kuhn 1970), so a policy paradigm brings forth a period of “normal policymaking.” Hall says that after a paradigm shift, first and second order policies are adopted to do the work of “[adjusting] policy without challenging the overall terms” set by the paradigm (Hall1993, 279). Evidence of this in the 1790 Patent Act can be seen immediately following its passage when Congress created the patent clerk (Federico1936). This is a clear first order change where “policy at time-1” (the creation of the clerk) is “deliberately” and directly influenced by “the outcomes of policy at time-0” (the need for one created by the Act). They happen frequently and largely respond to unforeseen consequences of past policy and “new developments” (Hall 1993, 281). The issuing of patents had the collective result of incrementally defining what was and was not useful, obvious, or otherwise patentable. Supreme Court decisions following the Patent Act also shaped this answer as well as the limits of Congressional power for granting patents.

Second order changes are rarer than first but not as profound as third order, paradigm shifting, actions. According to Hall they are instrumental adjustments that change the mechanisms underlying the current paradigm, but not its “hierarchy of goals” (Hall 1993). Walterscheid notes that few were happy with the Patent Act of 1790: not Jefferson, nor the other officials, nor inventors (more than half of whom were rejected by the Patent Board). Congress acted quickly to amend it to essentially remove the examination process inventors and officials alike thought stymied the system. Despite the fact that the system had changed from “one of registration rather than examination,” (Walterscheid 1999) this second Act is only a second order change because it preserved the central goal of the 1790 Act which moved the United States from “a patent custom to a patent system in the United States” (Walterscheid 1997) The standards for obtaining a patent still included non-obviousness and usefulness standards, it was still a formal application and fee based system universally applied, and it remained predicated on the idea that the in exchange for a monopoly over their production and use, useful inventions and discoveries would be disclosed to the public (Walterscheid 1997).

Today, the United States is at a juncture in Intellectual Property policy where new innovations and global governance organizations are pushing the limits of our current patenting paradigm. These new phenomena putting pressure on US Code Title 35 it may not be prepared to sustain. Understanding how IP area paradigms were created and overhauled in the past can be useful to inform these contemporary discussions. The controversy leading to the 1790 Patent Act is one such informative instance. Further examination of Patent Legislation over time will show how for long normal policy making continued after 1790 and at what point it began to fail as new inventions (like methods and software) and patenting mechanisms (like patent pools and thickets) that Congress could not anticipate in its first Act.

References

  1. Epstein, Steven (1995). “The Construction of Lay Expertise: AIDS Activism and the Forging of Credibility in the Reform of Clinical Trials.” In: Science, Technology & Human Values 20, pp. 408–437.
  2. Epstein, Steven (2009). Inclusion: Politics of Difference in Medical Research (Chicago Studies in Practices of Meaning). 1st Paperback. University of Chicago Press.
  3. Federico, PJ (1936). “Operation of the Patent Act of 1790.” In: J. Pat. Off. Soc’y 18, p. 237. url: http://heinonlinebackup.com/hol-cgi-bin/get_pdf.cgi? handle=hein.journals/jpatos18&section=43.
  4. Hall, PA (1993). “Policy Paradigms, Social Learning, and the State: The Case of Economic Policymaking in Britain.” In: Comparative Politics. url: http://www. jstor.org/stable/10.2307/422246.
  5. Jasanoff, Sheila (Dec. 2011). “Constitutional moments in governing science and technology.” In: Science and Engineering Ethics 4, pp. 621–38. issn: 1471-5546. doi: 10.1007/s11948-011-9302-2. url: http://www.ncbi.nlm.nih.gov/pubmed/ 21879357.
  6. Jefferson, Thomas (1813). Letter to Isaac McPherson.
  7. Kuhn, Thomas (1970). The Structure of Scientific Revolutions. 50th Anniv. University of Chicago Press. isbn: 978-0226458083.
  8. Latour, Bruno (1988). Science in Action: How to Follow Scientists and Engineers Through Society. Harvard University Press. isbn: 978-0674792913.
  9. Prager, FD (1944). “A History of Intellectual Property from 1545 to 1787.” In: J. Pat. Off. Soc’y 26, p. 711. url: http://heinonlinebackup.com/hol-cgi- bin/get_pdf.cgi?handle=hein.journals/jpatos26&section=144.
  10. — (1954). “Proposals for the Patent Act of 1790.” In: J. Pat. Off. Soc’y 36. url: http://heinonlinebackup.com/hol-cgi-bin/get_pdf.cgi?handle=hein. journals/jpatos36&section=28.
  11. The Constitution of the United States (1787).
  12. Walterscheid, EC (1999). “Use and Abuse of History: The Supreme Court’s Interpretation of Thomas Jefferson’s Influence on the Patent Law, The.” In: Idea: The Journal of Law and Technology 39, pp. 195–236. url: http://heinonlinebackup. com/hol-cgi-bin/get_pdf.cgi?handle=hein.journals/idea39&section= 14.
  13. Walterscheid, Edward C. (1997). “Charting a Novel Course: The Creation of the Patent Act of 1790.” In: AIPLA QJ. url: http://heinonlinebackup.com/hol- cgi-bin/get_pdf.cgi?handle=hein.journals/aiplaqj25&section=20.
  14. WIPO. “WIPO Intellectual Property Handbook.” pp. 17–160.

[^1]:
Francis Bailey came closest to securing a so-called “Special Act” from Congress for his invention of marking paper such that it could not be counterfeited. The Senate’s interest in creating a single system ultimately prevailed over Bailey’s bill.

[^2]:
“Fifty cents plus ten cents per hundred words of specification, two dollars for making out the patent, one dollar for affixing the Great Seal and twenty cents for endorsement and all other services” (Federico 1936, 237).

[^3]:
A colorful list of these inventions can be found at Federico (1936, 239).

[^4]:
The Letter to Isaac McPherson, Jefferson 1813, is one such letter.