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

  • SEARCH
  • Home
  • 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 7953999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:17:33+00:00 2026-06-04T03:17:33+00:00

This is a general question about Object Orientation and specifically overloading functions in .NET

  • 0

This is a general question about Object Orientation and specifically overloading functions in .NET (or any other framework or language). I am looking at an application that has a lot of duplicate code. For example, have a look at the following functions:

Public Function Test(ByVal Test1 As String)

//code that is specifically relevant to Test1 variable

End Function

Public Function Test (ByVal Test1 As String, ByVal Test2 As String)
    //code that is specifically relevant to Test1 variable
    //code that is specifically relevant to Test2 variable
End Function

I would of thought that best pratice would be to put: //code that is specifically relevant to Test1 variable in a separate function as it is common in both functions. Is this the case? I have always thought that duplicate code is a very bad idea.

  • 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-04T03:17:35+00:00Added an answer on June 4, 2026 at 3:17 am

    It is not better:

    Public Function Test(ByVal Test1 As String) 
        //code that is specifically relevant to Test1 variable
    End Function 
    
    Public Function Test (ByVal Test1 As String, ByVal Test2 As String) 
        Test(Test1)
        //code that is specifically relevant to Test2 variable 
    End Function 
    

    Overloading ideally should be about adding aditional features to the original function but preserving it’s original behaviour in case you use it somewhere else in your code.

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

Sidebar

Related Questions

This is more or less a general question and not about any specific ORM
Yesterday I asked this general question about decimals and their internal precisions. Here is
This is a general question about MVC as a pattern, but in this case
This is a general question about character encoding when using MD5 libraries in various
This is a general question about mongodb database design, but the reason for my
So this is more of a general question about apps and techniques rather than
This question is about 64-bit Java apps in general, although I came upon it
Yes, I know, yet another question about mutable objects. See this for general background
Although I'm programming in C++, this is more of a general question about design.
This is a general question about design. What's the best way to communicate between

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.