Re: Code style for property

2017-03-12 Thread Andrey via Digitalmars-d-learn
On Sunday, 12 March 2017 at 17:50:41 UTC, Stefan wrote: On Sunday, 12 March 2017 at 10:47:35 UTC, Andrey wrote: Hello, how better to declare properties, for example I have class: class Foo { this(in int x, in int y, Bar bar) { this.x = x; this.y = y; this.bar = bar;

Re: Code style for property

2017-03-12 Thread Stefan via Digitalmars-d-learn
On Sunday, 12 March 2017 at 10:47:35 UTC, Andrey wrote: Hello, how better to declare properties, for example I have class: class Foo { this(in int x, in int y, Bar bar) { this.x = x; this.y = y; this.bar = bar; } private: int x; int y; Bar bar; }

Re: Code style for property

2017-03-12 Thread Andrey via Digitalmars-d-learn
On Sunday, 12 March 2017 at 11:15:04 UTC, Nicholas Wilson wrote: You should only declare getters/setters if you need to (or think you may need to later) intercept the assignment or acquisition of a variable (logging, computing on demand) have a field as externally read only (setter

Re: Code style for property

2017-03-12 Thread XavierAP via Digitalmars-d-learn
On Sunday, 12 March 2017 at 11:15:04 UTC, Nicholas Wilson wrote: On Sunday, 12 March 2017 at 10:47:35 UTC, Andrey wrote: And I want make access to read x, y and bar. Probably I should add prefix for private members, that is a question: what prefix should I use? Now I use prefix p_ (from the

Re: Code style for property

2017-03-12 Thread Nicholas Wilson via Digitalmars-d-learn
On Sunday, 12 March 2017 at 10:47:35 UTC, Andrey wrote: Hello, how better to declare properties, for example I have class: class Foo { this(in int x, in int y, Bar bar) { this.x = x; this.y = y; this.bar = bar; } private: int x; int y; Bar bar; } And