I have a requirement where we call another system and have to prepare the corresponding request from our request.
Let us call classes - OurRequest, DownstreamCallRequest, DownstreamRequestAdapter
DownstreadmRequestAdapter has a method : public DownstreamRequest adapt(OurRequest ourRequest) signature.
I don't have any state variables in the Adapter class.
What will be a better OO design?
1. To have the adapter class with 'static' method - public static DownstreamRequest adapt(OurRequest ourRequest)
2. To have the adapter class with an instance adapt method but no state variables in the class
Concerns with static methods are different from concerns with static variables so there's really no comparison to be made here; it's apples vs oranges in this case, IMO, as long as no state is kept either way. I imagine you'd end up using a single instance to handle all requests anyway so that's essentially the same as having the method as a class member rather than an instance member. The only real difference you'll have is whether you're calling the method via an instance or via the class itself, which to me seems like it's pretty much the same difference in this case.