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

Liskov substitution principle, preconditions and abstract methods

Liskov substitution principle (LSP) says: Preconditions cannot be strengthened in a subtype. In C#, I could violate the whole principle as follows: public class A { public virtual void DoStuff(string text) { …
4
votes
3 answers

Drawback of using Abstract factory and which pattern address it

I have faced following question in interview for which I could not find any solution on Google or stack overflow. I don't know is it really a valid question(as I wasn't given any context. In which context he was talking about)?? I was asked to tell…
Yogesh
  • 3,044
  • 8
  • 33
  • 60
4
votes
4 answers

Should I care that passing in a class representation of an XML settings file violates the law of demeter?

I'm using a tool to automatically generate a class representation of a hierarchically organized XML file. The XML file is a settings file my app need to be able to access (read-only). If I pass in the top-level node (e.g., AppSettings) to a class…
devuxer
  • 41,681
  • 47
  • 180
  • 292
4
votes
2 answers

Instantiation of new object or reusing the same one for storing data

I have the following PHP class called Customer with function create() which stores customer's data into database: class Customer { public $createdby; public $cname; public function create() { ... } } Since I need to store more…
sbrbot
  • 6,169
  • 6
  • 43
  • 74
4
votes
3 answers

What are the most important structured software design principles?

Today I saw a job description that requires "significant experience coding in C++ and a thorough grounding in structured design principles", so I thought about what these principles are. First I felt it was a little odd to see C++ and "structured…
4
votes
1 answer

Introducing test-driven development to legacy code

Given: A LegacyControllerClass that extends a MonsterFrameworkClass (part of a very yucky framework that people are just living with for years). Framework class does lots of magic ranging from tons of logic in the default constructor to static…
aquaraga
  • 4,138
  • 23
  • 29
4
votes
1 answer

Doesn't the Factory pattern, violate the "Tell, Don't Ask" principle?

Procedural code gets information then makes decisions. Object-oriented code tells objects to do things. Alec Sharp When we are using the Factory pattern, we make decision, based on a property of a class except than the factory class, so this,…
Masoud
  • 8,020
  • 12
  • 62
  • 123
4
votes
4 answers

Is calling into other code a (SOLID) Single Responsibility Principles (SRP) violation?

Considering this class with business logic: public static class OrderShipper { public static void ShipOrder(Order order) { AuthorizationHelper.AuthorizedUser(); using (new PerformanceProfiler()) { …
user782596
  • 43
  • 3
4
votes
8 answers

When to stop DRYing up the code?

So DRYing up code is supposed to be good thing right? There was a situation in one of the projects I was working on where there were certain models/entities that were more-or-less the same except the context in which they were being used. That is,…
Chirantan
  • 15,304
  • 8
  • 49
  • 75
4
votes
5 answers

Newest Agile Design Methods for code construction

Hallo everybody Recently I've been reading the book: "Agile software development, Principles, Patterns and Practices" by Bob Martin The following (S.O.L.I.D) agile-design-principles are listed within the book: Single Responsibility Principle Open…
Harry
  • 3,592
  • 5
  • 21
  • 16
4
votes
8 answers

OO Software Design Principles

I am a huge fan of software design principles such as SOLID and DRY. What other principles exist for OO software design? Note. I’m not looking for answers like "comment your code" but instead looking for OO design principles like the ones discussed…
Kane
  • 16,471
  • 11
  • 61
  • 86
3
votes
6 answers

Having trouble understanding User Controls in C#

I'm new to usercontrols, having only created one so far, so bear with me. I've been reading today that usercontrols are supposed to be self-contained and not rely on any information from the parent container. I get that part, but what I'm having…
somacore
  • 6,294
  • 3
  • 24
  • 19
3
votes
2 answers

Why not all form controls could be rendered via HtmlHelper?

Does anybody know why could some HTML form controls be rendered using System.Web.Mvc.HtmlHelper (hidden, checkbox, password, textbox) and some couldn't and should be explicitly written in HTML (file, submit)? What is the principle of this…
Alexander Prokofyev
  • 33,874
  • 33
  • 95
  • 118
3
votes
4 answers

Web programming principles

Coming from a bit of a conventional (if rusty) programming background, I am busy getting to grips with the "stateless" nature of web sites. It is quite a mindset change! I've created a small web site for the team in which I work to use internally…
3
votes
1 answer

When is it reasonable to violate the Single Responsibility Principle?

After refactoring some service-layer classes in our java web application, i was asking myself at which point it is reasonable to stop adhering to the Single Responsibility Principle (SRP) and to keep the maintainability and readability of the code.…
Martin Schlagnitweit
  • 2,042
  • 6
  • 26
  • 42