solid-principles

Doesn't having more than 1 method break the Single Responsibility Principle?

亡梦爱人 提交于 2020-03-16 06:58:58
问题 I am quite confused with the Single Responsibility Principle. The Principle states that there should only be one reason for the class to change. The problem which I am facing is, any change to a method or any logic change in doing things would change the class. For example, consider the following class: class Person{ public void eat(){ }; public void walk(){ }; public void breathe(){ }; public void run(){ }; public void driveCar(Car car){ }; } Uncle Bob describes it as there should ONLY be a

Doesn't having more than 1 method break the Single Responsibility Principle?

筅森魡賤 提交于 2020-03-16 06:55:52
问题 I am quite confused with the Single Responsibility Principle. The Principle states that there should only be one reason for the class to change. The problem which I am facing is, any change to a method or any logic change in doing things would change the class. For example, consider the following class: class Person{ public void eat(){ }; public void walk(){ }; public void breathe(){ }; public void run(){ }; public void driveCar(Car car){ }; } Uncle Bob describes it as there should ONLY be a

SOLID principles and web page class

可紊 提交于 2020-02-22 09:44:54
问题 I am trying to follow SOLID principles when writing new classes and code. My question is about ASP.NET classes that extend the Page class i.e. ASPX files. If I had a page class that has a page_load event that creates instances of multiple objects e.g. Person class, Sport class etc then I believe this page class is tightly coupled with these classes. Is this the case or am I missing something obvious? Could it be that all classes should expose interfaces and the client (aspx pages) should use

SOLID principles and web page class

女生的网名这么多〃 提交于 2020-02-22 09:42:26
问题 I am trying to follow SOLID principles when writing new classes and code. My question is about ASP.NET classes that extend the Page class i.e. ASPX files. If I had a page class that has a page_load event that creates instances of multiple objects e.g. Person class, Sport class etc then I believe this page class is tightly coupled with these classes. Is this the case or am I missing something obvious? Could it be that all classes should expose interfaces and the client (aspx pages) should use

SOLID principles and web page class

只谈情不闲聊 提交于 2020-02-22 09:40:45
问题 I am trying to follow SOLID principles when writing new classes and code. My question is about ASP.NET classes that extend the Page class i.e. ASPX files. If I had a page class that has a page_load event that creates instances of multiple objects e.g. Person class, Sport class etc then I believe this page class is tightly coupled with these classes. Is this the case or am I missing something obvious? Could it be that all classes should expose interfaces and the client (aspx pages) should use

SOLID principles and web page class

眉间皱痕 提交于 2020-02-22 09:37:28
问题 I am trying to follow SOLID principles when writing new classes and code. My question is about ASP.NET classes that extend the Page class i.e. ASPX files. If I had a page class that has a page_load event that creates instances of multiple objects e.g. Person class, Sport class etc then I believe this page class is tightly coupled with these classes. Is this the case or am I missing something obvious? Could it be that all classes should expose interfaces and the client (aspx pages) should use

What is the scope of the Single Responsibility Principle? [closed]

僤鯓⒐⒋嵵緔 提交于 2020-01-28 02:43:47
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 6 months ago . Another engineer at my job asked me today about "what is this single responsibility thing?" and my answer was as follows: "Every scope of your code, be it an if statement, a function, a class, a module, should have one reason to change". But everywhere I read this, people

Inject require object depends on condition in constructor injection

╄→гoц情女王★ 提交于 2020-01-21 09:53:30
问题 I have an interface public interface ITrnsitReport { List<UserDefinedType> GetTransitReportData (); } And it has only one implementation which is public class TransitReport : ITrnsitReport { private IValidateInput _inputValidation = null; private readonly ITransitRepository _transitRepo = null; public TransitReport (IValidateInput inputValidation, ITransitRepository transitRepo) { _inputValidation = inputValidation; _transitRepo = transitRepo; } public List<UserDefinedType>

Is this correct understanding of Liskov Substitution Principle

混江龙づ霸主 提交于 2020-01-13 06:48:07
问题 This was asked to me in an interview. I answered him by saying that for same set of input both parent and child should produce same set of output. If child wants to extend parent's functionality it should do only on new inputs outside the range supported by parent. In that way, child will maintain the contract made by it's parent. I gave him example, that an api may be using a parent like this if(parent.getOutput(10) == 5){/*do something */} If child produced a different output here then that

Database Guy Asks: Object-Oriented Design Theory?

我的梦境 提交于 2020-01-12 02:28:23
问题 I've worked with designing databases for a loooong time, and these days I'm working in C# too. OO makes sense to me, but I don't feel that I have a good grounding in the deep theory of OO design. In database land, there's a lot of theory around how to design the structure of a database, the main notion being normalisation. Normalisation directly steers the structure of a database and to some extent dictates how to arrange entities in a database. Are there any similar concepts behind how to