solid-principles

Simple Factory vs Factory Method: Switch statement in factory vs. client

我怕爱的太早我们不能终老 提交于 2019-12-21 16:52:11
问题 I understand that one of the main advantages of the Factory Method over Simple Factory is that it doesn't violate the Open-Closed SOLID Principle. That is, the former doesn't require modifying the switch statement when new types are added. There is one piece on which I am hoping to get clarification. If I were to use a simple factory, I would have a factory like this (simplified): public class ObjectFactory { public static IObject CreateObject(ObjectTypeEnum objectType) { switch (objectType)

Open source projects that demonstrate TDD and SOLID priciples [closed]

房东的猫 提交于 2019-12-20 17:39:23
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I asked a similar question before, and got some good answers, but I think it was too general. Examples of great software design and implementation Does anyone know of any open-source projects that demonstrate really good TDD practices, and SOLID principles? TDD and SOLID are widely publicized, but I've never

Open source projects that demonstrate TDD and SOLID priciples [closed]

旧时模样 提交于 2019-12-20 17:38:08
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I asked a similar question before, and got some good answers, but I think it was too general. Examples of great software design and implementation Does anyone know of any open-source projects that demonstrate really good TDD practices, and SOLID principles? TDD and SOLID are widely publicized, but I've never

Is Interface segregation principle only a substitue for Single responsibility principle?

自作多情 提交于 2019-12-20 09:48:45
问题 Is interface segregation principle only a substitue for single responsibility principle ? I think that if my class fulfill SRP there is no need to extract more than one interface. So ISP looks like solution in case we have to break SRP for some reason. Am I right ? 回答1: No. Take the example of a class whose responsibility is persisting data on e.g. the harddrive. Splitting the class into a read- and a write part would not make practical sense. But some clients should only use the class to

Dependency Inversion Principle (SOLID) vs Encapsulation (Pillars of OOP)

家住魔仙堡 提交于 2019-12-20 08:07:03
问题 I was recently having a debate about the Dependency Inversion Principle , Inversion of Control and Dependency Injection . In relation to this topic we were debating whether these principles violate one of the pillars of OOP, namely Encapsulation . My understanding of these things is: The Dependency Inversion Principle implies that objects should depend upon abstractions, not concretions - this is the fundamental principle upon which the Inversion of Control pattern and Dependency Injection

Can good Object Orientated Design be formalised as good relational database design has been?

穿精又带淫゛_ 提交于 2019-12-19 09:08:22
问题 In the database world, we have normalisation. You can start with a design, crank the steps and end up with a normal form of the database. This is done on the basis of the semantics of the data and can be thought of as a series of design refactorings. In object orientated design, we have the SOLID principals and various other adhoc guidelines towards good design. Do you think it is possible to define the equivalent of normal forms for OO, such that a series of refactoring steps could move a

Liskov substitution principle and Streams

空扰寡人 提交于 2019-12-19 05:48:38
问题 Does the fact that there are Stream derived classes that cannot be written or sought break the Liskov substitution principle? For example, the NetworkStream cannot be sought, it will throw a NotSupportedException if the method Seek is called. Or because the existence of CanSeek flag it is ok? Considering the well known example of Square inheriting from Rectangle ... would the addition of the flags DoesHeightAffectsWidth and DoesWidthAffectsHeight to Rectangle fix the issue? Doesn't this open

Using the Single Responsibility Principle in the “real world” [closed]

十年热恋 提交于 2019-12-18 11:07:08
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 8 years ago . I basically want to get an idea of the percentage of people who think it's reasonable to use the Single Responsibility Principle in

Monkey-patching Vs. S.O.L.I.D. principles?

不打扰是莪最后的温柔 提交于 2019-12-18 10:34:36
问题 I'm slowly moving from PHP5 to Python on some personal projects, and I'm currently loving the experience. Before choosing to go down the Python route I looked at Ruby. What I did notice from the ruby community was that monkey-patching was both common and highly-regarded. I also came across a lot of horror stories regarding the trials of debugging ruby s/w because someone included a relatively harmless library to do a little job but which patched some heavily used core object without telling

How to implement SOLID principles into an existing project

被刻印的时光 ゝ 提交于 2019-12-17 22:31:37
问题 I apologize for the subjectiveness of this question, but I am a little stuck and I would appreciate some guidance and advice from anyone who's had to deal with this issue before: I have (what's become) a very large RESTful API project written in C# 2.0 and some of my classes have become monstrous. My main API class is an example of this -- with several dozen members and methods (probably approaching hundreds). As you can imagine, it's becoming a small nightmare, not only to maintain this code