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
3
votes
2 answers

How to resolve this dilemma when using generics in a simple factory

I have a Data class with several sub-class such as JSONData, XMLData, IntegerData. The task is to process different types of incoming data. So based on program to an interface, not an implementation, I created the following interface with generic…
Rui
  • 3,454
  • 6
  • 37
  • 70
3
votes
2 answers

What is mean by "Abstractions should not depend on details. Details should depend on abstractions" in Dependency inversion principle[DIP] means?

Before asking this question I like to say that this question in stackoverflow is very similar to my question but still the concept is not clear very confusing. I am trying to understand the dependency inversion principle but I could not able to…
3
votes
2 answers

Is this an anti-pattern or violates it some design-principles?

I try myself with design-patterns & -principles and have a question. Before, sorry for the bad coding-style habit !! I have an interface like ITest in this case: public interface ITest { public void method1(); } and then implement the methods…
3
votes
1 answer

The rule for preconditions/postconditions of derivatives

In his paper about LSP, uncle Bob mentioned : Now the rule for the preconditions and postconditions for derivatives, as stated by Meyer, is: ...when redefining a routine [in a derivative], you may only replace its precondition by a weaker one, and…
3
votes
2 answers

Need repository layout references

I am anticipating a battle over Subversion repositories: currently we have a single web application that was checked in as 3 main projects and 2 reports projects (when I started 6 months ago), is now up to 7 projects, and is expected to grow…
orbfish
  • 7,381
  • 14
  • 58
  • 75
3
votes
3 answers

designing shape class with circle and triangle

I am trying to understand the is-a vs is-like-a relationship where I read somewhere that we must try to follow design such that we always have is-a relationship and not is-like-a. Consider the classic example of shape base class and derived triangle…
MAG
  • 2,841
  • 6
  • 27
  • 47
3
votes
1 answer

Testing the creation of objects in a factory method

At the moment I'm writing a test-driven project, and I stuck in testing the following behaviour. I got an interface called Menu to which one can add dynamically entries through an addEntry-Method. There is another class which contains the Menu…
Janis
  • 1,020
  • 6
  • 14
3
votes
1 answer

Ruby DSL nested constructs

I am using the following code to enforce context of DSL nested constructs. What are the other ways of achieving the same functionality? def a &block p "a" def b &block p "b" def c &block p "c" instance_eval &block end …
I'm Mo
  • 131
  • 8
3
votes
1 answer

Why would an box character limit be larger than accepted form submission?

I've seen the same thing enough times now that it's sparked my curiosity. It's even on this site! The element on the "https://stackoverflow.com/questions/ask" sets maxlength=300 and data-max-length="150". Namely, the input…
TheRealFawby
  • 112
  • 8
3
votes
2 answers

What does "dependency inversion principle" mean in OOP?

What is meant by the "dependency inversion principle" in object-oriented programming? What does it do?
bunty
  • 2,665
  • 8
  • 30
  • 27
3
votes
2 answers

Is using Java Reflection Bad Practice?

I am building an application for a client and I am in the situation where I need to have the ability to reference a field value via a string, i.e the users uses a string to define which field they want to change the value of, this is part of an…
Sam Palmer
  • 1,675
  • 1
  • 25
  • 45
3
votes
2 answers

Does omitting super() and/or *weakening* preconditions violate the Liskov Substitution Principle?

I've been digging into some of the SOLID design principles lately, and some information I got from one source originally made sense to me, but based on the strict definitions I've been able to find for thr LSP, it seems like that info might not be…
3
votes
1 answer

Identify classes and class naming strategies

I am trying to understand Single Responsibility Principle and identify possible class that can be in my system. For now I know principles said by Uncle Bob, ie avoid weasel words like manager,data,super or processor. We should be able to write…
swapyonubuntu
  • 1,952
  • 3
  • 25
  • 34
3
votes
5 answers

Should static methods be separated from Classes with instance methods?

As a general convention, should static method(s) be separated into another class from a class with instance methods? Is there also an example of your reason?
Beginner questions
  • 343
  • 1
  • 4
  • 15
3
votes
3 answers

Abstract Class with only abstract methods and Interface - Which should I use?

Please note. This question is not an abstract class vs interface kind of question. Yes. I know. It's not necessary for a class which extends an abstract class to override all of its unimplemented methods. If a child class is not giving definition to…