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#
  4. need suggestion for the code

need suggestion for the code

Scheduled Pinned Locked Moved C#
databasequestion
7 Posts 4 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.
  • A Offline
    A Offline
    abcurl
    wrote on last edited by
    #1

    Project 1 I have four classes class1 this contains the variables, properties and constructors suppose

    private string abc;

    Interface2 This contains interfaces

    void a1();

    class3 this will have function definitions. basically this will contains functions to do the database interactions

    public void a1()
    {
    // code.....
    }

    class4 this will inherit Interface 2 and will override the definition.

    public void a1()
    {
    class3 a = new class3();
    a.a1();
    }

    Project 2 class5 this will have function

    public static Interface2 Getclass4_Details()
    {
    return new class4();
    }

    Project 3 In the form button click i am doing

    Interface2 Obj = null;
    Obj = project2.class5.Getclass4_Details();
    obj.a1();

    I am approaching in the above way to do database interaction. Am I approaching i the right direction ?

    L D 2 Replies Last reply
    0
    • A abcurl

      Project 1 I have four classes class1 this contains the variables, properties and constructors suppose

      private string abc;

      Interface2 This contains interfaces

      void a1();

      class3 this will have function definitions. basically this will contains functions to do the database interactions

      public void a1()
      {
      // code.....
      }

      class4 this will inherit Interface 2 and will override the definition.

      public void a1()
      {
      class3 a = new class3();
      a.a1();
      }

      Project 2 class5 this will have function

      public static Interface2 Getclass4_Details()
      {
      return new class4();
      }

      Project 3 In the form button click i am doing

      Interface2 Obj = null;
      Obj = project2.class5.Getclass4_Details();
      obj.a1();

      I am approaching in the above way to do database interaction. Am I approaching i the right direction ?

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      abcurl wrote:

      Am I approaching i the right direction ?

      I suspect not, but it is difficult to understand what you are trying to achieve. The only thing I would say is that this looks extremely complicated; are you sure you need so many classes and interfaces?

      MVP 2010 - are they mad?

      A 1 Reply Last reply
      0
      • L Lost User

        abcurl wrote:

        Am I approaching i the right direction ?

        I suspect not, but it is difficult to understand what you are trying to achieve. The only thing I would say is that this looks extremely complicated; are you sure you need so many classes and interfaces?

        MVP 2010 - are they mad?

        A Offline
        A Offline
        abcurl
        wrote on last edited by
        #3

        I am trying to do database interaction using the factory pattern. Please help

        L 1 Reply Last reply
        0
        • A abcurl

          Project 1 I have four classes class1 this contains the variables, properties and constructors suppose

          private string abc;

          Interface2 This contains interfaces

          void a1();

          class3 this will have function definitions. basically this will contains functions to do the database interactions

          public void a1()
          {
          // code.....
          }

          class4 this will inherit Interface 2 and will override the definition.

          public void a1()
          {
          class3 a = new class3();
          a.a1();
          }

          Project 2 class5 this will have function

          public static Interface2 Getclass4_Details()
          {
          return new class4();
          }

          Project 3 In the form button click i am doing

          Interface2 Obj = null;
          Obj = project2.class5.Getclass4_Details();
          obj.a1();

          I am approaching in the above way to do database interaction. Am I approaching i the right direction ?

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          It's not immediately clear to me why you need class4 as well as class3. What value do you gain by having class4 in there instead of having class3 implement interface 2? Class 4 seems to do nothing but bucket-pass calls straight on to class 3. By the way, better names might make the example a bit easier to understand.

          A 1 Reply Last reply
          0
          • D David Skelly

            It's not immediately clear to me why you need class4 as well as class3. What value do you gain by having class4 in there instead of having class3 implement interface 2? Class 4 seems to do nothing but bucket-pass calls straight on to class 3. By the way, better names might make the example a bit easier to understand.

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

            Reason - I am implementing the multiple inheritence concept in class4 by overriding the function

            D 1 Reply Last reply
            0
            • A abcurl

              I am trying to do database interaction using the factory pattern. Please help

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              I would suggest looking at some of the links here[^]. It is not a simple matter of a few lines of code, you will need to study the subject in some depth to get a workable solution.

              MVP 2010 - are they mad?

              1 Reply Last reply
              0
              • A abcurl

                Reason - I am implementing the multiple inheritence concept in class4 by overriding the function

                D Offline
                D Offline
                darkelv
                wrote on last edited by
                #7

                Both classes are in the same assembly, I too see no point in having class4 there, btw i think you should subclass Class3 instead of creating a new instance in the function in class4.

                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