Re:Fixing under-engineered code vs. fixing over-engineered code
by LeifCarrotson on Thursday August 26, 2021 @02:16PM
(#28318510)
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:
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.
Re:Fixing under-engineered code vs. fixing over-engineered code
by drran on Thursday August 26, 2021 @02:54PM
(#28318983)
Foreground and background color should be moved out to avoid repetition, e.g. BUTTONG_FG, BUTTON_BG. All other parameters are different, so no repetition.
https://www.contactandcoil.com/automation/industrial-automat...
Copy and paste are great tools. Making all 6 buttons in a particular grid with the code:
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.