<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	
	>
<channel>
	<title>
	Comments on: The Interface Principle in C++	</title>
	<atom:link href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Fri, 23 Mar 2018 14:00:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.3</generator>
	<item>
		<title>
		By: M Limber		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-879</link>

		<dc:creator><![CDATA[M Limber]]></dc:creator>
		<pubDate>Fri, 23 Mar 2018 14:00:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-879</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-344&quot;&gt;Alf P. Steinbach&lt;/a&gt;.

I prefer the &lt;code&gt;get&lt;/code&gt; prefix only for getters. For something like &lt;code&gt;getArea&lt;/code&gt; that is doing more than getting (even if cached), I prefer &lt;code&gt;calc&lt;/code&gt; as the prefix.

Some naming conventions use &lt;code&gt;void radius(float)&lt;/code&gt; and &lt;code&gt;float radius() const&lt;/code&gt; for setter/getter, others prepend &lt;code&gt;set&lt;/code&gt; and/or &lt;code&gt;get&lt;/code&gt;. This follows the guideline to make the code read like English: &lt;code&gt;car.setGear( Gear.Drive )&lt;/code&gt; means &quot;Hey, car, set your gear to Drive.&quot; vs. &lt;code&gt;car.gear( Gear.Drive )&lt;/code&gt; is a setter or a query or installing a new gear or something else?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-344">Alf P. Steinbach</a>.</p>
<p>I prefer the <code>get</code> prefix only for getters. For something like <code>getArea</code> that is doing more than getting (even if cached), I prefer <code>calc</code> as the prefix.</p>
<p>Some naming conventions use <code>void radius(float)</code> and <code>float radius() const</code> for setter/getter, others prepend <code>set</code> and/or <code>get</code>. This follows the guideline to make the code read like English: <code>car.setGear( Gear.Drive )</code> means &#8220;Hey, car, set your gear to Drive.&#8221; vs. <code>car.gear( Gear.Drive )</code> is a setter or a query or installing a new gear or something else?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: M Limber		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-876</link>

		<dc:creator><![CDATA[M Limber]]></dc:creator>
		<pubDate>Thu, 22 Mar 2018 16:47:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-876</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-362&quot;&gt;Jonathan Boccara&lt;/a&gt;.

I go back and forth on this idea for reasons like VK and Alf list. 

Tool support is not a trivial concern, and it&#039;s not obvious that the IDE experience could be as useful with free functions that are packaged with a class -- i.e., it&#039;s not just a problem right now and that the tools could catch up, but rather that the experience cannot be as good because they just don&#039;t know. 

Uniform call syntax could make this a little better because it would allow IDE-friendly lookup when calling &lt;code&gt;x.f()&lt;/code&gt;, but it still won&#039;t help if one wants to use the equally valid &lt;code&gt;f(x)&lt;/code&gt;. Maybe uniform call syntax means we start to prefer the former for this reason, among others?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-362">Jonathan Boccara</a>.</p>
<p>I go back and forth on this idea for reasons like VK and Alf list. </p>
<p>Tool support is not a trivial concern, and it&#8217;s not obvious that the IDE experience could be as useful with free functions that are packaged with a class &#8212; i.e., it&#8217;s not just a problem right now and that the tools could catch up, but rather that the experience cannot be as good because they just don&#8217;t know. </p>
<p>Uniform call syntax could make this a little better because it would allow IDE-friendly lookup when calling <code>x.f()</code>, but it still won&#8217;t help if one wants to use the equally valid <code>f(x)</code>. Maybe uniform call syntax means we start to prefer the former for this reason, among others?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Amir Shrestha		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-474</link>

		<dc:creator><![CDATA[Amir Shrestha]]></dc:creator>
		<pubDate>Tue, 08 Aug 2017 21:52:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-474</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-347&quot;&gt;VK&lt;/a&gt;.

I do agree with VK. Just to add more on his point 3, we should follow Interface Segregation Principle. However, putting all virtual methods in one interface is definitely not a good idea. We should try to separate them as much as possible. For example in the above class, we may  have following interfaces.

class IShape {
// generic methods pertinent to all types of shape object
virtual void getArea() = 0;
virtual void getPerimeter() = 0;
};

class ICircle {
virtual void getRadius() = 0;
// any other methods that is related to circle like objects
};]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-347">VK</a>.</p>
<p>I do agree with VK. Just to add more on his point 3, we should follow Interface Segregation Principle. However, putting all virtual methods in one interface is definitely not a good idea. We should try to separate them as much as possible. For example in the above class, we may  have following interfaces.</p>
<p>class IShape {<br />
// generic methods pertinent to all types of shape object<br />
virtual void getArea() = 0;<br />
virtual void getPerimeter() = 0;<br />
};</p>
<p>class ICircle {<br />
virtual void getRadius() = 0;<br />
// any other methods that is related to circle like objects<br />
};</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-362</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Sun, 25 Jun 2017 17:27:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-362</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-347&quot;&gt;VK&lt;/a&gt;.

Wow thanks Vlada for taking the time to express such a detailed opinion. I find your points valid and very interesting. What you&#039;re sharing makes for a much richer view on the whole topic.

Do we agree that the uniform syntax would solve most of the concerns you&#039;re raising on the Interface Principle?]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-347">VK</a>.</p>
<p>Wow thanks Vlada for taking the time to express such a detailed opinion. I find your points valid and very interesting. What you&#8217;re sharing makes for a much richer view on the whole topic.</p>
<p>Do we agree that the uniform syntax would solve most of the concerns you&#8217;re raising on the Interface Principle?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-361</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Sun, 25 Jun 2017 17:14:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-361</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-346&quot;&gt;Michael Kelley&lt;/a&gt;.

Yep you&#039;re right Michael, it&#039;s now fixed. Thanks!]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-346">Michael Kelley</a>.</p>
<p>Yep you&#8217;re right Michael, it&#8217;s now fixed. Thanks!</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Vadim Kalinsky		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-356</link>

		<dc:creator><![CDATA[Vadim Kalinsky]]></dc:creator>
		<pubDate>Sat, 24 Jun 2017 01:20:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-356</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-344&quot;&gt;Alf P. Steinbach&lt;/a&gt;.

I, personally, use &quot;get&quot; prefix to emphasize that the function/method really &quot;gets&quot; something, e.g. retrieves something from db, performs heavy calculations, etc etc. If it just returns private &quot;int radius&quot;, I just name it &quot;radius()&quot;]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-344">Alf P. Steinbach</a>.</p>
<p>I, personally, use &#8220;get&#8221; prefix to emphasize that the function/method really &#8220;gets&#8221; something, e.g. retrieves something from db, performs heavy calculations, etc etc. If it just returns private &#8220;int radius&#8221;, I just name it &#8220;radius()&#8221;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-349</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Thu, 22 Jun 2017 10:55:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-349</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-342&quot;&gt;Theldoria&lt;/a&gt;.

Thanks Theldoria, well spotted. This is now fixed.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-342">Theldoria</a>.</p>
<p>Thanks Theldoria, well spotted. This is now fixed.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Abinash Meher		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-348</link>

		<dc:creator><![CDATA[Abinash Meher]]></dc:creator>
		<pubDate>Wed, 21 Jun 2017 06:13:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-348</guid>

					<description><![CDATA[&#062; &#039;calls f(x, x1, ..., xn) if f is a method and not a free function. This...&#039;
Here did you mean &#039;if f is a free function and not a method&#039;?]]></description>
			<content:encoded><![CDATA[<p>&gt; &#8216;calls f(x, x1, &#8230;, xn) if f is a method and not a free function. This&#8230;&#8217;<br />
Here did you mean &#8216;if f is a free function and not a method&#8217;?</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: VK		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-347</link>

		<dc:creator><![CDATA[VK]]></dc:creator>
		<pubDate>Tue, 20 Jun 2017 21:37:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-347</guid>

					<description><![CDATA[I absolutely disagree. My three points against: 
1)
 Moving getPerimeter() and getArea() out of the public class methods 
makes these free functions hard to discover. As a programmer, assume you
 have an instance of Circle and you want to get its perimeter. What do 
you usually do? You type the name of the variable and then type . (or 
-&#062;) and wait what IDE autocompletion will suggest. You will get 
getRadius() so you will assume that there is no direct method for 
perimeter and you will open you high school math textbook and write the 
formula for calculating the perimeter from the radius yourself in your 
user code rather than using the existing library function. Is such code 
concise and maintainable? Definitely not!

2) It 
violates the &quot;least surprise&quot; principle. I do not know how other 
programmers feel about this, but I find the fact that getRadius() is a 
method and getPerimeter() is a free function extremely surprising! How 
are they different? Is radius more important than perimeter? Is there a 
logic in this decision? Oh, yes it is. But it is solely based on the 
implementation detail which is that you, by chance, decided to store the
 radius as the class private member. If you had stored the perimeter 
then the public interface would be different, wouldn&#039;t be? So you are 
indirectly exposing you implementation details as a burden to your 
users. What if in the future you decide to change this implementation 
detail? 

3) Design! Design! Design! General design 
should drive your decisions. Maybe this was just an artificial example, 
but you will not probably make a software dealing only with circles. You
 will more likely make software dealing with shapes and circles will 
only be one of the many shapes you will be able to work with. So you 
will have some interface (abstract class) Shape (or IShape if you will) 
and will design its interface. Would you add getRadius() into this 
interface? Definitely not because it relates only to circles. Would you 
put getArea() in this interface? Oh yes! Of course, every well behaved 
shape should have some area. So this is what should drive your interface
 design. Not the fact that you decided to store the radius to 
Circle::m_radius and then base all other decisions on this one.

Overall I think this article is extremely confusing for beginners.]]></description>
			<content:encoded><![CDATA[<p>I absolutely disagree. My three points against:<br />
1)<br />
 Moving getPerimeter() and getArea() out of the public class methods<br />
makes these free functions hard to discover. As a programmer, assume you<br />
 have an instance of Circle and you want to get its perimeter. What do<br />
you usually do? You type the name of the variable and then type . (or<br />
-&gt;) and wait what IDE autocompletion will suggest. You will get<br />
getRadius() so you will assume that there is no direct method for<br />
perimeter and you will open you high school math textbook and write the<br />
formula for calculating the perimeter from the radius yourself in your<br />
user code rather than using the existing library function. Is such code<br />
concise and maintainable? Definitely not!</p>
<p>2) It<br />
violates the &#8220;least surprise&#8221; principle. I do not know how other<br />
programmers feel about this, but I find the fact that getRadius() is a<br />
method and getPerimeter() is a free function extremely surprising! How<br />
are they different? Is radius more important than perimeter? Is there a<br />
logic in this decision? Oh, yes it is. But it is solely based on the<br />
implementation detail which is that you, by chance, decided to store the<br />
 radius as the class private member. If you had stored the perimeter<br />
then the public interface would be different, wouldn&#8217;t be? So you are<br />
indirectly exposing you implementation details as a burden to your<br />
users. What if in the future you decide to change this implementation<br />
detail? </p>
<p>3) Design! Design! Design! General design<br />
should drive your decisions. Maybe this was just an artificial example,<br />
but you will not probably make a software dealing only with circles. You<br />
 will more likely make software dealing with shapes and circles will<br />
only be one of the many shapes you will be able to work with. So you<br />
will have some interface (abstract class) Shape (or IShape if you will)<br />
and will design its interface. Would you add getRadius() into this<br />
interface? Definitely not because it relates only to circles. Would you<br />
put getArea() in this interface? Oh yes! Of course, every well behaved<br />
shape should have some area. So this is what should drive your interface<br />
 design. Not the fact that you decided to store the radius to<br />
Circle::m_radius and then base all other decisions on this one.</p>
<p>Overall I think this article is extremely confusing for beginners.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Michael Kelley		</title>
		<link>https://www.fluentcpp.com/2017/06/20/interface-principle-cpp/#comment-346</link>

		<dc:creator><![CDATA[Michael Kelley]]></dc:creator>
		<pubDate>Tue, 20 Jun 2017 17:41:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=603#comment-346</guid>

					<description><![CDATA[Shouldn&#039;t this 

&quot;calls f(x, x1, ..., xn) if f is a method and not a free function&quot;

actually be:

&quot;calls f(x, x1, ..., xn) if f is a free function and not a method&quot;]]></description>
			<content:encoded><![CDATA[<p>Shouldn&#8217;t this </p>
<p>&#8220;calls f(x, x1, &#8230;, xn) if f is a method and not a free function&#8221;</p>
<p>actually be:</p>
<p>&#8220;calls f(x, x1, &#8230;, xn) if f is a free function and not a method&#8221;</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
