- C# 7 and .NET Core Cookbook
- Dirk Strauss
- 155字
- 2021-07-03 00:12:04
How it works...
If you have code that looks like the preceding one, you are in contravention of the SRP. The StarShip class is no longer responsible for just itself and things that have to do with star ships. It now has to fulfill the role of logging errors to the database too. You see the problem here is that the database-logging code does not belong in the catch clause of the SetMaximumTroopCapacity method. A better approach would be to create a separate DatabaseLogging class with methods to create connections and write exceptions to the appropriate log table. You will also find that you are going to have to write that logging code in multiple places (in every catch clause). If you are finding that you are repeating code (by copying and pasting from other areas), you probably need to put that code into a common class, and you have likely broken the SRP rule.
- Unity 2020 By Example
- Learning Microsoft Windows Server 2012 Dynamic Access Control
- 從零開始:數字圖像處理的編程基礎與應用
- Docker and Kubernetes for Java Developers
- FreeSWITCH 1.6 Cookbook
- PostgreSQL技術內幕:事務處理深度探索
- React.js Essentials
- Java加密與解密的藝術
- Windows Server 2016 Automation with PowerShell Cookbook(Second Edition)
- Java:High-Performance Apps with Java 9
- Learning AngularJS for .NET Developers
- Python程序設計與算法基礎教程(第2版)(微課版)
- Everyday Data Structures
- Swift語言實戰晉級
- Learning Splunk Web Framework