TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Addition of 1 and 1 in PHP

158 点作者 gcmalloc大约 12 年前

29 条评论

jonascopenhagen大约 12 年前
Pretty much sums up how I feel about most of the big frameworks (Zend in particular, but also Symfony and CakePHP).<p>The problem of over-engineering isn't just related to the big PHP frameworks - the same problem exists in Python and Ruby.<p>At its core, web development is about taking some user input, validating it, throwing it in a database, and displaying it again (perhaps slightly modified) to users. That's a fairly simple concept, and frameworks should reflect that.
评论 #5348954 未加载
评论 #5348601 未加载
评论 #5349275 未加载
评论 #5348653 未加载
评论 #5349554 未加载
评论 #5348790 未加载
flatline大约 12 年前
The only flaw I can see is that the string literal '1' should have been declared as a const somewhere, preferably in another unrelated library, and called something like 'UNITY_VALUE'.
评论 #5348854 未加载
评论 #5349436 未加载
Mahn大约 12 年前
Reminds me of something I wrote a few months ago on how to detect negative numbers: <a href="http://stackoverflow.com/a/11910993/1329367" rel="nofollow">http://stackoverflow.com/a/11910993/1329367</a> but obviously the one above has much more value add and follows better design patterns.
评论 #5348530 未加载
评论 #5349808 未加载
seanp2k2大约 12 年前
I opened a few bugs to help get this library in a more usable state. I'd really love to see a SOAP API on this as well as result templating, a request router, and a controller.<p>It may also be useful to include a message queue (RabitMQ / SQS are good candidates) implemented using the pub/sub model to allow arbitrary scaling of the compute nodes.<p>I have some other ideas about something like JMX / MBeans here to allow arbitrary instrumentation of methods. This would provide more flexibility than the benchmarking module already included.
laurent123456大约 12 年前
It reminds me of a Zend Framework project I'm maintaining, where the previous dev apparently tried to apply any OOP pattern they've ever head about.<p>To get anything from the db, one needs to get a "service locator" (just a dumb global object but with a cooler name) that will parse a namespace and returns a repository that will call a mapper, which in turn will instantiate an entity, which somewhere deeps in the Zend Framework is going to run an SQL query (going through dozens of classes, just to make stack-traces more readable...) and, maybe, if I'm lucky, I'll actually get some usable data back.<p>Of course, adding a new table is just as much fun - dozens of modules, controllers, repositories, mappers and so on to create, and just as many configuration files to update. And, of course, if something's not quite right, good luck getting any sensible error from the framework.
neya大约 12 年前
Welcome to the enterprise world. If you are already working for a typically huge enterprise, you would have realized that this kind of coding (Engineering) is just another day at the office and people actually get paid (more) to over-engineer! Infact, anything done to reduce complexity is <i>actually</i> frowned upon, or will even get you labelled as an ignorant employee.
nadinengland大约 12 年前
The functional unit tests made me laugh: <a href="https://github.com/Herzult/SimplePHPEasyPlus/blob/master/tests/Functional/AdditionTest.php#L53" rel="nofollow">https://github.com/Herzult/SimplePHPEasyPlus/blob/master/tes...</a>
评论 #5349191 未加载
babuskov大约 12 年前
I know a couple of Java programmers that will find this helpful. Thanks.
评论 #5348426 未加载
nicholaides大约 12 年前
I'm not familiar with the PHP ecosystem. Is the author making fun something other than obvious over-engineering? Does he or she feel like that's a problem in the PHP ecosystem?<p>I'm criticizing, because it's funny. I'm just trying to figure out if theres some wisdom being conveyed that I'm missing.
评论 #5348452 未加载
评论 #5348468 未加载
评论 #5348453 未加载
sneak大约 12 年前
Oh, did someone port Twisted to PHP?
venomsnake大约 12 年前
I love it.<p>And I hope that after all the types of fad programming (that work almost as good as the fad diets) we will get to the "common sense programming" - use the proper tools and scale for the problem and don't try to fit the problem in your tools and frameworks.
zerovox大约 12 年前
The addition operator takes a collection of numbers, and add the first two? Given the lack of documentation, I find this extremely misleading and I couldn't recommend this library.
评论 #5348564 未加载
merinid大约 12 年前
This is so funny. The author's description is great on github, really fooling you at times. Even if this isn't intended as a joke, the dedication to doing something fun to prove a point got me thinking about over engineering design patterns too.
评论 #5348496 未加载
BjoernKW大约 12 年前
Hooray for enterprise software 'design patterns'.
runekaagaard大约 12 年前
What? No dependency injection framework? Pft! :)
评论 #5349384 未加载
alexvr大约 12 年前
Don't let this get too popular or people (non-HN, of course) might start using it.
michaldudek大约 12 年前
What if I need to add 2 and 1? Is there a lib for that? Or would this one need to be completely refactored?<p>Also, in what version could we expect ability to handle 2 digit (or more!) numbers?
评论 #5349382 未加载
评论 #5348534 未加载
clyfe大约 12 年前
From ZF :( <a href="https://twitter.com/_clyfe/status/265588170341625857" rel="nofollow">https://twitter.com/_clyfe/status/265588170341625857</a>
niggler大约 12 年前
While we are discussing PHP, why is the ternary operator nesting behavior different from every other mainstream language using "?" and ":" ?
评论 #5348655 未加载
评论 #5348822 未加载
评论 #5348707 未加载
评论 #5351113 未加载
lubujackson大约 12 年前
Can't recommend because of a 0 day exploit. If you add 0 you get root via SQL injection.
juskrey大约 12 年前
An example is pretty good, but I am not sure about scalability and load balancers.
评论 #5348480 未加载
lubujackson大约 12 年前
Uh oh, the LOLz have invaded Github. Pretty good one, though.
pestaa大约 12 年前
Yes this is a good joke until you realize there is no other way to get <i>some</i> level of type safety in PHP other than adding a bunch of unnecessary classes.
评论 #5348597 未加载
评论 #5348493 未加载
评论 #5348501 未加载
futhey大约 12 年前
WOW I thought I was alone all these years!
refiammingo大约 12 年前
What about subtraction now?
评论 #5349402 未加载
评论 #5348507 未加载
canibanoglu大约 12 年前
Hilarious!
jordan_clark大约 12 年前
Good one.
alexvr大约 12 年前
points += 500<p>This made my day.
camus大约 12 年前
while i get the joke , i'm sorry , but serious PHP development means bloated frameworks. You cant avoid it.<p>Frameworks code looks ugly because PHP looks ugly . But has anybody seen Rails source code ?Django's ? or even Sinatra's ? it is bloated too, but because Ruby and Python a well designed , when using them , you dont feel they are bloated.<p>That's why you end up ( in PHP ) writing yaml config files for DI, ORM , etc more than actual PHP.<p>If php looked more like Ruby or Python , using symfony 2 or ZF 2 would be less painfull.<p>Now let's consider something else. in Python you have WSGI , Ruby Rake ,etc ... which are really good stuff , universal in the way you plug into them to write your own framework.<p>Up until now, PHP devs felt they did not really need it. But as the PSR effort improves , we need frameworks to implement the same http kernels so we can plug any middleware no matter what the lib is , that's very important. You cant use raw PHP anymore. You need middleware you can use ACCROSS frameworks.<p>So should php devs use frameworks ? yes. just like Ruby , Python devs dont do raw CGI programming. Should i use guzzle instead of CURL ? yes because it has a beautifull and fluent API , and CURL is just plain ugly. Should i use Silex/Slim/Laravel instead of raw PHP ? yes because your application will scale with these simple frameworks. Writing raw PHP without PSR-0 autoloading , and no framework doesnt scale , period.<p>PHP has a real problem. I admit. It needs a real deep , breaking redesign, a clear separation between the core and libraries , and fat trimming. But framework designers did a great job trying to correct its flaws and making PHP development bearable.
评论 #5349213 未加载