On 09.09.2008 13:01:54 Vincent Hennebert wrote: > Hi, > > (Still catching up with the commits of the past month...) > > I’d like to take this commit as an opportunity to launch the debate > about copy-pasting: > > > Date: Mon Jul 28 06:03:40 2008 > > New Revision: 680339 > <snip/> > > Modified: > > xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java > > URL: > > http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java?rev=680339&r1=680338&r2=680339&view=diff > > ============================================================================== > > --- > > xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java > > (original) > > +++ > > xmlgraphics/fop/branches/Temp_AreaTreeNewDesign/src/java/org/apache/fop/render/intermediate/IFRenderer.java > > Mon Jul 28 06:03:40 2008 > > @@ -361,9 +395,120 @@ > > > > /** [EMAIL PROTECTED] */ > > protected void renderBlockViewport(BlockViewport bv, List children) { > > + //Essentially the same code as in the super class but optimized > > for the IF > > More than 80% of the code of this method is completely identical to the > overridden method. Surely there’s a way to optimize it and avoid that > code duplication in the same time...
I've spent a lot of time in implementations of renderBlockViewport in the past. I've been able to make small improvements over time but I've never found a solution that fits all output formats so far. Without any major refactoring of the code anyway, which is basically what I'm doing in the branch right now. > I can’t think of any good reason for copy-pasting code. That > artificially increases the size of the codebase, that makes the code > more difficult to understand and much more tricky to maintain. As soon > as a change is made somewhere, you’re almost sure that at least one > duplicated part will be forgotten somewhere. Don't you think I know that copy/paste programming is bad? > There is already way too much code duplication in the present codebase. > Let’s avoid introducing even more duplication in new commits, shall we? I'm trying all the time. Please note: the branch is work in progress and once it's done many renderer implementations will get deprecated to lighten the maintainance burden. Eventually they'll get removed and the copy/paste problem goes away. Jeremias Maerki
