|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Classes vs multi-dimensional arrays
To be honest, i've never really used classes in my code... That's because i don't always see the use of them...
I think with multi-dimensional arrays you can accomplish the same. So can anyone tell me of a script that can only be made with the use of classes? So i can see the use of them |
|
#2
|
||||||
|
||||||
|
RE: Classes vs multi-dimensional arrays
Well, a class is alot different from an array. The major difference is that a class has functions in it as well as data. From the PHP manual:
Quote:
Here is a small sample class you can look at to see the basic functionality of one: php Code:
Hope that helps a bit... |
|
#3
|
|||
|
|||
|
RE: Classes vs multi-dimensional arrays
Thanks for the sample...
I know (mostly) how classes work. But i see other people use classes where i use a structure of arrays and for-loops. For instance with the current contest. I'm sure a lot of people use classes to define the coördinates of each 'cell' in the maze. I use an multi-dim array like this to store my coordinates: $coords[$maze_num][$ypos][$xpos]. And it works perfectly. The only problem i can see is that other people won't understand my code easily, because it's less structured |
|
#4
|
|||
|
|||
|
RE: Classes vs multi-dimensional arrays
i'm all about arrays as well..
|
|
#5
|
|||
|
|||
|
RE: Classes vs multi-dimensional arrays
Same here. Classes get far too messy way too fast imho. But i actually want to see if i can incorporate classes into my thinking structure.. maybe it has some use.. ;)
|
|
#6
|
|||
|
|||
|
RE: RE: Classes vs multi-dimensional arrays
Quote:
Yeah, that's also what i'm trying to do... That's why i'm asking to think of a script/program that can only be done with classes... |
|
#7
|
|||
|
|||
|
RE: RE: Classes vs multi-dimensional arrays
Quote:
That's what I used to think, but in a couple of months, if you need to re-do sthg you did in a messy manner, you'll probably have forgotten how it works if it's not well structurated. That's also why everybody *needs* to comment is code |
|
#8
|
||||
|
||||
|
RE: Classes vs multi-dimensional arrays
I don't think it's possible to have a problem that can only be solved with classes. Classes may make some problems eaiser to think about and eaiser to code, but there are many ways to skin a cat.
Commenting code is important, but I think good, clear abstraction is more important. And usually, classes help clarify your levels of abstraction. |
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Classes vs multi-dimensional arrays |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|
|
|