Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [open-close]

The tag has no usage guidance.

1
vote
2answers
110 views

Does an IoC-Container violate the Open/Closed-Principle?

Right now I construct all objects of my application in the root class manually. Since it is getting ugly now, I want to switch to an IoC-Container like Autofac. Now I have to register each interface ...
8
votes
2answers
357 views

Difficulty making this class open-closed

Here is my problem: I want to read input from different HID devices such as a gamepad, racing well, joystick, etc. Pretty much any game controller. The issue is that they all have different inputs. ...
5
votes
6answers
564 views

In creating a “registry”, which is worse: using reflection or violating open/closed principle?

In my current software engineering course, my team is working on a library management system that is essentially a command-line/REPL environment with a half dozen commands, e.g. checkout, search, etc. ...
2
votes
2answers
279 views

How to change this implementation to cover drawbacks of Mediator Design Pattern here

I am new to design patterns, here is a classic example of basic mediator pattern that has 3 problems with it, first of all take a look at the application image, diagram, code and description: We use ...
5
votes
2answers
313 views

Specification pattern and open closed principle

I'm studying the SOLID principles and I'm having some troubles dealing with the Specification Pattern and the open/closed principle. The fact is that the Specification pattern introduced by Eric ...
2
votes
1answer
532 views

Open/Closed principle, good practices, and business rules

I'm discovering craftsmanship and trying to learn it, and I decided first to understand how to work with the SOLID principles. I'm actually facing some troubles while dealing with the Open/Closed ...
4
votes
2answers
3k views

Static factory method in base class

An increasingly popular definition of factory method is: a static method of a class that returns an object of that class' type. But unlike a constructor, the actual object it returns might be an ...
4
votes
1answer
142 views

Should the ability to locate where code is being used be a consideration?

I was modifying a class whose job is to load other classes from the same directory. Basically, everytime a new class is added you need to add a new CommandClass; statement to this class for it to be ...
0
votes
1answer
308 views

AGPL alternatives for commercial software

Are there any real alternatives (i.e. non-customized software license agreement) to the AGPL license if you want to share your source code and make money selling software licenses?
7
votes
5answers
1k views

Open Closed principle in design patterns

I am bit confused about how Open Closed principle can be applied in real life. Requirement in any business changes over the time. According to Open-Closed principle you should extend the class instead ...
2
votes
1answer
1k views

Open / Closed Principle

I found this code example explaining Open / Closed principle. Code before application of principle: public class Logger { public void Log(string message, LogType logType) { switch (...
0
votes
0answers
82 views

Did Apple violate OCP back when they released iOS 7

If I remember correctly, back when iOS 7 was released, there were a couple of issues regarding the public API of certain classes which implementation was completely changed. The following is an ...
18
votes
1answer
666 views

Why does(/did) Bertrand Meyer think subclassing is the only way to extend a “closed” module?

In Meyer's Object-Oriented Software Construction (1988) he defines the open/closed principle as follows: A module will be said to be open if it is still available for extension. For example, it ...
2
votes
3answers
2k views

Does class inheritance (in C#) violate the Open/Closed Principle?

I typically make all my methods private unless and until they need to be overriden by a sub-class. At that point I modify the base class to make that particular method protected virtual. Is it ...
1
vote
2answers
193 views

Is “file” also participate in open closed principle?

I know according to open closed principle, something like class,interface,code.... should be unchanged when add new functions or contents, but is file also in this case? I was designing a game, the ...
13
votes
4answers
2k views

Do mocks violate the Open/Closed principle?

Some time ago I read, on a Stack Overflow answer that I can't find, a sentence that explained that you should test public APIs, and the author said that you should test interfaces. The author also ...
31
votes
8answers
18k views

Is overriding Object.finalize() really bad?

The main two arguments against overriding Object.finalize() is that: You don't get to decide when it's called. It may not get called at all. If I understand this correctly, I don't think those are ...
5
votes
1answer
186 views

Peculiar architecture interfacing .NET to AutoCAD out-of-process

I have written a set of classes to interact with AutoCAD from an out-of-process .NET assembly, but it seems like my class architecture and interactions are unusual. I am struggling to find a better ...
1
vote
1answer
438 views

Open closed principle vs abstraction leaking (Java enums)

In Java, an enum is not a plain replacement for a number (like in C/C++), but a family of objects which can have properties. For instance public enum Order { NAME("Ordering by name"), SURNAME("...
5
votes
2answers
655 views

Does agile contradict to Open/Closed principle?

O/C principle dictates that production code should not be changed if system behavior augmention is required. Otherwise it becomes hard to trust tests. Following it as a dogma we are going to end with ...
0
votes
1answer
913 views

Interfaces between multiple projects

I'm slightly confused over the following: ProjectA -------- GetUsers (Implements IDBConnector) -------- IGetUsers -------- UserModel ProjectB -------- Main I have two projects one main project (...
0
votes
3answers
115 views

In the light of the open / closed principle, is shared code ownership still important?

I was recently thinking about the following. According to the open / close principle, once a piece of code X has been implemented and tested, it should not be modified any more. X can still be ...
5
votes
2answers
954 views

Does this factory method pattern example violate open-close?

In Head-First Design Patterns, they use a pizza shop example to demonstrate the factory method pattern. public abstract class PizzaStore { public Pizza orderPizza(String type) { Pizza pizza; ...
0
votes
3answers
736 views

Doesn’t active record violate SRP and OCP?

I have watched the active record classes in our project grow into large, do-it-all classes. When you need anything about a user, for example, you should go to the Person class. While this makes ...
3
votes
1answer
5k views

Protocol for closing a socket connection

I'm rolling my own application protocol on top of TCP. I'm using Linux and C. I'm wondering whether there is an advisable sequence to closing a socket connection. The client will always initiate ...
46
votes
8answers
15k views

LSP vs OCP / Liskov Substitution VS Open Close

I am trying to understand the SOLID principles of OOP and I've come to the conclusion that LSP and OCP have some similarities (if not to say more). the open/closed principle states "software ...
10
votes
7answers
3k views

Refactoring and Open / Closed principle

I have recently being reading a web site about clean code development (I do not put a link here because it is not in English). One of the principles advertised by this site is the Open Closed ...
12
votes
5answers
1k views

Is overloading an example of the Open/closed principle?

Wikipedia says "software entities (classes, modules, functions, etc.) should be open for extension, but closed for modification" The word functions caught my eyes, and I now wonder if we can ...