Archive

Posts Tagged ‘idea’

Easy, Simple, Wrong

December 17th, 2009

<rant>
Hey everyone, you can’t simplify indefinitely so stop trying so square the circle!

I’m not saying stop trying to simplify things, just stop once there’s a minimal and acceptable level of complexity. If you dumb it down too much, it’s plain wrong.

Once you’ve reached that point, either you leave well enough alone, or add to it by organizing things. More often than not organizing will actually degrade runtime performance but will decrease development time. If you’re not happy with that, maybe development isn’t for you. You’re likely going to prefer messes and will spend too much time shifting crap around instead than dealing with it.
</rant>

Sorry about that. :)

General, Ideas, Programming, Rants ,

Documentation Metrics

December 8th, 2009

I recently had a telephone conversation regarding documentation practices that planted a seed. I’m pretty sure this isn’t a new idea, how could it be, but it’s something that I’ve never seen explicitly stated.

I’m a big fan of static analysis and code metrics in general. The reason I’m a fan is that there’s something in my constitution that likes to see improvement over time. If I think a number correlates strongly enough with software quality, I’ll enjoy seeing that number improve. It’s soothing to me.

What I haven’t seen around is a metric that can be used to measure the quality of a software library’s documentation. Without such a metric, any investment in time towards improving its documentation will never be a sexy thing for me to work on, and I’m probably not alone in these feelings, since most projects have terrible documentation.

I think the # 1 most important thing to measure about a library’s documentation is its web analytics.

Here’s my train of thought: Ultimately documentation is about connecting users to answers. If your page is a promising candidate for solving their problem, then it should receive more quality visits. Anything you do that increases the number and/or quality of those visits is a step in the right direction. If you attempt to game the search engines, it would negatively affect the quantity of hits you’re documentation gets since search engines already take these kinds of things into account.

I’m not exactly sure how the metric will be computed but I’m absolutely sure it’d involve hits, duration of visits and bounce back rate.

I’m imagining a 3rd party documentation analytics embed code that can be used freely on open source projects and that can display on each documentation page a measurement of its “quality” and how its trended over time. It’d allow you to compare two equivalent projects’ documentation, and more importantly tell how much effort is being spent on a projects documentation.

Wouldn’t that be nice? So many open questions. What do you think?

Programming , ,

Neural Networks for Business Analysis

August 5th, 2009

First let me say that this idea isn’t quite flushed out yet, but it’s one that I hope you’ll find interesting.

First off, a little about what neural networks do:

1. They are approximate mappings from a set of inputs to a set of outputs
2. They can be trained with real world data
3. They handle fuzzy inputs pretty well

When you’re applying Neural Networks to a problem, you need to state the problem as a mapping.

For example, if I were trying to predict profitability of a factory, I’d decide on some things to measure about the factory and then relate those to its known profitability.

So for example, I might choose to measure # of employees, avg throughput per month, min throughput per work day, utilization, etc. and relate those things to the profitability of the factory as a measure between 0 and 1.

Now, one interesting thing about this is that some problems with my choices of measurements will become apparent during the training process.

If no matter how many samples I give it to train on or how many neurons the network has, it never seems to be any good at predicting profitability, then it means the things I’ve chosen to measure don’t matter.

If instead of wisely choosing things to measure, I’ve just measured every possible aspect of the factory, I’ll likely get something that predicts profitability, but that takes eons to train. Given that situation, I could start culling measurements and retraining, if the results don’t get worse and it takes less time to train it, then I can safely say that that particular measurement isn’t essential to the prediction (Think # of vending machines in the cafeteria). Repeating the process should lead to the minimum essential measurements and is essentially an automated form of Occam’s razor.

It is possible that no matter how hard I try, the thing won’t train. There might be no relation between inputs and outputs, though I think that for most problems the human beings chosing what to measure would rarely pick measurements that didn’t matter.

Anyway, like I said, this isn’t a finished thought, but i’m curious to know what other think about this approach.

General , ,

PHP Encapsulation Done Better

February 23rd, 2009

Encapsulation is great; it hides complexity and makes systems easier to maintain. With that in mind most developers thumb their noses at the idea of exposing internal state via public access modifiers.

What I’m proposing is that a PHP OO design is different than a full hog Java one, and that by using magic methods wisely, you can start off with a very simple public property based design, and then as requirements become more complex, refactor in the encapsulation using magic methods when required.

To illustrate the ideas take a look at the code below:

class Person {
  public $firstName;
  public $lastName;
 
  public function __construct($firstName, $lastName) {
    $this->firstName = $firstName;
    $this->lastName = $lastName;
  }
}
// Usage
$person1 = new Person('Allain', 'Lalonde');
echo $person1->firstName . ' ' . $person2->lastName;

Most developers consider the code above so bad that they’d willingly inflict the following torture on themselves:

class Person {
  private $_firstName;
  private $_lastName;
 
  public function __construct($firstName, $lastName) {
    $this->_firstName = $firstName;
    $this->_lastName = $lastName;
  }
 
  public function getFirstName() {
    return $this->_firstName;
  }
 
  public function getLastName() {
    return $this->_lastName;
  }
 
  public function setFirstName($firstName) {
    $this->_firstName = $firstName;
  }
 
  public function setLastName($lastName) {
    $this->_lastName = $lastName;
  }
}
 
// Usage
$person = new Person('Allain', 'Lalonde');
echo $person->getFirstName() . ' ' . $person->getLastName();

If you’re from a Java background, you might prefer the second version. It “feels” safer. You can change the implementation without breaking the code that uses the class.

Thing is though, using magic methods, you can encapsulate public fields.

As an exampke, say that you want to change the first piece of code so that the Person class is immutable (once an instance is created, it cannot change). You could refactor it as follows:

class Person {
  private $_firstName;
  private $_lastName;
 
  public function __construct($firstName, $lastName) {
    $this->_firstName = $firstName;
    $this->_lastName = $lastName;
  }
 
  public function __get($fieldName) {
    switch ($fieldName) {
      case "firstName":
        return $this->;_firstName;
      case "lastName":
        return $this->_lastName;
      default:
        throw new Exception("Attempted to access invalid property: ".$fieldName);
    }
  }
}
 
// Usage
$person1 = new Person('Allain', 'Lalonde');
echo $person1->firstName . ' ' . $person2->lastName;

The counter argument is that magic methods are considered slow, but I’ll argue that in most designs the use of this pattern would be minimal, and accessing a public property is faster than invoking a method. So it’ll probably be faster on average than invoking getters and setters for every property.

Now, I hope you followed my logic to now. And I’d love to hear your thoughts.

My 2 cents

PHP, Programming , , ,

Social Network for Personal Development Idea

February 3rd, 2009

Just had an idea for a Social Network dedicated to self improvement through group improvement.

I’m imagining a site where members announce their goals publicly and the system matches them up with other members with the similar goals.

Also, depending on the goal, it displays appropriate graphs showing the user’s progression.

The reason I think this has merit: people tend to keep goals they share publicly.

Now, the system could make your declaration public (as in your co-workers could find them), or public in that only other members with similar goals can see them.  I’m not sure exactly how I want it to work yet.

Just some first thoughts…

Ideas, Social Networking ,