title: Which programming design pattern would suit this project?
body: <p>Hello I'm looking for some guidance in choosing a programming design pattern to fit my current project.</p>
  
  <p>I'm been trying for months to find a nice project to start using patterns properly and a little project I've just started seems to provide the perfect platform to learn from. </p>
  
  <p>Basically I'm creating a Telegram Bot that will respond to users commands. That's not the part I'm having problems with, it's how best to structure my code so that adding new commands is clean and well structured.</p>
  
  <p>I don't need anyone to write any code for me, but is there a design pattern I could implement that would suit?</p>
  
  <p>Here's what I'm currently doing in puesudo (BTW I'm using Laravel) code:</p>
  
  <pre><code>//routes.php
  
    Route::post('inbound', ['uses' =&gt; 'inboundController@marshall']);
  
  
  
   //inboundController.php
  
     public function marshall($inboundMessage){
  
      //Extract the command from the inbound message eg "start"
      $command = extractfromtext($text);
  
      //Get the user id from the person who sent the message
      $userID = extractIdfromtext($text);
  
      //Compare the command in a switch statement
  
      switch ($command){
  
      case (start):
          return $result = new commandStart($userID)-&gt;fire();
          break;
      case (demo):
          return $result = new commandDemo($userID)-&gt;fire();
          break;
      case (another):
          return $result = new commandAnother($userID)-&gt;fire();
          break;
      default:
         break;
  
      }
  
     } 
  
  
  //Each command has it's own class:
  //Class commandStart
  
     public function __construct($userID){
         $this-&gt;userID = $userID
     }
  
     publin fuction fire(){
  
       //send a picture to the userID
  
     }
  
  
  
  //Class commandDemo
  
     public function __construct($userID){
         $this-&gt;userID = $userID
     }
  
     publin fuction fire(){
  
       //send a message to the userID
  
     }
  
  
  
  //Class commandAnother
  
     public function __construct($userID){
         $this-&gt;userID = $userID
     }
  
     publin fuction fire(){
  
       //send a video to the userID
  
     }
  </code></pre>
  
  <p>This works fine, but I feel that </p>
  
  <ul>
  <li>I'm repeating a lot of code (bad)</li>
  <li>Adding new commands means editing the "inbound class" file continuously. I think this breaks the open closed principle in SOLID.</li>
  <li>The switch statement has a "code smell" to me.</li>
  </ul>
  
  <p>I get very confused by all the names of the different type of patterns. Would someone advise me, which one would suit this scenario? I'm very happy to go and research  about it and how it's implemented, but I don't want to go off on a goose chase and pick an unsuitable one because I don't know any better!</p>
  
  <p>Thank you.</p>
  
  <hr>
  
  <p>Edit: It seems in my attempt to make the problem generic I made it too obtuse. I am already using MVC with Larvel. That is not the problem <em>I think</em> - I would like to know which design pattern would allow me to add more commands easily and cleanly - hopefully not having to use a switch statement.</p>
  
  <p>After reading some of the replies, I think I'm starting to get the idea of what to do. Out of interest - is the structure suggested below an actual design pattern or just good structured code?</p>