TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Describe yourself as a programming object

7 pointsby nextmoveoneover 17 years ago
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:<p>&#60;?php<p>class Auston {<p>function Auston(){ //basic stats $age = 21; $experience = 2.5; $knowsajax = true; $knowssemantichtml = true; $knowscss = true; $phone = '944-870-6259'; $email = 'auston.bsen@gal.cm'; }<p><pre><code> 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-&#62;google($skill); $query-&#62;storeIntoDB($relatedinfo); } elseif(isset($language)){ $relatedinfo = $query-&#62;google($skill); $query-&#62;storeIntoDB($relatedinfo); $readbook = $buybook-&#62;fromborderson($relatedinfo); $query-&#62;storeIntoDB($readbook); } else{ return false; } } function multitask($arrayofupto5tasks){ //I can easily manage 3-5 small tasks $i = 0; foreach ($arrayofupto5tasks as $value){ $query-&#62;storeIntoDB($value); $execute-&#62;task($arrayofupto5tasks[$i]); $i++ } } function deliverProjectIn($time){ $deliverytime = $time/3; $execute-&#62;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.'); } </code></pre> }<p>?&#62;

4 comments

neilkover 17 years ago
One morning, when Gregor Samsa woke from troubled dreams, he found himself<p>transformed in his bed into a PHP class. He lay between clumsy pointed <p>brackets, and if he lifted his head a little he could see his soft-referenced <p>underbelly, poorly indented and divided into giant blocks with redundant loops <p>and parallel data structures. The tests were hardly able to cover it and seemed<p>ready to slide off any moment. His many built-ins, pitifully feeble compared <p>to the bloated code they had to support, thrashed about helplessly <p>as he looked.
评论 #86677 未加载
评论 #86571 未加载
jgrahamcover 17 years ago
1. Your constructor has its entire contents commented out.<p>2. You should remove the $i in the function multitask(). You don't need it because the foreach is storing $arrayofupto5tasks[$i] in $value.<p><pre><code> function multitask($arrayofupto5tasks){ //I can easily manage 3-5 small tasks $i = 0; foreach ($arrayofupto5tasks as $value){ $query-&#62;storeIntoDB($value); $execute-&#62;task($arrayofupto5tasks[$i]); $i++ } } </code></pre> 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.<p>4. Your learn() function returns false in one case and doesn't return anything in others.
评论 #86575 未加载
评论 #86647 未加载
marcusover 17 years ago
I can't, it is considered bad form to write up a god object.
评论 #86567 未加载
ickyover 17 years ago
def icky(should_be_hacking=True):<p><pre><code> try: while should_be_hacking: yc.news.read() yc.news.post(inane=True) except IOError: grumble() hack() </code></pre>