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
1 answer

Django best user model design

Probably some of you would tell that is a recurrent topic, but after reading many articles, it still seems very ambiguous to me. My question is about the best way to use and to extend the User model preserving the authentication (and others)…
3
votes
3 answers

Observer pattern with different notifications

I'm trying to create an observer pattern that the subject notifies the observers with different notifications. Normally in observer pattern implementations you can see only one method called notify where it notifies the observers that something…
yayuj
  • 2,194
  • 3
  • 17
  • 29
3
votes
2 answers

Looking for the name of the following principle

I know there's a 'methodology' where the developer should write such functions, that the return value is always of the same type. So, say we have a function what tends to return an array, and something unwanted happens, like the argument is invalid,…
Attila Kling
  • 1,717
  • 4
  • 18
  • 32
3
votes
1 answer

DRY principle in Java

I have been reading about the DRY principle. Though it seems so easy, I am having difficulty in understanding how we actually achieve it in any project, be it a web application or Swing. Maybe a few examples will give me a lead and help me in…
beinghuman
  • 2,088
  • 7
  • 27
  • 36
3
votes
2 answers

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 interface? In other words, if an interface method…
2
votes
1 answer

Is Orthogonality inversely proportional with DRY principles?

According to The Pragmatic Programmer book "Orthogonality is closely related to the DRY principle". I'm not sure if I understand it the way the author wants the reader to. So I ask the question above. For example, you have class A and class B. Both…
2
votes
7 answers

When should I throw exception vs. return error ActionResult in ASP.NET Core Web API project?

I am making an ASP.NET Core Web API project with controllers. All API controllers derive from ControllerBase that has NotFound() method. I use this method from controllers whenever I can't find a resource that the client requested. However,…
mlst
  • 2,688
  • 7
  • 27
  • 57
2
votes
3 answers

How to have separate controller for each screen in flutter with clean architecture

I'm trying to implement Clean Architecture in my flutter app. There is a module named Purchase Order in my app. This contains List Screen, Filter Screen, Add Purchase Order Screen. Currently, I have one controller (GetxController) for all of them.…
ASAD HAMEED
  • 2,296
  • 1
  • 20
  • 36
2
votes
2 answers

Best approach to map enums to functions

I have 4 distinct file types. Each of these file types maps to a different file name pattern given an index. What is the best way to do this? Here is one approach: from pathlib import Path from enum import Enum base_path = "/a/b/c/d" class…
Chessnut
  • 65
  • 5
2
votes
2 answers

Help choosing my DDD aggregate roots within a provided scenerio?

I'm fairly new to DDD and have read a few articles about the concept so pardon if I'm lacking some knowledge. I'm curious on how this example should be modeled with aggregate roots. The basis is: There is an Employee, a Meeting and Comments. Each…
2
votes
1 answer

Creating new instance of concrete implementation in interface - is this an antipattern?

Let's say I have the interface AuthorDao with two different implementation classes for example MyAuthorDaoImpl1 and MyAuthorDaoImpl2. In my interface AuthorDao I have some basic crud methods and one extra method which is static for getting a new…
Rocky3582
  • 573
  • 4
  • 7
  • 17
2
votes
0 answers

Should a helper class implement an interface

I am implementing some functionality where I need to create a helper class for custom Math operations. Is it a good practice to implement an interface in this scenario? Usually we have single implementation for helper classes however in some…
Rob Wilkinson
  • 1,131
  • 5
  • 18
  • 34
2
votes
5 answers

UML help C# Design Principles

I have a problem understanding an UML below: Specifically, what is the relationship between PersistentSet and ThirdPartyPersistentSet? What is the relationship between PersistentObject and ThirdPartyPersistentSet? Please note that the UML is from…
Pingpong
  • 7,681
  • 21
  • 83
  • 209
2
votes
3 answers

Trying to understand MVC - am I already doing it?

I'm quickly getting knee-deep in larger and larger applications so I thought it'd be a good idea to learn what patterns are and how they work, etc. So, I'm watching some tutorials on youtube and reading some books on patterns and design principles…
linus72982
  • 1,418
  • 2
  • 16
  • 31
2
votes
1 answer

When does improving program cohesion worsen coupling?

I recently took an exam on design principles & patterns, and one of the questions in the exam was as follows : "Sometimes improving program cohesion may worsen coupling, give an example." From what I understand, cohesion is how focused a…