Community
Participate
Working Groups
Consider this code: ArrayList allKinds = new TestKindRegistry(point).getAllKinds(); assertEquals("id3", ((TestKind) allKinds.get(0)).getId()); assertEquals("id1", ((TestKind) allKinds.get(1)).getId()); assertEquals("id2", ((TestKind) allKinds.get(2)).getId()); It would be really useful if extracting a method from the first line would offer a method that was parameterized on a String, an ArrayList, and an int, with two duplications to replace, resulting in ArrayList allKinds = new TestKindRegistry(point).getAllKinds(); assertHasId("id3", allKinds, 0); assertHasId("id1", allKinds, 1); assertHasId("id2", allKinds, 2);
Postponing > 3.2
> It would be really useful if extracting a method from the first line [..] Not from the first line, but from: assertEquals("id3", ((TestKind) allKinds.get(0)).getId()); , extract method: void assertHasId(String id, ArrayList allKinds, int i) { assertEquals(id, ((TestKind) allKinds.get(i)).getId()); }
This seems related to bug 183189.