13

There are lots of other APIs I need to use besides the Selenium test tool to be able to get tests working. Not using them for just one week and the mind has lost all of them.

How is it possible to remember zillions of APIs?

7
  • 15
    I just forget them all and Google the API documentation when I need :)
    – Vitor Py
    Jul 12, 2011 at 17:03
  • really, but does not it increase the time by which you could finish coding :-/
    – Tarun
    Jul 12, 2011 at 17:08
  • 1
    Trying to memorize thousands of functions from many libraries will likely waste far more time than simply looking up an API when you need it. Jul 12, 2011 at 17:13
  • okies I see your point
    – Tarun
    Jul 12, 2011 at 17:15
  • Maybe this question might also help you: programmers.stackexchange.com/questions/140423/… Mar 26, 2012 at 15:09

8 Answers 8

36

You don't have to memorize a zillion functions. You just have to know how to look stuff up in the API documentation.

5
  • 1
    "how to look stuff up in the API", I need to learn this magic :)
    – Tarun
    Jul 12, 2011 at 17:09
  • 6
    First step is to find the damned documentation. Not easy at all for some APIs. Jul 12, 2011 at 17:11
  • 1
    @edA-qa: If all else fails, check the source code. If there's not only no documentation but there's no source code available, not even header files for the languages that use them... well, it might be time to switch to a different language.
    – JAB
    Jul 12, 2011 at 19:55
  • 1
    +1 I've been using some APIs for over 25 years, like the C printf() format syntax, and still have to look up the occasional weird detail on them.
    – Bob Murphy
    Jul 12, 2011 at 23:56
  • 1
    You indeed don't have to memorize them, but when you work with an API a lot, you will automatically remember how to use it. Also, IDEs ofcourse help a lot with auto-complete etc.
    – Jesper
    Jul 13, 2011 at 9:15
10

I am a lazy .NET developer and tend not to remember most APIs. I just use Intellisense to guide me. :-) This is why I can't understand how people code in dynamic languages. How do you live without Intellisense?!

6
  • 8
    Dynamic languages had graphical IDEs with IntelliSense long before static languages even had IDEs. Or graphics. Or any of the current mainstream static languages even existed. Jul 12, 2011 at 16:40
  • 1
    @Jörg: true, but code completion for dynamic languages will never work as well as for static languages. When you're looking at a variable in a Java project, then you can determine with 100% certainty what methods you can call on that variable, and what the return types will be. With Objective-C: almost, but not quite. JavaScript or Perl: forget it. Jul 12, 2011 at 16:55
  • No wonder I never stepped in to js or perl, just kidding
    – Tarun
    Jul 12, 2011 at 17:12
  • 2
    We pick languages that are simple and clearly documented. In the python world, it seems the adoption of code is commensurate with the quality of its documentation. Jul 12, 2011 at 17:14
  • 1
    @Mike Baranczak: You ask your run-time what is applicable, surely? I mean, it's not as if you'd be writing code without having a full REPL integrated into your dev environment anyway.
    – Vatine
    Jul 12, 2011 at 17:19
3

Keeping the documentation (e.g. MSDN) open while using it and extended use (i.e. Practice) tends to force the API the memory in.

For example, I wrote a lot of jQuery daily at the start of the year and could remember a lot of detail from the API. I've not worked with it a lot recently, so I don't remember as much as I did, but if I used it for a few days, it would come back to me.

There is no super-human knack, it's just repetition.

2
  • I was also thinking that if I keep using them then I would remember them
    – Tarun
    Jul 12, 2011 at 17:10
  • "Keeping the documentation (e.g. MSDN) open" -- this is where multiple screens come in handy -- I like to have an IDE open in the screen in front of me, and the documentation open in the screen to its right.
    – tcrosley
    Jul 12, 2011 at 18:21
2

If its not a particularly complex API, you may not have to remember all of it. I often skim reference manuals before programming with a particular API, and as I'm programming I'll remember a particular method name that sounds like it'd do what I want to accomplish. Then I'll look up that method name in the documentation to verify it does what I want.

This isn't the best technique. Hopefully if there is a better way to do something than the API bit you remembered, the documentation will mention it. But not always. As you practice this technique, you become more likely to form optimal solutions from the tidbits you remember.

1
  • This is what I do as well. I remember what it can do but look it up when I need to know how. Jul 12, 2011 at 21:43
2

A good developer can code using a framework, remembering a vast amount of the members. A great developer knows how to use documentation and resources.

These days the resources are endless. And literally at the click of a button, you can find exactly what you are looking for.

1

I don't think there's any easy way to learn a new API of any sorts. Some APIs are clearly named and easy to learn while others are complex or just plainly badly written.

I usually hunt the documentation for a given functionality that might help me solve an issue. When I'm done reading, I reflect on the newfound knowledge and eventually write a test if I'm unsure of what side-effects a call might have, while letting me try out the API.

0

Hoogle to search the API docs! (very specific to Haskell)

Now, suppose I'm doing a map on a list, but I don't want everything to map to something. I can say, the type of a function that does this would be

[a] -> (a -> Maybe b) -> [b]

I type this in to Hoogle to get:

mapMaybe :: (a -> Maybe b) -> [a] -> [b]

Okay, so I reversed the arguments. But I found the function based on typing it, which is often more useful than searching the entire index for a function that looks like it would do what I want.

I can then click on the link to get to the documentation to make sure it does what I need:

The mapMaybe function is a version of map which can throw out elements. In particular, the functional argument returns something of type Maybe b. If this is Nothing, no element is added on to the result list. If it just Just b, then b is included in the result list.

Of course, searching docs by index and by module is another good way to figure out the API without memorization.

0

In the specific case of Java, which has been linked to here from another question, the answer is simple: Do not bother memorizing the APIs. Why? Java SE has 3977 classes!

The Topmost / Leftmost / Most easy to reach bookmark on you web browser should be to the Java API docs, e.g. like this They are very thorough and, in most cases, well written. Between this and your IDE you can do most everything.

I am now learning node.js and Mongo, and have similar links to the node and mongoDB documentation, which isn't as nice but is still way better than nothing.

Not the answer you're looking for? Browse other questions tagged or ask your own question.