Questions tagged [object-oriented-design]

Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem.

Filter by
Sorted by
Tagged with
1 vote
3 answers
188 views

Too much parameter in a class' constructor, when trying to conserve the dependency injection principle [duplicate]

I am developing a simulator of a bank software system, where each operation (deposit, withdraw, transfer, ...) is just a string. I have 5 main classes : Bank where bank accounts are stored. ...
user avatar
  • 65
0 votes
2 answers
189 views

Which design pattern to use to make a mix of in-sequence and parallel HTTP calls?

We have to make a bunch of HTTP calls from Java/Spring-Boot application which will be mix of in-sequence and parallel. Level 1 : We make 3 parallel calls to Services 1 , 2 and 3 Level 2: After service ...
user avatar
  • 119
0 votes
2 answers
186 views

Design: Tying behavior to state

I have the following (hypothetical) setup and am wondering if anyone has design suggestions, keywords, or nudges. I have a class Walk that implements a method doActivity. This method keeps track of ...
user avatar
10 votes
4 answers
2k views

Can a class contain its own class?

Suppose I have the following class structure: A forest can have any number of trees, but each tree can belong to only one forest. If the forest is deleted, the tree is deleted. A tree must have at ...
user avatar
  • 219
-3 votes
1 answer
90 views

What are some of the good and bad aspects of this basic design? [closed]

I made this design for a university assignment, but I am genuinely interested of this design's good and bad aspects. The design was supposed to be an OOP design. The system is meant to be an online ...
user avatar
  • 105
-2 votes
1 answer
100 views

How to implement factory pattern in following case?

I have a program which downloads web pages and then scrapes html to create domain specific collection objects e.g. ProductCollection, CatalogCollection, NewsCollection and more. The idea is to create ...
user avatar
2 votes
1 answer
125 views

Rust design when object needs to query outside data for some uses

I am modeling a ship that has contracts. Each contract can either be a fixed rate contract which pays a set fixed amount every day or a market index contract which pays an amount that varies based on ...
user avatar
  • 57
1 vote
1 answer
108 views

Is the Target interface really necessary in adapter design pattern?

I saw a code example online that uses adapter pattern as: if you look at the HR system, the employee information in the form of string array and the ProcessSalary method of the Third Party Billing ...
user avatar
  • 127
-2 votes
6 answers
198 views

C#, design classes to be scalable

I'm creating an inventory management system, in which the program needs to handle a lot of different equipment, with the possibility for the product owner to increase the selection, without having to ...
user avatar
  • 9
0 votes
3 answers
282 views

Pattern for passing request context to business logic

I'm working on a project in which I have a clear separation between domain logic and the logic that exposes these features using an API (or whatever). For this I'm using the Onion Architecture. Now I ...
user avatar
  • 271
0 votes
1 answer
56 views

Object and ObjectManager circular dependency

As far as I know, circular dependencies are something to be avoided, yet I find myself often in a situation where I've got some Object, and an ObjectManager, that is supposed to "oversee" ...
user avatar
0 votes
2 answers
65 views

Where to put files (interfaces) that link two independent assemblies: Authentication and Main Program

I'm having an issue with dependencies in a C# app that I'm creating. I have an assembly for my authentication process, and a separate assembly for starting up the main program once authentication is ...
user avatar
  • 1,476
2 votes
2 answers
139 views

Given a 2D map with some entities on it, should the position be kept inside the map, or the entities?

I've got a 2D map, on which entities interact. Should an entity's position be kept on the map object, or on the entity object itself, or both? Why? What does decide where a property is kept? What ...
user avatar
  • 131
-3 votes
2 answers
268 views

Is inversion of control the opposite of "tell, don't ask" principle?

First, let me explain what I mean by inversion of control and tell, don't ask in this context. I have 4 classes MailController, UserData, Subscription and MailService. MailController is a consumer of ...
user avatar
-1 votes
2 answers
158 views

Robins magic Chess game: Where to put/split the behaviour to full fill Law of Demeter [closed]

So now i have a really concrete example; its highly related to that question here: Tell one, but ask the others? the important statements there are: In the comment section https://softwareengineering....
user avatar
-1 votes
1 answer
98 views

Different composition techniques from the perspective of the client

There exists different composition arts/techniques, i will present in the following some of them. The question then is do you know more techniques additional to my presented ones? And then the ...
user avatar
-2 votes
1 answer
70 views

Deep Object Graph Hierarchy: access an object which belongs to that hierarchy

Consider we have something like this: A person, which has a physical body with arms, each arm has a hand, each hand fingers, and each finger a fingernail. Another example: we have a car and a car-...
user avatar
-1 votes
1 answer
173 views

Modeling a workout schedule using OOP(DDD specifically)

I am just getting into DDD, and I am trying to model a very basic exercise schedule. I have a Schedule and I have a Slot the slot takes 0 - many Exercise entities. The schedule is composed of Slots ...
user avatar
0 votes
3 answers
421 views

Tell one, but ask the others?

Consider we have three classes which want to collaborate, then, where is the behaviour? I guess it can only be in one of the three classes or in a fourth one acting than as a procuedural connector-...
user avatar
0 votes
3 answers
228 views

Does encapsulation in OOP happen at run time or compile time?

Encapsulation is the hiding of an implementation in OOP the way I understand it. I searched on Google and I was thinking of trying to write a program to test, but my tests would only happen at run ...
user avatar
1 vote
2 answers
432 views

No trivial god-class refactoring

Consider you have the following code: class UserContainer { List<User> user; //some methods to get specific users, for example users, which are higher than 1,70meters } The User have a ...
user avatar
1 vote
1 answer
229 views

C# Design for database queries and commands

Currently I'm working on a project that will interact with a database. Based on my research, I would like to develop a repository class which responsability is to write/extract entities to/from a ...
user avatar
2 votes
2 answers
392 views

How to design correctly relationships of class diagrams?

I'm learning OOP so I decided to start a new project, a chess tournament manager. Here you can read about chess tournaments https://en.m.wikipedia.org/wiki/Chess_tournament Basically the user will be ...
user avatar
-1 votes
2 answers
155 views

Need help with thinking about design to build bidding service [closed]

I have a legacy service written in a procedural style which I am rewriting. I want to improve the maintainability first and foremost; the code gets tweaked often as the business rules change over time....
user avatar
  • 175
4 votes
3 answers
287 views

Passing object or using the field

I would like to know what is a more appropriate way to code in Java. Is it generally better to pass entire objects in the method's parameters or just using the fields from the class? Using the field: ...
user avatar
  • 63
4 votes
6 answers
2k views

Does using the word "base" in a class name indicate abstraction?

I'm wondering if there is a widely accepted convention for naming base classed in OOP. Does marking a parent class with "Base" indicate that it's abstract or that it's just an extended class?...
user avatar
  • 149
0 votes
2 answers
151 views

Inversion of control

I have been reading about inversion of control and dependency injection and I was wondering the following. Is there a good way to tell when it is okay to initialise an object inside a method body of a ...
user avatar
4 votes
2 answers
196 views

GoF Builder Pattern Applicability

The book Design Patterns: Elements of Reusable Object-Oriented Software says to use the builder pattern when The algorithm for creating a complex object should be independent of the parts that make ...
user avatar
0 votes
1 answer
108 views

Distributing responsibilities in a micro service in an Object Oriented manner for a 3rd party integration?

I'm trying to figure out how to structure a 3rd party integration microservice, and how to name the classes accordingly. If you had a classic shopping cart application which processed payments for ...
user avatar
1 vote
3 answers
235 views

How to create uniform interface of C++ classes without virtual methods?

I have been developing control software in C++. My hardware consists of a microcontroller with an integrated a/d converter and an external on board a/d converter. Both of these a/d converters have ...
user avatar
  • 141
0 votes
0 answers
69 views

Can someone suggest what pattern I used mistakenly and is it correct in this situation. Any alternative?

Client_1 uses --> IService_1 and thus Service1_impl public interface IService_1 { void DoTask_1(); } public class Service1_impl : IService_1 { private readonly IDepService_1_v1 ...
user avatar
  • 181
1 vote
2 answers
406 views

Is it wrong to extend an inner static class in java? (Builder pattern)

I'm working on a java project for the university. The project is a card game in which you travel around a 2D map and fight against some enemies. My part consists of creating the deck and the cards. I ...
user avatar
1 vote
2 answers
94 views

Good OO design pattern for variant return type needs

I've got a validation function something like this (pseudo-code): public function validate(Thing thing) { if (thing.a != "a") { return false; // most of the time } if (...
user avatar
  • 175
1 vote
1 answer
177 views

Why we don't use array of classes instead of Chain of Responsibility technique

I am new to SE. Recently I read about the Chain of Responsibility pattern, so basically what it does is: it creates a class that has some methods and also next class (next chain block), so when it ...
user avatar
-2 votes
2 answers
87 views

How would you create abstraction for event holding only Ids - references to other objects

class DomainEvent { } and then I have different events with following structure: class SomeEvent extend DomainEvent { private UUID orderId; private UUID orderlineId; private UUID productId; ...
user avatar
  • 520
-2 votes
1 answer
178 views

toppings in pizza factory?

Going through Head First Design Patterns, and their Pizza factory example, it seems that there is no room for specifying toppings. In general, if I have a process which contacts different APIs which ...
user avatar
  • 196
0 votes
1 answer
60 views

Composition without direct instantiation through constructor

I have 2 classes that independently operate on specific file formats: class FileWriterA and class FileWriterB. Each class has some shared methods (e.g., __enter__, __exit__, __str__, closed, is_closed,...
user avatar
  • 999
0 votes
1 answer
528 views

Machine Learning pipeline design patterns

In machine learning we have modules that perform operations on data in a sequencial manner. Modules are generally the following: Data Collection Module: Takes raw data from a resource (filesystem,...
user avatar
  • 133
-1 votes
1 answer
164 views

How to avoid cyclic dependency in UI application

I'm developing an UI application where I ran into an issue with a cyclic dependency. Here is the simplified code, to explain the problem. #include <list> class UiStyle; UiStyle* CreateStyle(); ...
user avatar
  • 33
3 votes
3 answers
783 views

Use inheritance to make single child, smaller

We have a relatively big class. One of my colleagues thinks we must split this class into a base & child class to make it smaller and cleaner. On the other hand, I believe when we know this parent ...
user avatar
0 votes
1 answer
297 views

Can we do domain modelling or create domain entities/models in NoSQL like Amazon DynamoDB? If yes then how?

Recently I was going through an article (link at the end) on AWS for DynamoDB NoSQL and got to know that they are suggesting to only have a single table with certain access patterns in your NoSQL ...
user avatar
6 votes
1 answer
739 views

Good design when polymorphism isn't possible

I am developing a visual editor for an entity component system. The editor must be able to modify the members of differents components subtypes, so we have a specific window for each component subtype....
user avatar
  • 191
6 votes
2 answers
310 views

DRY polymorphic object creation (always valid)

Assuming we have polymorphic entities such as the following, with constructors enforcing invariants (assume there could be lots of sub-classes). What would be an effective/elegant approach to ...
user avatar
  • 321
0 votes
2 answers
82 views

Conditionless code when working with a time bound cached map

I have this piece of code, and I've been racking my brain trying to think of a way in which I could factor out the if statements, mostly as practice to write code that is less conditional and more ...
user avatar
  • 129
2 votes
5 answers
557 views

All the properties of a domain object should support NULL value?

Imagine you have an application with the domain object User: public class User { public int Id { get; set; } public string Name { get; set; } public string Surname { get; ...
user avatar
  • 59
1 vote
1 answer
83 views

Proxy / Decorator Design pattern scalability to a lot of methods

I'm trying to solve a common problem of logging each method that calls 3rd party operation and I don't understand how to scale it up. Current implementation: public class ElasticsearchClient { ...
user avatar
  • 141
5 votes
4 answers
337 views

How to deal with different level of abstractions (blurred line between data and models)

My question is about the way to represent data models created at runtime. To illustrate, let's say we would like to create a CMS-like app in which end-users may create custom forms. Those forms are ...
user avatar
  • 241
2 votes
2 answers
149 views

What does abstraction mean in Bridge design pattern?

The bridge pattern is defined as 'The Bridge pattern decouples an abstraction from its implementation, so that the two can vary independently'. I get that abstraction here doesn't mean abstract class /...
user avatar
  • 145
4 votes
2 answers
123 views

How do I trigger conditional post processing action without violating SRP?

I have a User Model as below, this Model class is in the shared library. class User { private long userId; private String email; private String userType; private long departmentId; ...
user avatar
11 votes
4 answers
2k views

The role of OOP in the business layer

Below, I define an IInstantNotification Interface. TextNotification Class and EmailNotification Class inherit from this interface. public interface IInstantNotification<T> { List<...
user avatar

1 2
3
4 5
33