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
2answers
98 views

Anemic Domain Model VS coupling and dependencies- design conflict - need an Object oriented advice

on design stage , after finding my main objects , I am always find my self writing "manager" or "controllers" classes in order to handle the connection between them. some of the ...
3
votes
3answers
275 views

Undo/Redo with Command Pattern and Object Destruction

I'm developing a Command Pattern with Undo/Redo support. The environment is Unity C# but should be mostly language-agnostic. My initial commands comprise of adding and removing objects to and from a ...
-1
votes
2answers
175 views

Enum and Programming to Interface and best practices

I am learning stuff and have made 2 microservices, Listener and MyApp. Listener is a jms listener (consumer of messages) and MyApp is the app sending messages to queue. I have 2 type of events CREATE ...
4
votes
3answers
286 views

Is there any language where you can re-call the constructor on an instance of a class and any reason why not?

Is there any language or language feature where you can re-call the constructor on an instance of a class and is there any reason why you don't want to do this? For example, //let's say you have this: ...
4
votes
7answers
4k views

How do interactions between objects work?

I am getting confused when objects interact using OOP. Here i'm trying to model the interaction between a vending machine and a coin. The coin is inserted into the vending machine. The interaction is ...
32
votes
10answers
5k views

Does logging inside a class violate the SRP?

I wrote a class that takes a Logger class as one of its arguments: class QueryHandler: def __init__(self, query: Query, logger: Logger) -> None: self.query = query self.logger =...
0
votes
1answer
131 views

Best practice to create model objects in Java

I have an existing microservice that talks to a Natural Language Processing (NLP) product and fetches around 50 fields. I need to create domain objects in Java now from these fields. I read about ...
1
vote
2answers
66 views

Should selected person be part of my application layer? (MVP pattern)

Consider the following GUI screen: When user selects a person from PersonListView, EditPersonView should show person's first name and last name and allow the user edit. So, I end up with the ...
4
votes
7answers
517 views

When to use a class with a constructor vs using a method returning an object

I've been working in a rather large codebase filled to the brim with small classes such as class Person { public string name; public int age; public int height; } As a mainly front-end ...
4
votes
4answers
136 views

Approach to keep collection of parent entity sorted when child changes?

Assume a Person has a Phone and a Phone has Contacts. Assume in the real world the Contacts of a Phone are sorted by their first name. When I phone.add(Contact c), the phone sorts its contacts. Then ...
2
votes
2answers
90 views

Dynamic loading of objects defined during development for a running system

So I have a design/architectural question. I want to develop a pattern in a programming language that is able to allow a app command-line shell to send commands to a running application to create ...
1
vote
1answer
73 views

Imposing an object interface in Python

I wanted to implement a method insertCard in Python which interacts with only a specific type of object called a Card. The Card should always have a cardId and may have additional payload or fields ...
1
vote
1answer
102 views

Can Domain Services publish Domain Events on multi-aggregate operations?

I'm in a scenario where, when a certain command is applied on an aggregate, I have to change the state of the aggregate itself if ALL related aggregates are in the same state, then notify the world ...
0
votes
4answers
125 views

Thinking about data as object vs table row [closed]

It often happens that we have a set of structured data. Let's say our data is about charitable organizations. I could turn it into a list/set of objects/structs: struct Charity { let name: String ...
1
vote
4answers
197 views

How can composed sub-objects access the parent object?

Let's say I want to make a class for a car. A car has an engine, transmission, steering, radio, ... Each of these parts have its own internal state, so in C++ it makes sense to use composition like ...
0
votes
4answers
172 views

What is a suitable way to handle dependent instance variables?

In particular I am wondering if it is acceptable to have an instance variable that can be calculated by other instance variables (i.e. during the creation of the object)? On one hand I see the data ...
1
vote
3answers
182 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. ...
0
votes
2answers
140 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 ...
0
votes
2answers
146 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 ...
10
votes
4answers
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 ...
-3
votes
1answer
88 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 ...
-2
votes
1answer
68 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 ...
2
votes
1answer
115 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 ...
1
vote
1answer
102 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 ...
-2
votes
6answers
192 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 ...
0
votes
3answers
138 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 ...
0
votes
1answer
54 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" ...
0
votes
2answers
61 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 ...
2
votes
2answers
122 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 ...
-3
votes
2answers
192 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 ...
-1
votes
2answers
151 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....
-1
votes
1answer
90 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 ...
-1
votes
1answer
55 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-...
0
votes
0answers
34 views

Internal behavior VS external behavior with the count of method-parameter

Inspired by my own question + a fragment of Robert Bräutigams answer there: Tell one, but ask the others? i came up with this question here: let's take us the write method of a chatroom or any other ...
-1
votes
1answer
150 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 ...
0
votes
3answers
410 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-...
0
votes
0answers
45 views

Multiple endpoints but share the business layer

I am looking at a code base that has multiple APIs and traditional server rendered website. The business logic is duplicated between each of the APIs. I would like to clean this up and share the ...
0
votes
3answers
194 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 ...
1
vote
2answers
356 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 ...
1
vote
1answer
186 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 ...
2
votes
2answers
156 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 ...
-1
votes
2answers
150 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....
4
votes
3answers
233 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: ...
4
votes
6answers
908 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?...
0
votes
2answers
145 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 ...
4
votes
2answers
167 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 ...
0
votes
1answer
78 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 ...
1
vote
3answers
182 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 ...
0
votes
0answers
68 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 ...
1
vote
2answers
281 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 ...

1
2
3 4 5
32