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
0
votes
0answers
104 views

TaskManager class design

We implemented a TaskManager class for this purpose: execute a number of tasks asynchronously (off the UI thread) one after the other. Basically, this class includes a queue of tasks and the functions ...
6
votes
2answers
257 views

Suggested OO Design Pattern for a Query Builder

Essentially, I'm building a Query Builder (in C#, if that's relevant) which has this sort of interface, exposing more statically typed functions as the query gets more refined. AnimalQueryBuilder - ...
2
votes
2answers
316 views

Does OOP overemphasize the importance of noun and thus put action/verb in the less importance position ? [closed]

Steve yegge wrote an article called "Execution in the Kingdom of Nouns" back in 2006, 14 years later I still find the points he made valid. For example, "Action is what gives life its ...
0
votes
4answers
126 views

Where should transform method to convert from one class object to another class object should live in Java?

I have 2 POJO classes, DatabaseRecord and MyCustomRecord. In my service logic, I wanted to convert the object of type DatabaseRecord to object of type MyCustomRecord. The code for converting should be ...
-1
votes
3answers
119 views

Preventing presentation layer from directly accessing repositories?

I'm trying to design my application in line with the "onion architecture" principles, and have something like the following: HospitalController (depends on IHospitalService) \ --- ...
2
votes
2answers
70 views

Action objects VS handle/service-methods

a short question: class ItemActionObject { private final Object moreParameters; private final Object otherDependencies; private final Item item; public ItemActionObject(Item item, ...
-1
votes
1answer
50 views

Split object into multiple objects while keeping reasonable performance

I'm using C# but the problem could also be with Java. I have an object in the flow that is muted for setting up some properties during the flow of the program. Let say public class Person { public ...
17
votes
9answers
4k views

Which object should have the method?

I am trying to create an object model for a user and a chatroom. I'm stuck on where to place certain functionality when the objects collaborate. At the moment all the functionality for the User is ...
-2
votes
0answers
34 views

Naming of object which encapsulates an async “operation” / “process”

I have an application which sends and receives commands to and from an external device. I have modeled the interactions with the device as "usecases / interactors" which only do one thing, ...
0
votes
3answers
162 views

Advantages of strategy design pattern versus simple if-else

I am not clear on what advantage does strategy pattern offers over simple if-else. Example of poor code //poor code that we all can agree is not the way to go ----- main class ----- String ...
0
votes
2answers
101 views

Where to place methods that consume multiple object collections

We've been battling over where certain methods should live within our domain model, so looking for some adice and reasoning as to where they should go. Say we have a Project object now that Project ...
1
vote
1answer
93 views

Strategy Design Pattern vs Inheritance

I have to write a code where i have send some data (call it List of cases) using one of two integration tools (Jitterbit, Mulesoft), with possibility of adding more tools in future. Integration tool ...
0
votes
0answers
75 views

value-based function dispatch

Problem to solve I have a method parse_doc that should dynamically determine a parsing function to parse document_id based on the value of the document_id string: # list of files that may have ...
2
votes
3answers
149 views

Entities vs. Services in domain driven design (DDD)

I wanted to get some feedback on the design of a chat application I recently developed. The application is written in PHP, but the language probably isn't important here. The main components are User, ...
-1
votes
3answers
153 views

Specialization and LSP violation?

I have Document and ExternalDocument classes in my system, where ExternalDocument extends Document. The main distinction is that ExternalDocument holds onto externalDocumentId and externalEventId data ...
-1
votes
3answers
99 views

Difference between update a property and fire an event

It seems to me that update a property is always an 'event' and that all you can do with an event handler can be done in the property let/set routine. And, in my limited experience, I never needed to ...
0
votes
4answers
123 views

How does Object Oriented System or Decomposition supports reuse?

The 1 logic is that due to inheritance. But, except that how does Object Oriented Systems helps in reusability? I have read this article below. https://www.drdobbs.com/a-realistic-look-at-object-...
92
votes
9answers
18k views

Is it the correct practice to keep more than 10 years old spaghetti legacy code untouched without refactoring at all in big product development?

I have been in two software product houses for three years in a row. The first is a small company maintaining a fairly small management system with a monolithic legacy code base (almost twenty years). ...
1
vote
2answers
150 views

Composition vs Aggregation: is this a “hidden my dependencies” case?

I have been thinking about this for a while and could not get to a conclusion. I need to convert a object to another (that will end up serialized as XML). Both objects have many fields, let's have an ...
1
vote
2answers
119 views

How to implement rich domain model without referencing other objects?

I have some doubts about having rich domain model without having other entity objects inside it. Let's imagine that we have a product feed with no more than 10 products. Each product is made by some ...
3
votes
1answer
136 views

What do you call the interface design error that consists in splitting two public methods that should be called toghether?

Consider a poorly-designed interface in which there are two functions (say foo() and bar()) that can be called independently, but in order to get some expected behavior (or in order to keep the object ...
1
vote
3answers
120 views

Design with subclasses being aggregates of classes implementing interfaces

I have modelled a class structure, where subclasses Rectangle and Circle inherit from an abstract superclass Figure. All subclasses share an interface IGeometry that provides for getArea() and ...
0
votes
4answers
191 views

Loose coupling in Python

While I know this is the tight coupling example: class User: def __init__(self): pass def get_status(self): api_client = APIClient() status = api_client....
0
votes
1answer
112 views

Have the same logic in two different class hierarchies

I have the following class hierarchies abstract class Base<T> { abstract T getRelevantType(); } class A : Base<AType> { AType getRelevantType() } class B : Base<...
3
votes
1answer
139 views

How choose between functions or objects

I've seen different approaches and it's not clear to me which one is the correct one. Some dev use lots of small, very specific objects and use to compone them is some way to achieve their goal. ...
5
votes
6answers
396 views

How to modify object properties?

I've recently read a great article about unit testing. There was an example of a bad method which is not well designed. It looks like this public static string GetTimeOfDay() { DateTime time = ...
-1
votes
2answers
185 views

Unit testing private methods

preface: I know this topic has been asked about a lot on here in the past. Hopefully I will make it clear that I've read a fair amount of the questions/answers on the topic, and other literature, too. ...
3
votes
1answer
60 views

Is the class stereotype implicit in an UML class diagram ? Should it be specified?

Commonly I see class diagrams where there is no <<class>> stereotype. Others where there is the common <<interface>> and others with some interesting ones as <<shape>&...
0
votes
1answer
125 views

Why is the UNIX / FP style of smaller function composition not common?

TL;DR Why is the UNIX / functional style of composing and injecting smaller functions so much rarer than the Beck/Fowler/Bob refactor-to-objects style when it comes to writing maintainable, "...
5
votes
1answer
167 views

Real-world scenarios for protected inheritance

C++ supports protected inheritance: A class can derive from a base class B in a way that the "outside" world doesn't see that class "as a B" but the class itself and it's derived ...
4
votes
5answers
228 views

How to fix a pair of tightly coupled classes that store references to each other?

I have the following situation: class User { public Thing curThing; } //each thing can only belong to one user at a time //And vice versa class Thing { ...
-1
votes
1answer
61 views

Making a GUI for receiving/checking user input - how to arrange GUI and validation checks

Sorry if my question sounds general, I'm new to GUI and frontend/backend ideas and all that (mostly I just do scripts for math hw and such) but I make it more specific here. I have a program that runs ...
-2
votes
2answers
57 views

How to design a flexible multi-criteria prioritization?

Let's assume that we have a set of valid results, ex. Fruits: "Apple, Banana, Kiwi, Pear, ...". (In reality, it’s not fruits but complex objects) Now we need to pick the best result ...
0
votes
1answer
121 views

Using for_each instead of iterators to avoid iterator invalidation

I am writing a simple custom (special purpose) container and would like to allow for iteration over each element, however, avoid using iterators due to the problem of iterator invalidation. Instead of ...
2
votes
1answer
135 views

Efficient way to store “item” objects in a simple game

I am developing a simple text-based game. In this game, the user is able to collect items and store them in an inventory. My question is: how should I organize the internal structure of my game so ...
0
votes
1answer
86 views

Are inheritance, abstraction and polymorphism regarded as association in OOP?

In the realm of OOP, inheritance, abstraction and polymorphism are basic concepts of the paradigm. On top of that, there also have the concept called "associations" which I understand is ...
24
votes
6answers
6k views

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. ...
-6
votes
1answer
188 views

State design pattern for vending machine

I have to write a java program for a vending machine which: Accepts coins of 1,5,10,25 Cents i.e. penny, nickel, dime, and quarter. Allow user to select products Coke(25), Pepsi(35), Soda(45) Allow ...
-4
votes
1answer
58 views

Name of design pattern where type and instance classes are mirrored

I have used this design pattern in several entity-component designs. Now I want to introduce it to my team: It concerns a type-of relationship, where the instance structure and the type structure are ...
3
votes
5answers
233 views

Should I create different classes for the same technical object but different business usages

I know my question sounds a bit weird so I will try to explain my issue with examples. In my application, I have two types of business objects : Shops and Customers for example. Both of them can be ...
0
votes
1answer
81 views

Extension of classes - Where to put behaviour - How much direct-access is allowed

At this point i would exclude the inheritance.... So the question is about more like extend into a seperate class or into the class which should be extended, both play in the composition-league. So ...
0
votes
0answers
22 views

How to support alternative behaviour at the end of a pipeline when the new behaviour is decided at the beginning?

Let's assume we have a few loosely coupled components that form a pipeline. At the end is an file generating component. A new requirement comes in that requires an parallel alternative behaviour for ...
-1
votes
1answer
48 views

Preventing name collision between user-defined modules within a framework

I'm a contributor to a framework that's designed for producing synthetic data. The system allows the end-user to create custom data generators and load them into the framework. Currently we store the ...
4
votes
2answers
191 views

How to design a SOLID pipeline with different inputs

I regularly have the situation that I have some complex logic that I break into steps. For example an import of an Excel file where I need to apply some logic or a complex calculation that I break ...
0
votes
3answers
157 views

OOD vs MVC; Live Objects vs Everything in Database

How to make memory-efficient code, but still have all the possible code nicely encapsulated ? I have a feeling that the OO (object oriented) approach is more intuitive and the code is nicely ...
1
vote
4answers
148 views

Is a class with a high number of member variables bad and is there a design structure for data processing?

Context: Java, fairly new developer I have inherited code from a friend for a project that processes variables. The first thing i notice is the class has a ton of member variables. I have always been ...
4
votes
3answers
228 views

In Object-Oriented Programming, can a class be considered “too specialized”?

If a class can only perform one task, could it be considered to be "too specialized"? My intuition is that classes should be abstractions that are capable of representing themselves in multiple ways. ...
-2
votes
1answer
40 views

What's the best way to output optional information to the screen of a console application, throughout the entire program?

I'm creating a console program where the user has the option of making the output more verbose when the system processes their requests. There will always be an output, but the verbose output would ...
2
votes
1answer
130 views

Flat or nested classes

Im new to object design and Im trying to figure out which design is better. I have a Material entity which can have multiple versions. I have two designs, one is with nested classes, and the other is ...
-2
votes
1answer
116 views

Seeking a Pattern [closed]

First off, I totally understand that an interface cannot contain a static method because what would the method act on - that is clear. Suppose I want an interface to mandate a method that is ...

1
2 3 4 5
30