How to design an interface, where things need to be called in a specific sequence?
Posted
by
Vorac
on Programmers
See other posts from Programmers
or by Vorac
Published on 2014-08-22T10:32:44Z
Indexed on
2014/08/22
16:35 UTC
Read the original article
Hit count: 171
c++
|interfaces
The task is to configure a piece of hardware within the device, according to some input specification. This should be achieved as follows:
1) Collect the configuration information. This can happen at different times and places. For example, module A and module B can both request (at different times) some resources from my module. Those 'resources' are actually what the configuration is.
2) After it is clear that no more requests are going to be realized, a startup command, giving a summary of the requested resources, needs to be sent to the hardware.
3) Only after that, can (and must) detailed configuration of said resources be done.
4) Also, only after 2), can (and must) routing of selected resources to the declared callers be done.
A common cause for bugs, even for me, who wrote the thing, is mistaking this order. What naming conventions, designs or mechanisms can I employ to make the interface usable by someone who sees the code for the first time?
© Programmers or respective owner