I have a static method as following:
public static void writeArticle(TypeA typeA, TypeB typeB) {
AWriter writer = AFactory.getWriter("aWriter");
Article article = writer.newArticle();
/* PARAMETER WRITE START */
article.set("title", typeA.getTitle());
article.set("author", typeB.getName());
article.set("age", typeB.getAge());
// …
/* more set statments here */
writer.write(article);
}
Could this method cause a problem that the writer will write a value-mixed Article? That is, when 2 class (Class A and ClassB) instances calling this method, will Article get some of typeA values from ClassA and some from ClassB?
No. Why do you think the arguments from two different calls would get mixed up? There’s no reason to think they would.
If this is a multi-threaded program, you should ofcourse be careful with sharing objects between threads; if those objects have mutable state (member variables that can be changed) you should take care that two threads are not modifying the state at the same time.