New answers tagged

0 votes

Does interface segregation principle apply to configuration data holders?

Yes, but... When applied dogmatically you can end up arguing that every config value has its own individual purpose, which is not incorrect by itself, but it would be incorrect to then assume that ...
Flater's user avatar
  • 49.9k
0 votes

Service layer returns DTO to controller but need it to return model for other services

DTOs are used to help present your business objects. A single business object can have different representations that each cater to the needs of different clients. A Product might be presented using ...
Mehdi Charife's user avatar
1 vote

Does interface segregation principle apply to configuration data holders?

The Configuration object should not be pushed everywhere This question has an implied premise: If you have a class representing your applicative config file [and everything that consumes the config ...
Tim C's user avatar
  • 111
5 votes

Does interface segregation principle apply to configuration data holders?

Yes ISP applies. At least the idea behind it does. Oh sure ISP was supposed to be about interfaces but data structures need organizing as well. It’s nice when your data structure has just what you ...
candied_orange's user avatar
0 votes

How do access modifiers actually help programmers?

But why would you not want to be able to access an internal property? The main reason is when you're providing code to be consumed by another programmer you don't control, but you want to retain some ...
Steve's user avatar
  • 8,765
3 votes

How do access modifiers actually help programmers?

In the same way that we have guardrails and painted marking on our roads. Can't drivers just see where their lane is? Isn't it stupid to drive off the road and crash into a tree? Or drive into ...
nvoigt's user avatar
  • 7,767
0 votes

How do access modifiers actually help programmers?

I agree with @Flater that the short answer is: Encapsulation However I would expand the answer differently, to say that each protection level represents a contract between the original author and the ...
DavidT's user avatar
  • 3,338
5 votes

How do access modifiers actually help programmers?

This sounds like a rant trying to disguise as a question. If you want the short answer: encapsulation. I've linked to the wiki page but there is a ton of information available if you look this up in ...
Flater's user avatar
  • 49.9k
4 votes

How to deal with boolean or enum variables used to decide code flow?

You are misunderstanding things. Booleans are there to control code behaviour. What’s bad is calling a method with three arguments f(true, true, false) with no indication what each argument means ...
gnasher729's user avatar
  • 45.3k
5 votes
Accepted

Polymorphism with variable default argument count

The very core of what you're trying to achieve goes against the core principle of polymorphism: interchangeability. The concept of polymorphism is having the ability to write code that handles an ...
Flater's user avatar
  • 49.9k
3 votes

Polymorphism with variable default argument count

At first sight, your object hierarchy breaks the Liskov Substitution Principle (the "L" in SOLID), because I cannot substitute an instance of B for an instance of A due to the differing ...
Philip Kendall's user avatar
2 votes

How to deal with boolean or enum variables used to decide code flow?

Your question is vague, because we can only guess around how your code might look like, but I think it is still possible to answer your two questions directly: Q1: Whether we use enum or boolean ...
Doc Brown's user avatar
  • 207k
3 votes

How to model a player playing a Blackjack game in OOP?

There is no one true proper OOP design. So you'll still have to make some arbitrary decisions. But there are principles and concepts to follow if you want to stick to OOP. I have written it in a non ...
candied_orange's user avatar
3 votes

How to model a player playing a Blackjack game in OOP?

OOP doesn't work like the examples You probably won't have human style classes like Player, Dealer, Card, Table. You are more likely to have random classes that fit the way you program, DeckShuffler, ...
Ewan's user avatar
  • 75.8k

Top 50 recent answers are included