API Design
I've been into programming for a very long time. I remember being intrigued by LOGO in 2nd grade. In middle school it was BASIC. However, it wasn't until recently that I went past script kiddie and on my way to serious programmer. I've been scouring the web and devouring books to find out more. One of the most importantant steps to moving beyond script kiddie-ism is writing (re)useable API's. One thing I just came across today was a good presentation on API design. It's a nice video with the slides just below it. ...
The presentation, which is mostly Java-centric, brings up some good points. One thing is naming conventions. Many people don't like to read the instructions. A well named method or class can make your API easier to use. Even if you are the only one using it, a good name can help you remember what something is or does a year after you wrote the code.
Another good point is to keep things as private as possible. Sure, it feels easy to work with classes that have public properties but it can make things more complicated. An object should know if and when any of its properties change so that it can take appropriate actions to its own state. If some other object changes the properties of an object without it knowing, the object's state may not reflect the change properly. This welcomes hard to debug errors into your workday. You also have to remember that things change. A property may not change an objects state beyond itself now, but in the future it may have to do more. In actionscript the use of get and set functions can help you mitigate past errors and ease refactoring but many languages don't have this option.
A final aspect that lets you leave script kiddiedom behind is documentation. Document religiously. This is so important. Once again, even if you are the only person using your code it will help you figure out what you were originally doing a year ago when you wrote it.
For a more indepth analysis of API design at many different levels, as well as much more, a great reference is Code Complete by Steve McConnell. It has a wealth of knowledge on how to make your code better. I've learned so much from this book and may be doing a review soon.
----
Daryl "Deacon" Ducharme is currently "Code Czar" for the Interactive Agency Provis Media Group, LLC which helps organizations enhance identity, connect with customers and increase productivity.