The fancy term for what you're dealing with is temporal coupling.
My approach is to use types to enforce dependencies. Are there other ways?
There are many ways to do that.
Methods that mask their dependency on object state or global variables often cause this problem. The solution is to make those dependencies explicit.
For example you might have
and the only hint that they must be called in order is their names. This is less that ideal since that's not enforced and leaves us stuck with names that are not very descriptive.
One way to make their dependencies explicit is to take the state they require as arguments.
This makes it impossible to call them out of order. This works inside objects and in functional languages.
For an object oriented API that will be accessed from outside you can use what's most properly called a internal Domain Specific Language (iDSL). This should not be confused with other fluent interfaces that allow calling methods in any order by returning
this. iDSLs, such as Java 8 streams and JOOQ, return an intermediate object that dictates what methods are now legal to be called. This is what you're hinting at when you talk about controlling call order with types.
Returning the intermediate type and
this can be mixed to form a complex language full of both required and optional steps. But if you're in a language that offers named parameters with default arguments this might seem needless. Almost like it's a lot of fuss to get around a language limitation.