The true costs of development tools

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

redmonkey wrote: Code which doesn't function is one thing, but checking in code that doesn't build is very bad. Perhaps you can get away with your method of version control usage if you are a single developer but as part of a team, I do not believe that this is the way version control is intended to be used.
If people are going to break things, it's meaby better to let them branch and then merge back when they're done. In combination with tags i find this very flexible.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

timvw wrote:If people are going to break things, it's meaby better to let them branch and then merge back when they're done. In combination with tags i find this very flexible.
Correct, and we have several branches existing already but not for the purpose of convenience of having your personal local source available on another machine.
Roja
Tutorials Group
Posts: 2692
Joined: Sun Jan 04, 2004 10:30 pm

Post by Roja »

redmonkey wrote:No, it's because I work with 17 other developers and I'm not prepared to risk breaking the build process by checking in potentially 'half baked' and untested code purely for my convenience of having that code on another machine.
Woah there, back the hostility truck up. I never said anything about committing half baked code.

I test on a platform, I confirm that it works, and then I commit. Then I can move from platform to platform at will - scales from one developer to dozens, and there is no issue.
redmonkey wrote:Code which doesn't function is one thing, but checking in code that doesn't build is very bad. Perhaps you can get away with your method of version control usage if you are a single developer but as part of a team, I do not believe that this is the way version control is intended to be used.
I think you misunderstood what I meant. I work in a team of developers as well, the key was making sure the code works before committing it. I'm guessing that I work in a more atomic fashion (smaller, individual changes), while it sounds like you do larger, sweeping changes that need time to "fully bake", and as a result, you can't interrupt in the middle to switch platforms (or developers, or so forth).
redmonkey wrote:What I do is develop on one machine then if I need to test on another OS/machine I simply transfer my local source to that machine and build/test the code from that.
Now THAT is definitely ignoring the value of version control.

You asked what the true costs of different development tools were, and I explained why I prefer the tools I use - and why your preference for proprietary tools (in some cases) wouldn't work for me. I don't see in there why you needed to imply that I commit half-baked code, or work alone..
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

You know, you might want to investigate how Mozilla handles its build process: http://www.mozilla.org/hacking/life-cycle.html
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Roja wrote:I test on a platform, I confirm that it works, and then I commit. Then I can move from platform to platform at will - scales from one developer to dozens, and there is no issue.
The code base I work on supports multiple platforms, while some parts of the code base are unique to an idividual platform, many parts are common. When working on the common parts I ensure (or at least try to) that any changes work across all platforms prior to commit. I could test on my local environment (Win 32) and all is good, but I may have unknowingly broken the PPC platform build, I'd rather take the time out to test the platform prior to commit to ensure there is no potential for down time in the development.
Roja wrote:I think you misunderstood what I meant. I work in a team of developers as well, the key was making sure the code works before committing it. I'm guessing that I work in a more atomic fashion (smaller, individual changes), while it sounds like you do larger, sweeping changes that need time to "fully bake", and as a result, you can't interrupt in the middle to switch platforms (or developers, or so forth).
I think this may be where the fundamental flaw in communication lies between us. You are correct in your assumption, I tend to work on a task based develop and commit and due to the size and complexity (although it's not rocket science) of the code base there can be some time between commits, very rarely do I find myself commiting on a daily basis.
Roja wrote:Now THAT is definitely ignoring the value of version control.
Not in my mind, as above, I prefer to ensure that any changes made work across all platforms prior to commit.
Roja wrote:I don't see in there why you needed to imply that I commit half-baked code, or work alone..
Nor did see any need for you to imply that I misuse version control by not commiting frequently enough :P
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

when I work on multi-platform level code, I branch the tree do my work and commits there. After checking on the main platform I work on, I commit then build on the other platforms.. if it fails I work out the needed changes and so on.. committing to the same separated branch. Once that's all done, it goes to testing as a special set of builds for regression and so forth.. after that passes, the branch is merged into the tree.

Seems fairly straight forward to me, and doesn't break anyone else's builds while keeping all my code version controlled..
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Curious - I thought everyone committed half baked code for testing. ;) I can easily maintain two discrete versions/branches, with relevant update commands on alternate server environments. One for developer updates, t'other for migration to varying servers purely for testing just how half-baked that last commit was... Only repeating feyd here really...

I consider it very useful to test across a range of systems (and even configurations if possible). One of the banes of an open source developer is the infinite number of ways a specific configuration can break your application in some way. Those relatively rare (usually, not always) differences can cause no end of trouble...

On development tools. I have a tendency to simplify - down to plain text editor level with a little syntax colouring. I can see the value of an IDE, but I find many quite over-rated. Debugging is nice, but hardly essential (that depends entirely on the application/design - no offence, its worth it under certain cirsumstances I'm sure), a few echos in the right place with some fair design works quite nicely. Bugs tend to create unexpected behaviour, so if you allow for the detection of such it reduces undetected bugs. I'm one of those type hinting fans...;)

I've found unit testing to be a nice method of capturing a snapshot of behaviour. I'd place a lot more value on it than any debugger.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Just to be clear, the question was posed as to why I considered/classed the use of echo as a debugger to be a sacrafice of productivity. I provided a basic example, however, that's all it was, an example. That example in no way reflects my daily development practices. I do not run all my code through a debugger, nor do I use a debugger as a means to test the final application.
Maugrim_The_Reaper wrote:Debugging is nice, but hardly essential
Agreed, but how far do you extend that philosophy? Syntax highlighting is nice but hardly essential, a text editor is nice but hardly essential, but I would think that most of us have at least these two tools, and why is that? Probably for the same reason I do, because I feel that they aid the development process. Use a debugger, don't use a debugger, the choice is entirly down to the individual. Personally I choose to use a debugger whenever I feel it will aid the development.
Maugrim_The_Reaper wrote:I've found unit testing to be a nice method of capturing a snapshot of behaviour. I'd place a lot more value on it than any debugger.
I have very little experience with unit testing so I could be completely wrong but I wouldn't think that the two were mutally exclusive? By virtue of the name I would assume that unit testing should be used in the testing cycle where as a debugger would be used in the debuging process.

If I had to choose one or the other today, I'd choose a debugger. However, I'm perfectly willing to acknowledge that that decision is based on ignorance on my part due to my extremly limited knowledge of unit testing and it's capabilities/features/benefits.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Mine is very Maugrim-centric view ;) Unit testing is very useful in identifying WHERE and WHEN a problem is occurring. From there on in you need to discover the WHY. Finding the WHY varies surprisingly, whether you rely on a debuging process, echo's or other. I have a tendency to write the simplest code possible, and break it all down into separated tasks. So finding a bug for me is probably a lot simpler than in something more complex - thus a debugger's value is greatly reduced purely from my POV.

My own persuasion is to aid in preventing and detecting as early as possible any potential problems - so I largely end up with simple code, debugged on the fly based on the short term memory of my personal computer; my brain. Just remember that's just me - and I don't write a lot of rocket science code.

Just to sort of elaborate on unit testing a little. You offered one example early in the topic:
Specifically, I wanted to ensure/check that the ternary was acting as intended and that $conn_id contained the resource link for the DB connection after the first call to the function.
If you're following the Test Driven Development practice you would have written a test for this behaviour, then written just enough code to pass your test. So to verify the DB connection method works, and that it does indeed create a connection resource - you'd simply run the test, and ensure it passes.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Maugrim_The_Reaper wrote:
Specifically, I wanted to ensure/check that the ternary was acting as intended and that $conn_id contained the resource link for the DB connection after the first call to the function.
If you're following the Test Driven Development practice you would have written a test for this behaviour, then written just enough code to pass your test. So to verify the DB connection method works, and that it does indeed create a connection resource - you'd simply run the test, and ensure it passes.
OK, allow me to tap your knowledge on the subject of unit testing.

The check I was performing was not ensuring DB connectivity (I had already established that as part of the app that accesses the DB was running with no problems), I was performing two checks. 1, that the static var was being populated and 2, that there was only a single call to DB::connect within the script.

To be able to check these two points, I needed something that allows A) Inspection of a variable and it's contents and B) viewing of the code flow (in some form, admittedly I didn't need a line by line report but some sort of trace of calls and any calls within those calls recursively).

So, the question is, does unit testing provide this type of functionality?

I'm all for simplicity where ever possible. One thing that has stopped me from allocating some proper time to investigating unit testing is a fundamental belief of mine that developers cannot test their own code. You could test all day long for days/weeks and be convinced there are no 'major howlers' lurking within your code, give it to someone who has no idea of what it is and what it's supposed to do and (certainly if it's the initial version) they will invaribly break it within minutes :lol: For that reason (and limited exposure to unit testing) I'm not overly convinced about the idea.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

I'm all for simplicity where ever possible. One thing that has stopped me from allocating some proper time to investigating unit testing is a fundamental belief of mine that developers cannot test their own code. You could test all day long for days/weeks and be convinced there are no 'major howlers' lurking within your code, give it to someone who has no idea of what it is and what it's supposed to do and (certainly if it's the initial version) they will invaribly break it within minutes Laughing For that reason (and limited exposure to unit testing) I'm not overly convinced about the idea.
TDD (a separate practice that utilises Unit Testing) is a given during devepment - assuming you subscribe to the practice. Assuming for a moment you have written your tests, implemented your production code, and all tests are passing - then you have verified the application behaves as expected. I won't deny that this is fallable - the tests themselves could be erroneous, or might even be incapable of checking specific areas (esp. security). Like you said sometimes developers aren't the best for testing - peer review is invaluable. The test suite is primarily workout of the source code to ensure it works as expected, and that any changes are not effecting your expectations.
To be able to check these two points, I needed something that allows A) Inspection of a variable and it's contents and B) viewing of the code flow (in some form, admittedly I didn't need a line by line report but some sort of trace of calls and any calls within those calls recursively).
Singletons I've found to be something of a bane in unit testing. SimpleTest has a round of quick examples which are more useful than any explanation I could give - without becoming more verbose than usual. In PHP5 (difficult in PHP4 because of where static variables are declared - inside the function) you would use the "assert" family of functions to test the contents of a class property. http://www.lastcraft.com/unit_test_documentation.php

However I note that unit testing tests the flow of a class, how preset input/variables values are processed or operated upon, and if the results agree with what you expected. It's a nice workout, with a lot of value. What you are suggesting is different. You could create a test to ensure the singleton would work, but testing the number of times a certain function is called across the application in a single request is not its aim - if the singleton works as expected there's little need to check that far, unless you feel other code might be making unecessary additional calls (in which it would have an accompanying test for just that scenario).

Too verbose (this post) you should make a quick read of SimpleTest by Marcus Baker if you want to know more.
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Post by onion2k »

alvinphp wrote:If an editor saves me 10% then I would pay quite a bit for it (okay my work would), however if another ide exists with the same features and it costs less then I would go with that.
If I wanted to have 10% more coding time every day I'd just stop playing Counterstrike during office hours.

:twisted:
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Maugrim_The_Reaper wrote:Too verbose (this post) you should make a quick read of SimpleTest by Marcus Baker if you want to know more.
That's the plan, hopefully sooner rather than later. Thanks for your time.

No real need for debate or comments (unless of course you want to) but it seems where people have debated with me regarding echo vs true debugger I could probably debate along the same lines with unit testing vs my current approach.

By way of quick PHP example, I'm putting together a collection of a few functions for IP related issues at the moment. As per, I tend to run things through a little test script, the script in this case is as follows...

Code: Select all

<?php
// filename : $app_path . '/tests/ip.tst.php'

header('Content-Type: text/plain');
function show_text($text, $cr = true, $pad = 70)
{
  $text = $pad ? str_pad($text, $pad, '.') : $text;
  
  echo !$cr ? $text : $text . "\x0a";
} 

include('../lib/ip.cls.php');

$ips[0] = '232.106.10.7';
$ips[1] = '232.106.010.007';
$ips[2] = '232.106.010.000';
$ips[3] = '1080:0:0:0:8:800:200C:417A';
$ips[4] = '123.56..001';
$ips[5] = 'FEDC:BA98:7654:3210:FEDC:BA98:224.74.56.18';
$ips[6] = 'A0EC::FEDC:BA98:7654:3210';
$ips[7] = '::'; // compressed hex representation of 0:0:0:0:0:0:0:0
$ips[8] = '1080::8:123.231.4.99';
$ips[9] = '294967299';

$compare[0] = '244.66.10.27';
$compare[1] = '244.66.12.32';
$compare[2] = '244.66.17.32';
$compare[3] = '244.25.10.27';
$compare[4] = '133.66.10.27';
$compare[5] = '133.66.10.34';
$compare[6] = '2235697691';
$compare[7] = '244.66.12.27';
$compare[8] = '4097968667';

foreach ($ips as $ip)
{
  // there is potential here to loop within the loop, fine for testing but may
  // then require additional example scripts. leaving 'as is' as this script
  // should serve as both test and example for even the most braindead
  show_text("Testing IP address {$ip} ", false);
  ($type = IP::is_ip($ip)) ? show_text('Passed ', false, false) : show_text('Failed', true,false);

  if ($type & IP_V4)
  {
    show_text('(IPv4)', true, false);
  }
    
  if ($type & IP_V6)
  {
    show_text('(IPv6)', true, false);
  }

  show_text('Testing as IPv4 ', false);
  ($type = IP::is_ip($ip, IP_V4)) ? show_text('Passed ', false, false) : show_text('Failed', true,false);

  switch($type)
  {
    case V4_QUAD:
      show_text('(dotted quad)', true, false);
      break;
    
    case V4_INT:
      show_text('(integer)', true, false);
      break;
  }

  show_text('Testing as IPv4 strict ', false);
  IP::is_ip($ip, IP_V4, V4_STRICT) ? show_text('Passed', true, false) : show_text('Failed', true,false);  
  
  show_text('Testing as IPv4 quad ', false);
  IP::is_ip($ip, V4_QUAD) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('Testing as IPv4 integer ', false);
  IP::is_ip($ip, V4_INT) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('Testing as IPv6 ', false);
  ($type = IP::is_ip($ip, IP_V6)) ? show_text('Passed ', false, false) : show_text('Failed', true,false);

  switch($type)
  {
    case V6_HEX:
      show_text('(hex)', true, false);
      break;
    
    case V6_ZHEX:
      show_text('(compressed hex)', true, false);
      break;
    
    case V6_HEXDEC:
      show_text('(hex/dec)', true, false);
      break;
    
    case V6_ZHEXDEC:
      show_text('(compressed hex/dec)', true, false);
      break;
  }

  show_text('Testing as IPv6 hex ', false);
  IP::is_ip($ip, V6_HEX) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('Testing as IPv6 compresed hex ', false);
  IP::is_ip($ip, V6_ZHEX) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('Testing as IPv6 hex/dec ', false);
  IP::is_ip($ip, V6_HEXDEC) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('Testing as IPv6 compressed hex/dec ', false);
  IP::is_ip($ip, V6_ZHEXDEC) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('Converting to IPv4 integer ', false);
  ($int = IP::ip2int($ip)) ? show_text('Passed (' . $int . ')', true, false) : show_text('Failed', true, false);
  
  show_text('Converting to IPv4 quad ', false);
  ($quad = IP::int2ip($ip)) ? show_text('Passed (' . $quad . ')', true, false) : show_text('Failed', true, false);

  // SMA? acronym for Slightly More Advanced, best I could think of at the time 
  show_text('SMA testing as any except IPv4 integer ', false);
  IP::is_ip($ip, IP_ALL ^ V4_INT) ? show_text('Passed', true, false) : show_text('Failed', true,false);  

  show_text('SMA testing as IPv6 hex or IPv4 any ', false);
  IP::is_ip($ip, V6_HEX, IP_V4) ? show_text('Passed', true, false) : show_text('Failed', true,false);  

  show_text('SMA testing as IPv6 any or IPv4 integer ', false);
  IP::is_ip($ip, IP_V6, V4_INT) ? show_text('Passed', true, false) : show_text('Failed', true,false);  

  show_text('SMA testing as IPv4 quad or IPv6 any except compressed hex ', false);
  IP::is_ip($ip, V4_QUAD, IP_V6 ^ V6_ZHEX) ? show_text('Passed', true, false) : show_text('Failed', true,false);  

  show_text('', true, false);
}

show_text('Checking for client IP ', false);
($client = IP::client_ip()) ? show_text("Passed ({$client})", true, false) : show_text("Failed", true, false);
show_text('', true, false);

show_text("Comparison checking...", true, false);

for ($i = 0, $max = count($compare); $i < $max; $i++)
{
  $ip1 = $compare[$i];
  $ip2 = (isset($compare[$i + 1])) ? $compare[$i + 1] : $compare[0];
  
  show_text("Comparing {$ip1} against {$ip2} :", true, false);
  
  show_text('32-bit compare ', false);
  IP::ip_cmp($ip1, $ip2, 32) ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('24-bit compare ', false);
  IP::ip_cmp($ip1, $ip2, 24) ? show_text('Passed', true, false) : show_text('Failed', true,false);

  show_text('16-bit compare ', false);
  IP::ip_cmp($ip1, $ip2, 16) ? show_text('Passed', true, false) : show_text('Failed', true,false);

  show_text(' 8-bit compare ', false);
  IP::ip_cmp($ip1, $ip2,   ? show_text('Passed', true, false) : show_text('Failed', true,false);
  
  show_text('', true, false);
}

show_text('Done', false, false);
?>
This test script allows for feeding the functions with various data types/values and getting a good overview of the results, as the results look like this....

Code: Select all

Testing IP address 232.106.10.7 ......................................Passed (IPv4)
Testing as IPv4 ......................................................Passed (dotted quad)
Testing as IPv4 strict ...............................................Passed
Testing as IPv4 quad .................................................Passed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Failed
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Passed (3899263495)
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Passed
SMA testing as IPv6 any or IPv4 integer ..............................Failed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Passed

Testing IP address 232.106.010.007 ...................................Passed (IPv4)
Testing as IPv4 ......................................................Passed (dotted quad)
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Passed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Failed
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Passed (3899263495)
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Passed
SMA testing as IPv6 any or IPv4 integer ..............................Failed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Passed

Testing IP address 232.106.010.000 ...................................Passed (IPv4)
Testing as IPv4 ......................................................Passed (dotted quad)
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Passed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Failed
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Passed (3899263488)
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Passed
SMA testing as IPv6 any or IPv4 integer ..............................Failed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Passed

Testing IP address 1080:0:0:0:8:800:200C:417A ........................Passed (IPv6)
Testing as IPv4 ......................................................Failed
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Passed (hex)
Testing as IPv6 hex ..................................................Passed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Passed
SMA testing as IPv6 any or IPv4 integer ..............................Passed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Passed

Testing IP address 123.56..001 .......................................Failed
Testing as IPv4 ......................................................Failed
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Failed
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Failed
SMA testing as IPv6 hex or IPv4 any ..................................Failed
SMA testing as IPv6 any or IPv4 integer ..............................Failed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Failed

Testing IP address FEDC:BA98:7654:3210:FEDC:BA98:224.74.56.18 ........Passed (IPv6)
Testing as IPv4 ......................................................Failed
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Passed (hex/dec)
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Passed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Failed
SMA testing as IPv6 any or IPv4 integer ..............................Passed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Passed

Testing IP address A0EC::FEDC:BA98:7654:3210 .........................Passed (IPv6)
Testing as IPv4 ......................................................Failed
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Passed (compressed hex)
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Passed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Failed
SMA testing as IPv6 any or IPv4 integer ..............................Passed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Failed

Testing IP address :: ................................................Passed (IPv6)
Testing as IPv4 ......................................................Failed
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Passed (compressed hex)
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Passed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Failed
SMA testing as IPv6 any or IPv4 integer ..............................Passed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Failed

Testing IP address 1080::8:123.231.4.99 ..............................Passed (IPv6)
Testing as IPv4 ......................................................Failed
Testing as IPv4 strict ...............................................Failed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Failed
Testing as IPv6 ......................................................Passed (compressed hex/dec)
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Passed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Failed
SMA testing as any except IPv4 integer ...............................Passed
SMA testing as IPv6 hex or IPv4 any ..................................Failed
SMA testing as IPv6 any or IPv4 integer ..............................Passed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Passed

Testing IP address 294967299 .........................................Passed (IPv4)
Testing as IPv4 ......................................................Passed (integer)
Testing as IPv4 strict ...............................................Passed
Testing as IPv4 quad .................................................Failed
Testing as IPv4 integer ..............................................Passed
Testing as IPv6 ......................................................Failed
Testing as IPv6 hex ..................................................Failed
Testing as IPv6 compresed hex ........................................Failed
Testing as IPv6 hex/dec ..............................................Failed
Testing as IPv6 compressed hex/dec ...................................Failed
Converting to IPv4 integer ...........................................Failed
Converting to IPv4 quad ..............................................Passed (17.148.216.3)
SMA testing as any except IPv4 integer ...............................Failed
SMA testing as IPv6 hex or IPv4 any ..................................Passed
SMA testing as IPv6 any or IPv4 integer ..............................Passed
SMA testing as IPv4 quad or IPv6 any except compressed hex ...........Failed

Checking for client IP ...............................................Passed (127.0.0.1)

Comparison checking...
Comparing 244.66.10.27 against 244.66.12.32 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Failed
16-bit compare .......................................................Passed
 8-bit compare .......................................................Passed

Comparing 244.66.12.32 against 244.66.17.32 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Failed
16-bit compare .......................................................Passed
 8-bit compare .......................................................Passed

Comparing 244.66.17.32 against 244.25.10.27 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Failed
16-bit compare .......................................................Failed
 8-bit compare .......................................................Passed

Comparing 244.25.10.27 against 133.66.10.27 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Failed
16-bit compare .......................................................Failed
 8-bit compare .......................................................Failed

Comparing 133.66.10.27 against 133.66.10.34 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Passed
16-bit compare .......................................................Passed
 8-bit compare .......................................................Passed

Comparing 133.66.10.34 against 2235697691 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Passed
16-bit compare .......................................................Passed
 8-bit compare .......................................................Passed

Comparing 2235697691 against 244.66.12.27 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Failed
16-bit compare .......................................................Failed
 8-bit compare .......................................................Failed

Comparing 244.66.12.27 against 4097968667 :
32-bit compare .......................................................Failed
24-bit compare .......................................................Failed
16-bit compare .......................................................Passed
 8-bit compare .......................................................Passed

Comparing 4097968667 against 244.66.10.27 :
32-bit compare .......................................................Passed
24-bit compare .......................................................Passed
16-bit compare .......................................................Passed
 8-bit compare .......................................................Passed

Done
Granted my test script probably doesn't offer the same level of granularity that unit testing may, however, should there be errors within the code the output of this script will help me as I feel it provides a relatively good insight as to *where* and *when* the problem lies. From that I can examine the code base and optionally crank up a debugger if required as a means to resolve the issue.

Much as I'd love to say that my code works first time every time that's not the case, and I did indeed end up running parts of the code through a debugger. Whilst in there resolving the issue the debugger also highlighted a completely unrelated issue, a problem with my flag/option handling logic, so even though all seemed good on the outside and the desired results were being acheived, there was potential under the hood that under certain circumstances there could be additional and unnessecary function calls being made.

Hopefully soon I'll be able to draw my own conclusions but certainly for the moment, I'm still unclear as to what exact benefits I could gain from adding unit testing to my toolbox.
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post by Maugrim_The_Reaper »

Your output looks remarkably similar to what a unit test would output - of course a unit test works by testing classes.

I'm not in for a debate - its all down to preferences. I think one way, you think another. Same for all of us. Unit tests are a nice complement to the way I organise my code, which is purposefully kept simple (I'll do things the long way rather than compromise on readability, or use a complex piece of gymnastics ;)), littered with error checks, and is usually quote strict (in PHP5 I always use type hinting, abstracts and interfaces where they make sense). I simply find a debugger to be of less value than most probably would.

Not arguing against a debugging. I keep my XDebug pecl extension up to date... I just try to avoid the need to use it as much as possible.
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post by redmonkey »

Are you saying that my code is overly complex? Did you spill my pint? :D

I am actually in the process of rewritting a lot of my underlying functions/classes/code base but not really because I consider it/them to be overly complex, more a case of I consider them to be too feature rich/bloated.

The problem I had/have is that currently a lot of the under the hood workings have far more features than I actually use. Case in point, I'm rewritting my SQL database handlers at the moment. I wrote them a few years ago and I've been rehashing them ever since. Now, essentially there is nothing wrong with my current implementation and I wouldn't consider the code to be overly complex for the features it supports. However, given that I don't actually use/access most of the features then yes, it could be considered overly complex for the task at hand.

I had an error of judgement when I initially developed them as I thought it would be a good idea to bundle in a certain level of 'genericness', over time that judgement call has proved to be more of a hinderance rather than a help. Much as I hate to admit it, they are just filled with bloat which in turn adds complexity as the code attempts to be all things to all people.

I have to admit, that even while rewritting some of my code base there are areas which some may still consider to be overly complex.

I probably use more inline error checking than most, I haven't done much with PHP5 as yet but certainly within PHP4 I do use a lot of type casting and type checking a kind of psuedo type hinting if you like i.e. if (!is_int($somevar)) throw an error.

I'm always interested in what other developers take are on things and over the years I have changed various aspects of both my develpment practices and code styling as a direct result of conversations/debates with other developers.

You have actually got me thinking now to the point that I'm questioning my implemtation of a few parts of my IP class which I have been writting. Essentially it contains some wrapper functions (basically absraction functions) which I think make life easier for the average developer but I'm now wondering if the actual wrappers should exist or not :lol: I think I may post it up later and open it up for comments.
Post Reply