yh.h wrote:I have to weigh in on this. I think it is a huge leap you're making. You can't just assume OOP is always better than procedural because it seems like it makes your life simpler. In this case, it clearly does not. Too much simplicity for the sake of simplicity becomes overkill.
OOP making life simpler is the effect, not the cause. The cause is reducing what will probably end up being a rather large function or group of functions into simple component parts, grouped logically into sets of behavior and data (i.e. objects...).
If you'll notice in the first example posted by nor0101, the OOP version had methods for searching and sorting. These were not represented in the prodedural version. That means we need at least three functions for a comparable procedural example that work on the same global variable. Now, your argument was that a comment would fix things... one for each function? In every place that function is used? I'd much rather pass around and work with an explicit $rolodex object than use functions that modify an implicit global variable.
You also mentioned changes.. what if I want more user information stored in the rolodex? Say, a contact address and a billing address (pretty common requirement). That would require either adding more parameters on your function (yuck) or adding a new function. Now, that search function probably needs to get a little more complex. Are you gonna modify that too, or write another function? Either you're going to use search and replace for a week trying to replace all instances of all functions, or you're going to end up with sets of functions that vary slightly and duplicate functionality all across the board. OR... you could have that handy person object implement an interface and code another object that contains addresses.
I think you're arguing from the standpoint that more lines, more objects, and more methods make things more complex. They don't. Splitting a single complex function into simple parts is not making things more complex, nor is it simplicity for simplicity's sake... it's functional, and allows you to group code into reusable portions and localize changes. Those are pretty useful benefits, and far outweigh the argument that more lines of code = more complexity.