﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Colin Jack commented on Public vs. Published</title><description>Noticed you have Execute on the interface but not on the class...
  
  
@Andrey
  
"Doing something 'just for tests' feels as bad as doing something 'just for persistence' or 'just for specific IoC container'."
  
  
I think a lot of the time this is true, changes put in for testing don't necessarily prove that useful. That is not an argument against TDDD though, just not sure always designing for testability is always a good approach.
  
  
@Jon Skeet
  
Good, maybe not but I've seen it used where you have a seperation between layers but actually there is a tight relationship. For example only an AccountService (in one project) should access a member on Account (in another project), in those cases you can make the member public and only use it from AccountService or just use InternalsVisibleTo in order to give the project containing AccountService access.
</description><link>http://ayende.com/3377/public-vs-published#comment19</link><guid>http://ayende.com/3377/public-vs-published#comment19</guid><pubDate>Mon, 30 Jun 2008 12:36:42 GMT</pubDate></item><item><title>George Spofford commented on Public vs. Published</title><description>The first textbook I ever came across on computer security discussed role-based security access to functions prior to applying it to things like file and object access. I agree that public/private/protected/internal are too gross in their scopes- very convenient for lots of cases, but not adequate. I for one would like to be able to unit-test "private" methods and classes as well.  Of course, role-based or named-entity-based access authorization for code introduces a set of questions, but I'm quite confident that a broader set of cases could be handled with the answers that are easier to arrive at.
</description><link>http://ayende.com/3377/public-vs-published#comment18</link><guid>http://ayende.com/3377/public-vs-published#comment18</guid><pubDate>Fri, 27 Jun 2008 17:22:30 GMT</pubDate></item><item><title>Paul Batum commented on Public vs. Published</title><description>Jon, when working with NHibernate, I use InternalsVisibleTo to give Castle.DynamicProxy access to the internals of my domain model.This allows me to use the lazy loading that Castle.DynamicProxy provides while keeping stricter controls on the visibility of constructors.
</description><link>http://ayende.com/3377/public-vs-published#comment17</link><guid>http://ayende.com/3377/public-vs-published#comment17</guid><pubDate>Fri, 27 Jun 2008 08:06:33 GMT</pubDate></item><item><title>Jon Skeet commented on Public vs. Published</title><description>Out of interest, has anyone here ever seen a good use for InternalsVisibleTo *other* than testing? That's the only use I've had for it so far, and I'd be slightly worried at other uses, I suspect. If anyone's found one, I'd be interested to hear about it.
</description><link>http://ayende.com/3377/public-vs-published#comment16</link><guid>http://ayende.com/3377/public-vs-published#comment16</guid><pubDate>Fri, 27 Jun 2008 06:06:47 GMT</pubDate></item><item><title>Andrey Shchekin commented on Public vs. Published</title><description>I do not see any be-public requirements here: http://www.ayende.com/Blog/archive/2008/01/24/Interception-as-an-extensibility-mechanism.aspx, what am I missing?
</description><link>http://ayende.com/3377/public-vs-published#comment15</link><guid>http://ayende.com/3377/public-vs-published#comment15</guid><pubDate>Thu, 26 Jun 2008 13:12:44 GMT</pubDate></item><item><title>Andrey Shchekin commented on Public vs. Published</title><description>I do not see any be-public requirements here: http://www.ayende.com/Blog/archive/2008/01/24/Interception-as-an-extensibility-mechanism.aspx, what am I missing?
</description><link>http://ayende.com/3377/public-vs-published#comment14</link><guid>http://ayende.com/3377/public-vs-published#comment14</guid><pubDate>Thu, 26 Jun 2008 13:12:44 GMT</pubDate></item><item><title>Ayende Rahien commented on Public vs. Published</title><description>Because testability is a secondary concern. I often need to be able to support additional functionality, and I found out that creating this distinction means that I can get pretty good results over a long period of time.
  
here is an example:
  
http://www.ayende.com/Blog/archive/2008/01/24/Interception-as-an-extensibility-mechanism.aspx
</description><link>http://ayende.com/3377/public-vs-published#comment13</link><guid>http://ayende.com/3377/public-vs-published#comment13</guid><pubDate>Thu, 26 Jun 2008 06:44:52 GMT</pubDate></item><item><title>Petar Repac commented on Public vs. Published</title><description>Ed, 
  
I really don't see how "other explicitly defined assemblies" could access internal members. It would defeat the whole purpose of friend assemblies. 
  
  
Ayende, 
  
could you say why you dislike this method ? Because I see it very much like Andrey. 
  
  
The other way to test internal stuff could be to implement test classes inside the tested assembly itself and manage builds so that test classes are not included in release version. With partial classes maybe we could test private stuff to. Haven't tried this scenario myself..
</description><link>http://ayende.com/3377/public-vs-published#comment12</link><guid>http://ayende.com/3377/public-vs-published#comment12</guid><pubDate>Thu, 26 Jun 2008 06:24:01 GMT</pubDate></item><item><title>Ayende Rahien commented on Public vs. Published</title><description>You seem to be ignoring the part of testing not the only thing required.
  
And published is not the same as public. For published, I want to support this.
  
For public, it means that you can do things with it, but it is your responsability
</description><link>http://ayende.com/3377/public-vs-published#comment11</link><guid>http://ayende.com/3377/public-vs-published#comment11</guid><pubDate>Thu, 26 Jun 2008 06:14:52 GMT</pubDate></item><item><title>Andrey Shchekin commented on Public vs. Published</title><description>Testing works extremely well with InternalsVisibleTo. Also it seems the right thing to do -- why do something as big as making everything public just for testing purposes?
  
  
I always try to write my code to be test ignorant (making code modular or using interfaces are common sense good design decisions, not test-forced ones). Doing something 'just for tests' feels as bad as doing something 'just for persistence' or 'just for specific IoC container'.
  
  
But if you have an advanced scenario when you need these classes to be public, probably it means they are 'published' as well.
</description><link>http://ayende.com/3377/public-vs-published#comment10</link><guid>http://ayende.com/3377/public-vs-published#comment10</guid><pubDate>Thu, 26 Jun 2008 06:10:53 GMT</pubDate></item><item><title>James commented on Public vs. Published</title><description>Why wouldn't you mark the set parts of the properties to private since the way they should be initialized is via the Init method?
</description><link>http://ayende.com/3377/public-vs-published#comment9</link><guid>http://ayende.com/3377/public-vs-published#comment9</guid><pubDate>Thu, 26 Jun 2008 02:07:24 GMT</pubDate></item><item><title>Ed  commented on Public vs. Published</title><description>Adding InternalsVisibleTo a project's AssemblyInfo.cs will allow other explicitly defined assemblies access to internal members.   This is really helpful for unit testing.
  
  
Example:
  
--------------
  
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("UnitTests, PublicKeyToken=123456789abcdef0")]  
  
  
http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/
</description><link>http://ayende.com/3377/public-vs-published#comment8</link><guid>http://ayende.com/3377/public-vs-published#comment8</guid><pubDate>Wed, 25 Jun 2008 23:19:01 GMT</pubDate></item><item><title>Ayende Rahien commented on Public vs. Published</title><description>Petar, I am aware of that.
  
I strongly dislike this method
</description><link>http://ayende.com/3377/public-vs-published#comment7</link><guid>http://ayende.com/3377/public-vs-published#comment7</guid><pubDate>Wed, 25 Jun 2008 21:19:02 GMT</pubDate></item><item><title>Petar Repac commented on Public vs. Published</title><description>Ayende, 
  
you can test internal members if you make test assembly a friend assembly (with InternalsVisibleToAttribute)
</description><link>http://ayende.com/3377/public-vs-published#comment6</link><guid>http://ayende.com/3377/public-vs-published#comment6</guid><pubDate>Wed, 25 Jun 2008 21:16:41 GMT</pubDate></item><item><title>Ayende Rahien commented on Public vs. Published</title><description>andrey,
  
Internal is a bad solution, it means that you are only exposing things to the current assembly.
  
Testing, advance scenarios needs that access as well
  
</description><link>http://ayende.com/3377/public-vs-published#comment5</link><guid>http://ayende.com/3377/public-vs-published#comment5</guid><pubDate>Wed, 25 Jun 2008 20:19:24 GMT</pubDate></item><item><title>Adam Vandenberg commented on Public vs. Published</title><description>I've used the "Interface as published" thing before on my projects. I had class with a HUGE set of public methods being passed around, and I finally went around partitioning them into separate iterfaces, and rewriting the client code to accept only the narrowed interface.
  
  
This worked wonders.
  
  
I was able to componentize the kitchen-sink class and finally refactor the responsibilities into wherever they needed to go, rather than in the kitchen-sink.
  
  
It helps intellisense within the client code too, as I only see those methods which I "ought" be using, instead of everything the class has.
</description><link>http://ayende.com/3377/public-vs-published#comment4</link><guid>http://ayende.com/3377/public-vs-published#comment4</guid><pubDate>Wed, 25 Jun 2008 20:06:02 GMT</pubDate></item><item><title>chris commented on Public vs. Published</title><description>congrats, you've discovered OOP! ;)
</description><link>http://ayende.com/3377/public-vs-published#comment3</link><guid>http://ayende.com/3377/public-vs-published#comment3</guid><pubDate>Wed, 25 Jun 2008 20:04:39 GMT</pubDate></item><item><title>Nick commented on Public vs. Published</title><description>I use this all the time for my repository and service classes. It allows me to use property injection without publishing the public properties. I can still access those properties if I want to, but they aren't a part of the "published" interface to those classes.
</description><link>http://ayende.com/3377/public-vs-published#comment2</link><guid>http://ayende.com/3377/public-vs-published#comment2</guid><pubDate>Wed, 25 Jun 2008 19:44:45 GMT</pubDate></item><item><title>Andrey Shchekin commented on Public vs. Published</title><description>I think it's exactly what 'internal' is for.
  
I always make things like UserRepository internal.
</description><link>http://ayende.com/3377/public-vs-published#comment1</link><guid>http://ayende.com/3377/public-vs-published#comment1</guid><pubDate>Wed, 25 Jun 2008 19:24:18 GMT</pubDate></item></channel></rss>