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)

1
vote
2answers
41 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
2answers
110 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 ...
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 ...
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 ...
0
votes
3answers
204 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
48 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 ...
-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 ...
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 ...
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. ...
1
vote
0answers
65 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
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 ...
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 ...
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
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 ...
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 ...
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
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 ...
7
votes
3answers
323 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 ...
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 ...
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
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 ...
-1
votes
3answers
139 views

What is the difference between this->data, and directly just data?

In C++ Is using this->data slower than data ?
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
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
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
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. ...
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 ...
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.: ...
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 ...
-1
votes
1answer
157 views

Want Some Advice on Structuring My Text-Editing Program

I want to make a small command-line-run program that looks for a word or phrase in a target .txt. or .docx file, prints out a corresponding blurb about that phrase, and then replaces it with a ...
0
votes
0answers
68 views

Using Ruby ORM vs DB querying

If one were to set up an API in Sinatra connecting to MongoDB, is it absolutely necessary (or even a "best practise") to define models and use Mongoid (for example) to run DB operations such as User....
2
votes
1answer
107 views

Designing generic operations in object oriented languages

I found an interesting quote in SICP that I think is highly relevant in object oriented design: We see that, in general, a type may have more than one subtype. Triangles and quadrilaterals, for ...
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
153 views

Which pattern to use when I want to encapsulate large blocks of code?

I have a data structure, a large dictionary, that is mutated by several functions. Each function does a database call, some calculations and then changes the value of a key in the data structure. Each ...
2
votes
1answer
74 views

Is is ok to refer to object owned by root aggregate directly in this case?

While I'm trying to design classes based on DDD principles, I'm quite confused for this particular "pattern". For example, ScholarshipProgram contains many Cycle. They seem to be aggregate to me. ...
8
votes
3answers
565 views

How should an `Employee` class be designed?

I am trying to create a program for managing employees. I cannot, however, figure out how to design the Employee class. My goal is to be able to create and manipulate employee data on the database ...
0
votes
1answer
57 views

Dynamically create some types of array and return that array as a collection of arrays

As an example, I have database select query that returns n columns and I didn't know how many rows return (lets call x number of rows return). Sample code (c++ and SQLite): while (sqlite3_step(res) =...
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 ...
0
votes
1answer
71 views

Are there any drawbacks to using two opposite listeners?

In OOP there is a common pattern of using listeners and events. Recently I've come upon a task where two opposite listeners were setup to accomplish needed logic: private ValueChanger ...
4
votes
1answer
409 views

Clean OOP-Design: How to implement single responsibility and no procedural programming

I am currently trying to refactor a piece of C# code that is somewhat procedurally written. I want to make the design clean, object oriented and using classes with single responsibilities. The code ...
0
votes
0answers
42 views

Should I split function reference into a class reference and method reference?

We have code like ['Index::Show::AjaxPost', ...] which references a function AjaxPost in Index::Show module. I was ordained to refactor it in object oriented manner. Should I split it into [['Index::...
-3
votes
1answer
302 views

What is disinheritance in object oriented programming? [closed]

I am confused over Virtual Inheritance and disinheritance ? Is both are same ?
0
votes
0answers
108 views

A modification of singleton pattern

"Singleton" is widely considered anti-pattern ("bad" in everyday language). What about this alternative modified singleton pattern? An object constructor for our class ensures that at any given ...
0
votes
2answers
93 views

Static factory method in base class

An increasingly popular definition of factory method is: a static method of a class that returns an object of that class' type. But unlike a constructor, the actual object it returns might be an ...
0
votes
0answers
34 views

Choosing class names and relations for different user scopes

I am developing an online Order Management System using PHP in which I have some different behavioural scopes regarding the User class: some user scope under which the chronological transactions are ...
0
votes
1answer
117 views

How to search through an array of objects?

I am using an array of objects to store data to render a page. A few examples of the type of data each object can contain: PHP filepath for an include CSS filepath for CSS files Meta data of the ...
1
vote
2answers
78 views

How do you represent an object when you need to know which subtype you're working with?

I have some data that I need to represent in a form. As an example, it might look like this (in psuedo-json): [ { "value1" : "int" "value2" : "{1, 2, 3, 4, 5}" "value3" : "...
3
votes
0answers
61 views

Where should view-specific data/logic be defined in a PHP MVC application?

After many hours of research and thinking I have found an understanding, then coming to question it again, I am struggling to find something concrete which I can grasp and apply to my code in a ...