- 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.
- GAE編程指南
- HTML5移動Web開發(fā)技術(shù)
- C語言程序設(shè)計實訓(xùn)教程
- HBase從入門到實戰(zhàn)
- Windows Server 2012 Unified Remote Access Planning and Deployment
- 從0到1:Python數(shù)據(jù)分析
- RSpec Essentials
- Scala Reactive Programming
- C語言程序設(shè)計
- Python Data Science Cookbook
- 案例式C語言程序設(shè)計實驗指導(dǎo)
- 持續(xù)集成與持續(xù)交付實戰(zhàn):用Jenkins、Travis CI和CircleCI構(gòu)建和發(fā)布大規(guī)模高質(zhì)量軟件
- 從0到1:HTML5 Canvas動畫開發(fā)
- Distributed Computing in Java 9
- Python 3 Object:oriented Programming(Second Edition)