Patently Unpatentable: Federal Circuit is Trying to Develop New Test For Patentability

20. October, 2012

One of the old problems for patent office or a court is to determine whether a patent is patentable. “‘Laws of nature, natural phenomena and abstract ideas’ are not patentable under US law – but their particular inventive application is.” (source)

But with lawsuits like Apple vs. Samsung (great coverage on groklaw), it’s becoming obvious even for the hard-core patent defenders that things must change.

The Federal Circuit is now trying to come up with a test that answers whether software is patentable or just an abstract idea.

Maybe they should check this article on groklaw: What Does “Software Is Mathematics” Mean? – Part 1

 


Patently Unpatentable: Put a Camera Into the Headlight

19. October, 2012

Simple idea: If you exit a tight side street with high walls on both sides, you can’t see the traffic coming from the sides.

If there was a camera in the headlights of your car, you could see around the corner without exposing more than a few centimeters of your car.

Other interesting technologies:


Google, The Evil Empire

18. October, 2012

Google says “We’re not evil[*]” but some have their doubts. “Why insist, when you’re not?” they might ask.

The photo of an Imperial Stormtrooper in standing guard in one of their server farms might be fuel for the wary:

 

Source: Take a walk through a Google data center. When you start, take a step left and then turn left.

[*]: Actually, the slogan is “Don’t be evil.” See how a slight change of words changes the meaning of a sentence.


Comfortable Access to Config Options in Python

12. October, 2012

I always felt that Python’s ConfigParser API could be better. I like to access my config options like this:

    self.config.option

To solve this, I wrote ConfigProvider which can copy options from ConfigParser into a Python instance:

class ConfigProvider:
    __doc__ = 'Interface which can copy values from ConfigParser into a config object'
    
    def __init__(self, cfg):
        self.cfg = cfg
    
    def update(self, section, cfg):
        __doc__ = 'Updates values in cfg with values from ConfigParser'
        
        for name, value in inspect.getmembers(cfg):
            if name[0:2] == '__' or inspect.ismethod(value):
                continue
            
            #print name
            if self.cfg.has_option(section, name):
                setattr(cfg, name, self.cfg.get(section, name))

The magic happens in update() which examines the config object that you pass in and which copies the values from the external ConfigParser into it.

The gist “Comfortable config access with Python” contains the whole code and a demo.


TNBT: Documentation Sucks

11. October, 2012

Documentation is the unloved step-mother of software development: Nobody likes it.

On the writing side, documentation is either considered a waste of time:

  • I could write code in that time
  • It won’t be valid anymore after the code changes tomorrow, anyway
  • There is no way to make sure you can trust documentation
  • Stringing sentences is hard work, especially when you want to make them easy to read, understand and interesting to follow.
  • It’s hard to connect code samples with documentation
  • If I describe too many details, readers will be bored. If I omit too many, they will be confused. There is no way to know which level of detail is good.

On the reading side, it’s a waste of time:

  • I need to solve a problem, I don’t have time to search in a huge dump of text
  • If the author doesn’t trust the documentation, how can I?
  • It will contain too many details that I already know and omit too many facts that I need to understand what is going on.

The core of the issue is that documentation and code are two different things. Documentation is, by nature, abstract. It’s at least one step removed from the solution.

Does it have to be that way?

I hope, with new technologies like Xtext or JetBrains’ Meta Programming System, we will eventually be able to turn documentation into code.

So instead of writing hundreds of lines of code to open a window, give it a size, make sure it remembers its size and position, etc., we could write:

Allow the user to edit a Customer object which has properties from foaf:Person and one or more addresses.

Users can search for Customer objects by any of the name fields.

Note that the links are part of the documentation and the code; the underlying code generator should follow them and examine the code/documentation on the other side.

Related Articles:


Better Maven Deploy

9. October, 2012

mvn deploy has two major issues:

  1. If the project has several modules and the build fails in the middle, you will end up with a repository that is a mix of old and new modules.
  2. The POM must have the correct values in the distributionManagement element.

The former can break builds for your colleagues, the latter means you have to edit the POM file. Not a big deal – unless the POM file comes from an external source, say, an OSS project. If you edit it, you need to maintain the changes. But it gets ugly when your changes are committed to the external project.

The following script solves both problems. In a nutshell, it copies the POM, removes any existing distributionManagement elements, adds the ones you want and then builds using the new, temporary POM. If the build succeeds, the temporary POM is deleted.

The build itself is split into two steps. The first step does a local build, the second build skips tests and only uploads the results. It does run the compilers again but since the code was already built a few seconds ago, this shouldn’t be an issue.

Shell script.


Enums With More Than One Name

8. October, 2012

In Java, you sometimes encounter places where you need an enum with more than one name (or key). Here is the pattern that I use:

import java.util.HashMap;
import java.util.Map;

enum X {
    // "A" is the name of the enum, "a" is the second name/key.
    A("a"), B("b");

    private final static Map<String,X> MAP = new HashMap<String,X>();
    static {
        for( X elem: X.values() ) {
            if( null != MAP.put( elem.getValue(), elem ) ) {
                throw new IllegalArgumentException( "Duplicate value " + elem.getValue() );
            }
        }
    }

    private final String value;

    private X(String value) { this.value = value; }
    public String getValue() { return value; }

    // You may want to throw an error here if the map doesn't contain the key
    public static X byValue( String value ) { return MAP.get( value ); } 
}

Things to note:

  1. There are additional parameters in () after the enum name.
  2. You need a custom constructor which accepts the additional parameters. Like other Java classes, you can have as many constructors as you need.
  3. I’m filling the static map from a static block inside of the enum declaration. Looks odd but works. Java will first create all instances and then invoke the static code in my custom enum.
  4. You can look up enum values by using the static method byValue(). The name is not very good (it’s easy to get confused with enum‘s valueOf()). When the field is called code, I use byCode(). So in real life, it will be less confusing.