Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7833211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T12:36:13+00:00 2026-06-02T12:36:13+00:00

I’m about to write a set of methods on a server application that take

  • 0

I’m about to write a set of methods on a server application that take messages received from TCP socket, encode/decode them, and encrypt/decrypt them.

Considering messages are defined as special types, each with its own set of properties and total length, I need to opt for one of the following solutions:
1. Make methods that use generics, such as Encode<T>(...) where T : IMessage and then implement encoder/decoder for each type of message and have ResolveEncoder<T> that would pick encoder for wanted message
or
2. Make method that uses any type of message, as long as it implements IMessage, such as Encode(IMessage message), and use System.Reflection to determine everything I need to know about it.

I’m more interested in doing solution #2 as it makes my code 30 times smaller. However, I’m worried whether constant reflection of properties will hit the performance. Now as I’m time limited to finish the project, I can’t really “experiment”.

I would be grateful for any personal experiences or links with benchmarks on how performance falls with either of solutions.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T12:36:16+00:00Added an answer on June 2, 2026 at 12:36 pm

    Reflection can be fast enough. But need to be implemented correctly.

    Reflection Performance –

    Fast and Light Functions

    typeof
    Object.GetType
    typeof == Object.GetType
    Type equivalence APIs (including typehandle operator overloads)
    get_Module
    get_MemberType
    Some of the IsXX predicate APIs
    New token/handle resolution APIs in the .NET Framework 2.0
    

    Costly Functions

    GetXX  APIs (MethodInfo, PropertyInfo, FieldInfo, and so on)
    GetCustomAttributes
    Type.InvokeMember
    Invoke APIs (MethodInfo.Invoke, FieldInfo.GetValue, and so on)
    get_Name (Name property)
    Activator.CreateInstance
    

    Source – Dodge Common Performance Pitfalls to Craft Speedy Applications

    MethodInfo can be speed up – Improving performance reflection , what alternatives should I consider

    Good links:
    How costly is .NET reflection?
    http://www.codeproject.com/Articles/18450/HyperDescriptor-Accelerated-dynamic-property-acces

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I have a text area in my form which accepts all possible characters from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.