Chain-of-responsibility pattern and composition

Sorry for my ignorance but I am little bit confused about Chain-of-responsibility pattern and composition. Below is my code,

class ValidatorChain {      private $  validators;     public function __construct(IValidator ...$  validators)     {         $  this->validators = $  validators;     }      public function isValid(Argument $  arg): bool     {         foreach ($  this->validators as $  validator) {             if (!$  validator->isValid($  arg)) {                 return false;             };         }         return true;     } } 

What I needed is to keep multiple validation in one class and loop all the validations? Can you please suggest to improve the above code(including class name)? Can we call it Chain-of-responsibility pattern or it has any separate design name?

Loop Refactoring C# Unity

So I started learning OOs and code refactoring and decided to do some project. It just some simple quiz game.

Here are some mechanics

  • There are 3 sets

  • Each set have 8 Brands (types)

  • Each brand have 10 questions

So what I did was this

Set Class

public class Set{     public string setName;     public Brand[] brands; } 

Brand Class

public class Brand{     public string brandName;     public Question[] questions; } 

Question Class

public class Question {     public string question;     public string[] choices = new string[3];  //choices for each question     public string correctAnswer;  //will hold the correct answer for a question      public string questionID(){        // making a id for question         string qID = "";          qID += question + "|";          foreach(string choice in choices){             qID += choice + "|";         }          qID += correctAnswer + "|";          qID += fontSize;          return qID;     }  } 

So what I need is to create some kind of id for each question, what I did is this

public class QuestionManager : MonoBehaviour { public void saveToDB(){     int setID = 0;       foreach(Set set in sets){            int brandID = 0;           foreach(Brand brand in set.brands){                int questionID = 0;               foreach(Question question in brand.questions){                       string questionKey = "s" + setID + "|" + "b" + brandID + "|" + "q" + questionID;                }             brandID++;           }           setID++;       }  } } 

I’m really curious if there are some good refactoring for this kind of loop. Also I should add that I’ll be using this ids for getting the questions later.

办埃克塞特大学毕业证成绩单Q薇501058216【仿真英国文凭】修改成绩单造假英国本科学历/英国硕士学历代办英国学位证书|英国留信认证|英国使馆认证|教育部认证|国内真实可查存档The Unive

海外留学服务中心:专业代办外国文凭学历认证,QQ/微信501058216,高效办理国内\外毕业证、成绩单,包括澳洲新西兰,
加拿大,美国,英国,德国等大学学历认证(我们承诺:认证不成功退款!!!)实体公司,注册经营,质量保证,可视频看样本工艺质量,接受面谈。
一、快速办理高仿材料:
1、毕业证+成绩单+留学回国人员证明+教育部学历认证(全套留学回国必备证明材料,给父母及亲朋好友一份完美交代);
2、雅思、托福,OFFER,在读证明,学生卡等留学相关材料(申请学校、转学,甚至是申请工签都可以用到)。
注:上述高仿材料,随时都可以安排办理,毕业证成绩单,学校,专业,学位,毕业时间都可以根据客户要求安排。
二、办理流程:
1、收集客户办理信息;
2、客户付定金下单;
3、公司确认到账转制作点做电子图;
4、电子图做好发给客户确认;
5、电子图确认好转成品部做成品;
6、成品做好拍照或者视频确认再付余款;
7、快递给客户(国内顺丰,国外DHL)。
三、真实网上可查的证明材料
1、教育部学历学位认证,留服官网真实存档可查,永久存档。…

办埃克塞特大学毕业证成绩单Q薇501058216【仿真英国文凭】修改成绩单造假英国本科学历/英国硕士学历代办英国学位证书|英国留信认证|英国使馆认证|教育部认证|国内真实可查存档The Unive

CSS Help

Hello all,

I have recently started coding and have found myself to be good at HTML but CSS I struggle. If anybody would be able to help me… | Read the rest of http://www.webhostingtalk.com/showthread.php?t=1735370&goto=newpost

Best way of writing PHP, progressing & acquiring simple inputs & outputs

As my first simple PHP project, I’ve created a simple project that allows you to just enter your name and two numbers, where it displays them on the page and stores them in a database. It consists of 3 files: index.php, db.php & process.php. I wonder whether I have created the code efficiently.

I’m curious about all the talk behind procedural PHP vs PDO. I initially used some deprecated PHP5 functions and was corrected by the stack overflow community, but this has left me confused as to what specifically I should learn with PHP as a beginner. It sounds like procedural and PDO are very different, and that I should only pick one and learn that.

So my questions are as follows:

  1. Is the coding in my project acceptable?
  2. Is it similar to how most PHP projects are built? (i.e. are most procedural or PDO)
  3. What should I learn as a beginner? (procedural or PDO?)
  4. Do you have any beginner advice?

Any advice here would be very much appreciated as I’m new to PHP. Thanks for any help here. The files and code (excluding HTML & CSS) are below:

index.php:

<?php include 'db.php'; ?>  <?php // Fetch data from db $  query = mysqli_query($  con, 'SELECT * FROM data'); ?>  <!-- create a loop (while there are results in the DB, spit them out) -->             <?php while ($  row = $  query->fetch_assoc()) : ?>                 <li><?php echo $  row['t_name'] ?> entered <?php echo $  row['t_firstNo'] ?> and <?php echo $  row['t_secondNo'] ?> (result =                      <?php                         $  first = $  row['t_firstNo'];                         $  second = $  row['t_secondNo'];                         $  result = $  first * $  second;                         echo $  result;                     ?>)</li>             <?php endwhile ?>  <!-- if bad input, get & display error -->             <?php if(isset($  _GET['error'])) : // if error variable is there ?>                 <?php echo $  _GET['error']; // get the error ?>             <?php endif ?> 

db.php:

<?php  // Connect $  con = mysqli_connect("localhost", "tnnick", "PHPprojects", "timesNumbers");  // Test Connection if (mysqli_connect_errno()) {     echo 'Failed: '.mysqli_connect_error(); }  ?> 

process.php:

<?php include 'db.php' ; ?>  <?php     if(isset($  _POST['submit'])) { // if form submitted         $  nickname = mysqli_real_escape_string($  con, $  _POST['nickname']); // get the inputs         $  firstNo = mysqli_real_escape_string($  con, $  _POST['firstNo']);         $  secondNo = mysqli_real_escape_string($  con, $  _POST['secondNo']);     } ?>  <?php // validate inputs if(!isset($  nickname) || $  nickname=='' || !isset($  firstNo) || $  firstNo=='' || !isset($  secondNo) || $  secondNo=='' ) {     // if invalid input, send error to index.php     $  error = 'Bad input - try again.'; // create error message     header("Location: index.php?error=".urlencode($  error)); // attach to URL & send to index.php     exit(); } else {     // insert into DB     $  putIntoDB = "INSERT INTO data (t_name, t_firstNo, t_secondNo) VALUES ('$  nickname','$  firstNo','$  secondNo')";      // check it inserted     if(!mysqli_query($  con, $  putIntoDB)) {         die('Error');     } else {         header("Location: index.php");         exit();     } } ?>