mardi 22 novembre 2016

Progressive Disclosure in C++ API

Following my reading of the article Programmers Are People Too by Ken Arnold, I have been trying to implement the idea of progressive disclosure in a minimal C++ API, to understand how it could be done at a larger scale.

Do you know of any example I could take a look at?

I have found only one example on the web of such an implementation: the db4o library (in Java), but I do not really understand their strategy. For example, if we take a look at ObjectServer, it is declared as an interface, just like its extended class ExtObjectServer. Then an implementing ObjectServerImpl class, inheriting from both these interfaces is defined and all methods from both interfaces are implemented there.

This supposedly allows code such as:

public void test() throws IOException {
    final String user = "hohohi";
    final String password = "hohoho";
    ObjectServer server = clientServerFixture().server();
    server.grantAccess(user, password);

    ObjectContainer con = openClient(user, password);
    Assert.isNotNull(con);
    con.close();

    server.ext().revokeAccess(user); // How does this limit the scope to 
                                     // expert level methods only since it
                                     // inherits from ObjectServer?

    // ...
});

My knowledge of Java is not that good, but it seems my misunderstanding of how this work is at an higher level.

Thanks for your help!

Aucun commentaire:

Enregistrer un commentaire