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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Beginer ques on programmng practice

Beginer ques on programmng practice

Scheduled Pinned Locked Moved C / C++ / MFC
question
3 Posts 3 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi I am displaying information of a simple Cperson class in a dailog box - which is better practice to pass the information by parameter to the dailog via DDX or to pass a pointer to the Cperson object and let the dailog box extract the data ? Thanks

    J T 2 Replies Last reply
    0
    • L Lost User

      Hi I am displaying information of a simple Cperson class in a dailog box - which is better practice to pass the information by parameter to the dailog via DDX or to pass a pointer to the Cperson object and let the dailog box extract the data ? Thanks

      J Offline
      J Offline
      Jesse Ezell
      wrote on last edited by
      #2

      It would definately take less processor time to pass a reference or a pointer, so this would be the best option in that case. However, you can also have a dialog box class that accepts a Cperson class in its constructor, and then is permenantly linked with that Cperson or a copy of it. It is mostly a matter of opinion and depends on what you intend to use the dialog for. ================== The original message was: Hi

      I am displaying information of a simple Cperson class
      in a dailog box - which is better practice to pass the
      information by parameter to the dailog via DDX or to
      pass a pointer to the Cperson object and let the dailog
      box extract the data ?

      Thanks

      1 Reply Last reply
      0
      • L Lost User

        Hi I am displaying information of a simple Cperson class in a dailog box - which is better practice to pass the information by parameter to the dailog via DDX or to pass a pointer to the Cperson object and let the dailog box extract the data ? Thanks

        T Offline
        T Offline
        Tomb 0
        wrote on last edited by
        #3

        My suggestion would be pass a reference to the object and let the Dialog interrogate the object directly for the data. Why pass n parameters when half the raison d'etre for the object is the encapsulation of this data? Pass a reference. In fact, there are probably ways to display the data in a dialog in such a way (combined with a bright method or two in the CPerson object) such that you can change the internal data represented in the CPerson without having to modify the Dialog that displays it. One of the stratagems of the experienced programmer is to try to devise ways to insulate himself from changes in data structure within object classes - this tends to happen, and the less impact it has on code scattered across the project, the better.

        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