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. Use of design??

Use of design??

Scheduled Pinned Locked Moved C#
csharpdesignxmltutorialquestion
12 Posts 5 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.
  • S Offline
    S Offline
    sujithkumarsl
    wrote on last edited by
    #1

    Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass

    class BaseFileClass
    {
    protected void ProcessFile();
    }

    Then the derived classes

    class XMLClass : BaseFileClass
    {
    public override void ProcessFile()
    {
    //Process XML File
    }
    }

    class CSVCLass: BaseFileClass
    {
    public override void ProcessFile()
    {
    //Process CSV File
    }
    }

    class ExcelClass: BaseFileClass
    {
    public override void ProcessFile()
    {
    //Process Excel File
    }
    }

    On the main

    Base b = null;
    if( isXMl)
    {
    b = new XMLCLass();
    }
    else if( isExcel)
    {
    b = new ExcelCLass();
    }
    else if( isCSV)
    {
    b = new CSVCLass();
    }

    b.ProcessFile();

    What are the uses of this kind of a design??

    My small attempt...

    P Y T A 4 Replies Last reply
    0
    • S sujithkumarsl

      Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass

      class BaseFileClass
      {
      protected void ProcessFile();
      }

      Then the derived classes

      class XMLClass : BaseFileClass
      {
      public override void ProcessFile()
      {
      //Process XML File
      }
      }

      class CSVCLass: BaseFileClass
      {
      public override void ProcessFile()
      {
      //Process CSV File
      }
      }

      class ExcelClass: BaseFileClass
      {
      public override void ProcessFile()
      {
      //Process Excel File
      }
      }

      On the main

      Base b = null;
      if( isXMl)
      {
      b = new XMLCLass();
      }
      else if( isExcel)
      {
      b = new ExcelCLass();
      }
      else if( isCSV)
      {
      b = new CSVCLass();
      }

      b.ProcessFile();

      What are the uses of this kind of a design??

      My small attempt...

      P Offline
      P Offline
      PIEBALDconsult
      wrote on last edited by
      #2

      I think that would be the, "I don't know the Abstract Factory Pattern Pattern".

      S 1 Reply Last reply
      0
      • P PIEBALDconsult

        I think that would be the, "I don't know the Abstract Factory Pattern Pattern".

        S Offline
        S Offline
        sujithkumarsl
        wrote on last edited by
        #3

        hi Thanks for the update... do not misunderstand my intention.. i am not asking about design patterns, but what is the exact use of this kind of design?

        My small attempt...

        P 1 Reply Last reply
        0
        • S sujithkumarsl

          hi Thanks for the update... do not misunderstand my intention.. i am not asking about design patterns, but what is the exact use of this kind of design?

          My small attempt...

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          You might as well read up on that pattern while you wait for more responses.

          1 Reply Last reply
          0
          • S sujithkumarsl

            Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass

            class BaseFileClass
            {
            protected void ProcessFile();
            }

            Then the derived classes

            class XMLClass : BaseFileClass
            {
            public override void ProcessFile()
            {
            //Process XML File
            }
            }

            class CSVCLass: BaseFileClass
            {
            public override void ProcessFile()
            {
            //Process CSV File
            }
            }

            class ExcelClass: BaseFileClass
            {
            public override void ProcessFile()
            {
            //Process Excel File
            }
            }

            On the main

            Base b = null;
            if( isXMl)
            {
            b = new XMLCLass();
            }
            else if( isExcel)
            {
            b = new ExcelCLass();
            }
            else if( isCSV)
            {
            b = new CSVCLass();
            }

            b.ProcessFile();

            What are the uses of this kind of a design??

            My small attempt...

            Y Offline
            Y Offline
            yu jian
            wrote on last edited by
            #5

            In some manage system, this design pettern can be used. For example, according to the type of the login account to new the object. The normal user, manager.

            P 1 Reply Last reply
            0
            • S sujithkumarsl

              Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass

              class BaseFileClass
              {
              protected void ProcessFile();
              }

              Then the derived classes

              class XMLClass : BaseFileClass
              {
              public override void ProcessFile()
              {
              //Process XML File
              }
              }

              class CSVCLass: BaseFileClass
              {
              public override void ProcessFile()
              {
              //Process CSV File
              }
              }

              class ExcelClass: BaseFileClass
              {
              public override void ProcessFile()
              {
              //Process Excel File
              }
              }

              On the main

              Base b = null;
              if( isXMl)
              {
              b = new XMLCLass();
              }
              else if( isExcel)
              {
              b = new ExcelCLass();
              }
              else if( isCSV)
              {
              b = new CSVCLass();
              }

              b.ProcessFile();

              What are the uses of this kind of a design??

              My small attempt...

              T Offline
              T Offline
              T M Gray
              wrote on last edited by
              #6

              You designed it. If you don't know what it is for throw it away and start over.

              S 1 Reply Last reply
              0
              • Y yu jian

                In some manage system, this design pettern can be used. For example, according to the type of the login account to new the object. The normal user, manager.

                P Offline
                P Offline
                PIEBALDconsult
                wrote on last edited by
                #7

                That's not a design pattern... but it almost is.

                Y 1 Reply Last reply
                0
                • T T M Gray

                  You designed it. If you don't know what it is for throw it away and start over.

                  S Offline
                  S Offline
                  sujithkumarsl
                  wrote on last edited by
                  #8

                  Instead telling this kind of comments let me know this thing.. My intention is to know 'all the advantages' of this kind of a design... I guess the following please add if you know anymore 1) the implementation of different file type class can be isolated to separate class 2) i can simply add a new file type into this system 3) There wont be any change in obj.ProcessFile() as it is a base pointer. Pls add more to this

                  My small attempt...

                  P T 2 Replies Last reply
                  0
                  • S sujithkumarsl

                    Instead telling this kind of comments let me know this thing.. My intention is to know 'all the advantages' of this kind of a design... I guess the following please add if you know anymore 1) the implementation of different file type class can be isolated to separate class 2) i can simply add a new file type into this system 3) There wont be any change in obj.ProcessFile() as it is a base pointer. Pls add more to this

                    My small attempt...

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #9

                    True, except maybe for 2. You may want to use plug-ins if you want a lot of flexibility.

                    1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      That's not a design pattern... but it almost is.

                      Y Offline
                      Y Offline
                      yu jian
                      wrote on last edited by
                      #10

                      What is your means?

                      1 Reply Last reply
                      0
                      • S sujithkumarsl

                        Can anybody tell the exact use of design/design patterns in C#. Let me come with an example, i am designing a software for processing different type of input files. My design will be like this. I will have a baseclass

                        class BaseFileClass
                        {
                        protected void ProcessFile();
                        }

                        Then the derived classes

                        class XMLClass : BaseFileClass
                        {
                        public override void ProcessFile()
                        {
                        //Process XML File
                        }
                        }

                        class CSVCLass: BaseFileClass
                        {
                        public override void ProcessFile()
                        {
                        //Process CSV File
                        }
                        }

                        class ExcelClass: BaseFileClass
                        {
                        public override void ProcessFile()
                        {
                        //Process Excel File
                        }
                        }

                        On the main

                        Base b = null;
                        if( isXMl)
                        {
                        b = new XMLCLass();
                        }
                        else if( isExcel)
                        {
                        b = new ExcelCLass();
                        }
                        else if( isCSV)
                        {
                        b = new CSVCLass();
                        }

                        b.ProcessFile();

                        What are the uses of this kind of a design??

                        My small attempt...

                        A Offline
                        A Offline
                        Alan Balkany
                        wrote on last edited by
                        #11

                        The main advantage is that you can treat XML and CSV files in the same way. By processing both types as BaseFileClass, you can use the same code for handling both subclasses. This is a type of code reuse. It also makes the higher-level processing simpler, since it's independent of the details of your derived classes.

                        1 Reply Last reply
                        0
                        • S sujithkumarsl

                          Instead telling this kind of comments let me know this thing.. My intention is to know 'all the advantages' of this kind of a design... I guess the following please add if you know anymore 1) the implementation of different file type class can be isolated to separate class 2) i can simply add a new file type into this system 3) There wont be any change in obj.ProcessFile() as it is a base pointer. Pls add more to this

                          My small attempt...

                          T Offline
                          T Offline
                          T M Gray
                          wrote on last edited by
                          #12

                          A design should be evaluated based on how well it solves the problem. Without stating the exact problem you are trying to solve you can't know the advantages of one design over another. You also don't give an alternative design. Without an alternative to compare it against it has no advantage or disadvantage. What is the advantage of an orange? If the problem to solve is driving a nail and the alternative is a hammer there is no advantage. If the problem to solve is vitamin C intake and the alterntiave is a multi-vitamin, the advantages are taste and refreshment.

                          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