bj4947
bj4947

Reputation: 920

how to monitor if user is integrating my android library in correct flow?

I am thinking a way to monitor user's integration flow. I have an Android library which needed to be init first then users need to retrieve the instance of my library and call the api I provide to process some data. For example,

People ppl = new People();

ppl.init();

pp1.walk();

pp1.run();

there is an order of the api, user will have to call .init() first to initiate the relevant resources first so that the object ppl can process walk and run. Samething for .walk() and .run(), user has to call .walk() before .run().

What is the best practice to monitor if a consumer is using the library correctly? In other words, how do I know if they are really following the right order although I provide the details on integration guide?

I thought about adding some indicator in each method I provided and put them into the request sent to my server. For example, if I have index in walk() says 1 and index in run() says 2. When the request arrived at backend, I checked if the order of the index is 12 instead of 21. But what is the best practice of these? adding index seems not practical. Thanks.

Upvotes: 1

Views: 70

Answers (1)

zero298
zero298

Reputation: 26877

Throw an exception and indicate what has happened. If you're feeling generous, have your API try to recover state. Also make sure you have documentation for your API so that your users actually know proper usage.

What you're describing basically sounds like exceptions except more polite and obfuscated. Be direct and clear.

Exception: API not initialized

They'll google it or read your documentation and figure out what they did wrong.

Upvotes: 2

Related Questions