The Cache: Technology Expert's Forum
 
*
Welcome, Guest. Please login or register. September 22, 2019, 07:46:42 PM

Login with username, password and session length


Pages: [1] 2 3
  Print  
Author Topic: Misc PHP questions  (Read 8458 times)
Kovacs
Rookie
**
Offline Offline

Posts: 30



View Profile
« on: September 01, 2010, 04:10:15 PM »

1) Do you use any FRAMEWORKS?  If so, what and why?
2) Do you use a documentation system (phpdoc, doxygen etc).  If so, what and why?
3) Do you use any kind of (semi-) formal approach to testing?  Sprinkling your code with assertions? Unit testing? If so, what and why?
4) Do you use an IDE?  If so, what and why?

Please enlighten me, veteran coders.  I feel that there must be some way out there to make large multi-part software projects easier to understand, visualize and modify.
Logged

No links in signatures please
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #1 on: September 01, 2010, 05:26:40 PM »

1) Do you use any FRAMEWORKS?  If so, what and why?
Yes, my own handrolled code, supplemented with various libraries from others. Essentially a toolbox for me to glue together.

2) Do you use a documentation system (phpdoc, doxygen etc).  If so, what and why?
No. Never seemed to get better stuff than I could type quickly myself. Particularly since I don't really release APIs or low level stuff, but user apps that need more of a pretty documentation set than a whole lot of the same template for different data.

3) Do you use any kind of (semi-) formal approach to testing?  Sprinkling your code with assertions? Unit testing? If so, what and why?
No. My personal coding style of objectifying just about everything and then limiting access through a pinholed interface makes much of the testing others employ way overkill. I do, however, have lots of logging, nested exception handling and clear delineation of responsibility (as well as tightly walled gardens) so that the genesis of a problem can be identified, proven and repaired.

4) Do you use an IDE?  If so, what and why?
Predominately just text editors, although I used to love Delphi (many, many years ago). I do, however, use phpMyIDE every day Wink

Please enlighten me, veteran coders.  I feel that there must be some way out there to make large multi-part software projects easier to understand, visualize and modify.
There are LOTS of ways to do what you are looking for, but I've striven to become a hyper-efficient ronin and as such, do not choose into many of the large team techniques that are in fashion today. ITTO would probably be a good one to ping, I'll bet he weighs in here soon.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #2 on: September 02, 2010, 12:12:59 AM »

1) Do you use any FRAMEWORKS?  If so, what and why?

The Force.com IDE in Eclipse (3.5 currently).  It's the solution for the PaaS cloud I code in - Force.com.

2) Do you use a documentation system (phpdoc, doxygen etc).  If so, what and why?

Yes, me - because I prefer my own documentation to absolutely anything auto-generated.  My job is to make my documentation readable to me long after I'm done with a project and instantly to someone new to the code.  Beyond that, my own documentation has precise and lasting triggers for my brain to instantly "unpack" the zipped knowledge that just the right suggestion can describe in full.  This is akin to compartmentalizing top secret knowledge in an innocent messenger who couldn't reveal it to his captors under the worst kinds of torture, yet would recite the 5 page secret upon hearing the magic word "abracabullshit!"  Well that's overstated.  But my first description was closer to the mark.

3) Do you use any kind of (semi-) formal approach to testing?  Sprinkling your code with assertions? Unit testing? If so, what and why?

Religiously.  I'm a huge TDD fan and branching deeper into ADD/BDD (Acceptance Driven Development/Behavioral Driven Development).  ADD is natural for me but that's another story Wink  But my development platform not only includes a magnificent automated unit test framework that's completely integrated, it forbids publishing AppExchange applications that fail to provide a minimum of 75% test coverage.  This is a low mark and 100% is what's really targeted.  My code is always eventually covered at 100%.  Every single line that is......  Texas Tea....

4) Do you use an IDE?  If so, what and why?

VI for everyday work and Notepad for the hard stuff.  If Notepad can't handle it, which is impossible, I dust off my Apple II and break out the Magic Window!! 


* Magic Window.jpg (36.98 KB, 384x240 - viewed 241 times.)
Logged

I would love to change the world, but they won't give me the source code.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #3 on: September 02, 2010, 09:33:20 AM »

I have used my own, as well as codeigniter. I would probably use kohana instead since it does away with some of the weirdness of CI. Neither of which are for lazy-coding. they provide only a framework and a few functions to simplify very common actions. But its not like .NET for example which 8million functions that no one ever uses or even knows about.

i kind of liked them, but dont code much for the past year.

i used phpdesigner for a few years, worked well for me.
I also use sublime text editor. its very simple, like notepad, but with some basic coder oriented stuff. worth checking out if even only as your notepad replacement.

documentation... whats that? My code is my documentation, with a sprinkling of comments when the logic gets really crazy. Apparently i do pretty well because the few times people have taken over my code, they have commented on the ease of reading.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
Kovacs
Rookie
**
Offline Offline

Posts: 30



View Profile
« Reply #4 on: September 03, 2010, 05:33:30 PM »

Thanks for the replies guys!  Very interesting.

Quote from: perkiset
No. My personal coding style of objectifying just about everything and then limiting access through a pinholed interface makes much of the testing others employ way overkill. I do, however, have lots of logging, nested exception handling and clear delineation of responsibility (as well as tightly walled gardens) so that the genesis of a problem can be identified, proven and repaired.
Could you expand on your approach to interface design between objects please?  One thing I have major problems with is that sometimes you just have to change an existing interface and then that breaks a multitude of things further down the track, sometimes in ways that aren't immediately obvious.  Then without some kind of testing, you can't be entirely sure what's breaking and where.  Testing every last little thing comes with its own set of problems.  Your hands end up tied by bad design decisions from ages ago.  I would also love to hear a bit more about what you are logging and how you go about making it easy for yourself to identify where a bug is actually happening.  Any reading material you would recommend?

Quote from: isthisthingon
Yes, me - because I prefer my own documentation to absolutely anything auto-generated.  My job is to make my documentation readable to me long after I'm done with a project and instantly to someone new to the code.  Beyond that, my own documentation has precise and lasting triggers for my brain to instantly "unpack" the zipped knowledge that just the right suggestion can describe in full.
I know exactly what you mean!  It's like trying to remember someone's name - it's right on the tip of your tongue.  You haven't actually forgotten it, but you just can't get to it in your brain.  Just the right hint can suddenly make those neural pathways accessible again and you can consciously remember the name.  Could you give an example of what you mean by a trigger?

Quote from: nutballs
documentation... whats that? My code is my documentation, with a sprinkling of comments when the logic gets really crazy.
I've seen people on other forums give props to your code so I assume you have a bigger capacity for holding that kind of thing than me.  I'm trying to get to the point where I can plan and build a new bolt on component, test it for correctness and correct error handling, then "sign off" on it and basically never have to open the source again.  Just use it like a black box with a clearly documented interface.  Plus I need some plain english documentation in there for end users, outsourcers etc. as well as myself.
Logged

No links in signatures please
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #5 on: September 04, 2010, 09:07:38 AM »

most IDE's i have tried have some sort of commenting system. I think phpdesigner had an XML based one that seemed decent.

but ahh. you are looking for a full documentation system, not just commenting.
I actually think that phpdesigner might have that in it, and can tie end user documentation with code level comments if needed. I may be getting confused of course, because its been about a year. But i think it was like that.
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #6 on: September 04, 2010, 12:11:16 PM »

One thing I have major problems with is that sometimes you just have to change an existing interface and then that breaks a multitude of things further down the track, sometimes in ways that aren't immediately obvious.  Then without some kind of testing, you can't be entirely sure what's breaking and where.

 Ditto  Same issues with seemingly innocuous includes where your code could have been broken long before you realized this and would have been detected easily by simply executing through it automatically.

Any reading material you would recommend?

Yes definitely.  Working Effectively with Legacy Code by Michael Feathers.  It doesn't have to be a massive refactoring effort of a code base you didn't create.  It's simply this definition of his that sums it up for me: 

Q: What's the definition of legacy code?
A: Code without tests.

It's extreme and radical for most to even think this way.  But after becoming test infected myself, the thought of coding without them immediately feels like a game of software roulette.  Another comparison would be coding without a debugger and then realizing what wonders they are to behold.  The best of the best will always get by without them, as perks does.  But the satisfaction of clicking a button and seeing literally every single line of your software get executed with timing metrics reporting for every entry/exit point giving you the tools for unparalleled performance tuning, well let's just say it's the Little Mermaid singing A Whole New World around these parts.  Of course I AM in Northern California  ROFLMAO

Could you give an example of what you mean by a trigger?

Trigger is perhaps an easily misunderstood term since we are talking about development Smiley  But for the things I suspect will be easily forgotten, I sometimes associate some emotion with the naming or associated comments that will be easily "triggered" anytime in my future.  This could be pride, inspiration, a feeling of fear that some sketchy API will return something undocumented when the stated return possibilities are seemingly endless in the first place, etc.  But usually this isn't necessary since whatever I'm building has evolving and almost self-defining aspects that the included or developed elements can easily become tightly conceptually coupled with.  This then becomes a mental zip file where a class name or interface becomes a container for everything it has and is.

And in terms of open source and documentation I realize it's a different story.  If you google: Google Earth Chatter and click on the first link you'll see an open source / code share project with documentation that I'm pretty closely aligned with Wink

Cheers,
ITTO
Logged

I would love to change the world, but they won't give me the source code.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #7 on: September 04, 2010, 05:50:57 PM »

Could you expand on your approach to interface design between objects please?  One thing I have major problems with is that sometimes you just have to change an existing interface and then that breaks a multitude of things further down the track, sometimes in ways that aren't immediately obvious.  Then without some kind of testing, you can't be entirely sure what's breaking and where.  Testing every last little thing comes with its own set of problems.  Your hands end up tied by bad design decisions from ages ago.  I would also love to hear a bit more about what you are logging and how you go about making it easy for yourself to identify where a bug is actually happening.  Any reading material you would recommend?
I can't go greatly in depth at the moment, but wrap things up this way: when I am developing I see objects as living things, each with their own perspectives, capabilities and internal language. They have limited access points and clearly defined responsibilities and abilities. Testing those in a vacuum is relatively easy. And I can easily throw check points on the input/output mechanisms to make sure that what I am getting is precisely what I expect - or exceptions are thrown.

If classes become so large that they are difficult to see clearly how/what needs to be tested, then they are simply way to large. An old old colleague used to say (in the days of Structured Programming) that if a function was longer than one printed page, it was to big. That's a little extreme, but fits as an analogy nicely. If an object HAS to be tested in a whole lot of ways, with lots of different possible scenarios, then either the outside world is allowed to know too much about it's workings, or it is simply to complex and needs to be parsed into more understandable components.

Good design usually takes 3 iterations. I've found this to be mostly true since I started using OO methodology in about '91. Relax with that pseudo-truism, and your classes will probably take shape more quickly.

Logging: Often, in more complicated classes or classes that have to interact with other (non-me) entities, I will add a private method, Log, which takes a string parameter (what I want to log). The class then has a simple boolean public property that when true, actually logs what is passed and when false, returns instantly without doing anything. The Log function (provided logging is on) grabs a global file handle and appends to it. So any number of objects/functions can contribute to a true serialized logger. Exception handling does the same. Sometimes the variable is local only to a class, sometimes it is global to an app - if logging is on, I get a whole lot of data really fast about where things are going.

In one case, I have a system that has about 200K lines of code. It is some old Object Pascal stuff (Kylix) that was so complicated I actually have a logging rules XML file that describe where/when and even under what circumstances I want logging of (what) performed. This was because I ran hundreds of different websites with thousands of different capabilities through a single shared object - and trying to see what the state of a particular variable was, at the time I was attacked, on which site and by whom, and what their inbound URL and GET and POST params etc etc etc were was simply daunting. So this method allows me to turn logging on while the system is running, and then even get pinged with an email when something is added to the log, since it might not happen (mostly didn't, thank you Mr. Murphy) until say 4am the next day.

Hope that spins your gears.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #8 on: September 04, 2010, 06:39:43 PM »

This was because I ran hundreds of different websites with thousands of different capabilities through a single shared object - and trying to see what the state of a particular variable was, at the time I was attacked, on which site and by whom, and what their inbound URL and GET and POST params etc etc etc were was simply daunting. So this method allows me to turn logging on while the system is running, and then even get pinged with an email when something is added to the log, since it might not happen (mostly didn't, thank you Mr. Murphy) until say 4am the next day.

As elegant your design was, and how impressively it handled such diverse conditions, if you absolutely had to have better performance than PHP will provide and wound up with Kylix, Java, C#, or even Python/Ruby, auto-unit testing provides this level of confidence while minimizing code designed to reflectively maintain or improve stability through analysis.  Idea...   Keeping as much of that code as possible out of production is a key benefit as well  Nerd 

Test driven development provides an optimal safety net for large scale architectures of high complexity as well as potentially accelerating the development of new and perhaps even simple projects, including those in PHP.  It seems strange that the often considerable amount of additional test code could possibly improve your productivity.  Yet after you get over the initial hump that requires more time up front designing your tests along with your code (or before you even write your code - TDD), the rest of the implementation moves so much more quickly, at least in my experience.  It took me about 6 months to "get it" and after a few years I'm still learning more about it every day.

Anyway, the level of detail and useful information your logs provided makes me immediately think about feeding all of it to a test automation framework with a test harness and mock objects to crunch through every possible scenario when you change even so much as the text in a page.  Certainly for new development and any level of refactoring, tests are invaluable.  Then at some point you may find that the live logging can be scaled back to some degree, since the previously collected data fed through your test framework handles all the low hanging fruit for you 

 
« Last Edit: September 04, 2010, 06:45:39 PM by isthisthingon » Logged

I would love to change the world, but they won't give me the source code.
nutballs
Administrator
Lifer
*****
Offline Offline

Posts: 5627


Back in my day we had 9 planets


View Profile
« Reply #9 on: September 04, 2010, 08:23:29 PM »

all that said. testing for for pussies. trial by fire!!!!!!
Logged

I could eat a bowl of Alphabet Soup and shit a better argument than that.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #10 on: September 04, 2010, 08:43:15 PM »

LOL ITTO I wrote that framework in 2001 - it is still in operation today. PHP was, shall we say, a bit less capable at that time Wink

Actually it was legacy code from Delphi written in the late 80s, converted to Linux/Kylix and then expanded. At that time, the options for having anything other than CGI connections for dynamic sites were slim and Kylix pulled it off with aplomb. Needless to say, that code has not been actively developed for probably 5 years - but it's strong enough that it keeps pumping on to this day. Smiley
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #11 on: September 04, 2010, 08:43:54 PM »

@ Nuts: Fuckin'A, bubba.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
isthisthingon
Global Moderator
Lifer
*****
Offline Offline

Posts: 2879



View Profile
« Reply #12 on: September 04, 2010, 11:35:27 PM »

all that said. testing for for pussies. trial by fire!!!!!!

On someone else's dime??  Conscience to the lions, absolutely!  ROFLMAO  But if I was picking up the software development/software maintainability tab I'd accept nothing less  Mobster  (unless I was doing business with nutballs and perks of course Wink)

IMO, experienced first-class software engineers/architects have no "need" for TDD or automated unit tests in general, just like I have no "need" for any IDE productivity booster such as Eclipse - since who needs anything more than a command line?  Nothing could possibly be more productive than a command line, assuming one is of reasonable intelligence and has functional digits, right?  Regardless, vsloathe said it, I believe it, and that settles it!  Nerd

[Aw shit, it's nine directories deep and I'm lost in hypervisor land while eating buttered popcorn with my left hand!!  The humanity...]

(Send in the mouse....  there ought to be mouse....... well, maybe next year Smiley)
Logged

I would love to change the world, but they won't give me the source code.
Phaėton
Lifer
*****
Offline Offline

Posts: 555


⎝⏠⏝⏠⎠


View Profile
« Reply #13 on: September 05, 2010, 01:05:03 AM »

>Do you use an ide

      on mac: TextWrangler
on windows: psPad + included Ftp support with bitvise tunnelier for SFTP support.
     on Linux: geAny + gFtp

> If so, what and why?
if you dont have windows, its worth running a windows virtual just for phpDesigner2008
It sucked after that version...

But it uses xDebug and has it all ready to roll in the ide... its as close to the delphi IDE
as you could get.  If your debugging something really huge thats object oriented and
really confusing you can put variable watches... traces, breakpoints, etc..

It has code completion and code exploration... Lets say you have 10 files in a directory
and you include file 8 from file 2 ... when you type '$' and wait it suggests variable from the
other files..

You can put a breakpoint at a certain line and do a trace on $this-> and see all of its properties
with a mouseover.

Its a bit of a process to use and understand and doesnt really work for developing big projects
but if you have a wicked function you need to debug and 'step into/step over' , IDE style its FTW.

Eclipse IDE for php has similar functions but is HUGe, slow and i have yet to get it to work.  phpdesigner2008
is a great tool to help you make the jump.
Logged

When I was your age we used to walk to the TV to change the channel....  _̴ı̴̴̡̡̡ ̡͌l̡̡̡ ̡͌l̡*̡̡ ̴̡ı̴̴̡ ̡̡͡|̲̲̲͡͡͡ ̲▫̲͡ ̲̲̲͡͡π̲̲͡͡ ̲̲͡▫̲̲͡͡ ̲|̡̡̡ ̡ ̴̡ı̴̡̡
perkiset
Olde World Hacker
Administrator
Lifer
*****
Offline Offline

Posts: 10096



View Profile
« Reply #14 on: September 05, 2010, 12:05:11 PM »

@ITTO - as you well know and understand also, perhaps 90% of the programming is done while you're walking about, taking a shower or sitting at peace. Many times, I've already seen the code several times in my head, through different iterations, testing and results before I've ever gotten to the keyboard or even a whiteboard. The typing part is almost anticlimactic.

Also, re. IDE - all I need really is a text editor, because since my viewport is strictly a browser (I've not developed for an OS GUI in more than a decade) the text editor and a browser ARE my IDE. Throw in TimeMachine for backups and I'm golden.
Logged

It is now believed, that after having lived in one compound with 3 wives and never leaving the house for 5 years, Bin Laden called the U.S. Navy Seals himself.
Pages: [1] 2 3
  Print  
 
Jump to:  

Perkiset's Place Home   Best of The Cache   phpMyIDE: MySQL Stored Procedures, Functions & Triggers
Politics @ Perkiset's   Pinkhat's Perspective   
cache
mart
coder
programmers
ajax
php
javascript
Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC
Seo4Smf v0.2 © Webmaster's Talks


Valid XHTML 1.0! Valid CSS!