Go Back   Velocity Reviews > Newsgroups > Python
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

Python - Re: "Battleship" style game

 
Thread Tools Search this Thread
Old 02-25-2009, 10:31 PM   #1
Default Re: "Battleship" style game


On Wed, 25 Feb 2009 15:54:46 -0500, Shawn Milochik <> wrote:
>On Wed, Feb 25, 2009 at 3:15 PM, Diez B. Roggisch <> wrote:
>
>> Not really. The point about properties is that you *can* make attribute
>> access trigger getter or setter code.
>>
>> But not that you do unless there is an actual reason for that. The way you
>> do it now is simply introducing clutter, without benefit. Your class would
>> be half the current size - without loss of functionality.
>>
>>
>>
>> Diez
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>>

>
>It is true that it would be fewer lines of code with the same
>functionality, but it's better practice to have that framework in
>place so that any changes made in the future wouldn't break any of the
>code accessing my class. Obviously this is a fairly simple game that
>has a fixed set of rules, but I'm trying to cultivate good habits, and
>I don't think that doing it this way is anti-Pythonic.
>
>Unless, of course, anything I said is wrong, which is always possible.
>If I'm missing a bigger-picture idea, I'd like to know about it.


Much better practice would be writing unit tests for the behavior you
want. This is a vastly greater measure of protection against future
maintenance introducing bugs than the restrictions you're adding to
your implementation. So if you're looking for good habits to pick up,
start with unit testing. Your test.py files show you're at least
thinking about testing, but you should take a look at something like
the `unittest´ module in the standard library and take things to the
next level.

Jean-Paul


Jean-Paul Calderone
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
OT: Awards ceremony, Australian style Johnston DVD Video 1 12-02-2006 01:50 AM
2006 LG's Holiday of Style Product Briefing Silverstrand Front Page News 0 10-26-2006 10:24 PM
Mike Meyers - I like your style Roger A+ Certification 1 08-05-2003 02:55 AM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46