Questions tagged [design-principles]

Design principles are ideas that guide developers toward certain goals in software design.

Software has many different desirable quality aspects -- among them are reliability, security, maintainability, efficiency, and size; and these are all impacted by choices made by the developers. Software design principles tend to focus on the maintainability aspects of quality: is the code loosely coupled, or does it have many dependencies that make it hard to use? Is the code highly cohesive, or is a collection of unrelated information needed to use a module? Is the code readable and understandable? Is the code testable? Is the code usable and reusable? Is the code simple or complex?

Various design principles can be used by developers to advise them in making choices that will yield highly cohesive, loosely coupled, simple, maintainable designs. The SOLID design principles are an example of specific design advice for object oriented projects. The Principles of User Interface Design provide design advice for creating user interfaces.

309 questions
0
votes
1 answer

Is overriding a type of polymorphism?

After reading this article, it seems to me that overriding is a type of polymorphism, at least in C# programming.(Not speaking of java but about general programming) Is this correct?
Joe
  • 173
  • 1
  • 2
  • 9
0
votes
2 answers

What is the difference between the ISP and the OCP?

I don't understand what the difference is between the Interface Segregation Principle and the Open/Closed Principle. What I understand is that the ISP must make everything depend on interfaces and the OCP on classes and I see that both of them can…
0
votes
0 answers

How to prevent JSF namespace pollution

I consider JSF have a namespace pollution in which I have to expose private members to the world that I shouldn't do. Here's an example: Suppose I have a form with From data and To date input forms, which represented in the backing beans as: private…
Muhammad Hewedy
  • 29,102
  • 44
  • 127
  • 219
0
votes
1 answer

Is it a good idea to modify Magento Cutomer Model

A couple of days back I posted a question on StackExchange - Magento. Please read that post as this question is related. Since, I wanted to have this newly created customer attribute Unique. i.e no user should have same attribute as another already…
RHLK
  • 347
  • 3
  • 14
0
votes
0 answers

Public virtual method overridden as private. Generalization/specialization/Liskov principles violation?

As in Private function member called outside of class, one can write the following code: #include class A { public: virtual void f() { std::cout << "A::f()"; } }; class B : public A { private: void f() override { std::cout <<…
Jean-Baptiste Yunès
  • 34,548
  • 4
  • 48
  • 69
0
votes
1 answer

Python Methods: Returning data vs Storing data in attributes

This might be a general programming question rather than Python specific, but, what is the best practice when it comes validation classes? My first approach is having the method return a dictionary: class Validator(): def scene(self): #…
0
votes
2 answers

Should i have an object as attribute or primitive id?

This question is maybe opinion based but i am wondering which principle should i use. Here is my situation. I have a class named TravelOffer. This class looks like this: public class TravelOffer { private final long id; private final…
Joro Seksa
  • 1,525
  • 3
  • 18
  • 44
0
votes
1 answer

Design pattern to reuse code with different instances

I'm developing an API and in the controller the index, store, show, update and destroy methods are all the same except for the Model that is being used. How would you implement this? I was thinking about a ActionRepository where I create those…
guidsen
  • 2,333
  • 6
  • 34
  • 55
0
votes
3 answers

Computation of loop conditions

In a given loop eg: for(int i=0 ; i < strlen(s) ; i++){ //do something } Is the strlen(s) calculated for every iteration of the loop? How do the C and C++ languages handle this? If this function call is going to be made for every iteration and…
Nitin Labhishetty
  • 1,290
  • 2
  • 21
  • 41
0
votes
2 answers

Is the dependency inversion principle really present in the context of a DI system?

I managed to understand the dependency injection concept, but I simply don't see where the dependency inversion takes place. For example, this class has tight dependencies. class Man { public function eat() { $food = new Food(); …
0
votes
1 answer

Best approach to perform step wise dependent operation

What is the best approach to achieve this (probably using some design pattern )? Let say we have 3 stages to process a user input, at each stage data is validated/transformed and if successful next step is executed. Proceeding to next step is not…
sakhunzai
  • 13,900
  • 23
  • 98
  • 159
0
votes
3 answers

Class design, case for static methods

I had a discussion about usage of static method, briefly the argument is should a class definition have a method as static or instance method in the following scenario. There is a class that defines an entity i.e, what its properties are and what…
broun
  • 2,483
  • 5
  • 40
  • 55
0
votes
0 answers

Suitable Design Pattern for Multi Threaded Java Application

I am a newbie to java technology and have a little idea about design patterns. I have to write a java application that contains 3 independent threads: the first thread is used to write on a file "A" the second one is used to write on a file "B" and…
Razib
  • 10,965
  • 11
  • 53
  • 80
0
votes
3 answers

Specify the supertype of a class upon instantiation/declaration?

Is it possible to specify the parent of a class when I instantiate/declare that class? For example, can I do something similar to this: MonitoredDevice device = null; And then from that statement, the MonitoredDevice class would…
Stephen Watkins
  • 25,047
  • 15
  • 66
  • 100
0
votes
2 answers

Inject delegate method from derived to base class using constructor

Today I was re-factoring a library that I created and share code across multiple platforms (WPF, WF, WP7, WP8). The idea is that I use inheritance to extend functionality in classes. The top class expose couple of events to the client, this event is…
George Taskos
  • 8,324
  • 18
  • 82
  • 147