[英]How to prevent developers from use risky methods
I'm looking for a way to prevent developers from using some methods that are causing instability (Performance) issues for the site; 我正在寻找一种方法,以防止开发人员使用某些导致网站不稳定(性能)问题的方法。 for example, I have a method fetches the information from the database (eg
getData(String id)
), and another method fetches the information form the in-memory cache (eg getCachedData(String id)
). 例如,我有一个方法从数据库中获取信息(例如
getData(String id)
),另一个方法是从内存缓存中获取信息(例如getCachedData(String id)
)。 The getData(String id)
method is used in getCachedData(String id)
if and only if we have a cache-miss. 当且仅当我们有cache-miss时,才在
getCachedData(String id)
使用getData(String id)
方法。 How can I prevent developers from using getData(String id)
method? 如何防止开发人员使用
getData(String id)
方法? in other words, I need to force developers to use getCachedData(String id)
always. 换句话说,我需要强制开发人员始终使用
getCachedData(String id)
。
Please note that the access modifiers (private, protected, etc.), code design, or java docs are not
really preventing developers. 请注意,访问修饰符(私有,受保护等),代码设计或Java文档并
not
真正阻止开发人员。 Do we have a final solution for this issue? 我们是否有针对此问题的最终解决方案?
getData
would return getCachedData
. getData
将返回getCachedData
。 The interface is pretty unclear, there shouldn't be a method getCachedData
at all. 接口非常不清楚,根本不应该有方法
getCachedData
。 getData
returns either the cached data or newly-fetched data. getData
返回缓存的数据或新获取的数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.