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
0 answers

Usage of domain services as data provider to entities and value objects

Let's say I have a domain which purpose is to evaluate financial instruments in a given currency. We can imagine having an abstract instrument class defined as follow: Then we can have different implementations of the Valuate method. But in all the…
0
votes
2 answers

How to restrict access privilege between two classes in java?

I have two classes Player and Game public class Player { private List cards; public Player(){ cards = new ArrayList(); } } public class Game { List players; public Game(List players){ …
0
votes
0 answers

Is this type of dynamic construction a thing?

I am currently working on a project where I want to be able to create a options object by dynamically setting its properties on creation. This made me come up with this type of constructor-setter combination: Options options = new Options() …
dasdawidt
  • 13
  • 5
0
votes
1 answer

Should I plumb Cancellation Tokens through all of my class methods in an asp.net core 3.1 web API?

I've been building a web server in asp.net core 3.1 for a little while and I've started to notice (and frankly, dislike) that Im plumbing cancellation tokens through my application. I came up with a solution to this "problem" (it is and it isn't)…
0
votes
1 answer

Law of demeter: Exposing intern functionality, because of earlier extending?

It's a easy question. I have there some database-framework, which gives me a few methods working with them. So now i want to extend that behavior. I write a wrapper-class and add a few more methods with that functionality i wanted to extend it. Now…
0
votes
1 answer

python class operations on members vs static methods

I need some help figuring out the right OOP design choice for my python class. In my example, letters are appended to a string in separate steps. The string is then printed. For this application, it is not really important to the user to get the…
user1981275
  • 13,002
  • 8
  • 72
  • 101
0
votes
3 answers

Is the virtual keyword inherently in-violation of the Liskov Substitution principle?

The Liskov Substitution principle states that you should write your class inheritance such that swapping subtypes for their base types wont change the behavior of your application by doing so. However, the virtual keyword literally seems to exist to…
0
votes
4 answers

when to use design patterns and when to apply which solid principle?

I am confused! I'm trying to figure out when to apply Solid Principles and when to use which Design Patterns(Factory Method ,Builder Pattern etc.). I searched a lot but I can't find answer of my question. At the end I posted here. Please explain.
0
votes
1 answer

Is there a way to split HTML document into two files, structure and content?

As far as I know, it is considered a good practice in program development to move the strings to the separate files. It allows translators and copyrighters to easily work with them, without needing to touch files with code, and it simplifies…
0
votes
1 answer

Looking for "find a design pattern for a problem" questions

In a job interview I was asked find a design pattern for the problem. I'm looking for these types of questions with answers. Do you any resource like this?
Ali
  • 185
  • 11
0
votes
0 answers

Getting interface type from Sqlite Query with DynamicParameters

I have a model class as following which implements an interface; public class EngTrModel : IWordModel { public string Word { get; set; } public string Translation { get; set; } public string WordPair { …
zalky
  • 659
  • 1
  • 7
  • 12
0
votes
1 answer

Inheritance or composition in object oriented design

I have seen many class diagrams on popular websites and design courses defining the relationships using composition like: Admin has a person instance Umpire has a person instance As per me, shouldn't it be the case of inheritance as admin 'is-a'…
0
votes
1 answer

Is it fine to pass a value returned by await function as parameters in C#

I have declared a string extension method to decode a Base64 string something like : public static string DecodeFromBase64String(this string base64String) { return…
0
votes
2 answers

Is this a good example of Law of Demeter?

I'm studying for an oral exam, and I wonder if I have understood Law of Demeter correctly. In essence, I have understood that the Law of Demeter aims to loosen coupling by making classes less dependent on one another, and by not giving away…
0
votes
1 answer

How to build stuff objects using the decorator pattern?

I have some questions regarding the decorator pattern. As I have understood it, the decorator pattern exists to add behaviour to an object, ie "decorating the object" so you can compose different objects without the need of implementing lots of lots…