Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: RFC: object-oriented two-dimensional ragged array tutorial

by Jenda (Abbot)
on Sep 11, 2013 at 14:01 UTC ( #1053503=note: print w/replies, xml ) Need Help??

in reply to RFC: object-oriented two-dimensional ragged array tutorial

The question is ... why?

I mean, what's

my @AoA; $AoA[0] = [1,2,3]; $AoA[1] = [4,8]; $AoA[0][3] = 99; ...
if not a ragged array? I can set individual elements, I can query individual elements, I can set or get rows, ...

May I see some code that would benefit from your maze of classes?

Enoch was right!
Enjoy the last years of Rome.

Replies are listed 'Best First'.
Re^2: RFC: object-oriented two-dimensional ragged array tutorial
by paulymer (Novice) on Sep 11, 2013 at 21:49 UTC
    Yes, you have given an example of a ragged array. And yes, perl is great for building and manipulating them as you have shown. The difference between the example you give here and the examples I give in my tutorial is a nice contrast between programming in traditional perl5 and OOP with Moose. If you are working with simple scalars such as numbers or strings as elements of your data structures, then Moose would definitely be overkill. I can see your point, that my examples could be considered overkill since I have simply wrapped a 'Cell' class around a scalar string. If that was all I really needed to do, then yes, I went way overboard. I merely used this simple 'Cell' class as an example. Create any complex class with multiple attributes, multiple methods, and add dependencies between those attributes and methods, then tack on inheritance by sub-classing this complex class, and you might begin to see where this tutorial could be useful.

      Your argument is that you've used a simple, if ultimately unnecessary example, to demonstrate some of the more complex parts of OO; because you didn't want to detract from the techniques you were demonstrating with the detail of the classes you used to demonstrate them.

      That is a fine argument.

      However, without a convincing example of when it is necessary, (or beneficial in some tangible way), to use the techniques you are demonstrating, it leaves the demonstration looking like a solution looking for a problem.

      So, the challenge to you is: show a realistic example of using those techniques that cannot be trivially and beneficially replaced with simpler, non-OO code.

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053503]
and monks are getting baked in the sun...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (15)
As of 2017-01-20 20:35 GMT
Find Nodes?
    Voting Booth?
    Do you watch meteor showers?

    Results (177 votes). Check out past polls.