So this is how APIs get so messy?
Now I find that I need to organize the functions and objects into logical groups. And i have to find a good presentation for the API. I really don't like the outline format.
I can see that the bigger the code gets, the more messy it can be. So, I know I need a good naming convention from the beginning, and that is why I have been posting lately about my habits and alternate naming conventions and data structures.
Question:
What would be YOUR ideal way of navigating an API? How would you present your documentation?
Most used functions/variables at the top?
You like the outline format?
Table format sounds good?
How could I make the associations between functions or variables clearer?
They call me the Tutorial Doctor.
Starting to understand why APIs get so messy. I am creating what I call a "Senses System" (in my journal), and I want the functions and variables to be easy to use. So I have to choose common sense names, and I have to make the use of the functions common sense also.
Now I find that I need to organize the functions and objects into logical groups. And i have to find a good presentation for the API. I really don't like the outline format.
I can see that the bigger the code gets, the more messy it can be. So, I know I need a good naming convention from the beginning, and that is why I have been posting lately about my habits and alternate naming conventions and data structures.
Question:
What would be YOUR ideal way of navigating an API? How would you present your documentation?
Most used functions/variables at the top?
You like the outline format?
Table format sounds good?
How could I make the associations between functions or variables clearer?
I like how the documentation for SFML is laid out in modules, classes, and files. If you don't like HTML much, the precompiled Windows binaries bundle a nice .CHM with a navigation outline. The SFML documentation was made with Doxygen. And yes, it has tables where it makes sense.
While presentation is very important, it won't save a poorly designed API. In my view, it will usually take a number of iterations, and a lot of refactoring, before an API becomes really elegant and intuitive. Good design is the end product of an evolutionary process; it is not at all unusual for the first iterations to be messy. So, don't be afraid to refactor, tinker, experiment, and improve.
Any documentation is better than none. That being said there are a couple things I hate when reading documentation.
The only time documentation is worse then no documentation is when you simply run an auto document tool that gives no more information then intellisense would give, It's incredibly useless and wastes everyone's time.
That being said, I prefer documentation that details the API in a way that shows the user the way it was designed to be used. A list of namespaces/classes is useful only if you already know which class/namespace you are supposed to be looking into.. this is a good way to start your documentation (all the relevant information will exist), but then if you really want to create happy users, make a second pass explaining how to utilize your API with minimal set-up requirements with links on customizing behavior where appropriate.
Just remember that there are two types or people reading your documentation, the person that has never used your api before and the people who are trying to push the limits of your api.
You are right paragon about it being good to explain the way the API was intended to be used.
I have tried several times to use Unity, and every time I get overwhelmed by the API. I have found the engine I like to use for now though, but maybe I will go back to Unity. With the current API I use, the functions make sense, and are easy to understand. I can gain experience using APIs in general this way, and perhaps I will look towards more complicated (if that is just the case with Unity) APIs in the future.
But yeah, I dislike it when an API has no documentation at all. I've learned some good habits and naming conventions from the API I use though.
Right now I am making a bunch of small and useful functions to add functionality to a project that will be sort of a template anyone can use to start a game in the engine. It comes with a collection of models, sounds, fonts, and scripts, and I want it to be easy to use.
It turns out that what I am actually creating is a sort of library, and I have not done this before.
I am going to check out those links georger, to get some ideas on how to lay out the modules and classes. Thanks.
Any more tips would really help.
They call me the Tutorial Doctor.
Which API? Personally I found most APIs I worked relatively well designed, of course you have to consider the historical constraints but in general, I'm fine with them.
Starting to understand why APIs get so messy.
Previously "Krohm"
So, tinker and explain? Great tips.
You are right paragon about it being good to explain the way the API was intended to be used.
I have tried several times to use Unity, and every time I get overwhelmed by the API. I have found the engine I like to use for now though, but maybe I will go back to Unity. With the current API I use, the functions make sense, and are easy to understand. I can gain experience using APIs in general this way, and perhaps I will look towards more complicated (if that is just the case with Unity) APIs in the future.
But yeah, I dislike it when an API has no documentation at all. I've learned some good habits and naming conventions from the API I use though.
Right now I am making a bunch of small and useful functions to add functionality to a project that will be sort of a template anyone can use to start a game in the engine. It comes with a collection of models, sounds, fonts, and scripts, and I want it to be easy to use.
It turns out that what I am actually creating is a sort of library, and I have not done this before.
I am going to check out those links georger, to get some ideas on how to lay out the modules and classes. Thanks.
Any more tips would really help.
Once your API has stabilized into something useable, write a "hello world" kind of sample for it to go along with the documentation, to help users get familiar with the general flow of your library. Assuming your API warrants something like this, of course, if it is trivially easy then who cares (but then, the author usually isn't the best judge of that).
Make sure to use your API yourself in nontrivial applications, this is colloquially referred to as the "dog food test" in software development and means that the author of the library actually uses his or her own product for themselves, and tends to be a good indicator of software quality (for obvious reasons). If you don't like to use your API, that doesn't inspire other people to.
Do not try and perfect your API too much, in my experience there is a point where you stop improving the API and start overdoing it without even realizing it, so stop "tinkering with it" once you start finding yourself making silly, trivial modifications. It is tempting to make it as perfect as possible, but it doesn't pay off, you can't please everyone, and people are not stupid, they will understand how to work with your API even if it isn't immaculate.
“If I understand the standard right it is legal and safe to do this but the resulting value could be anything.”
Which API? Personally I found most APIs I worked relatively well designed, of course you have to consider the historical constraints but in general, I'm fine with them.
Starting to understand why APIs get so messy.
Well, as far as game development goes, I don't really like how scattered the Unity3D API is. And the naming conventions aren't that easy to pick up for beginners like me (like me).
The API I am using now is great, and easier to use. Now, Unity does have more functionality, so I understand why it is larger, but the names don't mesh, so when I am trying to do even a simple task, I have to go link by link to find what it is I want to do. An API can be large and still easily understood.
They call me the Tutorial Doctor.
Once your API has stabilized into something useable, write a "hello world" kind of sample for it to go along with the documentation, to help users get familiar with the general flow of your library. Assuming your API warrants something like this, of course, if it is trivially easy then who cares (but then, the author usually isn't the best judge of that).
Make sure to use your API yourself in nontrivial applications, this is colloquially referred to as the "dog food test" in software development and means that the author of the library actually uses his or her own product for themselves, and tends to be a good indicator of software quality (for obvious reasons). If you don't like to use your API, that doesn't inspire other people to.
Do not try and perfect your API too much, in my experience there is a point where you stop improving the API and start overdoing it without even realizing it, so stop "tinkering with it" once you start finding yourself making silly, trivial modifications. It is tempting to make it as perfect as possible, but it doesn't pay off, you can't please everyone, and people are not stupid, they will understand how to work with your API even if it isn't immaculate.
Great tips Bacterius. I am actually making a demo project that uses the main functions of the API. This way people can see how the code can be used rather than having to look at little code snippets in an outline somewhere online.
You are right about me needing to be able to use my own API without hating it. And I will try not to tinker too much. hehe. I like to write my code for ease of use by others, and for my future self, just incase I want to look back on my own code sometime, and perhaps modify it a bit.
Thanks again. Great tips everyone.
They call me the Tutorial Doctor.