Email idées pour pylint

from
subject
idées pour pylint
date
2004/06/16 18:20
Des  métriques proposées sur la liste TDD. 

----- Forwarded message from Camille Bell <cpbell1@yahoo.com> -----

From: Camille Bell <cpbell1@yahoo.com>
X-Spambayes-Classification: ham; 0.00
To: testdrivendevelopment@yahoogroups.com
Date: Wed, 16 Jun 2004 09:01:05 -0700 (PDT)
Subject: Re: [TDD] I thought I did TDD very well, but now...

Thomas,

Ron's comments on Pairing and Michael's comments on
Fitness and JUnit sound like good places to start. C#
is very close to Java, so anything Java based like
JUnit should be helpful.

Built In Test can get rather obtuse, if incorporated
into your classes, so using a tool like the XUnit
series which forces isolation helps.

Additionally consider getting a deeper understanding
of OO design. Most folks, especially Agile developers
do a fair bit of design at the code level, which is OK
as long as you know you are doing design and what to
do to refactor your design when needed. 

One of the best sources for good guidelines on OO
design is Arthur Riel's "Object_Oriented Design
Heuristics", ISBN 020163385X

An Agile Development specific way to clean up your
code is Refactoring. Since you have tests in place,
Refactoring is pretty safe and definitely recommended
if folks can't understand your code. See Martin
Fowler's "Refactoring: Improving the Design of
Existing Code" ISBN 0201485672 . Martin's book uses
Java for examples, but Java is close to C#. I have a
friend in the local DC Area XP group who has taken the
first chapter Refactoring examples and translated them
into C#. If you're interested, I can get you contact
information.

I have a personal checklist I use for evaluating
design in code. The checklist questions are
numbers/metrics based, because it makes it easy to
know if a guideline has been violated. There are
legitimate reasons to violate the assumptions on the
checklist, but generally, if you answer "no" to a
question you should consider refactoring unless you
have a really good reason to violate the rule. BTW,
these checklist questions assume a C++, Objective-C,
or Java type of OO language and so should apply also
to C#. Many of numbers should be reduced for
Smalltalk.

BTW, if others on the board have suggestions for
improvements to these questions (I haven't updated
them for some time), I'm open to suggestions.

Here's my Questions:

Camilles's Checklist for 
OO Design Consistency within Code 
(Clarity & Maintainability Focus)

An individual class probably lacks a good OO design if
any of the following guidelines are violated:

1. Does the protocol, header or interface file have 5
methods or more?
2. Does the class contain less than 20 attributes
(instance variables or data members in the class) for
non-GUI classes (40 for GUI)?
3. Is the number of methods in the protocol and/or
public methods in the header 20 or less?
4. Is there no use of global data or functions?
5. Are all attributes (instance variables or data
members) private?
6. Do sub classes avoid direct access to super class
attributes (e.g. only use accessor methods)?
7. Do methods average lines of code counts of 10 or
less?
8. Do all methods have lines of code counts of 25 or
less?
9. Are the complex parts of the class contained in
logical grouping of aggregate classes, instead of as
attributes or a single method with multiple complex
algorithms that parse or generate data?
10. Does the class contain 1 and only 1 key
abstraction?
11. Do all method contain 5 or less local variables?
12. Do most methods pass 3 or less parameters?

An inter-dependent system of classes (sub-system,
package, etc.) probably lacks good OO design unless
the following is true:

13. Does the class depend on more than 9 or less other
classes (ignore inheritance and aggregation)?
Determine this number by:
? Within the class methods note method calls to other
instantiated classes (count only the unique classes
not the methods).
? Outside the class count the number of other classes
which instantiated this class and call its methods
(try to read all related code and read controller
class code carefully).
? Add the two counts together.

A class hierarchy (class structure which shows class
inheritance and aggregation) probably lacks a good OO
design unless the following are true:

14. Is the total depth of inheritance hierarchy is 7
or less?
15. Do parent classes (super classes, base classes)
always have at least 2 children (sub-classes)?
16. Is the use of aggregation as least as common as
the use of inheritance?

David Astels' recent book "Test-Driven Development: A
Practical Guide" ISBN 0131016490 has wonderful
detailed examples of TDD in Java, where the BIT code
doesn't obscure the main code. Maybe you eat this up
when it came out or maybe you ignored it because it
was Java based instead of C#. If ignored, please give
TDD: A Practical Guide a look.

If you really, really, really want to get into the
guts of OO testing, the bible on the subject is Robert
V. Binder's book "Testing Object-Oriented Systems:
Models, Patterns, and Tools" ISBN 0201809389. Testing
OO Systems is nearly 1200 pages and was written before
the TDD books were published and covers areas of
testing you may not be interested as well as areas of
developer interest. Chapter 10 however does focus on
Class Testing and other chapters discuss how design
test harness and related topics.

hope some of this helps,

Camille
--- Thomas Eyde <teyde@online.no> wrote:
> Dear Group,

> I am hoping for some guidance here:

> First some background info: I started with TDD four
> years ago. Since then I have seen my test code
> improve. My tests are smaller, more concise, more
> expressive. I also see improvement in class design,
> as my classes are simpler to set up and test, they
> are small, loosly coupled and so on. I am pretty
> much satisfied by what I see.

> Almost.

> Now I have to realise that even I have been doing
> TDD for some time now, the only feedback I have got
> is my own. That is, until now. I am now the second
> person on a team developing a web portal in ASP.NET
> and C#. My coworker complaints about the complexity
> in my code and says he has a hard time understanding
> what the code is really doing. He thinks I add to
> many classes and as too many abstractions. I don't
> add anything until a test requires so, but every
> time I do, I hear complaints and I have to spend an
> amount of time to both explain why this is good to
> me and to sell why this is a little smarter if we
> are supposed to do TDD.

> Then I have this other, recent feedback. I have
> developed a kind of a reference implementation of
> some third party library, also in ASP.NET. This
> customer has a slightly different feedback: They say
> my code is well structured, but still complex. Even
> when I walk through the code, they don't understand
> what's going on.

> And I have to agree.

> I have no choice but to agree with them. The fact is
> that I have a hard time myself to find where the
> application "starts". There is really no start, but
> at some point the gui will meet the workflow logic,
> which then will meet the business logic, which in
> turn uses their library code.

> I guess that's my next territory to explore: How to
> layer my code so it's easier to hunt down the
> interesting parts. Do you have pointers to good
> resources, some guidelines, rules of thumb,
> anything?

> If other people can't see the whole picture in my
> code, then it's not good enough. I want my code to
> be good, I want to improve my coding skills, and
> want to do it fast.

> Thanks.
> Thomas Eyde

> [Non-text portions of this message have been
> removed]



> ------------------------ Yahoo! Groups Sponsor
> --------------------~--> 
> Make a clean sweep of pop-up ads. Yahoo! Companion
> Toolbar.
> Now with Pop-Up Blocker. Get it for free!
>
http://us.click.yahoo.com/L5YrjA/eSIIAA/yQLSAA/NhFolB/TM
>
--------------------------------------------------------------------~->


>  
> Yahoo! Groups Links

> http://groups.yahoo.com/group/testdrivendevelopment/

>     
> testdrivendevelopment-unsubscribe@yahoogroups.com

>  






__________________________________
Do you Yahoo!?
Yahoo! Mail - Helps protect you from nasty viruses.
http://promotions.yahoo.com/new_mail



------------------------ Yahoo! Groups Sponsor --------------------~--> 
Yahoo! Domains - Claim yours for only $14.70
http://us.click.yahoo.com/Z1wmxD/DREIAA/yQLSAA/NhFolB/TM
--------------------------------------------------------------------~-> 

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/testdrivendevelopment/

<*> To unsubscribe from this group, send an email to:
     testdrivendevelopment-unsubscribe@yahoogroups.com

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
 


----- End forwarded message -----

-- 
Alexandre Fayolle                              LOGILAB, Paris (France).
http://www.logilab.com   http://www.logilab.fr  http://www.logilab.org