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

Temporal coupling vs. complex constructor

I'm working through a book on writing Single Page Applications in Vanilla Javascript. (I'm working on a project where I'm not allowed to use React or any other frameworks, so I'm trying to get better ...
1
vote
0answers
19 views

Designing Models from complex ERP SQL tables

I have a project coming up where im supposed to upgrade an existing access app to a .net architecture. Im wondering how to design object oriented models from the giant tables and mutliple ...
2
votes
4answers
325 views

Instanceof code smell

The use of instanceof might be a code smell and I am in front of the following code which seems ok. Would you consider that instanceof should not be used in such case? What would be the pattern to use?...
3
votes
4answers
278 views

OOP - Is this data hiding?

I've been reading about data hiding and there seem to be slightly different definitions of it, so when trying to come up with a practical example, I'm not sure if I'm doing the right thing. So far, I ...
-1
votes
1answer
59 views

Which programming paradigm mixes well with reactive in java? [closed]

So I have the feeling that one can forget object oriented programming when reactive streams are in use, due to the lack of the async-await syntax (because with the call chaining, the state has to be ...
0
votes
1answer
68 views

Refactoring – Removing switch statement [duplicate]

There is a base class Product having all the generic properties and methods which a product should have. abstract class Product { public abstract function process(); } Now, These are the few ...
1
vote
2answers
113 views

Representing a recursive Structure in OOP

I want to represent an Edifact message in an OOP Language. An Edifact message has the following structure: message := [ ( segment | segmentgroup ) ] segmentgroup : = [ ( segment | segmentgroup )...
-1
votes
0answers
17 views

Incorporating Functions Into APIs [closed]

How are functions generally incorporated into APIs. I would imagine you could just cut and paste your function in as a method of a class, but is this actually how it would be done? I'm asking this ...
2
votes
1answer
87 views

C++ pattern for compile-time configurable class functionality

Due to resource limitations (embedded), I want to make some functionality that a class provides optional. The decision to include this optional functionality should be made at compile time. For ...
6
votes
8answers
626 views

How to apply OOP to real world examples without putting all logic in Manager classes?

I'm lately trying to implement a specific problem using an object-oriented approach. I get the main principles and its advantages, but I fail to apply it to a real world problem. Most examples one ...
2
votes
0answers
54 views

What's the use of interfaces vs classes in typescript?

In the company in which I work, it is customary to model entities using Interfaces when developing with Typescript. To me, it seems much more effective to model entities with classes and then ...
0
votes
1answer
64 views

c# Fluent Builder and invalid object state

I have a question about Fluent Interface Builder. I have a simple object like this: public class Person { public string Name { get; set; } public string Surname { get; set; } public int ...
1
vote
1answer
122 views

Do complex return types in interfaces exist in programming?

I believe, for PHP, that I've found the worst culprit when it comes to bad code: not being able to declare (return) implementation details through interfaces. This makes it unpredictable to see what ...
1
vote
3answers
357 views

Why shouldn't I create a class for every property?

In a particular program I had written, I noticed I had a few classes with this pattern: class IdObject: '''Objects with generated id properties''' def __init__(self, id_generator): ...
1
vote
1answer
81 views

Classes with lots of injected dependencies [closed]

I'm often finding that my classes end up with many (10-15) dependencies being injected. I realise there is no hard and fast rule, but someone once told me that more than 4 or 5 can be a code smell. ...
0
votes
1answer
174 views

Is it good practice to create a static class for database tables calculations?

I need to implement some system (using python pandas dataframe in my case) that parses raw data, then adds on calculated data, and then validates that calculated data (boolean output on some columns) ...
0
votes
1answer
43 views

Managing varying method parameters in bridge pattern [on hold]

There are two types of loans which can be created, Term Loan and CF Loan. There are multiple external services which provide one or both kind of loan services. External service which is providing one ...
0
votes
1answer
78 views

Initiating a class from its static method [closed]

What is the stand on initiating the class from its own static method? Are there any good practices about this? I feel need of initiating a class from its static method while implementing a job ...
0
votes
1answer
119 views

How to output exception messages in GUI applications in order to decouple application code to GUI code?

I want to make GUI applications such that the non-GUI code is independent from the GUI one (let's say I'll use Java 8 and Swing for example). The goal is that I could hypothetically change the GUI ...
-3
votes
1answer
74 views

Should I not use inheritance when I need subtype cast/instantiation from basetype?

Problem BaseType has a field String jsonData that represents a JSON string. The structure of the JSON string differs according to a field String dataType. SubTypeA, SubTypeB, SubTypeC all extends ...
0
votes
1answer
69 views

Clean code for multiple entity representations

I'm wondering what is a clean solution for representing an entity in many different format. Let's suppose I have the following entity: Person { Long id; String title; String firstName; ...
0
votes
3answers
225 views

How can we make a UML diagram (or something similar) for a project which doesn't contains classes (like non object oriented)?

I am working on a python project and I didn't use classes but created different modules and added functions in them. Now I need to draw a diagram to describe the project/application for a paper. I ...
-1
votes
1answer
257 views

What is the programming paradigm when I just use functions in a file to organize my program?

I'm programming a telegram bot with Python and, for a number of reasons, there are no classes in the whole project, just several functions correlated to the the file where they are located. E.g., my ...
1
vote
0answers
54 views

PHP: Binding PDO result values to class properties [closed]

I am new to PHP and am trying to figure out the best practice with respect to binding column values to properties in a class. The column names in the database are not ideal and I would like to extract ...
1
vote
2answers
67 views

Unit conversion of input to/output of public functions/methods

The question/s I'm working on a small scientific Python package. Many of the public methods it is going to offer will have to deal with dimensional input. A wavelength, for example, which could be ...
3
votes
2answers
337 views

Should one make the database calls in the constructor or method of a class?

Take the following instance for example: CreditCardApplication class public class CreditCardApplication { public int Id { get; set; } public string FirstName { get; set; } ...
0
votes
1answer
45 views

How to associate tree nodes with other objects before they have unique identifiers

I've been thinking about a simple software design problem. Imagine I am writing a web application to edit a tree of objects. Each node of this tree has an ID property that is filled in when the node ...
3
votes
4answers
235 views

simple OOP classes right approach

At start, I have these classes in code and consequently tables in the database. Person Company Address Both Person and Company have an address. So I have to establish a relationship between them. ...
0
votes
1answer
75 views

Implementing interface segregation

I am mainly concerned about how to create concrete objects properly when implementing different interfaces. I have a resource whose variants can support different interfaces. For example, say I have ...
1
vote
3answers
77 views

Applying Composition Over Inheritance to Page objects

I'm trying to figure out how to apply composition over inheritance to a system I'm building, and tripping up when I try to apply it to my page objects. The relevant objects are: PageFactory Page ...
1
vote
0answers
45 views

Extensible / Plugin Architecture in Python - overwriting methods deep in the inheritance tree?

Current situation I'm developing a test-framework in python for end-to-end tests for a large ERP application. The AUT (application under test = ERP system) is structured in modules and provides a lot ...
0
votes
1answer
203 views

Handling Different Parameters for Derived Classes

I'm designing an API and I ended up having a few pure abstract classes. Because of the nature of the problem that I'm solving, each derived class has to be initialized with different sets of ...
0
votes
1answer
67 views

PHP: simple class for storing read-only data structure, array alternative

I need to share some associative data between different parts of my application with two requirements: immutability (so read-only) safety against mispelling or unavailable index inside the data ...
1
vote
4answers
222 views

Interface with similar methods

I'm currently taking over a project that has a common pattern of interfaces like this: public interface EmailService { void sendInvitationEmail(Payload payload); void sendNotificationEmailToAdmin(...
0
votes
4answers
308 views

Is Template design pattern a bad practice due to inheritance?

I have been using Template Design pattern in my code for implementing CRUD procedures for different resources. There are some steps which are same for many resources and some which need some addition/...
0
votes
0answers
35 views

Neural Networks object creation from OOP perspective [duplicate]

Let's say that I have a class representing the Neural Network. The neural network is composed of three bigger units: a subpart_1, subpart_2 and subpart_3, being called in such a way, that the output ...
0
votes
1answer
83 views

What OOP design pattern would work best for an overseeing class connecting related objects enforced at compile-time?

The Problem I would like to create a managing "overseer" class that connects several related object groups together where any particular group is able to be easily swapped for another using C++11 ...
1
vote
2answers
108 views

Reading problem of object-oriented concept about the book “Object-oriented software construction 2/e”

I've been learning object-oriented concept from this book, and stuck in a specified concept in the middle of chapter 6. Because with no brief explaining beforehand, no one could understand my ...
15
votes
6answers
2k views

What is a precise issue with allowing getters?

I am not looking for an opinion about semantics but simply for a case where having getters sensibly used is an actual impediment. Maybe it throws me into a never-ending spiral of relying on them, ...
1
vote
4answers
112 views

Can encapsulation/information hiding cause problems in error identifying/locating?

I understand the principles behind opaque data types, encapsulation, information hiding, etc. in theory: preventing alteration to parts of a program can prevent people from accidentally messing it up, ...
0
votes
1answer
66 views

Which types of objects that are instantiated inside controller's methods should be injected into the controller instead?

Consider code below MyController //MyAction //MyHandler { public function processRequest() { // ... $myObject = new MyObjectClass(); $myObject->methodCall(); ...
2
votes
3answers
288 views

Is this design with globals bad?

I designed a Snakes and Ladders game. I divided into a reasonable amount of classes and I believe I did a good job regarding the OOP design. I have one question about a decision I made for the design,...
0
votes
4answers
181 views

methods that has only behavior and not manage class state, is that violation of encapsulation

This is a simple scenario in an office with employees and their manager. In this scenario, both managers and employees have a name attribute. Only the manager can change his own name Only the ...
0
votes
0answers
38 views

Querying the domain model

Background: I am working on a document classifier which needs to classify document based on some keywords. The list of keywords and the category is provided as the configuration parameter. The ...
0
votes
1answer
75 views

Structuring PHP classes that need to return multiple objects

I am trying to plan out php class structure for an order processing project. I've used classes before but I'm still not an expert on OOP yet. I've been searching for hours and can't seem to find the ...
1
vote
2answers
90 views

Looking for feedback on my Object-Oriented class diagram design

I can't find anywhere else where I can show an OO system design and get feedback on it. Could you identify any major issues with my design and how to fix them? The description of the problem is as ...
0
votes
0answers
18 views

Is it usually good practice to declare an association methods in two models despite only using the association on one side?

Let me elaborate. Say I have a model called Credit that is categorized by a Role model. A real life example would be a track from an album. The track will have credits detailing its' contributions: ...
1
vote
4answers
270 views

What's the purpose of explicit encapsulation?

Assume you have a library in which every function is public. Sooner or later developers who use your library will come up with a stable pattern of usage. In that terms external information of how ...
2
votes
2answers
76 views

What are the benefits of aggregating structure and functions associated with it in one object? [closed]

What are the benefits of aggregating a structure and functions associated with it in one object? What are the benefits of explicitly decalring a class. If i write procedural code i already know that ...
0
votes
1answer
145 views

DDD & composition

I have a project to build, which has the following requirements: topup a wallet by paying money in exchange for credit; this has also the constraint of needing an approval from the finance team, if ...