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

learn more… | top users | synonyms (3)

8
votes
4answers
2k views

How are entities with an identity and a mutable persistent state modelled in a functional programming language?

In an answer to this question (written by Pete) there are some considerations about OOP versus FP. In particular, it is suggested that FP languages are not very suitable for modelling (persistent) ...
1
vote
2answers
47 views

Handling exception types according to the current “layer” of appplication

Imagine this simple application use case, say, for fetching data from outisde of the app. These steps represent the "depth" of the layers, from top to bottom. UI touch event ViewModel handles said ...
1
vote
1answer
111 views

What would the best way to design a giant API wrapper class with multiple 'sections'?

Here's the problem I'm trying to solve: There's a rather large API I'm trying to write a wrapper class around. The simplest approach would be to make one class with a method representing each ...
0
votes
1answer
74 views

Abstract class vs relation between classes

Searching for simplest solution where a User can order an item. If someone purchases an item he will have one address. Which then is the invoice and shipping address. But he could add another address ...
0
votes
2answers
43 views

Trouble handling constraints for the input of a method

I'm looking for advice on how to handle constraints on the input of a method. I have a method that only works if the input argument(s) fulfill certain constraints. If the method is called on input ...
12
votes
8answers
9k views

How object oriented is PHP? [closed]

I had a chance to have an interesting conversation with my co-workers. Most of them are flash action script or Java developers. We talked about how well php handles OOP. I said that PHP can handle ...
19
votes
8answers
2k views

When do we actually use object-oriented programming? [on hold]

I am writing a program in Python, which basically manipulates strings, and I was wondering whether I should do it using OOP principles or not. The client did tell me he doesn't care about the code, he ...
18
votes
3answers
2k views

How to handle failure cases in C++ class constructor?

I have a CPP class whose constructor does some operations. Some of these operations may fail. I know that constructors do not return anything. My questions are, 1) Is it allowed to do some ...
0
votes
3answers
205 views

When NOT to use a class / member variable?

I am trying to learn WHEN NOT to use: classes member variables HERE IS THE CODE access_point_detection_classes.py from scapy.all import * class Handler : def __init__(self) : ...
0
votes
2answers
49 views

Object Oriented Python methods and their parameters

Let's say I have a class MyClass ... which has a data member x class MyClass1 : def __init__(self) : self.x = 1 Also a method which does something with x Should I pass self.x as a ...
2
votes
3answers
151 views

C++ vs Java: Pointing to Objects

In Java: private State current_state; As "State" is a superclass, I can then assign subclass objects to current_state, effectively making current_state point to a different object: current_state = ...
-4
votes
0answers
26 views

Objects and Classes in Python [on hold]

Can anyone: 1. Define what an object is in programming and python. 2. What is class in programming 3. Give an example of an object in python 4. Give an example of class in python I can't seem to ...
0
votes
3answers
237 views

Is it bad practice to ignore some parameters while implementing a method of a interface?

Should an interface method implemented by a class always use all parameters? By interface I do not necessarily mean actual interfaces, these could be other (abstract) classes which are extended, too. ...
2
votes
2answers
119 views

Nested functions: should I explicitly pass arguments or rely on scope?

Suppose I have a function f that uses two helper functions h and g to get the job done. There are two possible ways of dealing with this situation. (1) take explicit arguments and returns new objects ...
1
vote
0answers
67 views

Pass the parser to the sorter, or pass the sorter to the parser?

I have 2 objects that I'm not very certain what is the proper (or better) way I should use. I have a query builder object that constructs an SQL statement like $qb = new SelectQuery('users'); $qb-&...
4
votes
5answers
387 views

Is “too much methods” a valid reason to break the “composition over inheritance” rule?

I usually prefer to follow "composition over inheritance" rule, until I start stepping in the world of Java GUI. In my experience, for adding custom requirements in a GUI components, for example, add ...
4
votes
1answer
45 views

Correct Way to Implementing Authorization Checks in ASP MVC

In ASP MVC we have the Authorize attribute to perform check at either a controller level or at a controller method level. But what if you need to do check permissions inside a controller method e.g ...
11
votes
4answers
8k views

Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO ...
2
votes
2answers
157 views

When is it ok to instantiate all of my objects upfront?

I am currently working with a contractor who's code instantiates a large number of objects upfront at the start of the application. This application is written in ruby, but I wonder how something ...
2
votes
3answers
112 views

Implementing an event scheduler for animations

The basic idea is to have some animated widgets that sit in a container, quite similar to Qt (the only actual difference is that my widgets are animated). The animation is in some cases dependent on ...
2
votes
2answers
184 views

Class with methods that depend on a variable argument, but this variable is constant throughout large parts of the application

I am looking for advice on how to design the following scenario: I have a 3-dimensional vector class, the entries are of type double. I want two vectors to be considered equal if their corresponding ...
-2
votes
0answers
29 views

Need help in optimizing my arraylist class which contains combination of pair [closed]

Need help in optimizing my arraylist class which contains combination of pair: import java.util.ArrayList; import java.util.List; public class FieldsProvider2 { private MyObject object; private ...
2
votes
0answers
139 views

Is Nested Structure with Spread Responsibilities Not Logical?

Given the following code snippet in a Laravel Controller: $this->userRepository->saveByProject( $this->fileRepository->saveByProject( $this->metricRepository->...
2
votes
3answers
535 views

Could the creation of many methods in Java affect performance? [closed]

I was told by a colleague that in Java, the performance may be worse if we create more methods, stacking many methods calling over them in JVM, specially in a Java EE environment. This seems to ...
2
votes
2answers
233 views

Child class accessing its parent's method from Ancestor method

I find myself right now banging my head with the following issue (in PHP): I have an abstract base class, which has a non-abstract method, inherited and unchanged all over the inheritance chain (...
0
votes
1answer
124 views

What's the OOP way of dealing with a flow control heavy application?

I'm refactoring a huge WPF application whose complexity stems from the way it deals with flow control. It has a lot of "tiny business rules" that make it really difficult to make a modification ...
9
votes
4answers
693 views

Programming style in Perl

I work in Java so basically I use OOP paradigm during coding. I am about to start working in Perl and I was wondering what is the paradigm that Perl developers follow. In wiki it mentions that it ...
1
vote
1answer
55 views

Recursive interface implementation causes empty method

TLDR: I have a situation where interface implementations accept other implementations of that very interface. Only a subselection of these interface implementations should carry a certain method - but ...
1
vote
1answer
153 views

Elevator design challenge [closed]

I need to strengthen my OOP skills and hence I thought to implement an Elevator simulator. At first what seem to be a simple design has grown into a complete mess and has left me confused about my ...
4
votes
5answers
645 views

Understanding UML composition better

The difference between Composition and Aggregation in UML (and sometimes in programming too) is that with Composition, the lifetime of the objects composing the composite (e.g. an engine and a ...
7
votes
3answers
325 views

Writing a good/readable constructor that needs a lot of calculation to fill its fields

I have a class that has several fields which can only be filled consecutively by a lot of calculation. The 1st field can be set very easily. To fill the 2nd field, we take the 1st field's content and ...
4
votes
3answers
558 views

Avoiding constructors with many arguments

So I have a factory which creates objects of different classes. The possible classes are all derived from an abstract ancestor. The factory has a configuration file (JSON syntax) and decides which ...
8
votes
2answers
283 views

Working with more efficient but less functional ways of storing data

Since learning object oriented programming I've been confused about how to deal with multiple ways of storing data that have different levels of functionality and efficiency. I'm kind of new to this ...
1
vote
1answer
51 views

Does passing this as argument potentially cause exposure of invalid object state?

This question is based on two premises: First: an object must always have valid state. It is discussed in various posts, too. http://stackoverflow.com/questions/22408804/should-a-c-object-always-be-...
1
vote
1answer
72 views

What's polymorphic deployment

On pages 136 and 137 in The Clean Coder, Robert C. Martin describes how chips could be independently deployed thanks to a vtable: The solution was pretty simple. Each chip had to be decoupled from ...
0
votes
2answers
251 views

DDD Request Validation Handling

I stuck somewhere that I can't find a solution! There are plenty of validation questions here, but as far as I see, most of them were asking about entity validation. But what about request validation? ...
1
vote
1answer
139 views

Inheritance is better or composition design pattern in this scenario?

Design and implement Cash Register: Given a number of items you will be required to calculate the total bill. Items are charged for in a couple of different ways: A given price for each item, e.g. ...
-1
votes
3answers
139 views
1
vote
1answer
90 views

Making a member function treat two objects differently in Python

I have in my program a class with a member function that should treat certain objects slightly differently than others. In order to do this, it needs to know which object was passed to it, because ...
1
vote
1answer
40 views

Redesigning schedule value hierarchy

I have a couple of schedule value classes that represent the value a schedule holds for a specific slot. First, there's the ScheduleValue class for schedules with two dimensions, where the first one (...
0
votes
1answer
149 views

Question(s) about PHP PDO connections

Let's say I have a Db class [ db.php ] : <?php class Db { // class properties private $db_driver = ''; // dsn credentials private $db_dhost = ''; private $...
3
votes
1answer
86 views

Regarding the Organization of Bit Shifting Utility Functions in C++

I am developing a project in C++ that deals with converting an ASCII hexadecimal string representation into binary. The class also has utilities in it for extracting info from the string. Right now ...
14
votes
2answers
7k views

Why should a builder be an inner class instead of in its own class file?

Many Builder Pattern examples make the Builder an inner class of the object it builds. This makes some sense since it indicates what the Builder builds. However, in a statically typed language we ...
1
vote
1answer
156 views

Should we “prefer composition over multiple interface”?

Should we avoid multiple interface if possible? Because I think at most cases a class with multiple interfaces can be replaced with another version with composition and single interface only e.g.: ...
2
votes
3answers
145 views

Design of object alias

Suppose you develop an interpreter or file system. There are objects, like variables, procedures and files in some environment. They have a name and content (variable has current value, procedure has ...
1
vote
1answer
135 views

How to compute Pricing of Product & Options based on User Option Selection and Pricing per Option

I am building a service for pricing options of a product and for pricing the product itself when product has various options. Example User selects some X options out of Y options available, where X &...
1
vote
2answers
199 views

State Design Pattern

I've come across the following State Design Pattern which seems extremely logical and simple to implement: class CeilingFanPullChain { private State m_current_state; public ...
0
votes
2answers
187 views

How to avoid repeated instantiation and garbage collection for a trivial class?

I am developing a 2D tile-based RPG game for desktop and (hopefully) Android. To represent a tile location in the game, I am using a class called Location, which has a value for x, y, and room. room ...
6
votes
3answers
587 views

Is it better to expose or hide dependency in OOP?

Let's say I have an object A, which is too big(having too many methods and variables). So, I break it down to smaller objects. After that, I have Object A, B, and C. Obviously, Object A is from Class ...
9
votes
4answers
505 views

Parallel hierarchies - partly same, partly different

There are quite a few similar questions out there 1, 2, 3, 4, but non seems exactly the case in this question, nor do the solutions seem optimal. This is a general OOP question, assuming polymorphism,...