4 ms·
Describe yourself as a programming object
I was looking at craigslist posting for a job and it asked me to program myself as a php class. I thought this was cool and wanted to see if any YCer's wanted to give it a try. Here is me:
<?php
class Auston {
function Auston(){
//basic stats
$age = 21;
$experience = 2.5;
$knowsajax = true;
$knowssemantichtml = true;
$knowscss = true;
$phone = '944-870-6259';
$email = 'auston.bsen@gal.cm';
}
function beCreative($input){
//Does defining myself as an object constitute creativity?
$output = $input.rand($ideas, $thoughts);
return $output;
}
function learn($skill, $language){
//I love learning new things
if(isset($skill)){
$relatedinfo = $query->google($skill);
$query->storeIntoDB($relatedinfo);
}
elseif(isset($language)){
$relatedinfo = $query->google($skill);
$query->storeIntoDB($relatedinfo);
$readbook = $buybook->fromborderson($relatedinfo);
$query->storeIntoDB($readbook);
}
else{
return false;
}
}
function multitask($arrayofupto5tasks){
//I can easily manage 3-5 small tasks
$i = 0;
foreach ($arrayofupto5tasks as $value){
$query->storeIntoDB($value);
$execute->task($arrayofupto5tasks[$i]);
$i++
}
}
function deliverProjectIn($time){
$deliverytime = $time/3;
$execute->projectIn($deliverytime);
//that was a joke
}
function beAtWorkBy($time){
$wakeup = $time+3600;
$drivetowork = $wakeup+1800;
$gettowork = $drivetowork+1800;
//that was a joke
}
function showDemo(){
$arrayofsites = array('http://www.nextmoveinc.com/ycomb/heom_demo.html ', 'http://www.investorscrystalball.com', 'http://www.expeditedtravel.com/call-center/index.html' );
$site = rand(0,2);
header('Location :'.$site.');
}
}
?>
- jgrahamc 19y ago1. Your constructor has its entire contents commented out. 2. You should remove the $i in the function multitask(). You don't need it because the foreach is storing $arrayofupto5tasks[$i] in $value. function multitask($arrayofupto5tasks){ //I can easily manage 3-5 small tasks $i = 0; foreach ($arrayofupto5tasks as $value){ $query->storeIntoDB($value); $execute->task($arrayofupto5tasks[$i]); $i++ } } 3. It's disappointing that your showDemo() function has a hard coded number 2 in it ($site = rand(0,2);) since you could get that from the array length. And also the header() bit has an extra ' in it. 4. Your learn() function returns false in one case and doesn't return anything in others.
- deleted 19y ago[deleted]
- nextmoveone 19y agoi was hoping someone would do this... 1.the constructor isnt commented out in text mate, or dreamweaver just here(yc). 2.i need the $i cause i store the task into the db then execute it. 3. i could have done that, and it would scale. but i didnt cause i only have 3 demos. you are probably right about the extra ' 4. need to review it, im on my phone right now
- jgrahamc 19y ago1. I wondered if that might be the case. 2. I don't understand this explanation, is $value destroyed by the call to storeIntoDB? At the very least your $i++ needs a terminating ;
- nextmoveone 19y agoyou are right! i should have went with a while loop
- neilk 19y agoOne morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a PHP class. He lay between clumsy pointed brackets, and if he lifted his head a little he could see his soft-referenced underbelly, poorly indented and divided into giant blocks with redundant loops and parallel data structures. The tests were hardly able to cover it and seemed ready to slide off any moment. His many built-ins, pitifully feeble compared to the bloated code they had to support, thrashed about helplessly as he looked.
- deleted 19y ago[deleted]
- darose 19y agoLOL!!! I guess I'm the only one who got the ref. (For all you uncultured lamers: http://en.wikipedia.org/wiki/The_metamorphosis http://en.wikipedia.org/wiki/The_metamorphosis) :-)
- marcus 19y agoI can't, it is considered bad form to write up a god object.
- wlievens 19y agoI almost laughed out loud at this. At work :-)
- icky 19y agodef icky(should_be_hacking=True): try: while should_be_hacking: yc.news.read() yc.news.post(inane=True) except IOError: grumble() hack()