Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Performance Issue..... C#

Performance Issue..... C#

Scheduled Pinned Locked Moved ASP.NET
csharpbusinessperformancehelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    DineshSharmain
    wrote on last edited by
    #1

    Hi I have to write some functions so i want to confirm whats better... 1. if i write one function with lot of functionalities For exa.

    Function Unit()
    {
    ---- some code




    .
    .
    .
    }

    2. if I break down this function in multiple functions and the call them inside the function and these function will be written in business layer. For exa.

    Function Unit()
    {
    ---- some code

    Fun1(arg1,arg2)

    Fun2(arg1,arg2)

    .
    .
    .
    }

    Question 2 - is this a good practice (if not what are the drawbacks) or i must use directly Convert.ToInt16(oData). ****I am calling this at so many places

    public static short ConvertToShort(object oData)
    {
    if (oData.ToString() == "")
    {
    return 0;
    }
    else
    {
    return Convert.ToInt16(oData);
    }
    }

    Thanks

    Dinesh Sharma

    B 1 Reply Last reply
    0
    • D DineshSharmain

      Hi I have to write some functions so i want to confirm whats better... 1. if i write one function with lot of functionalities For exa.

      Function Unit()
      {
      ---- some code




      .
      .
      .
      }

      2. if I break down this function in multiple functions and the call them inside the function and these function will be written in business layer. For exa.

      Function Unit()
      {
      ---- some code

      Fun1(arg1,arg2)

      Fun2(arg1,arg2)

      .
      .
      .
      }

      Question 2 - is this a good practice (if not what are the drawbacks) or i must use directly Convert.ToInt16(oData). ****I am calling this at so many places

      public static short ConvertToShort(object oData)
      {
      if (oData.ToString() == "")
      {
      return 0;
      }
      else
      {
      return Convert.ToInt16(oData);
      }
      }

      Thanks

      Dinesh Sharma

      B Offline
      B Offline
      Brij
      wrote on last edited by
      #2

      For 1st Q: Regading performace both are almost same but for better managebility it always preferred to split in functions so that every function implement one feature.It's good practice. for 2nd : It'll be better if u use directly Convert.ToInt16(oData).but do use it in Try catch block cause if this function will not be able to convert it in int then it'll throw exception.

      Cheers!! Brij

      D 1 Reply Last reply
      0
      • B Brij

        For 1st Q: Regading performace both are almost same but for better managebility it always preferred to split in functions so that every function implement one feature.It's good practice. for 2nd : It'll be better if u use directly Convert.ToInt16(oData).but do use it in Try catch block cause if this function will not be able to convert it in int then it'll throw exception.

        Cheers!! Brij

        D Offline
        D Offline
        DineshSharmain
        wrote on last edited by
        #3

        Thanks for your reply...but are you sure the breaking of functions will not affect the performance (speed)

        Dinesh Sharma

        B 1 Reply Last reply
        0
        • D DineshSharmain

          Thanks for your reply...but are you sure the breaking of functions will not affect the performance (speed)

          Dinesh Sharma

          B Offline
          B Offline
          Brij
          wrote on last edited by
          #4

          As I said, It is almost same.When we do something there is a tradeoff associated.Breaking it into multiple function will just add very few LOC in if you convert it in Machine language.Those lines won't take significant time.But this will surely help u a lot while managing the code which is more important. Also,You can prioritise and implement as per your requirement.

          Cheers!! Brij

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups