<?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: Passing around complex objects is the opposite of encapsulation	</title>
	<atom:link href="https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/</link>
	<description>Blog of Rob Galanakis (@robgalanakis)</description>
	<lastBuildDate>Fri, 17 Feb 2012 11:34:41 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.4.2</generator>
	<item>
		<title>
		By: Daniel		</title>
		<link>https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/#comment-8258</link>

		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Fri, 17 Feb 2012 11:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.robg3d.com/?p=911#comment-8258</guid>

					<description><![CDATA[In that I quite agree. In general, I&#039;m of the opinion that _everything_ should be immutable by default. 80% purity will buy you quite a lot of sanity, which can then be spent on the 20% remaining horrible stuff.]]></description>
			<content:encoded><![CDATA[<p>In that I quite agree. In general, I&#8217;m of the opinion that _everything_ should be immutable by default. 80% purity will buy you quite a lot of sanity, which can then be spent on the 20% remaining horrible stuff.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Rob Galanakis		</title>
		<link>https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/#comment-8248</link>

		<dc:creator><![CDATA[Rob Galanakis]]></dc:creator>
		<pubDate>Thu, 16 Feb 2012 23:27:57 +0000</pubDate>
		<guid isPermaLink="false">http://www.robg3d.com/?p=911#comment-8248</guid>

					<description><![CDATA[In reply to &lt;a href=&quot;https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/#comment-8236&quot;&gt;Daniel&lt;/a&gt;.

Bundling up arguments into an object can be a great thing. The question for me is always- is the object mutable? If the object isn&#039;t mutable, I don&#039;t really care if you pass it around instead of a few arguments. If it is mutable, I&#039;d rarely take it as an argument to a function. Who knows what the function will do when it is passed a mutable instance? As I think I said in the article, I only pass mutable instances into functions (in general) with internal/inline methods/functions.]]></description>
			<content:encoded><![CDATA[<p>In reply to <a href="https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/#comment-8236">Daniel</a>.</p>
<p>Bundling up arguments into an object can be a great thing. The question for me is always- is the object mutable? If the object isn&#8217;t mutable, I don&#8217;t really care if you pass it around instead of a few arguments. If it is mutable, I&#8217;d rarely take it as an argument to a function. Who knows what the function will do when it is passed a mutable instance? As I think I said in the article, I only pass mutable instances into functions (in general) with internal/inline methods/functions.</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Daniel		</title>
		<link>https://www.robg3d.com/2012/02/passing-around-complex-objects-is-the-opposite-of-encapsulation/#comment-8236</link>

		<dc:creator><![CDATA[Daniel]]></dc:creator>
		<pubDate>Thu, 16 Feb 2012 12:30:28 +0000</pubDate>
		<guid isPermaLink="false">http://www.robg3d.com/?p=911#comment-8236</guid>

					<description><![CDATA[Not many reasons for this kind of crime that I can think of. In a statically typed language I suppose it&#039;s easy to allow exceptions to the rule because you desire a function of type Foo -&#062; Bar, although equally you could happily implement this as a pair of functions to extract and then manipulate whatever subset of Foo&#039;s data you&#039;re interested in, currying and composing towards some elegant solution.

I&#039;m more interested in where you draw the line, though. At some point, wrapping up the function arguments into a single structure affords better properties than simply passing in an awful lot of arguments piecemeal. Lots of arguments are horrible: potentially messing up the order, involving an awful lot of boilerplate for named args, or just unpacking the Foo into named arguments (why aren&#039;t you passing in the whole thing, at this point?). Yes, you should probably split the function up if it requires that much *stuff*, but something still needs to unpack the stuff and dispatch it to your small functions. Does the function orchestrating these take a Foo? 

To my mind, this becomes a bit of a wobbly issue. It&#039;s not so much a case of how many members frob needs to access, but whether the function notionally operates on Foos or a collection of subFooian values. Maybe the structure of Foo itself carries information. And this kind of argument extends to methods... to abuse your example, Foo.frob doesn&#039;t need to be on Foo, and if it has any useful behaviour in a universe absent Foos it probably shouldn&#039;t, but in many cases such offending functions are actually methods.

Part of the problem is that OO tends to leave us with the idea that we should only be passing objects around and using methods, when frequently operating on simple structures with independent functions is the Right Thing in my opinion.]]></description>
			<content:encoded><![CDATA[<p>Not many reasons for this kind of crime that I can think of. In a statically typed language I suppose it&#8217;s easy to allow exceptions to the rule because you desire a function of type Foo -&gt; Bar, although equally you could happily implement this as a pair of functions to extract and then manipulate whatever subset of Foo&#8217;s data you&#8217;re interested in, currying and composing towards some elegant solution.</p>
<p>I&#8217;m more interested in where you draw the line, though. At some point, wrapping up the function arguments into a single structure affords better properties than simply passing in an awful lot of arguments piecemeal. Lots of arguments are horrible: potentially messing up the order, involving an awful lot of boilerplate for named args, or just unpacking the Foo into named arguments (why aren&#8217;t you passing in the whole thing, at this point?). Yes, you should probably split the function up if it requires that much *stuff*, but something still needs to unpack the stuff and dispatch it to your small functions. Does the function orchestrating these take a Foo? </p>
<p>To my mind, this becomes a bit of a wobbly issue. It&#8217;s not so much a case of how many members frob needs to access, but whether the function notionally operates on Foos or a collection of subFooian values. Maybe the structure of Foo itself carries information. And this kind of argument extends to methods&#8230; to abuse your example, Foo.frob doesn&#8217;t need to be on Foo, and if it has any useful behaviour in a universe absent Foos it probably shouldn&#8217;t, but in many cases such offending functions are actually methods.</p>
<p>Part of the problem is that OO tends to leave us with the idea that we should only be passing objects around and using methods, when frequently operating on simple structures with independent functions is the Right Thing in my opinion.</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
