Tagged Questions

Mnemonics for set of design principles: Single responsibility, Open-closed, Liskov substitution, Interface segregation, Dependency inversion

learn more… | top users | synonyms

0
votes
0answers
94 views

Inheritance in imperative programming

My first introduction to programming was Java, which was horrible so I learnt Actionscript3 which was nice... "The point is" OOP was my introduction to programming where by I went on to gain a career ...
0
votes
1answer
60 views

Extending a class for debugging: public API, hidden implementation or something else?

I'm working on a fairly large project that involves 3D drawing, and I want to add some visualizers (for example, to see the bounding boxes of the objects) to make debugging easier. However, I'm having ...
2
votes
1answer
135 views

Implementation Coupling

This question is regarding Interface Segregation Principle Best-Practices. I use abstract examples below, but the question arises from actual code I've seen that performs what I can only call ...
4
votes
2answers
124 views

Does having many duplicated methods and deep inheritance hierarchies in GUI APIs (Java Swing, Android SDK) violate the SOLID design principles?

For those unfamiliar with the SOLID principles you can start reading here: Wikipedia article. However, most of my understanding comes from: http://www.objectmentor.com/resources/publishedArticles.html ...
35
votes
5answers
3k views

IOC Containers break OOP Principles

What is the purpose of IOC Containers? The combined reasons for it can be simplified to the following: When using OOP/SOLID Development principles, Dependency Injection gets messy. Either you have ...
4
votes
2answers
164 views

Reducing dependency cycles and reducing coupling

I'm trying to learn how to produce quality object-oriented code and have been studying concepts like SOLID. I'm currently working on an entity-component-process system for a small game engine. ...
0
votes
0answers
71 views

Dependency Inversion Principle

I have been studying also S.O.L.I.D. and watched this video: https://www.youtube.com/watch?v=huEEkx5P5Hs 01:45:30 into the video he talks about the Dependency Inversion Principle and I am scratching ...
1
vote
3answers
155 views

Am I violating LSP if the condition can be checked?

This base class for some shapes I have in my game looks like this. Some of the shapes can be resized, some of them can not. private Shape shape; public virtual void SetSizeOfShape(int ...
1
vote
1answer
170 views

Passing in config values to a method using SOLID principles

I have an email helper class that has a method that sends email: private static class EmailHelper { public static void SendEmail(string from, string to, string subject, string message) { ...
3
votes
3answers
486 views

Why not apply Interface Segregation Principle to “extreme”

Providing that clients would typically consume just one method, though methods would be conceptually related, why not always apply the Interface Segregation Principle to the extreme and have [many] ...
1
vote
2answers
101 views

Databases and the single responsibility principle

Can the single responsibility principle be applied to databases? relational databases I mean. I'm asking this because a typical database will have several tables and we may find something like that ...
2
votes
1answer
210 views

Design Patterns for creating tasks

I am developing software where each action in my entities need create tasks that will be execute in my infrastructure. When I create a task it is only records in the database. Afterwards, a windows ...
1
vote
1answer
100 views

Liskov substitution principle with abstract parent class

Does Liskov substitution principle apply to inheritance hierarchies where the parent is an abstract class the same way if the parent is a concrete class? The Wikipedia page list several conditions ...
3
votes
1answer
181 views

Does this Decorator implementation violate the Liskov Substitution Principle?

Please consider the following implementation of the Decorator design pattern: WordBank objects store strings and return them to the client through the method getWords(). The decorator class, ...
6
votes
3answers
340 views

How to adhere to the open-closed principle in practice

I understand the intent of the open-closed principle. It's meant to reduce the risk of breaking something that already works while modifying it, by telling you to try to extend without modifying. ...
73
votes
13answers
7k views

Why would Square inheriting from Rectangle be problematic if we override the SetWidth and SetHeight methods?

If a Square is a type of Rectangle, than why can't a Square inherit from a Rectangle? Or why is it a bad design? I have heard people say: If you made Square derive from Rectangle, then a Square ...
1
vote
2answers
215 views

How to refactor code that has 2 concerns

Say I have this code: if ($this->ship == "e") { $this->price->addLine($this->price->base * $this->price->e, 0, "Export"); ...
0
votes
2answers
118 views

High-Level Classes and Low-Level Classes [duplicate]

I've seen at SOLID there is a principle Dependency inversion principle. Also I've seen that: High-level Classes should not depend on Low-level Classes but both of them should depend on abstractions. ...
3
votes
2answers
394 views

Aren't decorators easily breaking the ISP?

"The Interface-Segregation Principle (ISP) states that no client should be forced to depend on methods it does not use." The decorator pattern is a design pattern to decorate a method of a class. For ...
3
votes
4answers
561 views

Is it good practice to declare and set properties in abstract classes?

I am using PHP and designing some abstract classes. I can declare properties with constant values within my abstract class and access/overwrite them from any class which extends this without re ...
1
vote
3answers
323 views

Gathering IP address and workstation information; does it belong in a state class?

I'm writing an enterprisey utility that collects exception information and writes to the Windows Event Log, sends an email, etc. This utility class will be used by all applications in the corporation: ...
35
votes
11answers
4k views

Ensure that each class has only one responsibility, why?

According to Microsoft documentation, the Wikipedia SOLID principe article, or most IT architects we must ensure that each class has only one responsibility. I would like to know why, because if ...
0
votes
0answers
148 views

API Client Design

I'm designing a client to the Tomtom WEBFLEET.connect API in PHP. (You can read more about the API through the full documentation here: ...
10
votes
5answers
865 views

Are there flavours of OOP where some or all of the SOLID principles are antithetical to clean code?

I recently had a discussion with a friend of mine about OOP in video game development. I was explaining the architecture of one of my games which, to my friend's surprise, contained many small ...
1
vote
0answers
125 views

How much segregation is too much in this design?

We are working on ASP.NET webforms application developed using WCSF (MVP pattern). In the application, there is a search screen that allows the user to enter some fields and display the results. We ...
1
vote
2answers
160 views

Dealing with an often occuring dependency that is not related to the class

I'm using view classes for my templating. These view classes often require the Routing class to get URI's from other pages. You could actually say that the Routing should be available to every view ...
3
votes
2answers
464 views

Implementing the Interface Segregation Principle

Does this IConvertible interface satisfy the Interface Segregation Principle (ie. the "I" in SOLID)? Here is the definition: public interface IConvertible { TypeCode GetTypeCode(); bool ...
9
votes
2answers
323 views

Too many CS files in a single project [duplicate]

I am working on a ‘brown-field’ project, with a team of programmers. I understand each programmer will have different styles. I am running into some criticism with my coding style, specifically ...
0
votes
0answers
108 views

Customizing configuration for PHP will Laravel 4 IoC be useful?

This topic has been discussed in this post: Customizing configuration with Dependency Injection However - I couldn't find one for PHP syntax and since one of the answers was to use a specific ASP.net ...
2
votes
1answer
216 views

Is more dependency inversion always better?

Is there any situation in industrial object-oriented programming when the dependency inversion principle should not be used?
1
vote
1answer
174 views

Handling array passed to object at creation

When creating my object I pass it an array of a row from my database. (everything in the array we will need, disregarding unnecessary elements at sql query level) When I need to access certain array ...
1
vote
2answers
371 views

Interface Segregation Principle - type hinting multiple interfaces

The question is about typehinting of the role interfaces. The code example has two DataMappers which typehint the interface they need in the constructor, FooDataMapper type hints the Preparable ...
2
votes
2answers
190 views

Achieving multiple tasks within one loop

With relation to what's considered good OOP engineering principles, SOLID, DRY, KISS etc I am wondering whether to complete multiple tasks within one loop when easily done. The problem is that this ...
2
votes
2answers
257 views

Single responsibility vs procedural programming

Single responsibility (from SOLID) is like making me create classes with only one public method. But if it's so, it would be possible use static methods, and go back to procedural programming. What's ...
25
votes
8answers
2k views

What is the real responsibility of a class?

I keep wondering if it is legitimate to use verbs that are based on nouns in OOP. I came across this brilliant article, though I still disagree with the point it makes. To explain the problem a bit ...
1
vote
1answer
546 views

Liskov principle: violation by type-hinting

According to the Liskov principle, a construction like the one below is invalid, as it strengthens a pre-condition. I know the example is pointless/nonsense, but when I last asked a question like ...
7
votes
4answers
323 views

Is throwing an error in unpredictable subclass-specific circumstances a violation of LSP?

Let's say I wanted to create a Java List<String> (see spec) implementation that uses a complex subsystem, such as a database or file system, for its store so that it acts as a persistent ...
2
votes
4answers
238 views

Why should IQueryProvider implementations throw NotSupportedExceptions?

Searching the web, we can find plentiful examples of various ORMs (nHibernate, EF, LinqToSql, etc.) that implement but don't actually support the full IQueryable<T> interface, throwing ...
3
votes
3answers
1k views

SOLID Application Structure and Design

A one possible structure for an application is to have it broken down into modules such as Data Access, Core, Services, UI. Now depending on what type of ORM you are using Data Access layer will have ...
0
votes
1answer
94 views

The line between ByRef Parameters and Module Variables

This question was brought up during a Standards discussion, which should revolve around SOLID Principles for Object Oriented Development. In your experiences, have you seen benefits or drawbacks in ...
4
votes
3answers
276 views

How can I improve this design so that I don't need to dynamically scan classes at runtime?

I'm in the middle of a redesign on the part of my current project that deals with user permissions and authorization. I have an interface named IUserPermissions that encapsulates this information. ...
112
votes
6answers
11k views

SOLID Principles and code structure

At a recent job interview, I couldn't answer a question about SOLID -- beyond providing the basic meaning of the various principles. It really bugs me. I have done a couple of days worth of digging ...
8
votes
3answers
546 views

Two contradicting definitions of Interface Segregation Principle – which one is correct?

When reading articles on ISP, there seem to be two contradicting definitions of ISP: According to first definition ( see 1, 2, 3), ISP states that classes implementing the interface shouldn't be ...
2
votes
2answers
516 views

Is it a Single Responsibility Principle violation?

I'm designing an OO graph library and at the moment I'm trying to figure out the design for a GraphEdge class. I've added setters and getters for it's nodes, direction and weight. This seemes ...
2
votes
2answers
1k views

Programming against a protocol in Objective-C

I stumbled accross the SOLID principles. There is one burning question. Should I always use protocols? I never saw someone using them in the way that a Java developer would use them. I tried it in a ...
2
votes
1answer
213 views

Creating an interface of interfaces

Background: We have a class that both listens on a socket and sets values on itself based on what it reads off the socket. I believe that adheres to SRP. To adhere to ISP we created one interface ...
6
votes
2answers
456 views

Is it good to have an interface plenty of methods which belong to different concepts, just to preserve the Liskov's Principle?

I'm currently studying a course based on Software Design and I had a discussion in class with my professor and some classmates about a problem represented by the next scenario: Scenario Imagine ...
3
votes
2answers
298 views

Single Responsibility principle VS KISS principle

Let's assume the modeling of User model in a context of a social network. User concept is composed of two notions: Authentication elements like userName/Password/Email etc... Extra data information ...
4
votes
1answer
505 views

Xerox SOLID example in PHP

There is a good example on Wikipedia regarding the violation of SOLID principles. The ISP was first used and formulated by Robert C. Martin while consulting for Xerox. Xerox had created a new ...
3
votes
2answers
172 views

Are there any well-known quantitative approaches to evaluate a particular design whether it satisfies or violates the SOLID design principles? [duplicate]

I designed an application framework by considering the SOLID design principles and supported by design patterns. However, I wonder if there are any automated tools or well-known approaches to evaluate ...