Design Patterns in Simple Examples

Discussion in 'Engineering Concepts' started by shabbir, Jul 5, 2007.

  1. yogeshchaudhari

    yogeshchaudhari New Member

    Joined:
    May 28, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hello Shabbir,

    You explanined it the way it should be. But, I think the zip file is corrupted. I did several attempts of download and found that zip is not getting downloaded completely. Can you please upload it once again.

    Yogesh
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    No and I again downloaded it and extracted it. Works fine for me. I am not sure how can I send you so many files without zipping them.
     
    xpertprogrammer likes this.
  3. johngate2100

    johngate2100 New Member

    Joined:
    Aug 11, 2010
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    Home Page:
    http://www.printingblue.com/
    This is very nice post and helpful for other people.
     
  4. dhanoopnambiar

    dhanoopnambiar New Member

    Joined:
    Aug 29, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
  5. mcc_prabha

    mcc_prabha New Member

    Joined:
    Sep 14, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    The Code sample zip file, seems to be having some issue. If I download, I am getting only the size 97KB and it is not archivable. Can you please check and share the zip file again.
     
  6. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    I tried downloading it once again now and it works fine for me and try it once again to see if it works. Size shown in the zip file should match your file size or else there might be some download errors.
     
    xpertprogrammer likes this.
  7. eckt

    eckt New Member

    Joined:
    Nov 22, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi!
    I'm doing all the pre work for developing a feature for a FOSS program and I need help on which design pattern to use. The feature(s) is the ability to add a range of filters to and image (like in photoshop). It has to be easily extendable as I might come up with new filters along the way but the code for applying each of these filters is largely the same (the only thing that's different is the filter values).
    Based on this do you know a design pattern that would be appropriate?
    Thanks for your help!
    -Emma
     
  8. drai82@gmail.com

    drai82@gmail.com New Member

    Joined:
    Dec 13, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    Great Article.
    I have one question. If I have to develop a IVRS, which Design Pattern should be used?
     
  9. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    The one (or combination of few) that best suits your need
     
    xpertprogrammer likes this.
  10. Hi528

    Hi528 New Member

    Joined:
    Dec 18, 2010
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Good Article...Thanks
     
  11. Nathim

    Nathim New Member

    Joined:
    Dec 9, 2010
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Really very good job Mr. shabbi
    thank U
     
  12. nsures

    nsures New Member

    Joined:
    Feb 10, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hello Shabbir,
    Excellent article, however i have trouble getting the attachment project (97 KB when i DLed) , could you please look into this

    Suresh
     
  13. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Hi suresh, I re-downloaded it and don't see any issues. If you still have issues getting the file email me and I will send you the file as an attachment.
     
    xpertprogrammer likes this.
  14. ashwinparmar

    ashwinparmar New Member

    Joined:
    May 16, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    I have solved your problem.
    -- Ashwin Parmar


    Code:
    <?php
      abstract class Control {
          abstract function Show();
       }
    
       class WinButton extends Control {
          function Show() {
             echo "I'm a WinButton: ";
          }
       }
    
       class MacButton extends Control {
          function MacButton() {
            echo "MacButton";
          }
          function Show() {
             echo "I'm an MacButton: ";
          }
       }
    
       class WinLabel extends Control {
          function Show() {
             echo "I'm a WinLabel: ";
          }
       }
    
       class MacLabel extends Control {
          function Show() {
             echo "I'm an MacLabel: ";
          }
       }
    
        abstract class GUIFactory {
          static function GetFactory() {
                if (TRUE) return new MacFactory();
                else return new WinFactory(); 
          }
          abstract function CreateButton();
          abstract function CreateLabel();
       }   
        
       class WinFactory extends GUIFactory{
            
            public function WinFactory() {
                $btn = new WinButton();
                $lbl = new WinLabel();
            }
       
            function CreateButton() {
                print_r($btn);
                return $btn;
            }
            function CreateLabel() {
                return $lbl;
            }
       }
    
       class MacFactory extends GUIFactory {
          // Its there just to have the Classdiagram going
            
          function CreateButton() {
             return new MacButton();
          }
    
          function CreateLabel() {
             return new MacLabel();
          }
       }
    
     
        $factory = GUIFactory::GetFactory(); // Return MacFactory
        $button = $factory->CreateButton();  // Return MacButton
        echo $button->Show();
        
        $label = $factory->CreateLabel();
        echo $label->Show();
        
    ?>
    
    =========================================================
     
    Last edited by a moderator: May 16, 2011
  15. ashwinparmar

    ashwinparmar New Member

    Joined:
    May 16, 2011
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    PHP:
    <?php
      
    abstract class Control {
          abstract function 
    Show();
       }

       class 
    WinButton extends Control {
          function 
    Show() {
             echo 
    "I'm a WinButton: ";
          }
       }

       class 
    MacButton extends Control {
          function 
    MacButton() {
            echo 
    "MacButton";
          }
          function 
    Show() {
             echo 
    "I'm an MacButton: ";
          }
       }

       class 
    WinLabel extends Control {
          function 
    Show() {
             echo 
    "I'm a WinLabel: ";
          }
       }

       class 
    MacLabel extends Control {
          function 
    Show() {
             echo 
    "I'm an MacLabel: ";
          }
       }

        abstract class 
    GUIFactory {
          static function 
    GetFactory() {
                if (
    TRUE) return new MacFactory();
                else return new 
    WinFactory(); 
          }
          abstract function 
    CreateButton();
          abstract function 
    CreateLabel();
       }   
        
       class 
    WinFactory extends GUIFactory{
            
            public function 
    WinFactory() {
                
    $btn = new WinButton();
                
    $lbl = new WinLabel();
            }
       
            function 
    CreateButton() {
                
    print_r($btn);
                return 
    $btn;
            }
            function 
    CreateLabel() {
                return 
    $lbl;
            }
       }

       class 
    MacFactory extends GUIFactory {
          
    // Its there just to have the Classdiagram going
            
          
    function CreateButton() {
             return new 
    MacButton();
          }

          function 
    CreateLabel() {
             return new 
    MacLabel();
          }
       }

     
        
    $factory GUIFactory::GetFactory(); // Return MacFactory
        
    $button $factory->CreateButton();  // Return MacButton
        
    echo $button->Show();
        
        
    $label $factory->CreateLabel();
        echo 
    $label->Show();
        
    ?>
     
  16. Lulugreen

    Lulugreen New Member

    Joined:
    May 23, 2011
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Nice article! It is very helpful for me! Thanks!
     
  17. r0o0cky

    r0o0cky New Member

    Joined:
    Jul 4, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Which pattern is best for an ASP.NET website with SQL server database and .NET framework 2.0, Thanks.
     
  18. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    The application of pattern depends on lot of factors and in your case the type of website you are creating. An ecommerce site in ASP and a CMS site in ASP may not have the same pattern applied.
     
    xpertprogrammer likes this.
  19. r0o0cky

    r0o0cky New Member

    Joined:
    Jul 4, 2011
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Thanks, Shabbir. I know that we have to take in account the type of application we are developing. We often hear of MVC or MVP, are these design patterns or something else.

    I wanted to know what basic pattern a new bie should follow, which is easy to maintain and work on. Or Are there some frameworks we should use.

    Mostly ASP.NET websites are developed using the code-behind page logic, or some develop interfaces implemented by the code-behind page and than pass the page instance to a controller or presenter.

    Any help from Shabir or other members, Thanks.
     
  20. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    To be honest I cannot name one pattern that every newbie should start with.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice