Gem code
-
Today while reviewing one of the code, i found this chunk :)
class MyClass
{
private int m_SomeValue;public int SomeValue { get { return m\_SomeValue;} } public void SomeMethod() { var value = GetValue(); //Some core logic on value } private int GetValue() { return SomeValue; }
}
At first i started to think is there any catch behind this style. after few mins, i found its lame to write this way and finally it was admitted ;)
-
Today while reviewing one of the code, i found this chunk :)
class MyClass
{
private int m_SomeValue;public int SomeValue { get { return m\_SomeValue;} } public void SomeMethod() { var value = GetValue(); //Some core logic on value } private int GetValue() { return SomeValue; }
}
At first i started to think is there any catch behind this style. after few mins, i found its lame to write this way and finally it was admitted ;)
I think the code is attempting to do something like this:
public int SomeValue {get; private set;}
-
I think the code is attempting to do something like this:
public int SomeValue {get; private set;}
Well nope, but still there wasnt a method needed to access/retrieve a instance member value :)
-
Today while reviewing one of the code, i found this chunk :)
class MyClass
{
private int m_SomeValue;public int SomeValue { get { return m\_SomeValue;} } public void SomeMethod() { var value = GetValue(); //Some core logic on value } private int GetValue() { return SomeValue; }
}
At first i started to think is there any catch behind this style. after few mins, i found its lame to write this way and finally it was admitted ;)
-
It's called "double encapsulation"! Wrap your field in a property, then wrap the property in a method! It will be even more object-oriented that way!
lol i bet it is!! :)
-
It's called "double encapsulation"! Wrap your field in a property, then wrap the property in a method! It will be even more object-oriented that way!