Jump to content
  • 0

жду критики


crautcher
 Share

Question

и стоит ли разбить метод на более мелкии составные части , дабы улучшить конструктивность?


<?php
function Hear($msg) #Обрабатывает сообщение и отправляет юзeру Ответ + вопрос
{

$this -> SetMinds('Со мной что то не тaк !'); //задаём ответ который не должен появится , если появится - действительно чтото не так
if (!$this -> SeakOrNot()); //проверка готовности к работе
if (!$this-> AdminCommands($msg)) //Не является ли текст командой
$this->GenerateAnswer($msg);//Выделяет вопрос из полученого сообщения или задаёт фолс

if (!$this->foundQ)
$this -> Dunno(); //Вывод сообщений когда незнаем что хотят

$answer =$this -> GetA( $this -> GetQID($this -> foundQ ) ); //получаем ответ на заданный вопрос

if (!empty($answer))
$this-> SetMinds ( $answer ); //шлем ответ юзеру
else
{
$this -> LastQuestion = $this->asked;
$this -> Dunno();
}

if ($this->LastQuestion) //если был задан вопрос в прошлом сообщении
{
$id = $this -> GetQID($this->LastQuestion); //пытаемся получить айдишник последнего вопроса
if (!empty($id))
{
$answer = GetAnswer($msg); //выделяем ответ на вопрос из сообщения
if ($answer != '')
{
if (!($this -> sql -> query("select text from answers where text='".$answer."' AND questionId = '".$id."' ")))
$this->AddA($answer,$id); //добавляем ответ если такого нет
}
}
}

$this->LastQuestion= $this -> GenerateQuestion(); //спрашиваем юзера
$this -> SendMind( $this->LastQuestion );

}

?>

Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

crautcher, ты оригинал :) выдрал метод из класса и предлагаешь нам что? :)

еслиб я все класы которые используются сюда выложил , никтоб даже и не подумал смотреть всю эту кучу кода ... :)

Link to comment
Share on other sites

  • 0

а ты думаешь сейчас понятно что все эти методы и свойства делают? Да и просто не понятно что ты хочешь услышать..

ну я коменты писал для этого . Что услышать ? Ну незнаю , вы же тут все люди с опытом , указать на недостатки. ладно в топку тему

Link to comment
Share on other sites

  • 0

самое первое что ты мог бы услышать кроме моих претензий, это стиль и подход написания. А так как он у всех свой и разный, то тут получилось бы не ответ на вопросы, а спор "у кого ... больше" :)

Edited by Gold Dragon
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy