Khi chúng tôi đã có mọi thứ trong thân cây, chúng tôi đã nhận lỗi khi cố gắng cam kết cũ mã vá trên đầu trang của mã mới của chúng tôi. Bây giờ, mặc dù chúng tôi đã có một thẻ cho phiên bản và một chi nhánh để làm việc. Phiên bản sửa chữa Hãy trong chi nhánh đó: | good-enough Sign Going from multiple responsibilies to a single responsibility ncc you vr done ail analysis you can Like all the methods hat don I make sense on a class and move those methods to classes hat do make sense for particular responsibility. Automobile Driver s đ driver s ỉỹỉĩí1- r d j X start void stopO void changeTires i es TiretJ -ydfd driveO void wdshO -Vơ ỏheổkOilO -void getớilO in driveU Automob l CaHVash wari a Aviomebtle Vo d Mechanic A CarWash class can handle washing ân automobile íhjr 5eĩ ro đ Auto ob le iiret ThwD v xd Now Automobile has only a single responsibility ------ dealing with its own basic functions Automobile start I void stofO void getớiio lint A mechanic IS responsible fơ changing tires and checking the 0 1 On an automobile liicrc-pue Fiv Dumb Questions 0 How does SRP analysis work when a method takes parameters like wash Automobile on the CarWash class Good question For your SRP analysis to make any sense you need to include the parameter of the method in the method blank So you would wnte The CarWash washes anl automobile itself That method makes sense with the Automobile parameter so It would stay on the CarWash class. 0 But what if CarWash took in an Automobile parameter as part of its constructor and the method was just washO Wouldn t SRP analysis give you a wrong result It would. If a parameter that might cause a method to make sense like an Automobile for the wash method on Carwash. IS passed into a class s constructor your SRP analysis might be misleading But that s why you always need to apply a good amount of your own common sense and knowledge ol the system in addition to what you learn from the SRP analysis you are here 159 don t repeat yourself Your design should obey thê SRP but also be PRY. The IS .ill about responsibility and whic h objec ts in your system do what. You want each object that you design to have just one responsibility- to locus on and when something about that responsibility changes you ll