DEV Community

Discussion on: Is This Snowflake Code?

Collapse
 
jacoby profile image
Dave Jacoby

Re: Your second paragraph

That would be Hungarian Notation, correct?

I looked at it in the 1990s, hearing it was Microsoft house style, and decided that Perl kinda had this with the sigils; $, @, % and &. I get the point of it, but I didn't see it as adding value. I don't see anything gained by my $fpPi = 3.14159. because you know what Pi is and how it is used. (Incidentally, that could now be my $fpπ = 3.14159.)

The problem of "what kind of thing IS this variable" is lessened by not having code blocks larger than an editor window, so that you can see most everywhere $line is used.

This also gets to convention. Repeating the read:

my @array ;
my $x = 0 ;
while ( my $line = <DATA> ) {
    chomp $line ;
    $line =~ s{\D}{ }mxg ;
    my @line = split m{|}mx, $line ;
    for my $y ( 0 .. 8 ) {
        my $digit = ' ' ;
        $digit = $line[$y] if defined $line[$y] ;
        $array[$x][$y] = $digit ;
        }
    $x++ ;
    }

@array is a two-dimensional array, and $x and $y represent positions within. $digit could be better-named, because it could be a single digit 1-9 but it could be a space, because I'm avoiding undefs. Is it better as $chDigit? But the whole thing is eleven lines and the only thing that is used after this is @array. (Which is too generic a name, but I couldn't think of a better one when I was coding it. @puzzle? @chPuzzle? @arrchPuzzle?

Currently, I'm doing a lot more with references, both arrayrefs and hashrefs, because I'm much more likely to pull from JSON or SQL, and the tools I have give me references, and I think that $objrefUser->{ uintID } would not give me any benefit.

There are places where it would make sense, but since I don't work in those places, I get why I am in the 99% on this one.