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. General Programming
  3. Visual Basic
  4. What is the best way to return a large amount of related information from a routine?

What is the best way to return a large amount of related information from a routine?

Scheduled Pinned Locked Moved Visual Basic
questionperformancehelp
3 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.
  • E Offline
    E Offline
    Euhemerus
    wrote on last edited by
    #1

    I have a routine for displaying to the user, information on the memory which is installed in their system. This routine is currently encapsulated in a class with each piece of information being returned as a property. The class's instantiated object is only used the once. The routine that provides the class's properties with their information is executed when the class is instantiated from the calling routine requiring the memory information thus: dim memInfo as new MemoryInformation. The class's code resides in the Public Sub New(). What I would like to know is, is this the best way to go about implementing this sort of functionality? Should I maybe use a Function and return the info in a collection of some sort or should the code in the class's New sub be moved to a separate method instead? I'm rather new to OO programming and haven't got my head round when is the best time to use a class instead of a function. Any help would be greatly appreciated.

    No trees were harmed in the posting of this missive; however, a large number of quantum states were changed.

    W 1 Reply Last reply
    0
    • E Euhemerus

      I have a routine for displaying to the user, information on the memory which is installed in their system. This routine is currently encapsulated in a class with each piece of information being returned as a property. The class's instantiated object is only used the once. The routine that provides the class's properties with their information is executed when the class is instantiated from the calling routine requiring the memory information thus: dim memInfo as new MemoryInformation. The class's code resides in the Public Sub New(). What I would like to know is, is this the best way to go about implementing this sort of functionality? Should I maybe use a Function and return the info in a collection of some sort or should the code in the class's New sub be moved to a separate method instead? I'm rather new to OO programming and haven't got my head round when is the best time to use a class instead of a function. Any help would be greatly appreciated.

      No trees were harmed in the posting of this missive; however, a large number of quantum states were changed.

      W Offline
      W Offline
      William Winner
      wrote on last edited by
      #2

      I vote for that being the best way. If you have a large amount of information that you need to return, then a class seems to be the way to go. As to whether to put it in the New or another function, I would normally put it into a function and have that function return a MemoryInformation class in case you want to reuse your class in a different way later, but I wouldn't begin to state that there's a right or wrong way to do that.

      E 1 Reply Last reply
      0
      • W William Winner

        I vote for that being the best way. If you have a large amount of information that you need to return, then a class seems to be the way to go. As to whether to put it in the New or another function, I would normally put it into a function and have that function return a MemoryInformation class in case you want to reuse your class in a different way later, but I wouldn't begin to state that there's a right or wrong way to do that.

        E Offline
        E Offline
        Euhemerus
        wrote on last edited by
        #3

        Thanks for the reply. I've been thinking along similar lines. My routines 'work' as I have them implemented at the moment. I was wondering at the time I was writing the routines whether it was the 'best' way. I've been 'brought up' as a procedural programmer and find OO programming a complete paradigm shift to what I'm used to!

        No trees were harmed in the posting of this missive; however, a large number of quantum states were changed.

        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