Click here to Skip to main content
16,007,111 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
GeneralRe: Referencing DLL's Pin
Wendelius20-Jan-09 9:56
mentorWendelius20-Jan-09 9:56 
GeneralRe: Referencing DLL's Pin
Member 362614020-Jan-09 11:02
Member 362614020-Jan-09 11:02 
GeneralRe: Referencing DLL's Pin
Wendelius20-Jan-09 11:08
mentorWendelius20-Jan-09 11:08 
Questionvisual studio thinks it resides in Europe, and we're actually in the US Pin
Mihai Pruna19-Jan-09 14:00
Mihai Pruna19-Jan-09 14:00 
AnswerRe: visual studio thinks it resides in Europe, and we're actually in the US Pin
Not Active19-Jan-09 15:32
mentorNot Active19-Jan-09 15:32 
GeneralRe: visual studio thinks it resides in Europe, and we're actually in the US Pin
Mihai Pruna20-Jan-09 2:57
Mihai Pruna20-Jan-09 2:57 
AnswerRe: visual studio thinks it resides in Europe, and we're actually in the US Pin
omlac20-Jan-09 3:16
omlac20-Jan-09 3:16 
QuestionDoes the use of many trivial classes with generics pose a performance penalty? Pin
supercat919-Jan-09 10:00
supercat919-Jan-09 10:00 
Using generics and interfaces in .net, it's possible to design a class so that a particular method name can invoke a number of different methods, based upon the type of a passed-in parameter. For example:
Class DoItMagic
    Interface iAct(Of T)
        Sub Act(ByVal param As T)
    End Interface

    Public Shared Sub exec(Of T)(ByVal target As iAct(Of T), ByVal param As T)
        target.Act(param)
    End Sub

    Public Shared Sub hitEverything(Of T, U As DoItMagic.iAct(Of T))(ByVal theEnum As IEnumerable(Of U), ByVal theParam As T)
        For Each thing As U In theEnum
            exec(Of T)(thing, theParam)
        Next
    End Sub
End Class

Class DoItTarget
    Implements DoItMagic.iAct(Of param1), DoItMagic.iAct(Of param2)

    Class param1
    End Class

    Class param2
    End Class

    Public Sub Act_param1(ByVal param As param1) Implements DoItMagic.iAct(Of param1).Act

    End Sub

    Public Sub Act_param2(ByVal param As param2) Implements DoItMagic.iAct(Of param2).Act

    End Sub
End Class

Class DoItTest
    Dim firstParam As DoItTarget.param1
    Dim secondParam As DoItTarget.param2

    Dim L As List(Of DoItTarget)

    Sub go()
        DoItMagic.hitEverything(Of DoItTarget.param1, DoItTarget)(L, firstParam)
        DoItMagic.hitEverything(Of DoItTarget.param2, DoItTarget)(L, secondParam)
    End Sub
End Class

This approach seems to work out pretty elegantly. The first hitEverything will call iAct(of Param1) on each element of the list; the second will call iAct(of Param2). Additional methods may be added by simply creating new classes and adding interface iAct(of eachNewClass), without any need to change anything in DoItMagic.

My questions:

  1. Are there any performance implementations with creating empty classes that are used as method selectors rather than as distinct ways of holding data (e.g. there might be a number of different classes that hold a single integer, but select different methods).
  2. Does invoking methods via generics pose any performance problems in cases where everything can be type-checked at compile time?
  3. What would be the performance implications in cases where things couldn't be checked until run-time (e.g. if a list holds a number of elements, not all of which will support any particular iAct(of type).
  4. Is this overall approach a brilliant idea, crazy idea, or somewhere in between?

I like the way this approach seems to work, but I would be very sad if I developed a lot of code with it and discovered that while it performed well in initial testing it sometimes dogged in real applications. Any thoughts?
AnswerRe: Does the use of many trivial classes with generics pose a performance penalty? Pin
Member 362614020-Jan-09 11:06
Member 362614020-Jan-09 11:06 
AnswerRe: Does the use of many trivial classes with generics pose a performance penalty? Pin
Mark Churchill20-Jan-09 14:36
Mark Churchill20-Jan-09 14:36 
GeneralRe: Does the use of many trivial classes with generics pose a performance penalty? Pin
supercat920-Jan-09 16:07
supercat920-Jan-09 16:07 
GeneralRe: Does the use of many trivial classes with generics pose a performance penalty? Pin
Mark Churchill20-Jan-09 16:31
Mark Churchill20-Jan-09 16:31 
GeneralRe: Does the use of many trivial classes with generics pose a performance penalty? Pin
supercat920-Jan-09 18:45
supercat920-Jan-09 18:45 
QuestionDynamic Blob field Pin
dwolver19-Jan-09 9:21
dwolver19-Jan-09 9:21 
AnswerRe: Dynamic Blob field Pin
Eddy Vluggen19-Jan-09 9:37
professionalEddy Vluggen19-Jan-09 9:37 
AnswerRe: Dynamic Blob field Pin
Wendelius20-Jan-09 9:22
mentorWendelius20-Jan-09 9:22 
GeneralRe: Dynamic Blob field Pin
Member 362614020-Jan-09 10:23
Member 362614020-Jan-09 10:23 
QuestionSSHExec:: RunCommand and X11 forwarding Pin
peppoRao7119-Jan-09 8:36
peppoRao7119-Jan-09 8:36 
QuestionVirtualPageProvider - Not getting hit on virtual file requests [modified] Pin
Tristan Rhodes19-Jan-09 3:51
Tristan Rhodes19-Jan-09 3:51 
AnswerRe: VirtualPageProvider - Not getting hit on virtual file requests Pin
cmk19-Jan-09 14:09
cmk19-Jan-09 14:09 
GeneralRe: VirtualPageProvider - Not getting hit on virtual file requests Pin
Tristan Rhodes20-Jan-09 2:24
Tristan Rhodes20-Jan-09 2:24 
GeneralRe: VirtualPageProvider - Not getting hit on virtual file requests Pin
cmk20-Jan-09 5:02
cmk20-Jan-09 5:02 
QuestionHow Can i develop programs in PPC(Pocket PC with Windows Mobile) Pin
ox010118-Jan-09 16:05
ox010118-Jan-09 16:05 
AnswerRe: How Can i develop programs in PPC(Pocket PC with Windows Mobile) Pin
«_Superman_»18-Jan-09 17:01
professional«_Superman_»18-Jan-09 17:01 
GeneralRe: How Can i develop programs in PPC(Pocket PC with Windows Mobile) Pin
ox010118-Jan-09 17:09
ox010118-Jan-09 17:09 

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.