문제

I am writing an API and have come across the following pattern:

My API will force the client user in what he/she writes. The code must test x number of sites on a portal by logging in/out with different credentials. I cannot rely on chance that another developer will write his/her own login code (and this is going to be common code) so I have written an abstract class with a private constructor to implement the logging in and out methods, and the main test method (which the user will have to override to fill in0.

I have not seen an API which imposes restrictions like this but then this is an API for the team.

Am I on the right track with this?

도움이 되었습니까?

해결책

This is the point of encapsulation. You as a developer decide what to hide before other programmers and which methods they are able to call. I see you just want to make sure this is a good decision, well, it is, it is one of the core concepts of OOP.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top