Click here to Skip to main content
15,899,937 members
Home / Discussions / C#
   

C#

 
AnswerRe: Getting information about a process's handles. Pin
Eddy Vluggen6-Mar-12 5:20
professionalEddy Vluggen6-Mar-12 5:20 
AnswerRe: Getting information about a process's handles. Pin
Dave Kreskowiak6-Mar-12 5:35
mveDave Kreskowiak6-Mar-12 5:35 
GeneralRe: Getting information about a process's handles. Pin
Septimus Hedgehog6-Mar-12 6:50
Septimus Hedgehog6-Mar-12 6:50 
GeneralRe: Getting information about a process's handles. Pin
Septimus Hedgehog6-Mar-12 23:51
Septimus Hedgehog6-Mar-12 23:51 
QuestionHow do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 0:07
GParkings6-Mar-12 0:07 
AnswerRe: How do you enforce use of dedicated factories? Pin
BobJanova6-Mar-12 0:40
BobJanova6-Mar-12 0:40 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 1:01
GParkings6-Mar-12 1:01 
GeneralRe: How do you enforce use of dedicated factories? Pin
BobJanova6-Mar-12 1:58
BobJanova6-Mar-12 1:58 
In the first place it should be trivial to explain to other devs why they should use a factory, since otherwise their instantiation code is going to contain reflection or type-selector-switching. (So will the code inside the factory, mind, so it's not technically better that way, but it does make the user code cleaner and that should be easy to demonstrate.) This is the one case where I absolutely agree with the factory pattern (along with the self-extending-collection I mentioned before).

An alternative pattern for the second way is to pass the catalog to the constructor and have instances register themselves. I'd generally prefer that to a factory – the registration is an external linkage of the instance, not an intrinsic attribute of it, and it doesn't make sense to me to tie instances to a particular factory simply because they need to register somewhere. Factories prohibit you from subclassing the item types for customised behaviour, whereas self-registration doesn't.

Are you a converted Java developer? The mention of Spring along with the factory-centric mindset makes that seem likely to me. If so, I think you should be looking to pick up .Net habits, not enforce your Java preferences on your team.

however i would expect anyone finding themselves doing such things to get at a ctor to ask themselves if that class was meant to be directly instantiated.
Right, but if the only reason that they ask that is because you've put an arbitrary mechanism into the code that amounts to nothing more than 'because I said so', you should be asking whether there is really a good reason why they shouldn't instantiate that class directly. If there's a good reason why the class needs to be factory-spawned, there will be some awkwardness involved in using it directly that will already cause them to wonder if they are missing something.

I have written quite complex .Net applications (solo and as part of a team) and I don't think I've ever had to use a factory, apart from the runtime loading against an interface (the plugin architecture common in .Net apps is essentially grand scale IPlugin factorying, and creating DbCommands against the correct type of database). I have had the container registration thing you mention and that can be solved without a factory.
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 2:30
GParkings6-Mar-12 2:30 
GeneralRe: How do you enforce use of dedicated factories? Pin
jschell6-Mar-12 8:54
jschell6-Mar-12 8:54 
AnswerRe: How do you enforce use of dedicated factories? Pin
Eddy Vluggen6-Mar-12 0:46
professionalEddy Vluggen6-Mar-12 0:46 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 1:03
GParkings6-Mar-12 1:03 
AnswerRe: How do you enforce use of dedicated factories? Pin
Eddy Vluggen6-Mar-12 5:19
professionalEddy Vluggen6-Mar-12 5:19 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 5:51
GParkings6-Mar-12 5:51 
GeneralRe: How do you enforce use of dedicated factories? Pin
Eddy Vluggen6-Mar-12 6:55
professionalEddy Vluggen6-Mar-12 6:55 
AnswerRe: How do you enforce use of dedicated factories? Pin
PIEBALDconsult6-Mar-12 2:28
mvePIEBALDconsult6-Mar-12 2:28 
AnswerRe: How do you enforce use of dedicated factories? Pin
SledgeHammer016-Mar-12 6:30
SledgeHammer016-Mar-12 6:30 
GeneralRe: How do you enforce use of dedicated factories? Pin
GParkings6-Mar-12 6:45
GParkings6-Mar-12 6:45 
GeneralRe: How do you enforce use of dedicated factories? Pin
SledgeHammer016-Mar-12 6:56
SledgeHammer016-Mar-12 6:56 
AnswerRe: How do you enforce use of dedicated factories? Pin
jschell6-Mar-12 8:48
jschell6-Mar-12 8:48 
AnswerRe: How do you enforce use of dedicated factories? Pin
jschell6-Mar-12 8:56
jschell6-Mar-12 8:56 
AnswerRe: How do you enforce use of dedicated factories? Pin
Clifford Nelson6-Mar-12 14:26
Clifford Nelson6-Mar-12 14:26 
GeneralRe: How do you enforce use of dedicated factories? Pin
BobJanova6-Mar-12 21:42
BobJanova6-Mar-12 21:42 
AnswerRe: How do you enforce use of dedicated factories? Pin
Clifford Nelson7-Mar-12 7:55
Clifford Nelson7-Mar-12 7:55 
GeneralRe: How do you enforce use of dedicated factories? Pin
lmoelleb8-Mar-12 1:39
lmoelleb8-Mar-12 1:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.