Teach you how to create a keyword matching Project (search engine) ---- 18th days, teach you how to do 18th days. Teach you how to create a keyword matching Project (search engine) ---- 18th days, teach you how to do 18th days and 18th days. Objective: what kind of hacker form artifacts have gone through: database experts teach you how to do keyword matching projects (search engines) ---- 18th days, teach you how to do 18th days
18th days
Guest string: Hacker form artifact
Those things we 've gone through: Database things
Start point: Teach you how to create a keyword matching Project (search engine) ---- day 1
Review: experts teach you how to perform keyword matching projects (search engines)-17th days
When talking about the code handed over by Shuai to the boss, he experienced a large number of Shuai and he really felt wronged.
From the perspective of the technical director, do the technical director really need to read the supervision code?
I remember that many companies advocate benefits, and the benefits serve as a measure of the value of a technical director.
Is the technical director wrong? Is it out of his duty range?
In fact, the boss saw that the exec method in the LinklistCharListHandle class had three levels of foreach, so he gave the handsome guy a batch.
Better than the boss, or the boss has higher expectations for the handsome boy.
He tried to extract the foreach as much as possible:
class LinklistCharListHandle extends CharListHandle { public function exec(){ $sql = "select word from category_linklist where cid='$this->selectorItem->cid'"; $linklist = DB::makeArray($sql); foreach($linklist as $strWords){ $words = explode(",",$strWords); $this->propertiesTransferCharlist($words); } } public function propertiesTransferCharlist($linkWords){ $properties = $this->selectorItem->getProperties(); foreach($properties as $property){ $this->charlist->addCore($property->value); if(in_array($property->value,$linkWords)){ $this->addCores($linkWords); } } } public function addCores($words){ foreach($words as $char){ $this->charlist->addCore($char); } }}
Shuai extracted two methods to make the program more understandable.
In fact, Shuai's approach is to use refactoring-one of the skills to improve the design of existing code, Extract Method to Extract functions.
Extract Method: Put this code into an independent function and let the function name parse the function's purpose.
Shuai has a sense of accomplishment. when he continued to give the code to the boss, he mentioned two points.
1. Why does propertiesTransferCharlist accept parameters.
2. addCores is the responsibility scope of that class.
He knows how to do the 2nd types of data. he moves the method to the Charlist class and the code is as follows:
core)) $this->core[] = $char; } public function addCores($words){ foreach($words as $char){ $this->addCore($char); } } public function getCore(){ return $this->core; } public function addBlacklist($char){ if(!in_array($char,$this->blacklist)) $this->blacklist[] = $char; } public function getBlacklist(){ return $this->blacklist; }}
In fact, Shuai's practice is to use refactoring-one of the skills to improve the design of existing code, the Move Method moving function.
Move Method: create a new function with similar behavior in the class most commonly referenced by this function. Convert the old function into a pure delegate function, or remove the old function completely.
I really don't know what to do with 1st of them. I went to consult with the boss. The boss gave the code to Shuai, and the boss's code was:
propertiesTransferCharlist(); } public static function linklist($cid){ if(!isset(self::$linklist) || !isset(self::$linklist[$cid]) || self::$linklist[$cid] == null){ $sql = "select word from category_linklist where cid='$cid'"; self::$linklist[$cid] = DB::makeArray($sql); } return self::$linklist[$cid]; } public function propertiesTransferCharlist(){ $properties = $this->selectorItem->getProperties(); foreach($properties as $property){ $this->charlist->addCore($property->value); $this->extendCharlist($property->value); } } public function extendCharlist($char){ $linklist = self::linklist($this->selectorItem->cid); foreach($linklist as $strWords){ $words = explode(",",$strWords); if(in_array($char,$words)){ $this->charlist->addCores($words); } } } }
Shuai looked at it and made a sigh. The original code was changed at will, and the difference was so big that it never felt like this before.
Shuai really hopes that he can find the boss on his own without having to go to the boss every day.
NLP (search engine) ---- 18th days, teach you to do 18th days 18th days guest string: The hacker form artifacts walk through those things: database...