<?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/"
	
	>
<channel>
	<title>
	Comments on: Classes without a face	</title>
	<atom:link href="http://matteo.vaccari.name/blog/archives/700/feed" rel="self" type="application/rss+xml" />
	<link>http://matteo.vaccari.name/blog/archives/700</link>
	<description>Extreme enthusiasm</description>
	<lastBuildDate>
	Mon, 25 Feb 2019 15:18:16 +0000	</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=5.1.1</generator>
			<item>
				<title>
				By: matteo				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94821</link>
		<dc:creator><![CDATA[matteo]]></dc:creator>
		<pubDate>Mon, 16 Jan 2012 12:59:40 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94821</guid>
					<description><![CDATA[More on the HashMap approach:

http://codekata.pragprog.com/2007/01/kata_ten_hashes.html]]></description>
		<content:encoded><![CDATA[<p>More on the HashMap approach:</p>
<p><a href="http://codekata.pragprog.com/2007/01/kata_ten_hashes.html" rel="nofollow">http://codekata.pragprog.com/2007/01/kata_ten_hashes.html</a></p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: matteo				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94783</link>
		<dc:creator><![CDATA[matteo]]></dc:creator>
		<pubDate>Mon, 09 Jan 2012 12:58:36 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94783</guid>
					<description><![CDATA[@Carlo: the goal is to filter the Transactions that a User might want to see or change.  The reason why User generates the Shops filter is that the filter depends on the Privileges that the User has, and on the Shops that the User has access to.  As it all depends on information that the User has, it makes sense (it seemed to me) to let the user implement the filter.

I see your point that it might make sense to add the User as a parameter to the methods in the repository, as in 

transactionsRepository.findAll(User, Criteria)

but then I would have to move a business rule from a domain object to the repository implementation (how Privileges and Shops interact.)  I prefer to keep repositories simple.]]></description>
		<content:encoded><![CDATA[<p>@Carlo: the goal is to filter the Transactions that a User might want to see or change.  The reason why User generates the Shops filter is that the filter depends on the Privileges that the User has, and on the Shops that the User has access to.  As it all depends on information that the User has, it makes sense (it seemed to me) to let the user implement the filter.</p>
<p>I see your point that it might make sense to add the User as a parameter to the methods in the repository, as in </p>
<p>transactionsRepository.findAll(User, Criteria)</p>
<p>but then I would have to move a business rule from a domain object to the repository implementation (how Privileges and Shops interact.)  I prefer to keep repositories simple.</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Uberto				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94776</link>
		<dc:creator><![CDATA[Uberto]]></dc:creator>
		<pubDate>Sun, 08 Jan 2012 20:23:53 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94776</guid>
					<description><![CDATA[&#062;About the hashmap approach: Uberto would probably be interested to know that it is recommended also in “Functional Programming for Java Developers” by Dean Wampler 

Well of course, after a Lisp session you would use hashmap for everything in Java. :)

Anyway we actually used an hashmap approach (with dedicated hashmap wrappers) in our last project and for sure it helped on the productivity side, but somewhere the code is pretty obscure. So it&#039;s not a way I would suggest always, but we thought that in general we can switch to dedicated intellisensed object later.]]></description>
		<content:encoded><![CDATA[<p>&gt;About the hashmap approach: Uberto would probably be interested to know that it is recommended also in “Functional Programming for Java Developers” by Dean Wampler </p>
<p>Well of course, after a Lisp session you would use hashmap for everything in Java. :)</p>
<p>Anyway we actually used an hashmap approach (with dedicated hashmap wrappers) in our last project and for sure it helped on the productivity side, but somewhere the code is pretty obscure. So it&#8217;s not a way I would suggest always, but we thought that in general we can switch to dedicated intellisensed object later.</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Carlo Pescio				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94775</link>
		<dc:creator><![CDATA[Carlo Pescio]]></dc:creator>
		<pubDate>Sun, 08 Jan 2012 14:42:17 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94775</guid>
					<description><![CDATA[&quot;About the possible loss of performance of using a “where” condition when a left outer join might perform better: I might consider thinking about this the day I find I actually have a performance problem.&quot;
--
that&#039;s fine of course, but (talking about the approach and not the specific example of user authentication) we have to recognize that exposing criteria that way is a non-modular decision. That is, you expose something from User that somewhere else you combine to form a statement or get objects from a cached table. If you change your decision later on, and move to some ad-hoc sql statements, the entire (entanglement :-) chain has to be somewhat unraveled. Not necessarily a big deal, but in this sense I tend to favor architectures where this tend not to happen.
(I talked a bit about modular decisions here: http://www.carlopescio.com/2010/11/design-structure-and-decisions.html)

Musing a bit with separation of concerns again, while lot of people seem mostly concerned with technological separation (view, model, persistence, etc), I tend to look for clear separation at the domain level as well (or even first). So, assuming I got what you&#039;re doing :-), I would not put knowledge of shops inside the user class. I would rather go the other way around and have shop know user (that would remove the need for the criteria thing too, but again I&#039;m thinking more in sql terms and less in cached objects terms).


By far, by a very long far, the number one problem I have to fight is against development taking too long, and code getting too tangled. I suspect this is the number one problem for the majority of shops? What do you think?
---
While I&#039;m not sure it&#039;s problem #1 everywhere, I&#039;m pretty sure it&#039;s in the top 10 :-))]]></description>
		<content:encoded><![CDATA[<p>&#8220;About the possible loss of performance of using a “where” condition when a left outer join might perform better: I might consider thinking about this the day I find I actually have a performance problem.&#8221;<br />
&#8212;<br />
that&#8217;s fine of course, but (talking about the approach and not the specific example of user authentication) we have to recognize that exposing criteria that way is a non-modular decision. That is, you expose something from User that somewhere else you combine to form a statement or get objects from a cached table. If you change your decision later on, and move to some ad-hoc sql statements, the entire (entanglement :-) chain has to be somewhat unraveled. Not necessarily a big deal, but in this sense I tend to favor architectures where this tend not to happen.<br />
(I talked a bit about modular decisions here: <a href="http://www.carlopescio.com/2010/11/design-structure-and-decisions.html" rel="nofollow">http://www.carlopescio.com/2010/11/design-structure-and-decisions.html</a>)</p>
<p>Musing a bit with separation of concerns again, while lot of people seem mostly concerned with technological separation (view, model, persistence, etc), I tend to look for clear separation at the domain level as well (or even first). So, assuming I got what you&#8217;re doing :-), I would not put knowledge of shops inside the user class. I would rather go the other way around and have shop know user (that would remove the need for the criteria thing too, but again I&#8217;m thinking more in sql terms and less in cached objects terms).</p>
<p>By far, by a very long far, the number one problem I have to fight is against development taking too long, and code getting too tangled. I suspect this is the number one problem for the majority of shops? What do you think?<br />
&#8212;<br />
While I&#8217;m not sure it&#8217;s problem #1 everywhere, I&#8217;m pretty sure it&#8217;s in the top 10 :-))</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: matteo				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94772</link>
		<dc:creator><![CDATA[matteo]]></dc:creator>
		<pubDate>Sat, 07 Jan 2012 14:41:40 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94772</guid>
					<description><![CDATA[About the hashmap approach: Uberto would probably be interested to know that it is recommended also in &quot;Functional Programming for Java Developers&quot; by Dean Wampler (http://my.safaribooksonline.com/book/programming/java/9781449312657)

About the possible loss of performance of using a &quot;where&quot; condition when a left outer join might perform better: I might consider  thinking about this the day I find I actually have a performance problem.  For the moment our performance is fine all around, and the functions are performance-critical do not depend on the speed of authenticating the users in the backoffice app :-)

I realize that, in general, you might have a performance problem if you code too much in the &quot;object&quot; world without thinking about how the database will perform.  The most common error is something like this (in Rails):

  Transactions.all.filter(&#124;t&#124; t.id == myId)

which pulls every transaction from the database and then selects just one :-)

In fact the part of the system that pulls out transactions for the user interface was implemented with a query optimized from day one for returning paginated data.  But apart from places where I know (from experience) that are likely performance problems, coding in a straightforward way is enough.  I just keep in mind that every HTTP transactions needs to pull from the database everything that is not in the HTTP request already.

By far, by a very long far, the number one problem I have to fight is against development taking too long, and code getting too tangled.  I suspect this is the number one problem for the majority of shops?  What do you think?

Correctness is also a concern, but by being very scrupolous in testing the application in various ways we have that more or less under control.  Of course TDD is one of the key ingredients, but we also need others (automated ATs for example.)]]></description>
		<content:encoded><![CDATA[<p>About the hashmap approach: Uberto would probably be interested to know that it is recommended also in &#8220;Functional Programming for Java Developers&#8221; by Dean Wampler (<a href="http://my.safaribooksonline.com/book/programming/java/9781449312657" rel="nofollow">http://my.safaribooksonline.com/book/programming/java/9781449312657</a>)</p>
<p>About the possible loss of performance of using a &#8220;where&#8221; condition when a left outer join might perform better: I might consider  thinking about this the day I find I actually have a performance problem.  For the moment our performance is fine all around, and the functions are performance-critical do not depend on the speed of authenticating the users in the backoffice app :-)</p>
<p>I realize that, in general, you might have a performance problem if you code too much in the &#8220;object&#8221; world without thinking about how the database will perform.  The most common error is something like this (in Rails):</p>
<p>  Transactions.all.filter(|t| t.id == myId)</p>
<p>which pulls every transaction from the database and then selects just one :-)</p>
<p>In fact the part of the system that pulls out transactions for the user interface was implemented with a query optimized from day one for returning paginated data.  But apart from places where I know (from experience) that are likely performance problems, coding in a straightforward way is enough.  I just keep in mind that every HTTP transactions needs to pull from the database everything that is not in the HTTP request already.</p>
<p>By far, by a very long far, the number one problem I have to fight is against development taking too long, and code getting too tangled.  I suspect this is the number one problem for the majority of shops?  What do you think?</p>
<p>Correctness is also a concern, but by being very scrupolous in testing the application in various ways we have that more or less under control.  Of course TDD is one of the key ingredients, but we also need others (automated ATs for example.)</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Carlo Pescio				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94768</link>
		<dc:creator><![CDATA[Carlo Pescio]]></dc:creator>
		<pubDate>Fri, 06 Jan 2012 09:14:44 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94768</guid>
					<description><![CDATA[As usual, design decisions should be tailored to the specific project, so it is entirely possible that in your case a simplified structure, where User takes on a few more responsibilities, was a sound choice.

Generally speaking (and so addressing some of Uberto&#039;s points on authentication being best modeled as a pure function) it might be better to transform the (awful :-) UserAuthenticationContainer class into a Credential class instead. 
Actually, in a scaled-up problem domain, you may have a hierarchy of Credential (uid+pwd, biometrics, auth. device, facebook auth., whatever). They have different logic and operate upon different data, therefore a polymorphic, class-based approach looks like a better fit.

I won&#039;t go into the SRP dungeon here, if not to point out that you are *not* (as somewhat implied by comments) moving persistence logic into the User (and not even into the PasswordDataItem, I suppose), at least not as far as authenticate() is concerned, as you delegate that to the registry object (which, I assume, is a sort of Repository).

FilterByUserShopsCriteria (ouch :-)) is more problematic, as we expose a deeper problem here. If I read your code properly, the condition() string will be used later to compose some SQL statement with a &quot;... AND shopId IN ( &lt;a&gt; )&quot; clause. 
In more than a few cases, a hand-crafted statement based on a left outer join would perform better (mileage may vary between db engines, table size, etc). That&#039;s the dark side of trying to move away, to some extent, from the underlying storage mechanism (by cutting along some modularity axis which might be at odd with the nature of the underlying mechanism).

About your previous post: I&#039;ve used the hashmap-based approach quite often. Works well for me, and it&#039;s actually a well-known pattern (documented back in 2002 in EJB Design Patterns by Floyd Marinescu as &quot;data transfer hashmap&quot;). In practice, some people hate it unconditionally, and would go through anything to experience the joy of intellisense :-), which requires strongly-typed data transfer objects. I tend to see dynamic objects as a slightly different material, with interesting properties, and like to mix materials according to their response to the actual forces at play.

Keep it up!

Carlo]]></description>
		<content:encoded><![CDATA[<p>As usual, design decisions should be tailored to the specific project, so it is entirely possible that in your case a simplified structure, where User takes on a few more responsibilities, was a sound choice.</p>
<p>Generally speaking (and so addressing some of Uberto&#8217;s points on authentication being best modeled as a pure function) it might be better to transform the (awful :-) UserAuthenticationContainer class into a Credential class instead.<br />
Actually, in a scaled-up problem domain, you may have a hierarchy of Credential (uid+pwd, biometrics, auth. device, facebook auth., whatever). They have different logic and operate upon different data, therefore a polymorphic, class-based approach looks like a better fit.</p>
<p>I won&#8217;t go into the SRP dungeon here, if not to point out that you are *not* (as somewhat implied by comments) moving persistence logic into the User (and not even into the PasswordDataItem, I suppose), at least not as far as authenticate() is concerned, as you delegate that to the registry object (which, I assume, is a sort of Repository).</p>
<p>FilterByUserShopsCriteria (ouch :-)) is more problematic, as we expose a deeper problem here. If I read your code properly, the condition() string will be used later to compose some SQL statement with a &#8220;&#8230; AND shopId IN ( <a> )&#8221; clause.<br />
In more than a few cases, a hand-crafted statement based on a left outer join would perform better (mileage may vary between db engines, table size, etc). That&#8217;s the dark side of trying to move away, to some extent, from the underlying storage mechanism (by cutting along some modularity axis which might be at odd with the nature of the underlying mechanism).</p>
<p>About your previous post: I&#8217;ve used the hashmap-based approach quite often. Works well for me, and it&#8217;s actually a well-known pattern (documented back in 2002 in EJB Design Patterns by Floyd Marinescu as &#8220;data transfer hashmap&#8221;). In practice, some people hate it unconditionally, and would go through anything to experience the joy of intellisense :-), which requires strongly-typed data transfer objects. I tend to see dynamic objects as a slightly different material, with interesting properties, and like to mix materials according to their response to the actual forces at play.</p>
<p>Keep it up!</p>
<p>Carlo</a></p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Uberto				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94759</link>
		<dc:creator><![CDATA[Uberto]]></dc:creator>
		<pubDate>Thu, 05 Jan 2012 11:00:04 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94759</guid>
					<description><![CDATA[Hi Matteo,

this is very interesting. I have a different opinion (as you probably know).
In few word I found the approach &quot;move the auth on the User&quot; unpractical, after a while, no matter what, the entities came up as a blob with too many concerns.
Specifically, if I want to change the way Criteria are used or db is build I don&#039;t want to have to change the User.
So my solution in these cases is using Functional programming approach. FilterByUserShopsCriteria and UserAuthenticationContainer for me they scream to be transformed in pure functions.
In this way also tests are simpler (I don&#039;t want to test criteria in the User tests) and no need for &quot;zombie&quot; classes with a single method. 
&quot;zombie&quot; -&#062; you create it, you use it, you kill it, you create it again somewhere else etc.]]></description>
		<content:encoded><![CDATA[<p>Hi Matteo,</p>
<p>this is very interesting. I have a different opinion (as you probably know).<br />
In few word I found the approach &#8220;move the auth on the User&#8221; unpractical, after a while, no matter what, the entities came up as a blob with too many concerns.<br />
Specifically, if I want to change the way Criteria are used or db is build I don&#8217;t want to have to change the User.<br />
So my solution in these cases is using Functional programming approach. FilterByUserShopsCriteria and UserAuthenticationContainer for me they scream to be transformed in pure functions.<br />
In this way also tests are simpler (I don&#8217;t want to test criteria in the User tests) and no need for &#8220;zombie&#8221; classes with a single method.<br />
&#8220;zombie&#8221; -&gt; you create it, you use it, you kill it, you create it again somewhere else etc.</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: matteo				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94758</link>
		<dc:creator><![CDATA[matteo]]></dc:creator>
		<pubDate>Thu, 05 Jan 2012 09:05:50 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94758</guid>
					<description><![CDATA[Thanks Franco!

This is a valid objection.  The User could start having too many responsibilities.  But I don&#039;t think that an object should really have a *single* responsibility.  It&#039;s OK for an object to have a small set of related responsibilities.  In my case, the User has the following responsibilities
&lt;ul&gt;
	&lt;li&gt;Maintain and represent its own information&lt;/li&gt;
	&lt;li&gt;Authenticating a user&lt;/li&gt;
	&lt;li&gt;Authorization of user actions&lt;/li&gt;
&lt;/ul&gt;
All of these responsibilities are related to who the User is, so they seem a cohesive set of responsibilities.  When you look inside the class, though, you don&#039;t see a whole lot of code.  Most of these responsibilities are delegated to data items that the user contains.]]></description>
		<content:encoded><![CDATA[<p>Thanks Franco!</p>
<p>This is a valid objection.  The User could start having too many responsibilities.  But I don&#8217;t think that an object should really have a *single* responsibility.  It&#8217;s OK for an object to have a small set of related responsibilities.  In my case, the User has the following responsibilities</p>
<ul>
<li>Maintain and represent its own information</li>
<li>Authenticating a user</li>
<li>Authorization of user actions</li>
</ul>
<p>All of these responsibilities are related to who the User is, so they seem a cohesive set of responsibilities.  When you look inside the class, though, you don&#8217;t see a whole lot of code.  Most of these responsibilities are delegated to data items that the user contains.</p>
]]></content:encoded>
						</item>
						<item>
				<title>
				By: Franco Lombardo				</title>
				<link>http://matteo.vaccari.name/blog/archives/700/comment-page-1#comment-94757</link>
		<dc:creator><![CDATA[Franco Lombardo]]></dc:creator>
		<pubDate>Thu, 05 Jan 2012 08:45:27 +0000</pubDate>
		<guid isPermaLink="false">http://matteo.vaccari.name/blog/?p=700#comment-94757</guid>
					<description><![CDATA[Nice post, Matteo!

Don&#039;t you think that this approach could violate the SRP? Now your user does authentication and generates the Criteria, and what more?
Sometimes I think that one of the problems of OOP is that it could lead to over-bloated objects: reality contains too many things for a class to express!]]></description>
		<content:encoded><![CDATA[<p>Nice post, Matteo!</p>
<p>Don&#8217;t you think that this approach could violate the SRP? Now your user does authentication and generates the Criteria, and what more?<br />
Sometimes I think that one of the problems of OOP is that it could lead to over-bloated objects: reality contains too many things for a class to express!</p>
]]></content:encoded>
						</item>
			</channel>
</rss>
