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
0
votes
1answer
39 views

How do I create a new class or struct with property of its own type?

I have been trying to figure out if I can create a class or struct with a property that is of the same class or struct. An example would be struct Number { var Value: Int = 0 var Rate: Number(...
0
votes
3answers
137 views

How should an abstract class require a value that will be constant for each subclass?

Let's say I have an abstract class A exposing a method called getE() which returns an object of type E which is an enum. The value returned by getE() will be defined per subclass. Put differently, ...
-1
votes
1answer
133 views

Other than the intent, is there a difference in how you implement Chain of Responsibility and Decorator Pattern?

I think it's fair to say that they are quite similar to each other. The only difference that I know is the intent. Chain of Responsibility: Avoid coupling between the sender of a request to its ...
-2
votes
1answer
67 views

How to model a small database application using CRC

I am going through this OO design course: https://www.coursera.org/learn/object-oriented-design/home/welcome and starting to look at the use of CRC cards. (class responsibility collaborators). I ...
-1
votes
3answers
102 views

How do I give a base class a property or method that returns different types in the concrete class?

I have a base class called FieldBase and I want to inherit from it to have different types like TextField and NumberField. I have a property Called Value which for the TextField is String and for the ...
0
votes
1answer
49 views

Select inheritance hierachy at run time

I want to model a machine with a class machine. By the way the architecture of the project has been built, the module that defines each machine is its own directory. So in directory manufacturer/...
1
vote
1answer
60 views

Adapt very different adapters to an Interface

I'm building a service to send push notifications to the user. At first, I designed an Interface for the push notification adapters, something like this: interface PushNotificationAdapterInterface { ...
8
votes
5answers
2k views

Interface implementation where one method body remains empty

I have producers that take data A, produce data B and send it public interface Producer<T>{ void produce(T data); void flush(); } public class DataBaseProducer ...
0
votes
3answers
120 views

What approach is commonly used when a generic object needs to be converted into a specialized object?

Let's say I have an instance of a superclass and at a later stage this object needs to be converted into a subclass instance (based on additional information that are stored in the object). Is it ...
-1
votes
1answer
198 views

How should I handle complex class construction?

I'm making a naval warfare strategy game, based on a boardgame, in C# and having difficulty finding a good way to construct my complex ship objects (I am a beginner in the language and OOP). Currently,...
6
votes
6answers
437 views

Should a Car object be responsible for checking if it is able to run on certain Road objects?

I have 2 kinds of objects in my system, Car and Road. A Car can be of various types and have properties like tire, tire size, engine, etc. A Road can be of multiple types and have properties like ...
0
votes
2answers
74 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
205 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
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 ...
0
votes
1answer
80 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
2answers
128 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
247 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
153 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
61 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
303 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 ...
-1
votes
1answer
83 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
141 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
58 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
82 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
48 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
464 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
46 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
516 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 ...
1
vote
1answer
118 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
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 ...
4
votes
3answers
740 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
112 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
156 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
274 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
139 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
89 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
114 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
114 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, ...
4
votes
2answers
230 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
464 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
329 views

Opposite verb to "inherits"

What's the name of the relationship opposite to "inherits"? Subclass inherits from superclass Superclass ______ subclass
2
votes
2answers
121 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
111 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
150 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
33 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
51 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 ...

1
2
3 4 5
64