Last active
December 30, 2015 06:49
-
-
Save chrisortman/7792303 to your computer and use it in GitHub Desktop.
I've been doing this thing where I pass an 'output' object into methods.
The things I like about this are * I can vary implementation of output objects like one for an MVC ViewModel and another for a WPF ViewModel
* Keeps privates of business objects (for lack of a better term) private
* When I have methods that need to return more than one thin…
This file contains hidden or 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 Payment { | |
private int _accountID; | |
private int _userID; | |
private decimal _paymentAmount; | |
/* I realize this looks almost like it should be a FI, but | |
that would just distract from the point */ | |
public void OnAccount(int id) { | |
_accountID = id; | |
} | |
public void FromUser(int userID) { | |
_userID = userID; | |
} | |
public void Amount(decimal amount) { | |
_paymentAmount = amount; | |
} | |
public void WithCard(CardData c) { | |
_cardData = c; | |
} | |
/* THIS */ | |
public void Review(ConfirmationPage page,ISomeLookupService s) { | |
page.PaymentDate = DateTime.Now; | |
page.PaymentDescription = "Credit Card ****" + _cardData.LastFour; | |
page.PaymentAccount = s.GetAccountDescription(_accountID); | |
} | |
/* INSTEAD OF */ | |
public ConfirmationPage Review(ISomeLookupService s) { | |
var page = new ConfirmationPage(); | |
page.PaymentDate = DateTime.Now; | |
page.PaymentDescription = "Credit Card ****" + _cardData.LastFour; | |
page.PaymentAccount = s.GetAccountDescription(_accountID); | |
return page; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And if its working for you, then rock it out!