emilybache / Racing-Car-Katas

Several code katas on a racing car theme

Home Page:https://youtu.be/ldthYMeXSoI

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Visibility of fields

pfichtner opened this issue · comments

Is it intentional that the fields are not private? This makes "get it under test without changing the production code" relatively easy (which it wouldn't be otherwise)

Alarm alarm = new Alarm();
alarm.sensor = new MySensorStub();

You make a good point. I was just looking at the other language versions and most have it private or protected. Package level privacy in Java is really quite permissive! I'd accept a pull request to make it protected, if you'd like to send one?

Is there anything wrong with changing it to private? Otherwise when leaving it protected, replacing the field in a inheriting Alarm class again would be to easy, wouldn't it?