Ir ko piedavat Posted July 31, 2007 Report Posted July 31, 2007 <?php define ('KOLEKTIVS', 'SIA Ustum'); define ('VIETA', 'Rigas centrs'); class Programmer extends Employee { public function isValid () { require 'Javascript.js'; require 'Database.sql'; } public function apply () { $to = 'gribustradat@ustum.lv'; $subject = 'Programmetaja vakance'; mail($to, $subject, $this->programmer_description); } } if(is_readable($this)){ $Person = new Programmer; $Person->apply(); if($Person->isValid()){ JobInterview(); } }else{ ReadManual(); } ?>
Ir ko piedavat Posted July 31, 2007 Author Report Posted July 31, 2007 Varbut ir versijas ka uzlabot/optimizet kodu? :)
black Posted July 31, 2007 Report Posted July 31, 2007 Nuja :) 1) metodes, kas saakas ar is(isValid, isEnabled, etc) parasti atgriez boolean. Include tur galiigi neiederas. 2) esmu pieradis pie Java naming convention. Tas nozīmē, ka metodes/variabljus atdala ar lielajiem burtiem, nevis underscore (isValid(), nevis is_readable(), $programmer->programmerDescription, nevis $programmer->programmer_description. Citādi dažādās vietās tiek izmantoti dažādi 'naming convention'. 3) Un $programmer->programmer_description vajadzētu būt $programmer->description, jo skaidrs, ka description attiecas uz programmeri, nevis uz sazin ko veel. 4) metode JobInterview() mosh vajag rakstīt ar mazo burtu (ti, jobInterview()). Klasēm lai paliek lielais sākuma burts 5) jobInterview() vajadzeetu padot arii $programmer objektu
dmitriy Posted July 31, 2007 Report Posted July 31, 2007 (edited) black, 1. Saja gadijuma tas ir obligati, jo metode neko neatgriez prieks is_readable, bet gadijuma ja nepietiek zinasanu, mes nomirtu uz require 2. nak laikam no: http://lv.php.net/manual-lookup.php?pattern=is_〈=en ;) 5. tas jau attiecas uz new Job :) Edited July 31, 2007 by dmitriy
Ir ko piedavat Posted July 31, 2007 Author Report Posted July 31, 2007 epastu lasam? :) uz ko attiecas tas jautajums? :) darba dienas mailu parbaudu ~15,32 reizes :)
v3rb0 Posted August 1, 2007 Report Posted August 1, 2007 (edited) black, kā šitais vairants :) define ('KOLEKTIVS', 'SIA Ustum'); define ('VIETA', 'Rigas centrs'); class Programmer extends Employee { public function isValid () { return @include('Javascript.js') && @include('Database.sql'); } public function apply () { $to = 'gribustradat@ustum.lv'; $subject = 'Programmetaja vakance'; mail($to, $subject, $this->description); } } $me = new Programmer(); if(isAvailable($me) && $me -> isValid()) { $me->apply(); Ustum::jobInterview($me); } edit: burtiņi edit2: isValid() edit3: isValid() otro reiz Edited August 1, 2007 by v3rb0
black Posted August 1, 2007 Report Posted August 1, 2007 (edited) doma nav slikta :) Edited August 1, 2007 by black
andrisp Posted August 1, 2007 Report Posted August 1, 2007 To isValid vajag savādāk: :) public function isValid () { if (@include('Javascript.js') && @include('Database.sql')) { return true; } return false; }
bubu Posted August 1, 2007 Report Posted August 1, 2007 A kam tur if's? public function isValid () { return @include('Javascript.js') && @include('Database.sql'); }
dmitriy Posted August 1, 2007 Report Posted August 1, 2007 (edited) Grey_Wolf, dažu iemeslu dēļ ;) viena no tām, man tagad ir kas darāms Edited August 1, 2007 by dmitriy
Kaklz Posted August 2, 2007 Report Posted August 2, 2007 Iesākumam par ļaunu nenāktu nodefinēt arī Employee klasi ;)
cilveks Posted August 2, 2007 Report Posted August 2, 2007 Pie JobInterview() met exception'us, vajag noķert. Pēc dzīvē "pieredzētā" spriežu.
Recommended Posts