Redian新闻
>
求教:Facade Pattern vs Static Variable
avatar
求教:Facade Pattern vs Static Variable# Java - 爪哇娇娃
G*l
1
请教在ACCESS query中, 如何count 每个有ID几个consecutive/continuous date for
each task?
JOB ID Date
TASK1 A 4/12/2009
TASK1 A 4/13/2009
TASK1 A 6/2/2009
TASK1 A 6/3/2009
TASK1 A 6/4/2009
TASK2 A 6/5/2009
TASK2 A 6/6/2009
TASK2 A 6/7/2009
TASK2 A 6/8/2009
TASK2 A 6/9/2009
TASK2
avatar
l*o
2
I am maintaining a legacy SDK. The SDK will behave differently for different
platform. It's using a static variable and requires the static variable to
be created before any API call like the following:
Example for static variable (OLD CODE):
SDKContext.init();
VideoManager manager = new VideoManager();
public void VideoManager#search() {
SDKContext.search();
}
Components like VideoManager are all over the place. My gut feeling tells me
I should use Facade pattern instead, but can't be sure.
Example for Facade (MY PREFERRED WAY):
SDKContext context = new SDKContext();
VideoManager manager = new VideoManager(context);
public void VideoManager#search() {
context.search();
}
What's the pros and cons of facade pattern vs creating all API using a
static variable and invoke it implicitly? Any recommendation/suggestion is
welcomed.
avatar
g*g
3
Depends on how heavy is SDKContext creation and whether it's thread safe to
share it. You may have different approach.
avatar
s*e
4
Maybe I misunderstood you. But I do not think this is the case for the
facade. I do not think you are coding a facade even you call it so.
Maybe what you really need is the factory method or abstract factory.
Usually a static variable can be coupled with the abstract factory.
相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。