Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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

0
votes
1answer
186 views

Polymorphism/Inheritance design concerns

I have a FtpServerDataSeriesProvider that is used to provide data series from Ftp server files: public interface class FtpServerDataSeriesProvider { IEnumerable<DataSeries> GetDataSeries();...
1
vote
2answers
225 views

How to refactor code when capturing calls made to an API service

I am currently in charge of designing the API of a new service. It started simple enough, 10 different URIs or so were allowed. I knew I was not doing the best code, but frankly I did not see a better ...
0
votes
1answer
180 views

Refactoring bad code switch statment without distort everything

Once in a while I’m stumbling on switch statements during a Code Review session. I would like to find a more elegant way of this code .... $istannceOfClass = $repository->loadFoo(); switch($...
0
votes
1answer
40 views

Bill Splitter application UML Design

I just want to improve this design, share your thoughts. Q1. I have specialized Splitter class based on monetary unit as "MonetarySplitter" and "NonMonetarySplitter". Whether doing so is correct? To ...
4
votes
3answers
193 views

Where to put the the composition?

In the following diagram I have a Car which has a Motor. An Audi A6 is a Car which has a Motor of type 2.4 L V6. So both the Car and the Audi have a composition on a motor. However it looks ...
1
vote
1answer
75 views

Interfaces for waypoints

I have a waypoint class which i use to connect a bunch of other waypoints up. But i also have a special type called a consumer, this is not technically a waypoint but it needs to act like one in that ...
2
votes
2answers
138 views

With the Static Factory Constructor design pattern is there a preferred way to remove “all” object references?

Consider the following implementation of a static factory pattern... public class Names{ private static final Map<String, Name> NAME_MAP = new HashMap<>(); private final String firstName, ...
1
vote
2answers
100 views

Design for 2 closely related (1 for 1) classes that may alter each other

I have a program that communicates with an API to get information on different organizations, so I have an Organization class and an ApiCall class which are both closely related. As the API I'm using ...
-1
votes
1answer
158 views

Enforcing IF, ELSEIF and ELSE on collection of ojects

I am designing a project where I have to enforce IF, ELSEIF and ELSE conditions on collection of objects. For example: public class Box { private List<Item> items; } I want to define IF ...
0
votes
0answers
108 views

Is it a valid OOP design for Python?

I have following class design (not exact but you can get the idea): WRITE_METHODS = ('POST', 'PATCH') class CanPOST(BasePermission): def has_permission(self, request, view): return ...
0
votes
2answers
166 views

Use getter interfaces as a way to reuse DTO fields

Assume I have a lot of DTO for a same domain model like this: class User{} //DTO @Value.Immutable interface SimpleUserDTO { getName getAge } @Value.Immutable interface RegisterUserDTO ...
1
vote
4answers
464 views

Violation of Liskov Substitution Principle?

I've have an animal class class Animal { public function eat(Food $food); } the subclass who inherit it actually cannot support all kinds of Food (Cat can only eat meat): class Cat extends ...
2
votes
1answer
65 views

Should I create seperate interfaces as a way to centralize annotation?

Assume I have these classes: @Entity @Data class Student{ @Size(min = 8) public String name; public int age; ... } @Data class StudentDTO{ @Size(min = 8) public String name; ...
3
votes
2answers
381 views

What differentiates function objects from poltergeists?

The Short (Original) Version How are function objects, sometimes called "functors" in C++ and other OO languages, where they make sense different from classes symptomatic of the poltergeist anti-...
3
votes
2answers
298 views

What is control abstraction in the context of functional programming?

I understand concept data abstraction as it is relevant to OO programming. However on contrary it seems Function Programming promotes or makes use of concept control abstraction. I tried searching ...
0
votes
2answers
164 views

OOP, SRP, and Checkers

I have just started oop and decided to program a checker's engine. I have few concerns about the way that I have structured my code and I am not sure if I am failing to understand the principals ...
0
votes
1answer
46 views

The difference between product scenarios and requirement's Use cases in Software Specifications [closed]

I am trying to write down a specification for a project ( still a starter ) and I got into the nuance between the two sections : product scenarios and the following requirement's Use cases. I didn't ...
0
votes
1answer
87 views

Modeling web scraper

I'm working on a small application that is supposed to scrape/parse a few website and I'm wondering which would be the best way to achieve this (keeping DRY/SOLID in mind). Here's some pseudocode: ...
9
votes
6answers
3k views

what can go wrong in context of functional programming if my object is mutable?

I can see the benefits of mutable vs immutable objects like immutable objects take away lot of hard to troubleshoot issues in multi threaded programming due to shared and writeable state. On the ...
0
votes
2answers
83 views

Inside a non-static non-virtual method, if it just use a few non-static members, should I turn it into static methods with parameters?

According to Are there guidelines on how many parameters a function should accept?, it is ok for a method to have few parameters. According to https://stackoverflow.com/questions/11240178/what-is-...
8
votes
3answers
529 views

Communication between decoupled components using events

We've got a Web App where we have a lot (>50) of little WebComponents that interact with each other. To keep everything decoupled, we have as a rule that no component can directly reference another. ...
0
votes
0answers
57 views

How to implement M-N relationship to reflect the domain correctly

If I have three entities like this: WorkingGroup WorkingTime Shift The WorkingGroup has one or more workingTime public class WorkingGroup { public WorkingGroup() { ...
0
votes
2answers
264 views

How to make method calls more generic when dealing with multiple class types?

I have a loader class that executes data loading functions at boot-time for my application to give me test data. The idea is pretty simple, I'm reading in XML data, using JaxB to turn it into a POJO ...
1
vote
1answer
61 views

Accessing properties of composited classes without breaking encapsulation

We've built a class that allows you to easily draw stuff on a <canvas> element. That class is called Canvas. I've encapsulated the <canvas> element and the class itself in a WebComponent, ...
-1
votes
1answer
124 views

The concept of linking objects and classes

This isn't so much as a specific code review, but a concept review when converting a class diagram to code and then eventually a database, in Python. I know how to add things in to a database, but I ...
1
vote
2answers
204 views

Does increase of number of classes have impact for performance

I'm in the middle of refactoring a project (in C++11) and I'm struggling with a decision is it good to change huge enum with about 100 record to separate classes. This enum is used in about 4 places ...
3
votes
2answers
233 views

Should complex return objects be wrapped in a helper class?

In refactoring some code I found a helper method get_records_from_file that has a complex return signature: class RecordDefinition: def __init__(self): self.foo = None self.bar = ...
0
votes
2answers
202 views

Declaration Types in OOP

I would like know opinions about the next sentence: "In a object oriented static typed language you should declare variables and parameters as broad as possible and return types as narrow as possible"...
2
votes
2answers
97 views

Pattern for modulating an object based on a variable

I am writing some code that really smells but I can't figure out exactly why. I have documents that exist in multiple languages. I want to be able to serve a document in its requested language and be ...
-1
votes
1answer
113 views

How to Model below Hiearchy with OOP

Note that I cannot use static inheritance due to language limitations (Java). There is a general Building class. Each instance of Building has properties that exist regardless of instance variables (...
42
votes
8answers
11k views

Class that does not represent anything - is it correct?

I am just designing my application and I am not sure if I understand SOLID and OOP correctly. Classes should do 1 thing and do it well but from the other hand they should represent real objects we ...
2
votes
2answers
558 views

What's the difference between a Mixin and a Trait?

From what I can tell from Scala and Hack- Mixins: Can have state (ie. instance properties) Can only provide concrete methods Can have constructors, that are called in the same order that their ...
3
votes
3answers
289 views

Is an Enum changing the behaviour of an Entity bad?

I am very new to Domain-Driven Design. I have come across a part of a domain which I'm not sure if I have modeled in the best way possible. There is a Membership entity which has a membership type. ...
-1
votes
1answer
155 views

OO Class Design for ATM card

I have to design a Class for ATM cards with the following attributes: Cardholder Name Card Number Pin Other than getters and setters, I have a method to validate the pin of the ATM. As per the ...
7
votes
1answer
1k views

OOP ECS vs Pure ECS

Firstly, I am aware that this question links with the topic of game development but I have decided to ask it here since it really comes down to a more general software engeneering problem. During the ...
-3
votes
1answer
74 views

Handling different versions of a program and benchmarking with OO

Note: I'm not sure if the way I phrase the question initially will fit 100% on this board, so please help me to focus on the main point. Scenario: You develop an algorithm or a neural network that ...
2
votes
3answers
160 views

Defining a lot of attributes in a class

Suppose that you have to develop a program which stores the products with their features and perform some operations on them, and you decide to design a class to represent the products. Each product ...
0
votes
1answer
199 views

Is it a good idea to load all user data on top of each file including sensitive information?

I've written a User class like this: <?php class User{ private $id; private $username; private $password; private $name; private $email; private $key; private $phone; ...
2
votes
0answers
50 views

How to interface with very badly written code in Python? [duplicate]

I have to extend some very badly written Python code (no documentation, very interdependent, barely any encapsulation, very static, everything hard-coded, etc..) and therefore do I obviously have to ...
1
vote
1answer
97 views

How to verify that every object responsible for Itself

I wonder if I have multiple objects and how to list their responsibilities where every Object Must be Responsible for Itself for example: If I have three objects: Employee,Schedule,Shift. and ...
6
votes
4answers
340 views

How to incorporate external entity models in conceptual model?

If I want to create a conceptual model for my new application, and during the analysis, I found that some objects like employee, department ..etc are a part of another system. and all the data related ...
0
votes
2answers
67 views

Where and how to store URLs in a web module?

Situation I am currently refactoring existing web code. The code currently revolves around a ServerConfiguration object. It looks something like this: string UrlBase = "https://myserver.com/api" ...
7
votes
3answers
2k views

Sample code to explain Banana Monkey Jungle problem by Joe Armstrong [closed]

In the book Coders at work Joe Armstrong stated that: I think the lack of reusability comes in object oriented languages, not in functional languages. Because the problem with object oriented ...
1
vote
0answers
274 views

What are a few arguments against SOLID principles? [closed]

I've been practicing SOLID in my code-base (PHP) as best as I could as of late and the progress is clear. Code is more readable, more maintainable and everything in-between. The problem is that I ...
1
vote
1answer
72 views

Best way to code actions and their criteria/checks

I've been trying to make my code cleaner and I have came across an issue which I don't know what the best solution is. This is the code I want to "clean". Please bare in mind that I am refactoring ...
4
votes
3answers
502 views

OOP PHP: How to avoid each class for each table situation

I am working on a project of an online service provider. I have tables for admin, agent, customer and tables for data storage like city, services, category, sub-category, gender. I have created ...
5
votes
2answers
262 views

Abstraction of VAOs, VBOs and Models

I have gone down the rabbit hole that is abstracting away a working game engine in OpenGL and C++. Before reaching the other side I'd like to ask about my current design, which is - the more I look at ...
0
votes
1answer
58 views

PHP User, Customer, Business Relationship

I am creating an invoice management system that has a User Class that handles the login system. Currently each User is associated with a Customer and the Customer class handles obtaining Monthly ...
0
votes
0answers
45 views

How to pass a variable to class used by a service in DI?

I have a problem with passing a parameter to a request I want to make. I cannot find the proper way of doing it. I made the code simpler, than it really is, only to concentrate on the problem. I ...
0
votes
2answers
55 views

How inject a collaborator who needs a back reference into a constructor

Following Hevery's advice to inject collaborators into constructor rather than new'ing things within constructor body, how gracefully do this when a collaborator needs a back reference to its owner, ...