|
Over-engineered code has a lot of coupling where incidental equivalence may have been misapplied as fundamental sameness. This was discussed here on one of my favorite PLC programming blogs: https://www.contactandcoil.com/automation/industrial-automat... Copy and paste are great tools. Making all 6 buttons in a particular grid with the code: grid.AddNewButton(1, 1, "Thing 1", Color.White, Color.Black, onClick1());
grid.AddNewButton(1, 2, "Thing 2", Color.White, Color.Black, onClick2());
grid.AddNewButton(1, 3, "Thing 3", Color.White, Color.Black, onClick3());
grid.AddNewButton(2, 1, "Thing 4", Color.White, Color.Black, onClick4());
grid.AddNewButton(2, 2, "Thing 5", Color.White, Color.Black, onClick5());
grid.AddNewButton(2, 3, "Thing 6", Color.White, Color.Black, onClick6());
keeps this incidental sameness in mind. Just looking at the above code causes programmers everywhere (myself included) to imagine ways in which the above could be done with a `for` loop, computing the row and column numbers from the index, using string concatenation for the labels, creating an array of onClick handlers and indexing into it... But that forces fundamental sameness where there may not be any; a little repetition doesn't hurt. |