<?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: How to Design Function Parameters That Make Interfaces Easier to Use (3/3)	</title>
	<atom:link href="https://www.fluentcpp.com/2018/11/30/function-parameters-3/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/</link>
	<description>Jonathan Boccara&#039;s blog</description>
	<lastBuildDate>Sun, 02 Dec 2018 07:08:00 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.5.4</generator>
	<item>
		<title>
		By: Hank Thetank		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1516</link>

		<dc:creator><![CDATA[Hank Thetank]]></dc:creator>
		<pubDate>Sun, 02 Dec 2018 07:08:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1516</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1508&quot;&gt;Bartlomiej Filipek&lt;/a&gt;.

4-5 parameters is already a lot. I usually start thinking at 3. Following clean code. IveI worked on a code base with many parameters added over time... Horrid.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1508">Bartlomiej Filipek</a>.</p>
<p>4-5 parameters is already a lot. I usually start thinking at 3. Following clean code. IveI worked on a code base with many parameters added over time&#8230; Horrid.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Jonathan Boccara		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1515</link>

		<dc:creator><![CDATA[Jonathan Boccara]]></dc:creator>
		<pubDate>Sat, 01 Dec 2018 20:35:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1515</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1510&quot;&gt;CarelC&lt;/a&gt;.

Thanks. Indeed, we could use strong types here. The reason why I didn&#039;t show this in the article was to focus on one aspect of the design at a time. But maybe this doesn&#039;t make the purpose clearer!
Thanks for noticing the typo, it is now fixed.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1510">CarelC</a>.</p>
<p>Thanks. Indeed, we could use strong types here. The reason why I didn&#8217;t show this in the article was to focus on one aspect of the design at a time. But maybe this doesn&#8217;t make the purpose clearer!<br />
Thanks for noticing the typo, it is now fixed.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: NapOli1084		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1512</link>

		<dc:creator><![CDATA[NapOli1084]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 16:14:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1512</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1508&quot;&gt;Bartlomiej Filipek&lt;/a&gt;.

+1.

It makes extensibility and maintenance much easier. And allows passing around the pack of parameters. It&#039;s a strategy I often use when the function is actually an asynchronous operation, it allows to easily queue parameter pack and treat it later. Which is also often 2-3 layers of code below, so prevents having to modify each layer when a new parameter is added.

And there&#039;s another important aspect that&#039;s missing here, it&#039;s that a structure enforces explicit parameters at the call sites. E.g.:

OptionParameters params;
params.price = 10.0;
params.yearsToMaturity = 7.0;
...
computeOption(params);

Is much clearer than function taking plain values such as computeOptions(10.0, ..., 7.0,...).

I don&#039;t feel that makes it less obvious about what to pass to the function, as you simply have to lookout the definition of the structure.

And I&#039;m not convinced &quot;being obvious as to what to pass for them&quot; is the #1 objective for function parameters, I feel like &quot;being obvious as to what IS PASSED TO them&quot; at call sites is even more important. The code we write will be read much more often than we write it, and by other programmers. I don&#039;t think we should make it easier to write the function if that makes it harder to read at call site.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1508">Bartlomiej Filipek</a>.</p>
<p>+1.</p>
<p>It makes extensibility and maintenance much easier. And allows passing around the pack of parameters. It&#8217;s a strategy I often use when the function is actually an asynchronous operation, it allows to easily queue parameter pack and treat it later. Which is also often 2-3 layers of code below, so prevents having to modify each layer when a new parameter is added.</p>
<p>And there&#8217;s another important aspect that&#8217;s missing here, it&#8217;s that a structure enforces explicit parameters at the call sites. E.g.:</p>
<p>OptionParameters params;<br />
params.price = 10.0;<br />
params.yearsToMaturity = 7.0;<br />
&#8230;<br />
computeOption(params);</p>
<p>Is much clearer than function taking plain values such as computeOptions(10.0, &#8230;, 7.0,&#8230;).</p>
<p>I don&#8217;t feel that makes it less obvious about what to pass to the function, as you simply have to lookout the definition of the structure.</p>
<p>And I&#8217;m not convinced &#8220;being obvious as to what to pass for them&#8221; is the #1 objective for function parameters, I feel like &#8220;being obvious as to what IS PASSED TO them&#8221; at call sites is even more important. The code we write will be read much more often than we write it, and by other programmers. I don&#8217;t think we should make it easier to write the function if that makes it harder to read at call site.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: NapOli1084		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1511</link>

		<dc:creator><![CDATA[NapOli1084]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 15:46:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1511</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1509&quot;&gt;jft&lt;/a&gt;.

The Boost Parameter library provides that.
https://www.boost.org/doc/libs/1_68_0/libs/parameter/doc/html/index.html

I never tried it though, so can&#039;t tell about its limitations/drawbacks, and it&#039;s an external library, so may not fit all projects.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1509">jft</a>.</p>
<p>The Boost Parameter library provides that.<br />
<a href="https://www.boost.org/doc/libs/1_68_0/libs/parameter/doc/html/index.html" rel="nofollow ugc">https://www.boost.org/doc/libs/1_68_0/libs/parameter/doc/html/index.html</a></p>
<p>I never tried it though, so can&#8217;t tell about its limitations/drawbacks, and it&#8217;s an external library, so may not fit all projects.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: CarelC		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1510</link>

		<dc:creator><![CDATA[CarelC]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 12:28:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1510</guid>

					<description><![CDATA[Very nice series, thanks.

Are you perhaps contradicting yourself... 
In your &quot;computeOption&quot; function prototype you are not following your recommendation in Part2: &quot;Use strong types to make calling your interfaces a no-brainer&quot;
Double for price, yearsToMaturity and strike leaves room for improvement :)
I am guessing this was just plain oversight...

PS: Spelling mistake in heading &quot;repecting&quot; should read &quot;respecting&quot;]]></description>
			<content:encoded><![CDATA[<p>Very nice series, thanks.</p>
<p>Are you perhaps contradicting yourself&#8230;<br />
In your &#8220;computeOption&#8221; function prototype you are not following your recommendation in Part2: &#8220;Use strong types to make calling your interfaces a no-brainer&#8221;<br />
Double for price, yearsToMaturity and strike leaves room for improvement 🙂<br />
I am guessing this was just plain oversight&#8230;</p>
<p>PS: Spelling mistake in heading &#8220;repecting&#8221; should read &#8220;respecting&#8221;</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: jft		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1509</link>

		<dc:creator><![CDATA[jft]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 10:04:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1509</guid>

					<description><![CDATA[There&#039;s also, of course, function default parameters which can help to reduce the number actually used if the default ones are only likely to be given in specific circumstances.]]></description>
			<content:encoded><![CDATA[<p>There&#8217;s also, of course, function default parameters which can help to reduce the number actually used if the default ones are only likely to be given in specific circumstances.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Bartlomiej Filipek		</title>
		<link>https://www.fluentcpp.com/2018/11/30/function-parameters-3/#comment-1508</link>

		<dc:creator><![CDATA[Bartlomiej Filipek]]></dc:creator>
		<pubDate>Fri, 30 Nov 2018 07:16:00 +0000</pubDate>
		<guid isPermaLink="false">https://www.fluentcpp.com/?p=2014#comment-1508</guid>

					<description><![CDATA[nice series!


I&#039;m always fan of packing long list of parameters into a separate structure. You think that 4...5 params is still ok, but then you have to add another one... and replace the call place many times.
With separate structures it&#039;s easier - you just add another field in the separate type, so it&#039;s more scalable and readable.]]></description>
			<content:encoded><![CDATA[<p>nice series!</p>
<p>I&#8217;m always fan of packing long list of parameters into a separate structure. You think that 4&#8230;5 params is still ok, but then you have to add another one&#8230; and replace the call place many times.<br />
With separate structures it&#8217;s easier &#8211; you just add another field in the separate type, so it&#8217;s more scalable and readable.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
