From: Sven R. <rei...@ma...> - 2002-12-04 16:33:07
|
Recently, Baptiste wrote that he was unhappy with the name of this method. I agree with him insofar as it is not clear at all from the name what this method is supposed to do. Inspecting the source code, it becomes clear that it does the following: It calls add three times, where the 2nd call is a keyed one (i.e., the object stores the range under some name). I don't see the advantage of combining these 3 calls into one. Thus, IMO the best way to deal with this name is to inline the method. We would have 3 method calls instead of one, but it becomes clearer what the code does. I would also rename the keyed version of SourceBuilder::add to something like addKeyed or addAndRemember. I would have gone ahead and done it, but I'd like to hear the reasons for introducing this method in the first place. Any comments? Sven. BTW, is there anybody on this list except for Baptiste and me? -- Sven Reichard Dept. of Math. Sci. University of Delaware rei...@ma... |
From: Baptiste L. <gai...@fr...> - 2002-12-04 21:20:14
|
----- Original Message ----- From: "Sven Reichard" <rei...@ma...> To: "CppTool Mailing List" <Cpp...@li...> Sent: Wednesday, December 04, 2002 5:32 PM Subject: [Cpptool-develop] SourceBuilder::add3 > Recently, Baptiste wrote that he was unhappy with the name of this method. > I agree with him insofar as it is not clear at all from the name what this > method is supposed to do. > > Inspecting the source code, it becomes clear that it does the following: > It calls add three times, where the 2nd call is a keyed one (i.e., the > object stores the range under some name). > > I don't see the advantage of combining these 3 calls into one. Thus, IMO > the best way to deal with this name is to inline the method. We would have > 3 method calls instead of one, but it becomes clearer what the code does. > I would also rename the keyed version of SourceBuilder::add to something > like addKeyed or addAndRemember. Lisibility of user code. Source code build that's way is already difficult to read, if we were to split simple statement on multiple lines, it would become near impossible. For instance (renaming add3 to addKeyingMid): builder_->addKeyingMid( " if ( ", "x", " > 3 )", "var1.3" ); builder_->add( " {" ); builder_->addKeyingMid( " int ", "x", " = ", "var2.1" ); builder_->addKeyingMid( "", "x", ",", "var2.4" ); builder_->addKeyingMid( "", "y", "=", "var3.1" ); builder_->addKeyingMid( "", "x", ";", "var2.2" ); builder_->addKeyingMid( " ", "y", ";", "var3.2" ); builder_->addKeyingMid( " ", "x", ";", "var2.3" ); builder_->add( " }" ); Is just a lot more readable and compact than: builder_->add( " if ( " ); builder_->addKeyed( "x", "var1.3" ); builder_->add( " > 3 )" ); builder_->add( " {" ); builder_->add( " int " ); builder_->addKeyed( "x", "var2.1" ); builder_->add( " = " ); builder_->addKeyed( "x", "var2.4" ); builder_->add( "," ); builder_->addKeyed( "y", "var3.1" ); builder_->add( "=" ); builder_->addKeyed( "x", "var2.2" ); builder_->add( ";" ); builder_->add( " " ); builder_->addKeyed( "y", "var3.2" ); builder_->add( ";" ); builder_->add( " " ); builder_->addKeyed( "x", "var2.3" ); builder_->add( ";" ); builder_->add( " }" ); A lot of C++ structure seems to be expressible in three parts when writing keyed text for test. This includes variable declarations, if/for/while/switch conditions, and some expressions. addKeyingMid() keeps the code compact and somewhat readable. I can't see Inlining as a solution. Renaming is the best solution I see for now; providing a similar facility in some other but practical form is another one. For now, I suggest to simply rename add(string, string) to addKeyed() and add3() to addKeyingMid(). Baptiste. > > I would have gone ahead and done it, but I'd like to hear the reasons for > introducing this method in the first place. > > Any comments? > > Sven. > > BTW, is there anybody on this list except for Baptiste and me? > > -- > Sven Reichard > Dept. of Math. Sci. > University of Delaware > rei...@ma... |
From: Ian D. <ia...@in...> - 2002-12-06 17:21:46
|
> BTW, is there anybody on this list except for Baptiste and me? I'm lurking. Hoping to learn before diving in. -- Ian |
From: Dakshinamurthy K <kd...@su...> - 2002-12-06 17:36:13
|
I am also lurking for the time being - too much work pressures. I hope to get in few weeks from now. Thanks and Regards KD -----Original Message----- From: cpp...@li... [mailto:cpp...@li...]On Behalf Of Ian Davis Sent: Friday, December 06, 2002 10:53 PM To: Cpp...@li... Subject: Re: [Cpptool-develop] SourceBuilder::add3 > BTW, is there anybody on this list except for Baptiste and me? I'm lurking. Hoping to learn before diving in. -- Ian ------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ Cpptool-develop mailing list Cpp...@li... https://lists.sourceforge.net/lists/listinfo/cpptool-develop |