- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Aside from TRWTF, which is using PHP when there are so many superior Microsoft alternatives available, I'm not really seeing a problem.
I'm a big proponent of wrapping framework functions like this. You never know when you might need to pop in some logging or embed some business logic at this level. At which point, wrapping it early saves a lot of code changes in the future.
Admin
A comment on every line is not "well commented" code.
Admin
I can't believe so many of you are ok with this code. It certainly does not improve maintainability. People who work on this code in the future will not be expecting it. And if a particular function he's encapsulating does eventually become depreciated, they'll still have to CTRL+F for it and change it. Encapsulating functions just for consistency in naming convention is plain stupid. It increases clutter, file size, execution overhead, and confusion.
CAPTCHA: nulla. Your arguments are nulla and void.
Admin
Oh. And I thought this post was about ponies...
Admin
Admin
Apparently all of you that believe this is the best (or even a good) way to handle it have never heard of grep or sed/awk.
Should he wrap every php function that could possibly change in the future, even those implementing agnostic algorithms? Whatever would he do if PHP died one day? Oh the horror.
Admin
I haven't yet seen the right implementation, so I've just written my own. It follows some nice patterns and is, of course, easy to extend. The code is mostly self-documenting so I didn't bother to write elaborate comments. Have fun with it!
Admin
/**
function getPostBody() { if( !detectEarthStatus() ) { //Do something there in the future that we have no idea about today } else {
}
echo "I wated all of that time wrapping everything in logic because I love to write code for the sake of writing code." . getPostBody();
Admin
It's not about losing it. It's just for consistent naming convections, the comments on the function even says so.
Admin
0/10
Admin
Dude.. You write methods called "_assertNameKnown" and you forget to use assert, and you don't even specify an assert_callback? Obviously that was a rushed job, it could have been much more enterprisey!
Admin
You work at my company don't you? Seriously, that is what the proposition was for the project, and the management bought the story, promoted the staff.
2 years later, and they don't like how it looks, so they are going to redo it. Same XML barf, just rewriting the framework, also writing legacy support. But instead of relying on the legacy support for existing tests, they will port all of them over as well. It should keep them busy for a couple years and improve the product by 0%.
Admin
Dang, I knew I was missing something! I keep learning a lot here at WTF, best practices and all. Will be included next time!
Admin
I can't belive I'm the only one who doesn't see what this developer is doing here.
HE'S EVALUATED BY KLOC COUNT!!!!
Do get the job his company HR wanted to know if he'd ever worked on a program with 10^^8 or more lines of code?
His PHB had an intern write a script that reports lines of code/week/developer.
He's doing what his boss is paying him for!
Admin
Actually, given that PHP is not consistent in the least regarding how it names functions, let alone the order of parameters, a library that does a lot of this, and makes things sane and consistent, might be welcomed
Admin
I would do it like this:
function detectEarthStatusWrapper(){ //May need to add code in the future return detectEarthStatus(); }
function detectEarthStatus() { return true; }
function getPostBody() { if( !detectEarthStatusWrapper() ) { //Do something there in the future that we have no idea about today } else { return sprintf( "This is called %s. I suspect you have very %s experience working with teams of talented %s and just like to impress your friends with %s.", "over-engineering", "little", "developers", "LOC" ); } }
Admin
Admin
*although in this example I pass some_parameters on, in reality the parameters would change (if in nothing else then in order) Then we wanted to use different libraries, but instead of modifying this wrapper, we insert another layer
When I worked there, there were 5 layers already (and as it was my first proper IT job, it didn't really occur to me until halfway through an implementation of yet another shim that perhaps we were doing it wrong - and who would have listened to me anyway?
Now, I get upset when people even think about doing things this way.
Admin
If you want to standardize your php, couldn't you use cpp or emacs -batch?
Admin
Admin
etc...
There's a difference between well commented and well commented
Admin
you might still need the ol' Cntrl-F, but you'll only be replacing one instance not 567.834 of them
Admin
Some people, when confronted with a problem, think “I know, I'll use regular expressions.” Now they have /^\d+$/ problems.
Admin
also 1)Some people develop on Widoze 2)Not sure a sed or awk approach is necessarily best either
Admin
he could scrape the php.net website from wayback machine for the timelines of various (all?) php functions over differing versions then and automatically generate the php wrappers code accordingly ... as a bonus if php/wayback machine died he'd just get a simple 404
Admin
You're genius.
Admin
Your comment about nothing at all smells like spam.
Admin
I think of you as a genius.
Admin
Yup - you're definitely a genius.
Admin
Your coworker was a dumbass. Is he still doing that shit, wasting time and all?
Admin
There's only one base-64 encoding, dude. If you need something else, then don't fucking call it base-64.
Admin
What a lame excuse. When did any framework [that should be used] release anything that isn't back-compatible? If you name one, then you know which one you should not use.
Admin
Like it fucking matters what the naming style is (as long as it's readable). Give it up! We'll never agree to the same coding style, and give it the fuck up. Let me indent, (and you fucking don't, if that's what you like); let me begin my function names with a capital letter (and you fucking lowercase it, if that's what you like), etc.
Admin
You're probably just another so-called developer who spends more time talking the talk instead of walking it. Go solve problems, vs talking about coding styles.
Admin
If PHP isn't back-compatible across its versions, then it's de-facto a joke platform.
Admin
he-he. Then there'll be a guy wrapping your wrappers, in case they get changed.
I totally agree with your sarcastic comment. Fuck the wrapper-happy coders. They just create clutter.
Admin
If you used split() you were either already using regular expressions or using the wrong method; explode() is the correct method to use if you don't need regular expressions.
Besides, split() is merely deprecated (not removed), it echoes an E_DEPRECATION warning which should be shown on development servers and hidden on production servers.
Admin
Captcha: ACSI - the dyslexic sibling of ASCII
Admin
Commenting relatively readable code is for pussies. Comments should be used to explain the concept, business logic, and similar - and not to re-tell/rephrase what code statement already do. It's just clutter.
Admin
If you need a job, we're hiring.
Admin
Yup. Let's also think about a way to wrap PHP code-block declarations (or whatever the proper name is), in case they change in the future. I'm talking about "<?php" here...
Admin
Please don't apply for jobs here.
Admin
Bigger troll are you, motherfucker - even assuming he IS one.
Admin
Admin
WOW. sino appears, abuses everyone for the hell of it, and then seems to think people would want to work with him....
Admin
Wouldn't it make more sense to write a wrapper AFTER a potentially troublesome PHP version change, effectively re-creating the old functions using their old names? No need to search through code to change, no need to write wrappers ahead of time.
Admin
I especially like the wasteful coding of the interior of the functions. Three lines when (even assuming a wrapper was justifiable) this would have done for base64Encode:
Especially the initialization of $output, which was immediately overwritten, demonstrates a desperate lack of understanding of coding principles.
Admin
I was thinking the same thing. And then there was this:
Who's the troll now?
Admin
Maybe "20 Years" is like the biblical "40 days and 40 nights" - ie "an unspecified amount of time"
Admin
Why would he need to fix that last 0.834 of them [/troll]