solid-principles

Does implementing multiple interfaces violate Single Responsibility Principle?

北城以北 提交于 2019-12-03 05:51:43
From Wikipedia : Single responsibility principle states that every class should have a single responsibility, and that responsibility should be entirely encapsulated by the class. Does that mean implementing multiple interfaces violates this principle? I would say not by itself. A class can have one responsibility, but do multiple things in the process, and implement one interface for each set of things it needs to do to fulfill its responsibility. Also, interfaces in Java can be used to say things about what properties the class has (for example, Comparable and Serializable ), but not really

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

孤街浪徒 提交于 2019-12-03 05:10:42
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 seen it really done myself, I'd just like to get an idea of what it might look like in a project (large or small)? Spring Framework Uncle Bob FitNesse . This is about 50K lines of Java code. It was build with TDD , and has about 90% code coverage (probably higher). There is a strong use of

How to obey Law of Demeter?

♀尐吖头ヾ 提交于 2019-12-03 04:52:33
问题 Any time I see articles about Law of Demeter the author never seems to give a solid example of how to obey this law. They all explain what it is and show an example of breaking the law but that is easy. There is probably lots of ways to obey this law (good design and planning being one) but in very simple terms would this be a way to obey it? Let's say I have a class with these properties: public class Band { private Singer singer; private Drummer drummer; private Guitarist guitarist; } I am

Patterns to implement SOLID principles

為{幸葍}努か 提交于 2019-12-03 03:27:57
I'm doing a presentation of SOLID design principles and I'm trying to connect the Single Responsibility Principle and the Open-Closed principle to design patterns. Currently I have SRP: proxy, façade OCP: strategy, command Are there any other basic patterns I should include? The SOLID principles are more attributes of a good OO language and framework than anything else. They don't handily translate into design patterns. Rather, they influence good vs. bad in a design pattern. Generally, all of the SOLID principles show up in each design pattern somewhere. If all the SOLID principles don't show

Examples of great software design and implementation [closed]

℡╲_俬逩灬. 提交于 2019-12-03 02:48:32
问题 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 hope this isn't a duplicate... What is the most solidly designed and implemented software system/framework/application that you've come across? It seems like TDD, SOLID principles, OO design patterns, and things like that can be easily theorized on podcasts and blogs using really simple examples, but it's hard

How to practice SOLID principle of OOP design? [closed]

假如想象 提交于 2019-12-03 01:43:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I'm new to SOLID principle but I understand it. My main problem is having a hard time designing my classes to follow the SOLID specially the Dependency Inversion. Sometimes it's easy to write the whole logic into procedural pattern rather than to use SOLID. For example: Let's say

How do you define a Single Responsibility?

回眸只為那壹抹淺笑 提交于 2019-12-03 01:39:33
问题 I know about "class having a single reason to change". Now, what is that exactly? Are there some smells/signs that could tell that class does not have a single responsibility? Or could the real answer hide in YAGNI and only refactor to a single responsibility the first time your class changes? 回答1: The Single Responsibility Principle There are many obvious cases, e.g. CoffeeAndSoupFactory . Coffee and soup in the same appliance can lead to quite distasteful results. In this example, the

Design pattern for default implementation with empty methods

帅比萌擦擦* 提交于 2019-12-03 01:27:46
Is there a specific design pattern that describes the scenario where a non-abstract default implementation is provided that implements all or some of the methods on the interface with empty, NO-OP implementations. This being done with the intent of alleviating subclasses with the burden of implementing methods that they themselves may not need/use: public interface MyInterface { public void doThis(); public void doThat(); public void done(); } public class MyClass implements MyInterface { public void doThis() { // NO-OP } public void doThat() { // NO-OP } public void done() { // Some standard

How to obey Law of Demeter?

邮差的信 提交于 2019-12-02 18:08:08
Any time I see articles about Law of Demeter the author never seems to give a solid example of how to obey this law. They all explain what it is and show an example of breaking the law but that is easy. There is probably lots of ways to obey this law (good design and planning being one) but in very simple terms would this be a way to obey it? Let's say I have a class with these properties: public class Band { private Singer singer; private Drummer drummer; private Guitarist guitarist; } I am somewhere in the program and I have an instance of this Band class and I want the guitarists name, what

How to practice SOLID principle of OOP design? [closed]

穿精又带淫゛_ 提交于 2019-12-02 17:11:49
I'm new to SOLID principle but I understand it. My main problem is having a hard time designing my classes to follow the SOLID specially the Dependency Inversion. Sometimes it's easy to write the whole logic into procedural pattern rather than to use SOLID. For example: Let's say that we are creating an Attendance Monitoring System, and we have logic(or procedure) that scan the employee fingerprint, get it's ID, determine whether or not it's valid or not, determine what time he was in, write the login info to the database, and show if it's successful or not. It is easy to write this in a