The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
1answer
42 views

How do you keep up with 'requiring new methods in an interface' (Following LSP and adding new methods to interface seems to violate ISP)

I have a game that deals with opening and closing doors and the Door Engine deals with IDoor interface which has Open() and Close() contracts So far so good. the game is tested and works fine. Now a ...
4
votes
1answer
123 views

Where to initialize objects

I have an BallEntity class that is part of a game that uses a Entity Component System architecture. This class have 'components' that are like the attributes of that class. I create and initialize ...
1
vote
1answer
166 views

Is a class representing a JSON response a DTO, a domain object, or something else?

Consider a restful service in Spring MVC. I am wondering how to package my response classes, i.e. how to name the containing package. First I thought of them as being domain objects. But they are ...
2
votes
2answers
114 views

Difference between Single Source Of Truth and Single Responsibility Principle?

So I just found out about the term single source of truth while watching video series about programming code interviews. From what I understood it meant that the single source of truth is an ...
0
votes
1answer
50 views

SOC and self-initializing configuration

Disclaimer: I'm using C# for code examples. But I guess they should be readable/understandable for everyone. If they are not: please leave a comment. Okay I have a Client-Server application. The ...
3
votes
4answers
373 views

YAGNI principle put to practice

I recently came across to this principle and so far it is clear the fact that doing things that you don't need at the moment is not feasible as they might not be used or might be changed. That being ...
1
vote
4answers
777 views

try/catch open/closed principle violation

I have three or more different custom exceptions that a class can throw and I need to use try/catch in order to discover which exception was thrown. In my point of view this piece of code violates ...
1
vote
1answer
195 views

Tell, Don't Ask and Immutability in a non-directional network

I'm working on a small project in which I'm attempting to practice relatively strict adherence to two ideas: Tell, don't ask (TDA) Immutability The main concept in this project is a Map (as in a ...
1
vote
2answers
177 views

Define fields only once

I'm looking for a method to describe fields in a structured way, so I am able to reuse it in various languages and levels of my application. For instance, if I'm developing an Android application ...
0
votes
1answer
187 views

Technical example of modeling a domain with OOD?

Considering favoring composition over inheritance and looking at various design patterns there are multiple approaches to modeling a domain. Say you have some Entities which are very similar in some ...
0
votes
2answers
73 views

putting methods in base class that doesnt make sense/belong there [closed]

I've been lately thinking over design principles and patterns and a question did strike me. Let us say, I want to design a racing game. I want to design the classes for a variety of cars. each car ...
6
votes
2answers
474 views

Dependency Inversion Principle: Understanding how both low level components and high level components depend on abstractions

I'm learning about the Dependency Inversion Principle. It states that: High level modules should not depend upon low-level modules. Both should depend upon abstractions. For a while I tried to ...
3
votes
2answers
707 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 ...
2
votes
1answer
146 views

Single Responsibility Principle and higher levels of abstraction

Two common phrasings for the Single Responsibility Principle (SRP) are "each module should be responsible for a single feature or functionality in a system", and "each module should have only one ...
2
votes
3answers
665 views

Pattern for costly precondition check before acting

Let's say I have a method DoTheThing() which requires the precondition-check CanTheThingBeDone() to return true. The latter method is time consuming as it accesses the database. I'm finding it hard ...
5
votes
5answers
900 views

Martin Fowler's Refactoring book: switch statement is using other object's data, why is that bad ? A deeper explanation is sought for.

In the code sample below the Rental object is using Movie's fields to do a switch statement. Martin says : this is a bad idea but he does not give any deeper explanation as to why ? Of course, you ...
6
votes
4answers
999 views

“Extends is evil” vs. OCP?

As far as I have understood(?), the "Extends is evil" idea is in direct opposition to the Open Closed Principle? In here, the concept of OCP is presented as inherently using Extends: ...
1
vote
1answer
174 views

Component design: getting cohesion right

I currently have a set of components named DataValues, ValueParsers, ValueFormatters and ValueValidators. The first one defines an abstract base class DataValue and contains a whole load of ...
14
votes
6answers
2k views

Loose Coupling in Object Oriented Design

I am trying to learn GRASP and I found this explained (here on page 3) about Low Coupling and I was very surprised when I found this: Consider the method addTrack for an Album class, two possible ...
8
votes
3answers
906 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
3answers
153 views

Abstracting out a module or using the Module Singleton directly?

I am working on a module which is dependent on other module for some functionality. Now the dependent module provides a lot of functionality and I need only few of them, hence got the idea to create ...
7
votes
3answers
417 views

Is it a basic principle, or highly desirable, to have class methods that return “$this” rather than a value?

I've really just begun to learn OOP. I started about a year ago and have written probably 15,000 lines of it. But I wrote it all with hardly any experience looking at other people's OOP. Most of my ...
14
votes
4answers
2k views

How does the Law of Demeter apply to object-oriented systems regarding coupling and cohesion? [closed]

How does the Law of Demeter applied to object-oriented systems with coupling and cohesion? I was reading a book "Software development and professional practice" and came across the chapter about LoD, ...
2
votes
4answers
119 views

Feature organization / authentication? [closed]

Let's say I have a product that has different features, or different feature access depending on things (i.e Premium User, Beta, Demo, Logged-in User, etc..). What's the best way to organize a system ...
59
votes
2answers
7k views

Are there any OO-principles that are practically applicable for Javascript?

Javascript is a prototype-based object oriented language but can become class-based in a variety of ways, either by: Writing the functions to be used as classes by yourself Use a nifty class system ...
1
vote
5answers
284 views

Is there a term for “Use procedures that execute a single task”? [closed]

I'm having a discussion with a fellow developer, and I'm trying to argument this in something like a short "term". SoC (Separation of Concerns) is pretty straight forward design practice, but it ...
13
votes
1answer
715 views

Does Liskov Substitution Principle also apply to classes implementing an interface?

LSP states that classes should be substitutable for their base classes, meaning that derived and base classes should be semantically equivalent. But does LSP also apply to classes implementing an ...
21
votes
9answers
3k views

What can go wrong if the Liskov substitution principle is violated?

I was following this highly voted question on possible violation of Liskov Substitution principle. I know what the Liskov Substitution principle is, but what is still not clear in my mind is what ...
13
votes
1answer
846 views

How to verify the Liskov substitution principle in an inheritance hierarchy?

Inspired by this answer: Liskov Substitution Principle requires that Preconditions cannot be strengthened in a subtype. Postconditions cannot be weakened in a subtype. Invariants ...
9
votes
5answers
1k views

When to stop inheritance?

Once upon time ago I asked a question on Stack Overflow about inheritance. I have said I design chess engine in OOP fashion. So I inherit all my pieces from Piece abstract class but inheritance still ...
1
vote
3answers
758 views

Recommended content for layers

As an expansion from my previous question about using separate projects for seperate layers - Good practice on Visual Studio Solutions I now wish to know if I am putting the right functionality in ...
2
votes
2answers
140 views

Where does “isolating complexities” lie in the realm of design principles?

I was just curious, it's something I think most people are aware of as a technique: You have some abominable data that simply must be parsed and you can do nothing to simplify the algorithm for doing ...
4
votes
2answers
190 views

Does the single responsibility principal promote flexibility?

Does the single responsibility principal promote flexibility? If not what are the other methods to make your classes more flexible? By flexibility I mean, a class is able to function correctly at any ...
4
votes
2answers
167 views

Does KISS encourage tools and frameworks that expose complex leaky abstraction layers?

Tools and frameworks make complex tasks simple. This seems like something that would be supported by KISS(keep it simple stupid). Tools and frameworks also have the potential to introduce leaky layers ...