Skip to main content

All Questions

7votes
8answers
5kviews

Is "avoid extra null pointer risk" a reason to avoid "introduce parameter objects"?

According to Should we avoid custom objects as parameters?, I know I can group related parameters to improve readability of the function, eg: Original version: public void showSchedule(long startDate,...
wcminipgasker2023's user avatar
12votes
5answers
4kviews

Why is "hidden dependency" (required things not in parameter list directly) a disadvantage of "global variables", but not in "preserve whole object"?

According to https://softwareengineering.stackexchange.com/a/200092, as I know, "preserve whole object" is a refactor method that passes the whole object instead of required parameters only, ...
wcminipgasker2023's user avatar
2votes
3answers
284views

How do I model this scenario so that it adheres to OOP principles?

I have a Slide class with subclasses referring to the different types of slides (IntroSlide, SummarySlide, etc.): abstract class Slide { String slideType; final String title; final String ...
Hello's user avatar
2votes
3answers
261views

What is the relationship between the terms "association", "aggregation", and "composition"? [closed]

I try to brush up on my technical interview skills as I plan to seek a better offer I don't recall being ever asked that really, but I still want to clear up any confusion. What is association, ...
Sergey Zolotarev's user avatar
3votes
4answers
600views

Why is "dependency injection" ok, but not "the opposite of preserve whole object (pass required parameters only)"?

According to Why should I use dependency injection?, "dependency injection" has some advantages, for example: "Non dependency injection" version: public class Client{ private ...
wcminipgasker2023's user avatar
169votes
18answers
303kviews

Is it better to return NULL or empty values from functions/methods where the return value is not present?

I am looking for a recommendation here. I am struggling with whether it is better to return NULL or an empty value from a method when the return value is not present or cannot be determined. Take ...
P B's user avatar
  • 2,379
1vote
1answer
337views

Mapping complex objects to other similar complex objects

I am working on two applications that serve the same purpose. The first application is more feature rich and its types are more complex, but uses old technologies and will be retired. It will ...
vicch's user avatar
3votes
3answers
272views

Handle hierarchical relationships between large number of enums

I am working on a C# project and I have a somewhat large number of labels (~100) that have some sort of relationships between one another. Here is a minimal dummy example that illustrates this: ...
evolved_antenna's user avatar
31votes
9answers
8kviews

Is extracting an interface just for testing purposes a code smell?

I will explain with an hypothetical example. Suppose that my domain is Cars. Everyone around the software, talks about cars. Car is the aggregate root of aggregate roots. For example, CAR table has ...
George Z.'s user avatar
31votes
6answers
11kviews

Visitor Pattern: what's the point of the `accept` method?

I'm trying to fully understand the visitor pattern. What I've learnt so far (correct me if I'm wrong) is: It's about adding operations to classes, without modifying the source code of those classes. ...
bgusach's user avatar
0votes
2answers
275views

What is a good architecture / design pattern for giving multiple shared attributes in different combinations?

I have a need for many different objects to have various combinations of attributes. For a demonstrative example, a flaming dog would have a dog attribute, a flame attribute, and a tail attribute, ...
Fred Etingen's user avatar
1vote
2answers
287views

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

I am working on algorithm implemented in C++ that maintains several enum types. Say 3 to 4 enum types each with at least 4 different values. Plus the code maintains several boolean variables. The code ...
Mahesha999's user avatar
1vote
3answers
987views

Storing multiple instances on a Singleton?

RefactoringGuru's example Singleton in Python has an _instances dictionary field class Singleton(type): _instances = {} def __call__(cls, *args, **kwargs): if cls not in cls....
Michael Moreno's user avatar
1vote
1answer
164views

How to implement DMG (Game boy) cpu's register using OOP patterns/principles to max code reusability?

I-m looking to learn better use of OOP principles/patterns so I decided to start implementing at least the basics of a GB emulator (technical part is widely covered on diff sites). So I started with ...
Allende's user avatar
1vote
2answers
663views

For more than one parameter, when NOT to introduce parameter object?

I know there are some questions about "Introduce parameter object", eg: Is "Introduce Parameter Object" actually a good pattern?, Should we avoid custom objects as parameters?, ...
wcminipgasker2023's user avatar

153050per page
close