{"id":191548,"date":"2013-08-27T13:01:03","date_gmt":"2013-08-27T09:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=191548"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=191548","title":{"rendered":"<span class=\"post_title\">\u0417\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       \u041e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u0411\u0430\u0440\u0440\u0438 \u0413\u0430\u0439\u043b\u0437, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043c\u043d\u0435 \u0438 \u0437\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0434\u043e\u0441\u0442\u043e\u0435\u043d \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<blockquote><p>\u00ab\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435: \u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b \u0440\u0435\u0432\u044c\u044e \u043a\u043e\u0434\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2013 \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 null, \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 null \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0423 \u043c\u0435\u043d\u044f \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043b\u0438\u0441\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u043e\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u00ab\u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0438 \u043c\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0443\u0441\u043a\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0438\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0447\u0435\u0441\u0442\u043d\u044b\u043c, \u044f \u0431\u043e\u0440\u044e\u0441\u044c \u0441 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0447\u0438\u0442\u0430\u043b \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439. \u042f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u043e\u0431\u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a \u0436\u0435 \u0432 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432 \u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0431\u043b\u043e\u0433\u0430\u0445.<br \/>  \u00ab\u0412\u044b \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0434\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u0433\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043a\u043e\u0434\u0443 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0435\u043a\u0430?\u00bb<\/p><\/blockquote>\n<p> <a name=\"habracut\"><\/a><br \/>  \u0412\u043e\u043e\u0431\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u044f \u043d\u0435 \u0434\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 <i>\u0445\u0443\u0436\u0435 <\/i>\u0438\u043b\u0438 <i>\u043b\u0443\u0447\u0448\u0435 <\/i>\u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u0430. \u041a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043d\u0430 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0432\u043b\u0438\u044f\u044e\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b, \u0442\u0430\u043a \u0447\u0442\u043e \u043a\u0440\u0430\u0442\u043a\u0438\u0439 \u043e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0432: <i>\u0432\u0441\u0451 \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432.<\/i><br \/>  \u0422\u0430\u043a\u043e\u0439 \u043e\u0442\u0432\u0435\u0442, \u0431\u0435\u0437\u0443\u0441\u043b\u043e\u0432\u043d\u043e, \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0434\u043e \u0442\u0435\u0445 \u043f\u043e\u0440, \u043f\u043e\u043a\u0430 \u043c\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u043c \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u0432\u043e\u043f\u0440\u043e\u0441:<i> \u043e\u0442 \u043a\u0430\u043a\u0438\u0445 \u043e\u0431\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u0441\u0442\u0432 \u043f\u0440\u043e\u0438\u0441\u0442\u0435\u043a\u0430\u0435\u0442 \u044d\u0442\u0430 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044c?<\/i> \u0412 \u0434\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435, \u044f \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u044b. \u041e\u0434\u043d\u0430\u043a\u043e, \u044f \u043d\u0435 \u0441\u043e\u0431\u0438\u0440\u0430\u044e\u0441\u044c \u0437\u0430\u044f\u0432\u0438\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u0430 \u0441\u0442\u0430\u0442\u044c\u044f \u044f\u0432\u0438\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u043e\u0431\u044a\u0435\u043c\u043b\u044e\u0449\u0438\u043c \u0438\u0437\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u0442\u0435\u043c\u044b.<\/p>\n<h5>\u041f\u043e\u0437\u0432\u043e\u043b\u0435\u043d\u0438\u0435 \u043a\u043e\u0434\u0443 \u0443\u043f\u0430\u0441\u0442\u044c.<\/h5>\n<p>  \u041a\u0430\u043a\u043e\u0432\u0430 \u0446\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0435\u0441\u043b\u0438 \u0432\u0441\u0451 \u0447\u0442\u043e \u0432\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0435\u0442\u0435\u0441\u044c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u2013 \u044d\u0442\u043e \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435? \u041d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043b\u0438 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u0445\u043e\u0440\u043e\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u0434\u0430\u0442\u044c \u043a\u043e\u0434\u0443 \u0443\u043f\u0430\u0441\u0442\u044c? \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430.<\/p>\n<pre><code class=\"cs\">  public class ProductDetailsController {             private readonly IUserRepository userRepository;             private readonly IProductRepository productRepository;             private readonly ICurrencyExchange exchange;              public ProductDetailsController(                 IUserRepository userRepository,                 IProductRepository productRepository,                 ICurrencyExchange exchange) {                 this.userRepository = userRepository;                 this.productRepository = productRepository;                 this.exchange = exchange;             }              public ProductDetailsViewModel GetProductDetails(string userId, string productId) {                 var user = this.userRepository.Get(userId);                 var targetCurrency = user.PreferredCurrency;                  var product = this.productRepository.Get(productId);                 var convertedPrice =                     this.exchange.Convert(product.UnitPrice, targetCurrency);                  return new ProductDetailsViewModel {                                                        Name = product.Name,                                                        Price = convertedPrice.ToString()                                                    };             }         } <\/code><\/pre>\n<p>  \u0412 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 <code>ProductDetailsController<\/code>, \u043c\u0435\u0442\u043e\u0434 <code>GetProductDetails <\/code>\u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <code>ProductDetailsViewModel<\/code>, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u044a\u0435\u043a\u0446\u0438\u0438 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0435\u0432, \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u0443\u044f \u0446\u0435\u043d\u0443 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430 \u0432 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u0443\u044e \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u043c \u0432\u0430\u043b\u044e\u0442\u0443 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442\u044c \u043d\u0430 \u044d\u043a\u0440\u0430\u043d\u0435. \u0420\u0430\u0434\u0438 \u0434\u043e\u0441\u0442\u0438\u0436\u0435\u043d\u0438\u044f \u0446\u0435\u043b\u0438 \u0441\u0442\u0430\u0442\u044c\u0438, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u0435\u043c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 <code>null<\/code>. \u041a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u043f\u043e\u0439\u0442\u0438 \u043f\u043e \u043f\u0440\u043e\u0432\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GetProductDetails<\/code>? \u041a\u0430\u043a \u043c\u043d\u043e\u0433\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u044b\u043c\u0438 \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438?<br \/>  \u0414\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043c\u043d\u043e\u0433\u043e, \u043a\u0430\u043a \u0432\u044b\u044f\u0441\u043d\u044f\u0435\u0442\u0441\u044f. \u0414\u0430\u0436\u0435 \u043e\u0442\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u0439 \u043e\u0442 \u0441\u0432\u043e\u0438\u0445 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u044d\u0442\u043e\u0442 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u043a\u0443\u0441\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430 \u043c\u043e\u0436\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c <code>NullReferenceException<\/code>, \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0432 \u0448\u0435\u0441\u0442\u0438 \u0441\u043b\u0443\u0447\u0430\u044f\u0445. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u043e\u0442\u0447\u0451\u0442 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0441 \u0432\u0430\u0448\u0435\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u043d\u0430\u0445\u043e\u0434\u044f\u0449\u0435\u0439\u0441\u044f \u0432 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0430\u0446\u0438\u0438. \u0422\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0430 \u0441\u0442\u0435\u043a\u0430 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 <code>GetProductDetails <\/code>\u0438 \u0442\u0438\u043f\u043e\u043c \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <code>NullReferenceException<\/code>. \u041a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0448\u0435\u0441\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0441 \u043d\u0443\u043b\u0435\u0432\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u0441\u0442\u0430\u043b \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u043e\u0448\u0438\u0431\u043a\u0438?<br \/>  \u0414\u0430\u0432\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u043f\u0430\u0441\u0442\u044c, \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0442\u0440\u0443\u0434\u043d\u043e \u043e\u0442\u0432\u0435\u0442\u0438\u0442\u044c \u043d\u0430 \u044d\u0442\u043e\u0442 \u0432\u043e\u043f\u0440\u043e\u0441. \u0418 \u043d\u0435 \u0437\u0430\u0431\u044b\u0432\u0430\u0439\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0443\u0447\u0435\u0431\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440. \u0411\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u043b, \u0438\u043c\u0435\u043b \u0431\u043e\u043b\u0435\u0435 5 \u0438\u043b\u0438 6 \u0441\u0442\u0440\u043e\u043a \u043a\u043e\u0434\u0430, \u0442\u0430\u043a \u0447\u0442\u043e, \u0432\u044b\u044f\u0441\u043d\u0435\u043d\u0438\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u044b \u0432\u043e\u0437\u043d\u0438\u043a\u0448\u0435\u0439 \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u043e \u0441\u0442\u0430\u0442\u044c \u0447\u0435\u043c-\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0438\u0433\u043e\u043b\u043a\u0438 \u0432 \u0441\u0442\u043e\u0433\u0435 \u0441\u0435\u043d\u0430.<br \/>  \u041f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043a\u043e\u0434\u0443 \u0443\u043f\u0430\u0441\u0442\u044c \u2013 \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u0438\u0448\u0435\u0442\u0435 \u043e\u0447\u0435\u043d\u044c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b (\u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u044f \u0441\u0442\u0440\u043e\u0433\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e), \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0449\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043d\u0435 \u0442\u0430\u043a \u043d\u0430\u0441\u0443\u0449\u043d\u0430, \u043d\u043e \u0447\u0435\u043c \u0432\u0430\u0448\u0438 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u0438\u043d\u043d\u0435\u0435, \u0442\u0435\u043c \u043c\u0435\u043d\u0435\u0435 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u00ab\u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043a\u043e\u0434\u0443 \u0443\u043f\u0430\u0441\u0442\u044c\u00bb \u0437\u0432\u0443\u0447\u0438\u0442.<\/p>\n<h5>\u0417\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u043e \u0441\u043f\u0430\u0441\u0435\u043d\u0438\u0435?<\/h5>\n<p>  \u041f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u044f\u0432\u043d\u044b\u0445 \u0441\u0442\u043e\u0440\u043e\u0436\u043a\u043e\u0432 \u043d\u0430 <code>null<\/code>, \u0432\u044b \u0441\u043c\u043e\u0436\u0435\u0442\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u0438\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435:<\/p>\n<pre><code class=\"cs\">public class ProductDetailsController {             private readonly IUserRepository userRepository;             private readonly IProductRepository productRepository;             private readonly ICurrencyExchange exchange;              public ProductDetailsController(                 IUserRepository userRepository,                 IProductRepository productRepository,                 ICurrencyExchange exchange) {                 if (userRepository == null)                     throw new ArgumentNullException(&quot;userRepository&quot;);                 if (productRepository == null)                     throw new ArgumentNullException(&quot;productRepository&quot;);                 if (exchange == null)                     throw new ArgumentNullException(&quot;exchange&quot;);                  this.userRepository = userRepository;                 this.productRepository = productRepository;                 this.exchange = exchange;             }              public ProductDetailsViewModel GetProductDetails(                 string userId,                 string productId) {                 var user = this.userRepository.Get(userId);                 if (user == null)                     throw new InvalidOperationException(&quot;User was null.&quot;);                 var targetCurrency = user.PreferredCurrency;                  var product = this.productRepository.Get(productId);                 if (product == null)                     throw new InvalidOperationException(&quot;Product was null.&quot;);                  var convertedPrice =                     this.exchange.Convert(product.UnitPrice, targetCurrency);                 if (convertedPrice == null)                     throw new InvalidOperationException(&quot;Converted price was null.&quot;);                  return new ProductDetailsViewModel {                                                        Name = product.Name,                                                        Price = convertedPrice.ToString()                                                    };             }         } <\/code><\/pre>\n<p>  \u041b\u0443\u0447\u0448\u0435 \u043b\u0438 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434? \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u043f\u0440\u0438\u0447\u0438\u043d \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u043e\u0448\u0438\u0431\u043e\u043a \u2013 \u0434\u0430. \u0412 \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 \u043a\u043e\u0434\u0430, \u0435\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435 \u0438\u0437 \u0432\u0430\u0448\u0435\u0439 \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u0443\u0435\u043c\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0432 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043f\u043e\u0434\u0441\u043a\u0430\u0436\u0435\u0442 \u0441 \u043a\u0430\u043a\u043e\u0439 \u0438\u0437 \u0448\u0435\u0441\u0442\u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u0441 <code>null<\/code>-\u0441\u0441\u044b\u043b\u043a\u043e\u0439 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0430\u0441\u044c \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430. \u0415\u0441\u043b\u0438 \u0431\u044b \u044f \u043d\u0430\u0445\u043e\u0434\u0438\u043b\u0441\u044f \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438, \u0442\u043e \u044f \u0431\u044b \u0437\u043d\u0430\u043b \u043a\u0430\u043a\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u0438\u0437 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0432\u0443\u0445 \u044f \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0451\u043b.<br \/>  \u041e\u0434\u043d\u0430\u043a\u043e, \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438, \u0432\u0441\u0451 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u0445\u0443\u0434\u0448\u0438\u043b\u043e\u0441\u044c. \u041c\u0435\u0442\u043e\u0434 <code>GetProductDetails <\/code>\u0443\u0434\u043b\u0438\u043d\u043d\u0438\u043b\u0441\u044f \u0441 \u043f\u044f\u0442\u0438 \u0434\u043e \u043e\u0434\u0438\u043d\u043d\u0430\u0434\u0446\u0430\u0442\u0438 \u0441\u0442\u0440\u043e\u0447\u0435\u043a \u043a\u043e\u0434\u0430. \u0417\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0431\u043e\u043b\u0435\u0435 \u0447\u0435\u043c \u0443\u0434\u0432\u043e\u0438\u043b\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a! \u041f\u0440\u043e\u0445\u043e\u0434 \u043f\u043e \u0442\u0435\u043b\u0443 \u043c\u0435\u0442\u043e\u0434\u0430 \u0442\u043e\u043d\u0435\u0442 \u0432 \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044f\u0445, \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u0435\u0442\u043e\u0434 \u0441\u0442\u0430\u043b \u0447\u0438\u0442\u0430\u0442\u044c\u0441\u044f \u0445\u0443\u0436\u0435. \u0415\u0441\u043b\u0438 \u0432\u044b \u0442\u0438\u043f\u0438\u0447\u043d\u044b\u0439 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442, \u0442\u043e \u0432\u044b \u0447\u0438\u0442\u0430\u0435\u0442\u0435 \u043a\u043e\u0434 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435, \u0447\u0435\u043c \u043f\u0438\u0448\u0435\u0442\u0435 \u0435\u0433\u043e, \u0442\u0430\u043a \u0447\u0442\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u0435\u043b\u0430\u0435\u0442 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0431\u043e\u043b\u0435\u0435 \u0442\u0440\u0443\u0434\u043d\u043e\u0447\u0438\u0442\u0430\u0435\u043c\u044b\u043c, \u0434\u043e\u043b\u0436\u043d\u0430 \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u0432 \u0432\u0430\u0441 \u043e\u0449\u0443\u0449\u0435\u043d\u0438\u0435 \u0437\u0430\u043f\u0430\u0448\u043a\u0430. \u041d\u0435\u0442 \u0441\u043e\u043c\u043d\u0435\u043d\u0438\u0439 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u0441\u0447\u0438\u0442\u0430\u044e\u0442 \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043b\u043e\u0445\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439.<\/p>\n<h5>\u0423\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u044c.<\/h5>\n<p>  \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043b\u0438 \u0441\u0431\u0430\u043b\u0430\u043d\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0444\u0430\u043a\u0442\u043e\u0440\u044b, \u0432\u043b\u0438\u044f\u044e\u0449\u0438\u0435 \u043d\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0438 \u0435\u0451 \u0440\u0435\u0448\u0435\u043d\u0438\u0435? \u0414\u0430, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043d\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c \u043a\u0430\u043a, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u043e\u0440\u043d\u0435\u0432\u0443\u044e \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u041f\u0435\u0440\u0432\u043e\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430 \u043d\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e \u0441\u043b\u043e\u0436\u0435\u043d, \u043d\u043e \u0434\u0430\u0436\u0435 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u044d\u0442\u043e, \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0441\u043b\u0443\u0447\u0430\u0435\u0432, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e\u0442 \u043a\u043e\u0434 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u044c\u0441\u044f. \u0427\u0442\u043e \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u043d\u0443\u043b\u0435\u0432\u044b\u0445 \u0441\u0441\u044b\u043b\u043e\u043a, \u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f <a href=\"http:\/\/en.wikipedia.org\/wiki\/Tony_Hoare#Quotations\">\u043e\u0448\u0438\u0431\u043a\u0430 \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435 \u044f\u0437\u044b\u043a\u0430<\/a>, \u043d\u043e \u0432 \u0446\u0435\u043b\u043e\u043c, \u0432\u043e\u043f\u0440\u043e\u0441 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u043c\u043e\u0436\u0435\u0442\u0435 \u043b\u0438 \u0432\u044b \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c \u0438\u043b\u0438 \u043d\u0435\u0442. \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0437\u043e\u0432 <code>IUserRepository.Get<\/code> \u044d\u0442\u043e <a href=\"http:\/\/xunitpatterns.com\/indirect%20input.html\">(\u043a\u043e\u0441\u0432\u0435\u043d\u043d\u043e) \u0442\u043e\u0436\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/a><br \/>  \u0412 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u0443\u0435\u0442 \u0432\u0430\u0448\u0430 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0443 \u0432\u0430\u0441 \u043b\u0438\u0431\u043e \u0435\u0441\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c, \u043b\u0438\u0431\u043e \u0443 \u0432\u0430\u0441 \u0442\u0430\u043a\u043e\u0439 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u043d\u0435\u0442. \u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u043d\u0430 \u043c\u0438\u043d\u0443\u0442\u0443, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043f\u0440\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0448\u0435 \u041f\u041e \u044d\u043a\u0441\u043f\u043b\u0443\u0430\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0432 <a href=\"http:\/\/blog.ploeh.dk\/2012\/12\/18\/RangersandZookeepers\/\">\u00ab\u0434\u0438\u043a\u043e\u0439 \u043c\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438\u00bb<\/a>. \u0412\u0430\u0448\u0438\u043c \u041f\u041e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0430\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u0438\u043b\u0438 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435, \u0432\u044b \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0432\u0445\u043e\u0434\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c. \u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0442\u0430\u043a, \u0442\u043e, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0432\u044b \u0437\u0430\u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c <a href=\"http:\/\/en.wikipedia.org\/wiki\/Robustness_principle\">\u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438<\/a> \u0438 \u043e\u0441\u0442\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0443\u0431\u0435\u0436\u0434\u0451\u043d\u043d\u044b\u043c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432\u044b \u0434\u0435\u0439\u0441\u0442\u0432\u0443\u0435\u0442\u0435 \u0432 \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0432\u0445\u043e\u0434\u043d\u044b\u0445, \u043d\u043e \u0438 \u0432\u044b\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445. \u0414\u0440\u0443\u0433\u0438\u043c\u0438 \u0441\u043b\u043e\u0432\u0430\u043c\u0438, \u0432\u044b \u043d\u0435 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 (\u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0434\u044c\u044f\u0432\u043e\u043b\u044c\u0441\u043a\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f) \u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u043c\u0443 \u043a\u043e\u0434\u0443.<br \/>  \u041f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u0434\u0430, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u0440\u0430\u043d\u0435\u0435, \u043c\u043e\u0436\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u043d\u0443\u043b\u0435\u0432\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0441\u0432\u043e\u0438\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 <code>userId = null, <\/code>\u0438\u043b\u0438 (\u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u043e\u0449\u0440\u0451\u043d\u043d\u043e), \u0435\u0441\u043b\u0438<code> user.PreferredCurrency = null.<\/code> \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0441\u043b\u0435\u0434\u0443\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0451 \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0445 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0439:<\/p>\n<pre><code class=\"cs\"> public class ProductDetailsController {             private readonly IUserRepository userRepository;             private readonly IProductRepository productRepository;             private readonly ICurrencyExchange exchange;              public ProductDetailsController(                 IUserRepository userRepository,                 IProductRepository productRepository,                 ICurrencyExchange exchange) {                 if (userRepository == null)                     throw new ArgumentNullException(&quot;userRepository&quot;);                 if (productRepository == null)                     throw new ArgumentNullException(&quot;productRepository&quot;);                 if (exchange == null)                     throw new ArgumentNullException(&quot;exchange&quot;);                  this.userRepository = userRepository;                 this.productRepository = productRepository;                 this.exchange = exchange;             }              public ProductDetailsViewModel GetProductDetails(                 string userId,                 string productId) {                 if (userId == null)                     throw new ArgumentNullException(&quot;userId&quot;);                 if (productId == null)                     throw new ArgumentNullException(&quot;productId&quot;);                  var user = this.userRepository.Get(userId);                 if (user == null)                     throw new InvalidOperationException(&quot;User was null.&quot;);                 if (user.PreferredCurrency == null)                     throw new InvalidOperationException(&quot;Preferred currency was null.&quot;);                 var targetCurrency = user.PreferredCurrency;                  var product = this.productRepository.Get(productId);                 if (product == null)                     throw new InvalidOperationException(&quot;Product was null.&quot;);                 if (product.Name == null)                     throw new InvalidOperationException(&quot;Product name was null.&quot;);                 if (product.UnitPrice == null)                     throw new InvalidOperationException(&quot;Unit price was null.&quot;);                  var convertedPrice =                     this.exchange.Convert(product.UnitPrice, targetCurrency);                 if (convertedPrice == null)                     throw new InvalidOperationException(&quot;Converted price was null.&quot;);                  return new ProductDetailsViewModel {                                                        Name = product.Name,                                                        Price = convertedPrice.ToString()                                                    };             }         } <\/code><\/pre>\n<p>  \u042d\u0442\u043e, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0435\u0449\u0451 \u0431\u043e\u043b\u0435\u0435 \u0443\u0436\u0430\u0441\u043d\u044b\u043c, \u0447\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0433\u043e \u0441\u0442\u0438\u043b\u044f. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442\u0435 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0435\u0431\u044f, \u043d\u043e \u0438 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434. \u041f\u043e\u0445\u0432\u0430\u043b\u044c\u043d\u043e, \u043d\u043e \u0430\u0431\u0441\u043e\u043b\u044e\u0442\u043d\u043e \u043d\u0435\u0447\u0438\u0442\u0430\u0435\u043c\u043e.<br \/>  \u0414\u043e \u0441\u0438\u0445 \u043f\u043e\u0440, \u043a\u043e\u0433\u0434\u0430 \u044f \u043f\u0438\u0448\u0443 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0436\u0438\u0432\u0451\u0442 \u0432 \u00ab\u0434\u0438\u043a\u043e\u0439 \u043c\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438\u00bb, \u0442\u0430\u043a\u043e\u0435 \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2013 \u044d\u0442\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u043e, \u0447\u0442\u043e \u044f \u0434\u0435\u043b\u0430\u044e, \u0445\u043e\u0442\u044f \u044f \u0432\u0441\u0451 \u0440\u0430\u0432\u043d\u043e \u0441\u043a\u043b\u043e\u043d\u044f\u044e\u0441\u044c \u043a \u0442\u043e\u043c\u0443, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0441\u0442\u0438 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0447\u0442\u043e, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u044f \u0431\u044b \u0441\u043e\u0431\u0440\u0430\u043b \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043b \u0432\u0441\u0435 \u0432\u0445\u043e\u0434\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0443\u0436\u0435 \u0437\u0430\u0442\u0435\u043c \u044f \u0431\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u043b \u044d\u0442\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443.<\/p>\n<h5>\u0417\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u0430\u044f \u043c\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u044c.<\/h5>\n<p>  \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0436\u0438\u0432\u0451\u0442 \u0432 <a href=\"http:\/\/blog.ploeh.dk\/2012\/12\/18\/RangersandZookeepers\/\">\u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u0439 \u043c\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438<\/a>? \u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0441\u0440\u0435\u0434\u0435, \u0432\u0435\u0441\u044c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u043e\u0434\u043d\u043e\u0439 \u0438 \u0442\u043e\u0439 \u0436\u0435 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b, \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0432\u0430\u043c\u0438 \u0438 \u0432\u0430\u0448\u0438\u043c\u0438 \u043a\u043e\u043b\u043b\u0435\u0433\u0430\u043c\u0438? \u0415\u0441\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0434\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0434\u0440\u0443\u0433 \u0434\u0440\u0443\u0433\u0443, \u0441\u043b\u0435\u0434\u0443\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u0447\u0430\u0441\u0442\u044c \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439.<br \/>  \u0412 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043a\u043e\u043c\u0430\u043d\u0434, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b, \u044f \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u043b, \u0447\u0442\u043e \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438. \u041d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e <code>null <\/code>\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u043c\u044b\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c. \u0415\u0441\u043b\u0438 \u0447\u043b\u0435\u043d \u043a\u043b\u0430\u0441\u0441\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 <code>null<\/code>, \u0442\u043e \u0431\u0430\u0433 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435, \u043d\u0435 \u0432 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u0421 \u0443\u0447\u0451\u0442\u043e\u043c \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0430\u0432\u0438\u043b\u0443, \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439 \u043a\u043e\u0434 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u043a\u0440\u0430\u0449\u0451\u043d \u0434\u043e \u0442\u0430\u043a\u043e\u0433\u043e:<\/p>\n<pre><code class=\"cs\">public class ProductDetailsController {     private readonly IUserRepository userRepository;     private readonly IProductRepository productRepository;     private readonly ICurrencyExchange exchange;       public ProductDetailsController(         IUserRepository userRepository,         IProductRepository productRepository,         ICurrencyExchange exchange)     {         if (userRepository == null)             throw new ArgumentNullException(&quot;userRepository&quot;);         if (productRepository == null)             throw new ArgumentNullException(&quot;productRepository&quot;);         if (exchange == null)             throw new ArgumentNullException(&quot;exchange&quot;);           this.userRepository = userRepository;         this.productRepository = productRepository;         this.exchange = exchange;     }       public ProductDetailsViewModel GetProductDetails(         string userId,         string productId)     {         if (userId == null)             throw new ArgumentNullException(&quot;userId&quot;);         if (productId == null)             throw new ArgumentNullException(&quot;productId&quot;);           var user = this.userRepository.Get(userId);         if (user.PreferredCurrency == null)             throw new InvalidOperationException(&quot;Preferred currency was null.&quot;);         var targetCurrency = user.PreferredCurrency;           var product = this.productRepository.Get(productId);         if (product.Name == null)             throw new InvalidOperationException(&quot;Product name was null.&quot;);         if (product.UnitPrice == null)             throw new InvalidOperationException(&quot;Unit price was null.&quot;);           var convertedPrice =              this.exchange.Convert(product.UnitPrice, targetCurrency);           return new ProductDetailsViewModel         {             Name = product.Name,             Price = convertedPrice.ToString()         };     } } <\/code><\/pre>\n<p>  \u0422\u0430\u043a-\u0442\u043e \u043b\u0443\u0447\u0448\u0435, \u043d\u043e \u0435\u0449\u0451 \u043d\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e\u2026 \u043d\u043e, \u043f\u043e\u0434\u043e\u0436\u0434\u0438\u0442\u0435: \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u043b\u044f \u0447\u0442\u0435\u043d\u0438\u044f \u044d\u0442\u043e \u0442\u043e\u0436\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043c\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u0447\u0442\u043e \u043c\u044b \u0438 \u0438\u0445 \u043c\u043e\u0436\u0435\u043c \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c:<\/p>\n<pre><code class=\"cs\">public class ProductDetailsController {     private readonly IUserRepository userRepository;     private readonly IProductRepository productRepository;     private readonly ICurrencyExchange exchange;       public ProductDetailsController(         IUserRepository userRepository,         IProductRepository productRepository,         ICurrencyExchange exchange)     {         if (userRepository == null)             throw new ArgumentNullException(&quot;userRepository&quot;);         if (productRepository == null)             throw new ArgumentNullException(&quot;productRepository&quot;);         if (exchange == null)             throw new ArgumentNullException(&quot;exchange&quot;);           this.userRepository = userRepository;         this.productRepository = productRepository;         this.exchange = exchange;     }       public ProductDetailsViewModel GetProductDetails(         string userId,         string productId)     {         if (userId == null)             throw new ArgumentNullException(&quot;userId&quot;);         if (productId == null)             throw new ArgumentNullException(&quot;productId&quot;);           var user = this.userRepository.Get(userId);         var targetCurrency = user.PreferredCurrency;           var product = this.productRepository.Get(productId);           var convertedPrice =              this.exchange.Convert(product.UnitPrice, targetCurrency);           return new ProductDetailsViewModel         {             Name = product.Name,             Price = convertedPrice.ToString()         };     } } <\/code><\/pre>\n<p>  \u0412\u043e\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0445\u043e\u0440\u043e\u0448\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u0432\u0435\u0440\u043d\u0443\u043b\u0438\u0441\u044c \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u0434\u0430. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0440\u0430\u0437\u043d\u0438\u0446\u0435\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0430\u043b\u0438\u0447\u0438\u0435 <a href=\"http:\/\/c2.com\/cgi\/wiki?GuardClause\">\u0441\u0442\u043e\u0440\u043e\u0436\u043a\u0430 <\/a>\u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430. \u041a\u043e\u0433\u0434\u0430 \u0441\u043b\u0435\u0434\u0443\u0435\u0448\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438, \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0447\u043b\u0435\u043d\u043e\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0436\u0435. \u041d\u0435\u043c\u043d\u043e\u0433\u043e \u0441\u043f\u0443\u0441\u0442\u044f, \u043f\u043e\u0441\u043b\u0435 \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u043f\u0440\u0438\u0432\u044b\u043a\u043d\u0435\u0442\u0435, \u0432\u044b \u0438\u0445 \u043f\u0435\u0440\u0435\u0441\u0442\u0430\u0451\u0442\u0435 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u044c. \u042f \u0441\u0447\u0438\u0442\u0430\u044e \u0438\u0445 \u043d\u0435\u043a\u043e\u0439 \u043f\u0440\u0435\u0430\u043c\u0431\u0443\u043b\u043e\u0439 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0447\u043b\u0435\u043d\u0430. \u041a\u0430\u043a \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u044c \u043a\u043e\u0434\u0430, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u0440\u043e\u0441\u043a\u0430\u043a\u0438\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u0436\u043a\u0438 \u0438 \u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u043f\u043e\u0442\u043e\u043a\u0435 \u043b\u043e\u0433\u0438\u043a\u0438, \u0431\u0435\u0437 \u043f\u0440\u0435\u0440\u044b\u0432\u0430\u044e\u0449\u0438\u0445 \u0432\u0430\u0441 \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a, \u043c\u0435\u0448\u0430\u044e\u0449\u0438\u0445 \u0447\u0442\u0435\u043d\u0438\u044e \u043a\u043e\u0434\u0430.<\/p>\n<h5>\u0418\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f.<\/h5>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0435 <code>null<\/code>-\u0441\u0441\u044b\u043b\u043a\u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0442\u043e \u043a\u0430\u043a\u0438\u043c \u0442\u043e\u0433\u0434\u0430 \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043a\u043b\u0430\u0441\u0441 <code>User<\/code>, \u0438\u043b\u0438 \u043a\u043b\u0430\u0441\u0441 <code>Product<\/code>, \u043c\u043e\u0433\u0443\u0442 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u0443\u0441\u0442\u043e\u0439\u0447\u0438\u0432\u043e\u0441\u0442\u0438? \u0422\u0435\u043c \u0436\u0435 \u0441\u0430\u043c\u044b\u043c \u043f\u0443\u0442\u0451\u043c:<\/p>\n<pre><code class=\"cs\">public class User {     private string preferredCurrency;      public User()     {         this.preferredCurrency = &quot;DKK&quot;;     }       public string PreferredCurrency     {         get { return this.preferredCurrency; }         set         {             if (value == null)                 throw new ArgumentNullException(&quot;value&quot;);               this.preferredCurrency = value;         }     } } <\/code><\/pre>\n<p>  \u0417\u0430\u043c\u0435\u0442\u044c\u0442\u0435, \u043a\u0430\u043a \u043a\u043b\u0430\u0441\u0441 <code>User <\/code><a href=\"http:\/\/blog.ploeh.dk\/2011\/05\/26\/CodeSmellAutomaticProperty\/\">\u0437\u0430\u0449\u0438\u0449\u0430\u0435\u0442 \u0441\u0432\u043e\u0438 \u0438\u043d\u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b<\/a>. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <code>PreferredCurrency <\/code>\u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <code>null<\/code>. \u042d\u0442\u043e\u0442 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c: <a href=\"http:\/\/blog.ploeh.dk\/2011\/05\/24\/Poka-yokeDesignFromSmelltoFragrance\/\">\u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044f<\/a>.<\/p>\n<h5>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435.<\/h5>\n<p>  \u041a\u0430\u043a \u0432\u0441\u0435\u0433\u0434\u0430, \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0444\u0430\u043a\u0442\u043e\u0440\u043e\u0432, \u043b\u0435\u0436\u0430\u0449\u0438\u0445 \u0432 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438\u043b\u0438 \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u0432\u0430\u0448\u0435\u0439 \u043a\u043e\u0434\u043e\u0432\u043e\u0439 \u0431\u0430\u0437\u044b. \u0412\u0430\u043c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435, \u0435\u0441\u043b\u0438 \u0432\u0430\u0448 \u043a\u043e\u0434 \u0436\u0438\u0432\u0451\u0442 \u0432 \u00ab\u0434\u0438\u043a\u043e\u0439 \u043c\u0435\u0441\u0442\u043d\u043e\u0441\u0442\u0438\u00bb, \u0447\u0435\u043c \u0442\u043e\u0433\u0434\u0430, \u043a\u043e\u0433\u0434\u0430 \u043e\u043d \u0436\u0438\u0432\u0451\u0442 \u0432 \u0437\u0430\u0449\u0438\u0449\u0451\u043d\u043d\u043e\u0439 \u0441\u0440\u0435\u0434\u0435. \u041f\u043e \u0441\u0435\u0439 \u0434\u0435\u043d\u044c, \u044f \u0441\u0447\u0438\u0442\u0430\u044e \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435\u043c \u0432\u0435\u0440\u0443 \u0432 \u0442\u043e, \u0447\u0442\u043e \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u043d\u0435\u0440\u044f\u0448\u043b\u0438\u0432\u043e\u0433\u043e \u043a\u043e\u0434\u0430; \u043c\u044b \u0432\u0441\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c <a href=\"http:\/\/blog.ploeh.dk\/2012\/12\/18\/ZookeepersmustbecomeRangers\/\">\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u0430\u043c\u0438-\u0440\u044d\u0439\u043d\u0434\u0436\u0435\u0440\u0430\u043c\u0438.<\/a><br \/>  \u0411\u0435\u0441\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043d\u044b\u0439 \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u0432\u0440\u0435\u0434\u0438\u0442 \u0447\u0438\u0442\u0430\u0435\u043c\u043e\u0441\u0442\u0438. \u0417\u0430\u0449\u0438\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u2013 \u044d\u0442\u043e \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0435\u0449\u0451 \u043e\u0434\u043d\u0430 \u043e\u0442\u0433\u043e\u0432\u043e\u0440\u043a\u0430 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0441\u043f\u0430\u0433\u0435\u0442\u0442\u0438-\u043a\u043e\u0434\u0430. \u041d\u0430\u043f\u0440\u043e\u0442\u0438\u0432, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u044f\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0431\u043e\u0439 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u044f\u0446\u0438\u044e. \u042f \u0437\u043d\u0430\u044e, \u0447\u0442\u043e \u043c\u043d\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0435\u0441\u0442\u044c.   \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/191548\/\"> http:\/\/habrahabr.ru\/post\/191548\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       \u041e\u0434\u0438\u043d \u0438\u0437 \u043c\u043e\u0438\u0445 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0435\u0439, \u0411\u0430\u0440\u0440\u0438 \u0413\u0430\u0439\u043b\u0437, \u043d\u0435\u0434\u0430\u0432\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u043c\u043d\u0435 \u0438 \u0437\u0430\u0434\u0430\u043b \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439, \u043f\u043e \u043c\u043e\u0435\u043c\u0443 \u043c\u043d\u0435\u043d\u0438\u044e, \u0434\u043e\u0441\u0442\u043e\u0435\u043d \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<blockquote><p>\u00ab\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u0441 \u043e\u0434\u043d\u043e\u0439 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0435\u0439 \u043d\u0430 \u0440\u0430\u0431\u043e\u0442\u0435: \u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u043b \u0440\u0435\u0432\u044c\u044e \u043a\u043e\u0434\u0430 \u0438 \u0432\u0441\u0442\u0430\u0432\u0438\u043b \u0437\u0430\u0449\u0438\u0442\u043d\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2013 \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430 \u043d\u0430 null, \u043e\u0434\u043d\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0430 null \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f, \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u043e\u0433\u043e \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430. \u0423 \u043c\u0435\u043d\u044f \u0442\u0430\u043a\u0436\u0435 \u0438\u043c\u0435\u043b\u0438\u0441\u044c \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043c\u043e\u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<br \/>  \u00ab\u041f\u043e\u0445\u043e\u0436\u0435, \u0447\u0442\u043e \u043f\u0440\u0435\u043e\u0431\u043b\u0430\u0434\u0430\u044e\u0449\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439 \u0441\u0440\u0435\u0434\u0438 \u043c\u043e\u0438\u0445 \u043a\u043e\u043b\u043b\u0435\u0433 \u043f\u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043f\u0443\u0441\u043a\u0430\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043e\u043a \u0438 \u0434\u043e\u043f\u0443\u0449\u0435\u043d\u0438\u0435 \u043f\u0430\u0434\u0435\u043d\u0438\u0439. \u0415\u0441\u043b\u0438 \u0431\u044b\u0442\u044c \u0447\u0435\u0441\u0442\u043d\u044b\u043c, \u044f \u0431\u043e\u0440\u044e\u0441\u044c \u0441 \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0435\u0439, \u0442\u0430\u043a \u043a\u0430\u043a \u044f \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0441\u0447\u0438\u0442\u0430\u043b \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439. \u042f \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0432\u0435\u0440\u0435\u043d, \u0447\u0442\u043e \u0434\u0435\u043b\u043e \u043e\u0431\u0441\u0442\u043e\u0438\u0442 \u0442\u0430\u043a \u0436\u0435 \u0432 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432 \u0438 \u0437\u0430\u043f\u0438\u0441\u0435\u0439 \u0432 \u0431\u043b\u043e\u0433\u0430\u0445.<br \/>  \u00ab\u0412\u044b \u043d\u0435 \u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0434\u0430\u0442\u044c \u0441\u043e\u0432\u0435\u0442 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0442\u043e\u0433\u043e, \u043f\u043e\u0447\u0435\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0437\u0430\u0449\u0438\u0442\u043d\u043e\u043c \u0441\u0442\u0438\u043b\u0435, \u0432\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442\u044c \u043a\u043e\u0434\u0443 \u043f\u0440\u043e\u0432\u0430\u043b\u0438\u0442\u044c\u0441\u044f \u0438 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u0440\u0430\u0441\u0441\u0438\u0440\u043e\u0432\u043a\u0443 \u0441\u0442\u0435\u043a\u0430?\u00bb<\/p><\/blockquote>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-191548","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/191548","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=191548"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/191548\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=191548"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=191548"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=191548"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}