views:

30

answers:

3

I was performing a code review and I saw a class that a developer had created, that only contained public instance-fields. This class is not used in business logic; it is merely used to hold test data (the developer created this for a test).

Is this alright? Why or why not?

+1  A: 

If it is a class which just holds test data, and it helps perform the test then maybe.... But it might be worth asking the question, where else does the developer flagrantly expose members?

brumScouse
+1  A: 

In Python, for example, there is no such thing as a private field. You prepend class members' names with an underscore if you want to designate them as private, and hope that people who do not know what they are doing will not mess with them. So... this does not seem to make Python programs any more error prone or unsafe in any way. So I would say - it is definitely not a problem, especially considering there is no business logic in it.

Ivan P
+1  A: 

It's definately something I'd be questioning.

If it's used for testing only, then it should be easily identifiable that it is only to be used for testing. This could be done by using an agreed naming standard, or your test classes could be separated from your production code (perhaps in a different project or equivalent container for your language).

Jason Young