What wastes your time as a PHP'er?

Off Topic:

Gah I just wrote a really long post about stats, then sitepoint went down temporarily!

I don’t know what you’re trying to achieve here but you need to be careful with any conclusions you make. Firstly, the sample size is so small you can’t really claim anything is statistically significat. Secondly, as with any survey, you can’t judge how people rate “time wasting” what one person mentions as highly important, someone else may consider insignificant. Finally, you have the “me too” problem. Because it’s an open survey people will read the answers and naturally get reminded of an issue, this will often take over what the would have said otherwise–skewing the results.

So far, we could extrapolate that “Repetition wastes twice as much time as Evaluating 3rd party code” but this isn’t an accurate statement. each occurance of “Evaluating 3rd party code” may take three times as long as each occourance of “repetition”. A more accurate conclusion is that “Repetition is more likely to be a waste of time”… but it may also be easier to work around.

Because your questions are open-ended there’s no way you can know whether some of these are actually related. E.g. Flakey API and Evaluating 3rd party code probably are.

Again, I don’t know what you’re doing with this data but you do need to be wary of any conclusions you make from it.

Hi…

Yes - their base class is inflicted all over the place.

What’s worse is that by taking over such jobs as configuration, environment (machine differences), instantiation and dependency management for every possible use case, setting up the framework gets so convoluted you have no hope of internalising it.

That forces you to grep everywhere. If the setup throws an exception, don’t expect a stack trace to make any sense.

Combine that with a universal base class and you can say goodbye to print_r() as well, not to mention you now depend on half of your app plus an entire framework. Take over autoload for the final dash of confusion.

That’s true genius.

You can’t figure out what’s been instantiated, you don’t know what parameters it received, you can’t print_r() it, you’ve no idea where it came from and if you do find out, you daren’t fix it anyway :(.

yours, Marcus

Hi…

Revised summary:

4 mentions: Repetition, Refactoring own code.

3 mentions: Exploring new ideas/tools, Lack of readable code and bad naming, Missing tests.

2 mentions: No docs, Writing docs, Client communication, Overdesign, Lack of identity map, Evaluating 3rd party code, Magic routing, Trying to find code, Rewriting distrusted code, No version control, Non standard error reporting, Registry pattern.

Single mentions in waiting: Tendency to be “smart”, Mixing languages together, Writing tests, Too much in a method, sprintf(), Changing session variables, Task handover, Pointless marshalling, Boss distrusts open source, Campaigning for better practices, Bad bespoke frameworks, Flakey API, Waiting for provider, Planning, No deployment process, Not being able to use PHP, Users can’t login, Excessive inheritance, Slow remote infrastructure, Bad tests, Multiple projects in one repo.

Some real gems are appearing in the two hits category. Keep 'em coming people. If you’ve already posted and hit something nasty over the next few days, I’ll include that too.

yours, Marcus

Hi…

I’m with you on that one. Welcome to the cloud :(.

I take it everyone has seen the spider webs?
http://www.trinity.edu/jdunn/spiderdrugs.htm

yours, Marcus

Sorry Marcus, skipping right to this one to rant. My biggest waste is actually NOT being able to use PHP because it is not an “accepted standard architecture”. Stuff I can kick out in PHP in a few hours on the weekend takes my team weeks to do in the proprietary “compile to several version old flash” tool that is part of the accepted architecture. And then changes take 10 times as long as well :frowning: Probably not the angle you were looking for in this thread though.

Regards,
Jason

For clarification, is it that these framework authors only provide one way to do things (e.g., only works with their base class or configuration system) and you want more flexibility? And which parts need the most flexibility – presentation code? domain code?

Hi…

What % of your time is spent refactoring? What do you think the payback time will be in this particular case?

Nice, but too off topic. Sorry. Please try again.

Aha! What is causing you difficulty understanding them? Conventions or the lack? Poor APIs? Surprises?

This is the stuff I’m after. Can you post some snippets of stuff that has caused you some head scratching?

So stack traces and the included files are important sources of information. I do the same thing.

My first problem is to find the file where the code is. That shouldn’t be a problem, yet framework authors can find all sorts of clever ways to obfuscate this basic starting point :rolleyes:

A bad stack trace and a bad print_r() can stop me in my tracks as well. To me stack traces and dump-able objects are part of the API.

It strikes me that good software has easy to find code (however badly written) - is this the advantage of older dummer frameworks? Or are you having trouble with mainly other things? Or is this one problem of many?

yours, Marcus

Hi…

What I’m actually doing here is something called “narrative capture”:
http://learnwiki.org/wiki/index.php?title=Narrative_Capture_Method

Rather than have everyone say what they think wastes their time (biased), I’m looking for recent stories and correlating the results. Much harder to unconsciously game.

Of course a bit of fieldwork with every one jotting down what they are doing every couple of hours would be better, but having some alarm go off four times a day could get a little disruptive.

So far not much to go on, but here are the scores so far…

4 mentions: Repetition, Refactoring own code.

3 mentions: Exploring new ideas/tools, Lack of readable code and bad naming.

2 mentions: No docs, No tests, Writing docs, Client communication, Overdesign, Lack of identity map, Evaluating 3rd party code, Magic routing, Trying to find code, Rewriting distrusted code.

The singles are even less significant: Tendency to be “smart”, Mixing languages together, Writing tests, Too much in a method, sprintf(), Non standard error reporting, Registry, Changing session variables, Task handover, Pointless marshalling, No version control, Boss distrusts open source, Campaigning for better practices, Bad bespoke frameworks, Flakey API, Waiting for provider, Planning, No deployment process.

Any ideas on how to group the data?

Need more stories here people - please help. I’ll N-gram all the posts if we get a few more.

yours, Marcus

Oh dear - whatever that definition is, I’ve just been handed some…

Legacy Code:
You know you’re working on legacy code when -

  • There is no documentation inline or otherwise and the author is either retired, fired or dead
  • You have to step through at least 3 files to locate the origin of a variable
  • You have to step through a function to know what it expects and what it returns
  • You find 100 line+ blocks of code commented out - and those are the only comments you’ve found so far
  • It resembles a famous italian dish
  • You get the distinct impression you’ve just boarded the Mary Celeste - i.e. somebody left in a hurry…

(any more? add as you feel appropriate

Sad thing is, I know I’ve written a fair bit of this myself. To all of those who work on my appalling code, I repent! I’m doing my best to redeem the sins of the past with reams of Docblocks and legions of Unit Tests…

Hi…

No. That’s the framework author’s egotistical fantasy.

I want to automate repetitive tasks and get leverage by using prebaked code for common tasks. I want no other interference. I have no use for “consistency” any more than “conventions”. My app will always be different (otherwise I’d use a CMS).

“Consistency” is an overhead that confuses everyone and costs money in ramp up time every time a new dev has to work on it. It’s evil, and the framework author as an uphill struggle to convince me it’s a necessary evil that will pay it’s way. That explanation had better be good as I’m starting from sceptical.

yours, Marcus

Heh, isn’t that the point of a using a framework? To keep everything consistent and let you quickly build into it? I’d like to see a framework where your controllers don’t extend a base class. You’ll get lots of repeated code :stuck_out_tongue: As for a framework having its own config file, i think that’s again is not something you’re going to be able to avoid.

It sounds to me like you’re using the wrong framework and ORM. All code has to have a usability scope of some description. There’s no way anyone can make an ORM which caters to everyone’s possible needs or a framework that will satisfy everyone. Some people will want high flexibility while others will just want to be able to quickly develop on it. There’s always a balance, I don’t think you can really blame framework authors for this.

Hi…

OK, here’s mine:

  1. Someone wrote a validator to an ORM field that prevented my script running. A lack of unit tests allowed my colleague to put in a default field that was invalid. Not just me that got broken by this.

I was able to get the Locale tag from the error message easy enough, but then couldn’t find it in the code. Turns out that in Solar the error message ERROR_MY_MESSAGE is automatically assigned to a validator called validateMyMessage(). How about that for a grep beating piece of magic?

I never figured that one out. Another colleague that worked on Solar itself told me that’s how it works. Now I also grep for “yMessage” too.

  1. I could put the same again, as it was a 2+ hour delay. As I have so many at the moment, I can add another.

I’m trying to write a bunch of migrations that work transactionally. This is a foreign concept to the Solar ORM. A colleague wrote a UnitOfWork add on, and I added an IdentityMap. All this should be built in of course, but that’s just the start of the problem.

Solar overrides everything, including having special exception classes that display differently, weird conventions for storing up error messages in an insanely nested array structure and then dumping them into the stack trace, etc, etc. It takes control of the stack traces. The stack traces are even upside down. To make matters worse, our version of Solar is an old one that has been forked in-house.

This combination makes it a nightmare to find out what actually caused a transaction to fail. I can spend several hours chasing this down at a time and often have to edit our fork to extract errors.

Leave the PHP error mechanism alone. “Just say throw”.

  1. Rant time. I have to grep. I have to grep a lot. A mixture of autoload, weird half baked service locators, factory pluggable registries and other bloated bits of confusion mean that I can never ever find the files that a piece of code depends on. PluggableRegistry is not a pattern. Patterns are solutions that work.

Grepping is labour intensive, skilled work. It’s expensive. If I have to grep the source, that source is a mess. Lately the search space is the entire app and the entire framework too. require_once() is simple and works. There has to be a damn good reason to replace it.

And while I’m on the subject… :wink:

Why is it the framework authors seem to think they are going to tell the poor little pleb application developers how to code? They create conventions where perfectly good PHP mechanisms already exist (PEAR::Error anyone?), force the creation of entire classes for trivial validation tests, make everything extend the framework base class, insist on their own configuration system and factories…grrr.

Listen Mr. Framework author - the reason I don’t publish an OS framework is because I am gainfully employed. The reason you can write one is because obviously you are not. Don’t tell me how to code. Don’t be clever (you aren’t), dump the magic and keep out of my way.

Well, I feel better now :).

yours, Marcus

Hi…

How would you have found out?

What sort of things take time? What was the last thing specifically?

Yes. Unless you get something systemic, such as a constant stream of unrealistic features.

OK, so what wastes your time, or are you in one of the super productive teams?

yours, Marcus

Hi…

Have you tried buffering with a message queue? Did you know beforehand that this service was flakey? Is there any way you could have found out?

Why weren’t they present to start with? Could you not have scheduled this fix ahead of time so tat it would be ready now?

Do they know what they want? Should developers be bought in later once they sort this stuff out? Or should a developer have been involved earlier, while they were sketching the idea on a napkin in a cafe?

yours, Marcus

Well that was just one example. There are some much better thought out, mvc type frameworks which still contain several gotchas. Changing session variables at random points, header redirects to success pages with no error checking. Having to trace through function calls to find the entry point and file being used to do the part I want. All this stuff costs me time. Usually more than it takes to fix the often trivial thing the client wants changing.

In my case, the problem is, for a long time the business had only one developer. As you said, how is my boss (who knows little more than HTML) supposed to know? The company started off as a print design business, went into web design and the next logical step was web development.

As you said, there’s no way for people who have less knowledge to tell.

And of course:

I think a better question is, what can we really do about poor quality legacy code? Nobody has time to re-write it.“If it ain’t broke don’t fix it” the code works, it’s just a nightmare to modify and extend. You could hack some better code into it but that’s not great. The next person who looks at the code will be even more confused!

Reorganized my file structure, experimented with namespaces and dependency injection.

We don’t have version control on a large e-commerce site we’re doing (yes, you read that right). In order to start working on a task, I had to download the entire site via FTP, which overwrote some local changes I had made and forgotten about. Also exported the DB, dropped my local version, and imported the latest which overwrote some fields I had added. Luckily I had a backup from reinstalling my OS last week.

I have ADD, so I could go on all day (and do) but here are a few: trying to find naming conventions, directory structures, controller method organizations, etc. that I like and can work with (and changing my mind constantly).

Trying to write functionality from scratch that has already been written because I hate using code I haven’t written or because my boss is paranoid about open source software being insecure.

Trying to convince my coworkers to use version control, OOP, the latest stable version of PHP, automatic deployment, automatic testing, open source frameworks or CMSs, open source project management/invoicing software, etc.

Trying to rewrite our 10-year old procedural “codebase” that is crusty as hell.

Trying to figure out what clients want when they don’t know what they want.

Trying to implement things in PHP that Ruby on Rails has built in.

Reading forums and blog posts about design patterns, DDD, TDD, ORMs, productivity, etc. and trying to implement enterprise-level solutions for mom and pop businesses.

Trying to implement “perfect” solutions when they don’t exist.

That’s probably a good start.

Hi…

Both points completely chime with me. I spent two days retrofitting an identity map into a migration script. In this case it was Solar that was deficient. This thing has been in PoEAA since 2003ish for goodness sake. Do people like rolling dice when they save data?

yours, Marcus

I just finished salvaging some data from a log file that should have been sent to an external service. Since said external service fails randomly and gives very poor feedback, it’s pretty much hit-and-miss. Luckily I was foreseeing enough to log each call.

Waiting for external service provider to implement and roll-out a couple of extra fields for a data structure. Then asking him to fix it so it conforms to the specification. Which should be simple, as JSON is fairly bare-bones.

Agreeing with people about who does what and what exactly we’re trying to accomplish. So, in short - People.

  1. Evaluating 3rd party code for use in projects
  2. Lack of solid versioning/deployment process
  3. Feature creep from the client disrupting iterative development process. Important schedule hours dedicated to maintenance/testing/profiling replaced with introduction of hacks and last minute feature requests which then get cemented into the project.

Reading the code of my fellow devs. You always find some neat new thinking to tackle a problem.

Getting our CI Machine to build our client code. With client code i mean a enterprise javascript widget system which was build ontop of jquery and
a huge amount of custom classes. Never thought that the integration into hudson could take so much time - but it’s running by now with all it’s unit testing and deployment glory. But it was nasty i can tell you…

I am a strong proponent of visual clean code (besides it being object oriented and working to it’s expectations). I need the code to have some sort of rhythm when skimming lots and lots of code. So my biggest time waster is educating the people that work with me to adhere to some common coding style rules - it’s hard and sometimes they curse me for being that pedantic but after working with me for some time they appreciate it. But man, it wastes my time and does’nt help my hair staying black (;

cheers
Chris