[#4567] Re: What's the biggest Ruby development? — Aleksi Niemel<aleksi.niemela@...>

Dave said:

18 messages 2000/08/23
[#4568] Q's on Marshal — Robert Feldt <feldt@...> 2000/08/23

[#4580] RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/25

[#4584] Re: RubyUnit testcase run for different init params? — Dave Thomas <Dave@...> 2000/08/25

Robert Feldt <feldt@ce.chalmers.se> writes:

[#4623] Re: RubyUnit testcase run for different init params? — Robert Feldt <feldt@...> 2000/08/28

On Sat, 26 Aug 2000, Dave Thomas wrote:

[#4652] Andy and Dave's European Tour 2000 — Dave Thomas <Dave@...>

24 messages 2000/08/30
[#4653] Re: Andy and Dave's European Tour 2000 — matz@... (Yukihiro Matsumoto) 2000/08/30

Hi,

[#4657] Ruby tutorials for newbie — Kevin Liang <kevin@...> 2000/08/30

Hi,

[ruby-talk:04503] RubyUnit and encapsulation.

From: Hugh Sasse Staff Elec Eng <hgs@...>
Date: 2000-08-18 16:51:55 UTC
List: ruby-talk #4503
My_class's instance variables are not all "attr :<name>" type variables,
so some can only be accessed from inside the class.  That is fine, it is
what OO is all about.

I design some RubyUnit tests for My_class, with a Testing_class to do
them.

I have 3 ways I could do this:

1 Test the external interface to My_class only.  

My tests will outlive any implementation details of My_class, but they
won't tell me too much about why they have failed, if they do.

2 Test the internals of the class.

I cannot get at these from Testing_class, but if I could I could guarantee
that each method of My_class was doing what I intended, even private
methods, so I could simplify the testing structure, and localise bugs more
easily.

3 Make more of the internals of My_class visible to the outside world

This would make 2 easier, but if I change the internals later, then my
interface changes.


It seems like 1 is the only sensible way to do this, and "If the errors
don't localise the bugs, then Tough!".  The implication seems to be that I
should redesign my class, but in what way(s)?  My class currently holds
arrays, hashes, and booleans in a unified whole. Most of the methos setup
the correct values in these as files are processed. Is such a question too
case-specific to have any useful general answer(s)?

	Hugh
	hgs@dmu.ac.uk


In This Thread

Prev Next