Test of Microformatter
Posted in Uncategorized on December 12th, 2008 by Alan Hietala – Be the first to commentthis is a test of our awesome office
this is a test of our awesome office
I’ve been dealing with some API’s lately some better designed than others. One thing struck me while I was coding away. wouldn’t it be neat if your IDE could show you what methods were usable based on a set of preconditions for those methods?
Here is an example of what I mean. Method 1 requires nothing but the object to be initialized. method 2 requires authentication and therefore either the object to be initialized with the correct information or have an authentication property set. If these conditions aren’t met the intelisense would show the method as not having all of its preconditions met and you would know that something else needs to be filled out in order for your code to execute properly.
Granted, if the API is built properly an exception would be thrown that would let you know what was wrong, but alas not all code is created equal.
one good way would be to support this type of metadata in the comments much like how javadoc etc is generated. It could take the form of // pre:this.constructor(string, int)||this.someproperty = set
meaning that this method requires the constructor to have been called in its string, int overload, or that someproperty is set.
This would help big time in a compiled language as no compile would be necessary to catch oversights. It would also help with code genereation as a developer could simply select the precondition they want to fill out and have it show up in the code nicely.
This would also have a nice side effect of developers having incentive to write comments something that are often too few and too far between.