tagged [getter]

"Getters should not include large amounts of logic." True or false?

"Getters should not include large amounts of logic." True or false? I tend to assume that getters are little more than an access control wrapper around an otherwise fairly lightweight set of instructi...

25 Nov at 12:32

Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA

Rhino Mocks AssertWasCalled (multiple times) on property getter using AAA I have a mocked object that is passed as a constructor argument to another object. How can I test that a mocked object's prope...

C# getter and setter shorthand

C# getter and setter shorthand If my understanding of the internal workings of this line is correct: Then it behind the scenes does this: What I really need is: ``` private bool IsDirty { get; set; } ...

15 Feb at 21:36

TDD, DDD and Encapsulation

TDD, DDD and Encapsulation After several years of following the bad practice handed down from 'architects' at my place of work and thinking that there must be a better way, I've recently been reading ...

View's getWidth() and getHeight() returns 0

View's getWidth() and getHeight() returns 0 I am creating all of the elements in my android project dynamically. I am trying to get the width and height of a button so that I can rotate that button ar...

8 Dec at 14:1

Abstract property with public getter, define private setter in concrete class possible?

Abstract property with public getter, define private setter in concrete class possible? I'm trying to create an abstract class that defines a property with a getter. I want to leave it up to derived c...

Getters, setters, and properties best practices. Java vs. C#

Getters, setters, and properties best practices. Java vs. C# I'm taking a C# class right now and I'm trying to find out the best way of doing things. I come from a Java background and so I'm only fami...

9 Feb at 18:23

Good or bad practice? Initializing objects in getter

Good or bad practice? Initializing objects in getter I have a strange habit it seems... according to my co-worker at least. We've been working on a small project together. The way I wrote the classes ...

2 Nov at 12:26

How to override a getter-only property with a setter in C#?

How to override a getter-only property with a setter in C#? This question has been revised to make it clearer. The answers below seem to reflect that this method works well. Hopefully this question c...

4 Aug at 05:30

Why is a simple get-statement so slow?

Why is a simple get-statement so slow? A few years back, I got an assignment at school, where I had to parallelize a Raytracer. It was an easy assignment, and I really enjoyed working on it. Today, I ...

20 Jun at 09:12