On Fri, 25 Dec 2009 16:57:04 +0100, Christoph Friedrich wrote: 
> I am new to Perl and I am not sure if my Coding Style is good. Could
> some of you please check if my Coding Style is good or tell me what I
> should change to get a good Coding Style? You can find 2 files of my
> current project under http://www.christophfriedrich.de/code/ Please
> check it so that I can write good code on bigger projects.

Nice choices of names.


    my $self = bless({}, ref ($class) || $class);

This is cargo cult programming for object construction.  The actual 
utility of a constructor that can work both as a class method and some 
sort of cloning function is severely limited and copying this style leads 
to fuzzy thinking about object class design.

        $self->{'size'} = $size;

Hash keys that are 'well-behaved' are better off unquoted, the code 
becomes easier to read.

                        $cells[$row][$col] = 
DragonNet::Games::Sudoku::Board::Cell->new(size => $size);

You have very long package names.  Consider using http://search.cpan.org/
~ovid/aliased-0.30/lib/aliased.pm to make the code more succinct.

                $cells[$row] = ();

An unusual idiom for setting a scalar to undef.  However, since that value 
ends up being a reference to an array, this line is unnecessary.  
Autovivification will take care of you.

-- 
Peter Scott
http://www.perlmedic.com/
http://www.perldebugged.com/
http://www.informit.com/store/product.aspx?isbn=0137001274

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to