Questions tagged [object-oriented]

A methodology that enables a system to be modeled as a set of objects that can be controlled and manipulated in a modular manner

Filter by
Sorted by
Tagged with
-1
votes
0answers
16 views

Should we put behaviors (method) in constant class in Java?

Should we put behaviors (method) in constant class in Java? If not then why? Which clean code practice/principle I am breaking while doing that? public class TagConstants { public static final ...
-1
votes
3answers
165 views

How to reduce the number of classes in a project?

i'm trying to design a game program, but when thinking about which objects to introduce there seems to be far too many. For example for main object "Player" there are a lot of peripheral ...
1
vote
2answers
65 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 ...
0
votes
1answer
74 views

Best practices for seperating/designing classes and methods for use in testing

I run unit and integration tests on my system. These create, start, stop and delete Docker containers. I want the exact same state in my Docker environment at the end of the tests as I had at the ...
0
votes
1answer
67 views

Name of the relationship between a child object and parent interface?

If Pet is a class that implements the interface INameable, and dog is an instance of Pet, what is the name of the relationship between dog and INameable? In casual conversation and while talking with ...
0
votes
3answers
82 views

DDD - storing and retrieving entities of an aggregate from the outside

In my doctor's appointment booking system, I identified the following entities: Doctor Patient Appointment I also identified an aggregate, which is Doctor (aggregate root) and Appointment. It's an ...
0
votes
2answers
121 views

Do you usually instantiate dependency objects in the constructor?

I know that we usually inject the dependencies by instantiating them in the constructor of the class we are injecting to. However, in my own experience, I just pass the class of the dependency as a ...
2
votes
1answer
52 views

Python inheritance: how to check the closest abstract parent class?

I'm dealing with two categories of machine learning algorithms. For simplicity, let's call them A and B. There are multiple concrete algorithms in each category, and my goal is to implement all of ...
1
vote
4answers
249 views

Would this violate the Liskov Substitution Principle?

Say I have a set of objects from an "old system" that I want to convert to a newer set of corresponding classes. Each specific class has its own way of being converted. So I 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 ...
0
votes
1answer
65 views

How can I cleanly express these dependencies?

Consider this hypothetical scenario. I have a user form that has a collection of controls that are made available/unavailable based on certain criteria. One important criterion is product type. On ...
2
votes
1answer
128 views

Composition or Inheritance for classes with almost similar implementations but different input and outputs for methods?

I have the following classes, which have quite similar method implementations. Only the classes' method inputs and outputs seem to be of different types. When I put it like this, it sounds like a case ...
0
votes
1answer
47 views

How to prevent mutual dependencies when implementing database relationships

To explain the problem imagine you have two entities User and Group. The OO implementation has two classes UserModel and GroupModel. UserModel should have a method getGroups() (returning instances of ...
0
votes
2answers
77 views

Can and should constructors do more work than merely assigning values to fields? [duplicate]

A typical introductory example to OOP, classes, and constructors is object Car, with properties such as float fuel, bool is_engine_running, etc etc, and a class and constructor definition might be as ...
0
votes
0answers
45 views

What's the proper way to avoid long parameter lists? [duplicate]

If I architect to utilize use-cases then I soon arrive at long param lists. As an example: class MainViewModel @Inject constructor( private val getUsers: GetUsers, private val deleteUser: ...
0
votes
2answers
395 views

How can Python, a language that supports Object Oriented Programming, be implemented in C, which is not an Object Oriented Programming language?

To my understanding, C does not have the concept of objects, then how can Python be implemented in C to support something that C can not? How is the concept of "Object" modeled in C? What is ...
1
vote
1answer
44 views

Page Object Model: Relationship between a page object and a driver

There's a question that struggles me for a long time already and so far I couldn't find or figure out a good answer. Hopefully, you will help me with that, folks. Before the story, a little background:...
4
votes
7answers
483 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 ...
3
votes
2answers
87 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 ...
1
vote
1answer
99 views

If methods are actions that an object can perform, how do we represent abstract objects?

I have read that objects contain the actions it can perform as functions and its attributes as variables. But i am getting confused with objects that don't seem to perform any actions such as an ...
0
votes
4answers
165 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 ...
4
votes
3answers
271 views

What about Utility-Classes, but without hard dependencies?

The average utility class: A stateless class that provides some functionality by exposing static methods. Its default constructor is private to avoid instantiation. When ever the average utility class ...
1
vote
2answers
109 views

Designing UI module for an application

I have an UI module that will expose only one class - UserInterface. The class will be responsible for collecting user input and providing output (command line UI style). From logical way of thinking, ...
-1
votes
1answer
91 views

If I have 2 different implementations of the same interface but with the same methods should I have 2 interfaces? [closed]

I have 2 different implementations of the same interface, but each one of those objects have different implementations, however they have the same methods, should I create one interface for each type ...
-1
votes
3answers
263 views

What are the differences between Class Oriented Design and Object-Oriented Design?

I saw an answer on SO which said that just having a class with methods doesn't make it OOP and that it represents Class Oriented Design. I'd like to hear the differences between Class Oriented Design ...
2
votes
1answer
134 views

Do we still use modular subsystems with object-oriented models?

I have been reading some old design books (SSADM, JSD.etc) on software engineering that deal mainly with a procedural view of creating systems. I was just wondering if we still use these old ...
1
vote
1answer
79 views

Loose coupling vs transparency in visitor pattern that visits composite

I have a composite object (I will call it A) that has fixed number of sons (I will call them A1 and A2) All of them have an Accept(Visitor) method. I have a GUI, A is the main window that consists of ...
1
vote
0answers
88 views

Scalable architecture design for managing data flow in C++ using an Observer design pattern

What I need I need a suitable and scalable solution to manage data flow between the classes in my C++ program. Why I need it Upon new feature requests, I'm continually adding new classes to the ...
0
votes
1answer
109 views

Any tradeoffs for using open methods?

I was trying to understand the use of multi-methods recently and saw several claims that they solve the Expression Problem. However, I ended concluding that it is not the multi-methods that solve it, ...
3
votes
2answers
213 views

How to model classes that can be extendable?

I have recently inherited a codebase which has a weird problem and I am trying to search for an extensible solution that can solve my issue. Consider I have a model class that is used as a model to ...
2
votes
1answer
297 views

Dependency Injection: Dealing with late property initialization

I am using some C# pseudo to illustrate here. Below, you will see a Service and a Client (in the context of using DI). The service has a required property that will need to be initialized by the ...
2
votes
5answers
305 views

Opposite verb to “inherits”

What's the name of the relationship opposite to "inherits"? Subclass inherits from superclass Superclass ______ subclass
2
votes
2answers
119 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 ...
2
votes
1answer
95 views

Selective method inheritance

I have a lot of classes that are just a CRUD interface for microservices. They only have a param for the endpoint and some of the methods get_list / get_item / create / update / delete / activate / ...
-1
votes
2answers
135 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
76 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
51 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
29 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
48 views

Model design for `Team`s and `Member`s

Say we have to create a model for a company, where employees can be part of many different teams. A team can have member members. Members can be part of many teams. How to design database tables for ...
-4
votes
3answers
205 views

Confused between HAS-A and representation [closed]

I'm currently working on a game in which a maths module is being used, here is one of the classes called Vertex. I'm getting confused with the relationship between HAS-A and objects representation. I ...
0
votes
1answer
108 views

Is it any more efficient to reuse a variable than to create a new object?

In a project I am working on we load various entities from the database, do some work then attempt to save the resulting entities. If saving the result is not successful, we return a Result object ...
-1
votes
1answer
138 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
1answer
50 views

Memento Pattern:Philosophy of createMemento() method in Originator class

I've question about the philosophy of createMemento() in Originator class in Memento Pattern. My teacher said: now that Originator class no longer stores Memento objects internally, we should give it ...
0
votes
0answers
34 views

Pipeline pattern for MVC based GUI application?

I've got an application that uses MVC to run individual, isolated scripts to support our office. There is a root application will open new windows (limit 1 per tool) for each tool opened and each ...
-1
votes
2answers
86 views

Payment Processor using polymorphism?

I am writing a payment Processor class, then will take different payment objects in input and talks to external services to process payment.My class is designed using polymorphism as follow: public ...
1
vote
4answers
198 views

Software-design for algorithm engineering

I'm currently working on an program that solves a graph optimization problem. I know the "standard" software-design principles like information hiding, modularization, etc. What I'm ...
0
votes
3answers
401 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
2answers
84 views

Interface and Implementation Classes

I know various forms of this question have come up before, but none of them quite seem to answer in a way that I can apply to / understand in relation to what I regularly see others doing. ...
1
vote
2answers
331 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
2answers
84 views

Should a single method in a service class perform multiple operations for its controller?

Let's say I have a controller called MessageReceiverController which is a controller of an API that other services can call and include messages in the requests. For each of the messages the ...

1
2 3 4 5
63