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. C / C++ / MFC
  4. shortsighted design - so can I do this now?

shortsighted design - so can I do this now?

Scheduled Pinned Locked Moved C / C++ / MFC
databasedesignquestion
6 Posts 4 Posters 1 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.
  • N Offline
    N Offline
    ns
    wrote on last edited by
    #1

    I made a database class and the Open() function is quite flexible but opens a recordset based on a specific query. Its too involved to remove that inflexibility. Now I am wanting to use my database class but open with a whole different query. SO is it okay if I have a function called DbClass::Open2() which opens a database based on my new specific query (I may make Open2 be able to take any query but for the moment not). then when I want to open a database with my new query I can instantaite a new db object and call its open2 which in no way will interere with the db object which called Open1 (the original). Any comments? I know this is not good programmmming but do you agree that I can call two different versions of Open if I so desire... Thanks, ns

    J T 2 Replies Last reply
    0
    • N ns

      I made a database class and the Open() function is quite flexible but opens a recordset based on a specific query. Its too involved to remove that inflexibility. Now I am wanting to use my database class but open with a whole different query. SO is it okay if I have a function called DbClass::Open2() which opens a database based on my new specific query (I may make Open2 be able to take any query but for the moment not). then when I want to open a database with my new query I can instantaite a new db object and call its open2 which in no way will interere with the db object which called Open1 (the original). Any comments? I know this is not good programmmming but do you agree that I can call two different versions of Open if I so desire... Thanks, ns

      J Offline
      J Offline
      Jason Henderson
      wrote on last edited by
      #2

      Just call it Open but use different parameters. C++ will be able to figure it out. Its called method overloading.

      Jason Henderson
      quasi-homepage
      articles
      "Like it or not, I'm right!"

      A 1 Reply Last reply
      0
      • N ns

        I made a database class and the Open() function is quite flexible but opens a recordset based on a specific query. Its too involved to remove that inflexibility. Now I am wanting to use my database class but open with a whole different query. SO is it okay if I have a function called DbClass::Open2() which opens a database based on my new specific query (I may make Open2 be able to take any query but for the moment not). then when I want to open a database with my new query I can instantaite a new db object and call its open2 which in no way will interere with the db object which called Open1 (the original). Any comments? I know this is not good programmmming but do you agree that I can call two different versions of Open if I so desire... Thanks, ns

        T Offline
        T Offline
        Todd Smith
        wrote on last edited by
        #3

        Why not rename Open to something more descriptive and change our code? Then add another function for your 2nd query. Use something like QueryCustomers and QueryProducts instead of Open and Open2. Todd Smith

        N 1 Reply Last reply
        0
        • T Todd Smith

          Why not rename Open to something more descriptive and change our code? Then add another function for your 2nd query. Use something like QueryCustomers and QueryProducts instead of Open and Open2. Todd Smith

          N Offline
          N Offline
          ns
          wrote on last edited by
          #4

          Good idea! I'm just so glad I could extend my class. Appreciate your advice. Thanks, ns

          1 Reply Last reply
          0
          • J Jason Henderson

            Just call it Open but use different parameters. C++ will be able to figure it out. Its called method overloading.

            Jason Henderson
            quasi-homepage
            articles
            "Like it or not, I'm right!"

            A Offline
            A Offline
            AlinRO
            wrote on last edited by
            #5

            ?????? << excuse my english please, i'm romanian >>

            J 1 Reply Last reply
            0
            • A AlinRO

              ?????? << excuse my english please, i'm romanian >>

              J Offline
              J Offline
              Jason Henderson
              wrote on last edited by
              #6

              void MClass::Open() void MClass::Open(int i) void MClass::Open(char c) Are different functions of the same class with the same name but having different parameters. This is called function overloading.

              Jason Henderson
              quasi-homepage
              articles
              "Like it or not, I'm right!"

              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