Tagged Questions

The tag has no wiki summary.

learn more… | top users | synonyms

1
vote
4answers
686 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
74 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
129 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
159 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
70 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
351 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
496 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
121 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 ...
1
vote
3answers
359 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
697 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
874 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
162 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
586 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
151 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
402 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
114 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 ...
51
votes
2answers
5k 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
280 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
578 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 ...
18
votes
8answers
2k 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 ...
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 ...
2
votes
3answers
659 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
136 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
162 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 ...
6
votes
5answers
292 views

Please help me give this principle a name [closed]

As a designer, I like providing interfaces that cater to a power/simplicity balance. For example, I think the LINQ designers followed that principle because they offered both dot-notation and ...