标签云

微信群

扫码加入我们

WeChat QR Code


isn't doing anything else in a setter other than setting the value of the property an example of wrong usage in Java.

2018年12月10日54分02秒

euphoria83 Perhaps, but that doesn't preclude it from happening.

2018年12月10日54分02秒

If the Student object is a business/domain object, you are now mixing infrastructure details. Ideally, a business/domain objects should be concerned only with business/domain logic.

2018年12月11日54分02秒

What if you add some sort of boolean to the getter like: PHP: public function getName($outsideCall = true){ if($outsideCall){ $this->incrementNameCalled(); } return $this->name; } and then from within the Object itself, if you called get name, you could keep it from incrementing by: PHP: $name = $this->getName(false); Am I just going overboard here?

2018年12月11日54分02秒

I was driven by the same need you had to comment... Plus it was answered not closed ;)

2018年12月11日54分02秒