由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Java版 - what is really hard is testing
相关主题
啥时候java spring framework也成了legacy framework了[ZT] choose your java xml parser
在AWS如何作测试eclipse 不认 namespace 吗? (转载)
有没有人熟悉tomcat?急!请教namespace到底应该有最后那个/不?
eclipse的jetty服务started但8080口显示404 errorRe: component之间怎样送消息?
Spring + Jersey 的 REST API, servlet context 能看到 Spring (转载)What are the key features of the EJB technology?
how to update swing componentsHow does a client find and connect to a specific
@goodbug: Wicket vs JSFRe: how to display text above component
jmock ?? or any other mocking tools?what does lightweighted mean?
相关话题的讨论汇总
话题: global话题: component话题: like话题: namespace
进入Java版参与讨论
1 (共1页)
c******n
发帖数: 4965
1
recently went through a lot of spring code testing, using mocks and in-mem
h2 db.
spring is kind of a mess, u declare a @component, and then it becomes global
accessible to everyone. as u accumulate more and more library dependencies,
all those @component (or those beans declared in the contexts) become like
trash to you, it's almost like the global variables in C coding days
w**z
发帖数: 8232
2
DI is useful , but sometimes it is a bit messy, hard to know what is going
on. I have seen big applicationcontext.XML with hundreds of lines, bit
painful going through it.

global
dependencies,
like

【在 c******n 的大作中提到】
: recently went through a lot of spring code testing, using mocks and in-mem
: h2 db.
: spring is kind of a mess, u declare a @component, and then it becomes global
: accessible to everyone. as u accumulate more and more library dependencies,
: all those @component (or those beans declared in the contexts) become like
: trash to you, it's almost like the global variables in C coding days

g*****g
发帖数: 34805
3
I don't quite understand your complaint. It wasn't like the alternative is
easier to test. @Component is like a global service that has namespace, that
's much different from global variables. With mockito you can inject mock
dependencies for unit test.

global
dependencies,
like

【在 c******n 的大作中提到】
: recently went through a lot of spring code testing, using mocks and in-mem
: h2 db.
: spring is kind of a mess, u declare a @component, and then it becomes global
: accessible to everyone. as u accumulate more and more library dependencies,
: all those @component (or those beans declared in the contexts) become like
: trash to you, it's almost like the global variables in C coding days

c******n
发帖数: 4965
4
--- "@Component is like a global service that has namespace"
what is the namespace ?
if in 2 libraries, written by 2 people, both mark
@Component
public class AuthorA implements SomeInterface {
}
@Component
public class AuthorB implements SomeInterface {
}
now in my application code, I just want to grab an "author", and do
public class MyTestSuite {
@Autowired
SomeInterface blah;
...
}
here since AuthorA and AuthorB are both discovered as "@Component", they are
like global variables, and makes my test fail to resolve the auto-wire of
SomeInterface. well my complaint is not really about tests only, just that
I found these issues during tests. my point was more "it's difficult to
provide a set of tests that prove that your code works given this huge
global context containing everyone's trash beans "

that

【在 g*****g 的大作中提到】
: I don't quite understand your complaint. It wasn't like the alternative is
: easier to test. @Component is like a global service that has namespace, that
: 's much different from global variables. With mockito you can inject mock
: dependencies for unit test.
:
: global
: dependencies,
: like

g*****g
发帖数: 34805
5
The namespace is the classname, which is global unique.
An interface implemented by two classes, while commonly seen, is not gonna
be the majority of your beans. And you can always use @Qualifier

【在 c******n 的大作中提到】
: --- "@Component is like a global service that has namespace"
: what is the namespace ?
: if in 2 libraries, written by 2 people, both mark
: @Component
: public class AuthorA implements SomeInterface {
: }
: @Component
: public class AuthorB implements SomeInterface {
: }
: now in my application code, I just want to grab an "author", and do

c******n
发帖数: 4965
6
that is not a proper namespace, it's exactly the same false argument that u
can make global vars work by giving them "unique" names

【在 g*****g 的大作中提到】
: The namespace is the classname, which is global unique.
: An interface implemented by two classes, while commonly seen, is not gonna
: be the majority of your beans. And you can always use @Qualifier

g*****g
发帖数: 34805
7
It's global service, not global variable. I don't think OOP is against
global service. And as I said, @Qualifier can solve your problem.

u

【在 c******n 的大作中提到】
: that is not a proper namespace, it's exactly the same false argument that u
: can make global vars work by giving them "unique" names

1 (共1页)
进入Java版参与讨论
相关主题
what does lightweighted mean?Spring + Jersey 的 REST API, servlet context 能看到 Spring (转载)
SCEA 1.4 beta exam (Free)how to update swing components
anyone use org.gxos package?@goodbug: Wicket vs JSF
Help! About Weblogicjmock ?? or any other mocking tools?
啥时候java spring framework也成了legacy framework了[ZT] choose your java xml parser
在AWS如何作测试eclipse 不认 namespace 吗? (转载)
有没有人熟悉tomcat?急!请教namespace到底应该有最后那个/不?
eclipse的jetty服务started但8080口显示404 errorRe: component之间怎样送消息?
相关话题的讨论汇总
话题: global话题: component话题: like话题: namespace