If you don't clone in Java then what do you do and what do you call it?
java, oop
Solution
Effective Java recommends either of the following:
A copy constructor (as noted by others):
public Item(Item item)
A copy factory method:
public static Item newInstance(Item item)
(Also, no copying for immutables)
The primary difference is that with #1 you choose the actual class of the result, and with #2 the implementer can return a subclass. The semantics of the class may guide you into which one is best.
Problem
Does anyone have any suggested or established best practices and naming conventions for copy constructors / factory methods etc in Java? In particular, say I have a class `Thing` and I want a method somewhere that returns a new `Thing` with the same value as a `Thing` passed in (or as the instance if it's an instance method). Would you have this as constructor or a static factory method or instance method? What would you call it? As per the title, I want to avoid `clone()` and `Cloneable`.