This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirstViewModel | |
: MvxViewModel | |
{ | |
private string _firstName; | |
public string FirstName | |
{ | |
get { return _firstName; } | |
set { _firstName = value; RaisePropertyChanged(() => FirstName); RaisePropertyChanged(() => FullName); } | |
} | |
private string _lastName; | |
public string LastName | |
{ | |
get { return _lastName; } | |
set { _lastName = value; RaisePropertyChanged(() => LastName); RaisePropertyChanged(() => FullName); } | |
} | |
public string FullName | |
{ | |
get { return string.Format("{0} {1}", _firstName, _lastName); } | |
} | |
} |
Because of this, sometimes some of us find ourselves thinking wouldn't it be nice if our ViewModels were thinner - e.g. a bit more like:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class FirstViewModel | |
: MvxViewModel | |
{ | |
public string FirstName { get; set; } | |
public string LastName { get; set; } | |
public string FullName | |
{ | |
get { return string.Format("{0} {1}", FirstName, LastName); } | |
} | |
} |
Well, @TwinGuille didn't just think this - he went off and coded it!
Using the tools from @SimonCropp's excellent Fody - https://github.com/Fody - @TwinGuille posted an awesome blog post on how to achieve thinner, slimmer, easier-to-code, easier-to-understand ViewModels.
This is 100% awesome - check it out at http://twincoders.com/blog/codigo-limpio-con-fody/ - well deserving of a badge of awesomeness.
No comments:
Post a Comment