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)

7
votes
2answers
167 views

Am I using Zend Form library correctly? (I am effectively duplicating work in Controller and in View)

Brief Summary This question is asking for guidance on how to deal with Zend Form library that allows me to specify how to construct each form element (Controller side) and how to render each element (...
1
vote
2answers
122 views

swift typealias vs empty inherited class

I am working on JSON model classes in a swift project. Examples of the sample JSON and classes are below. In the JSON response, there can be many different unique statistics returned, but they all ...
2
votes
2answers
128 views

Abstraction on Iterator Pattern?

Recently, I had the task to implement a research project where I had to read an XML file. XML file contained a list of messages that I had to send to some other system on a specific port. Each message ...
0
votes
2answers
202 views

General term for T[], T*, and T& [closed]

An array of T, a pointer to T, and a reference to T (represented as T[], T*, and T& respectively by Type.ToString) all share the similarity that they are constructed from an "element" type (which ...
3
votes
1answer
122 views

Confused about approach I should take to designing classes for a card game

My primary goal is to create a Euchre game in Python. Euchre card games are rare on the Linux platform, no matter the language or the desktop flavor of choice. For now I want to be able to just ...
3
votes
0answers
87 views

How to think about a schedule that pulls from a database as objects

I am working on a personal project using Python. I have been using version control to the best of my abilities and if you would like to check it out and run the app https://github.com/CodeAmend/old-...
0
votes
1answer
38 views

Boolean flags in Presenters to control flow of execution

I can see people use boolean flags, especially in Controllers / Presenters, to control the flow of execution. For example, public void onButtonClicked() { hasButtonClicked=true // code here }...
3
votes
4answers
148 views

Low-level error handling

I am working with some low-level (by that I mean code that can't use C++ exceptions and/or the standard library) code that makes heavy use of classes. Basically, every class contains a bool initialize(...
0
votes
0answers
58 views

Concepting a Server - Handling Clients/Connections

I am writing the Server-Side of an Application, just for practicing my Java programming skills. I have made an attempt to program it, but I am not satisfied with my solution and I think it is because ...
2
votes
3answers
147 views

Shall I call this “Multitasking” in OOP?

I am very new to programming and have this humble OOP-related question: Can we have a module in a OOP-manner written program, that contains 2 or more OOP features? Say, both Encapsulation and ...
9
votes
3answers
303 views

How to manage single responsibility when the responsibility is shared?

I have base two classes, Operation and Trigger. Each has a number of subclasses which specialise in certain types of operations or triggers. A Trigger can trigger a specific Operation. Whilst an ...
1
vote
1answer
171 views

What is the DRY-est factory pattern to instantiate subtypes based on one of their properties' values?

Take the following class hierarchy: Client FacebookClient PinterestClient TwitterClient Each client must define a value for an enum property named ClientType (string property Url in the ...
3
votes
1answer
98 views

Snap to grid functionality in drawing application

I'm working on drawing application and I want to provide grid with snap to grid functionality. I'm trying to find the right way how to do that (ideally some design pattern), but I'm quite confused ...
2
votes
2answers
120 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
126 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 &...
-2
votes
2answers
137 views

How do you hash 4 doubles into a size_t?

I have bounding boxes the key type. Box { double mins[2]; double maxs[2]; } And I want to have Box as the key type in the D programming language, so I have to implement: size_t toHash() const @...
1
vote
0answers
108 views

Change object state in different point in program

This is not about whether or not getters/setters are wrong. I understand its impact to encapsulation and that question has been raised here and SO several times already. I also do not want to just ...
0
votes
1answer
93 views

Is it possible to detect misuse of passing self type argument in compile time?

I just hit the very basic problem in OOP and I cannot see any working solution except postponing appropriate check until run time. It is pretty clear notion of an action "do something with value of ...
2
votes
1answer
260 views

When mapping from a database, do OOP objects (entities) need to store the database values in attributes?

When it comes to OOP where an external database is being read from and written to, is it necessary to have attributes/properties within the objects to store the data? Or is it enough to simply read ...
2
votes
3answers
176 views

When and why would you extract an abstract method from an abstract class to an interface?

I have been asked the following question in an interview: "What is the need of an interface when you can have an abstract method within an abstract class?" Which I did not know the answer to. Could ...
2
votes
2answers
201 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 (...
4
votes
1answer
132 views

Which C++ IO interfaces for a complex data source i.e. converter

My question: When you've got a complex converter like, that takes chunks or large result sets out of a database, converts it into a line by line file/resource in the end, should one either design it ...
3
votes
2answers
327 views

Is turning a method into a class to use it across many classes bad practice? [closed]

Let's say I have a sort method inside of my class and another class that has no relationship with that class needs the same method. Instead of writing that method twice and breaking the do not repeat ...
1
vote
2answers
73 views

Does my code still break encapsulation and uses getters/setters instead of the TellDontAsk principle?

I and one guy have been discussing potential solution of a problem on an unrelated board, regarding the typical getter/setter hate, ie. using getters/setters leads to procedural programming. I ...
1
vote
2answers
157 views

A generic helper class, a project specific class, and the rest of project

I have a generic helper class (1) that can be used in other projects also. Imagine something like basic handling of file and folders, something useful and DRY that always come in handy. I have ...
1
vote
1answer
102 views

Compiler design prevent register override

I'm trying to write a compiler for a self-designed CPU with accompanying instruction set. The CPU has 3 registers, 2 input registers (B and C) and one output register (D). When for example an ADD ...
3
votes
2answers
459 views

Cleanest way to expand a base class without explicitly mapping properties in C#

Lets assume I have following base class: public class Base { public int Id {get; set;} public string SomeText {get; set;} public string SomeOtherText {get; set;} public static Base ...
3
votes
0answers
140 views

Finite state machine menu design

I'm creating a FSM in python (it's a step sequencer and sample pad based on a Raspberry Pi 2). Right now there are two states and the third is the Menu. This is handled by a class System which ...
3
votes
1answer
230 views

How can a object have many types?

I am currently reading Design Patterns - Elements of Reusable Object-Oriented Software. I am in chapter 1 at page 16 in section Class versus Interface Inheritance. There in the last line of the page ...
1
vote
2answers
113 views

Does an interface including several methods that return instances of Object make sense?

I am in the process of writing my first true API. In the process, I am defining an interface for mapping complex data structures onto other complex data structures. At the moment, the interface ...
28
votes
8answers
6k views

Is it acceptable to copy and paste long but straightforward code instead of wrapping them into a class or function?

Suppose I have a segment of code to connect to internet and show connection results like it: HttpRequest* httpRequest=new HttpRequest(); httpRequest->setUrl("(some domain .com)"); httpRequest->...
1
vote
3answers
256 views

Java need to call many methods systematically

I have a group of methods that is going to be very large. I need to be able to call methods systematically from a large group, in two different ways. The methods create a new item object with ...
2
votes
3answers
183 views

Why does the overriding rule of C++ not care about visibility changes?

In C++, it is possible to write an overriding for a base class's method even if the visibility declaration of the two don't match. What are the possible design considerations under the decision of not ...
25
votes
5answers
3k views

Is it a good practice to avoid constants by using getters?

Is it a good practice to replace constants used outside of classes by getters? As an example, is it better to use if User.getRole().getCode() == Role.CODE_ADMIN or if User.getRole().isCodeAdmin()? ...
0
votes
1answer
133 views

Can I enforce the overriding of GetHashCode() and Equals() methods for users of a generic container class?

I have a container class similar to the one below (with much of the logic omitted): class Container<T> { Dictionary<T, TWrapped> contains = new Dictionary<T, TWrapper>(); ...
2
votes
4answers
253 views

Handling Multiple Collections in C#

I'm currently trying to learn C# and want to enhance my understanding of Object Oriented Programming (OOP). I'm hoping to accomplish this by experimenting with a small program that keeps track of my ...
1
vote
3answers
60 views

How to decide what instance variables to have in a class?

Most OO guides say not to store things in instance variables if they can be easily calculated, because the state might become inconsistent, and there is more code to maintain. I am trying to come up ...
26
votes
8answers
5k views

Is it a good practice to use List of Enums?

I am currently working on a system where there are Users, and each user have one or multiple roles. Is it a good practice to use List of Enum values on User? I can't think of anything better, but this ...
6
votes
1answer
173 views

Software design: recommend approach to avoid slicing/type erasure here

Here is a concrete minimal example to formulate my question : In small ball game, you have a physics engine that moves the objects regularly: void move(set< PhysicalObject* > objets, Duration ...
8
votes
4answers
461 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,...
2
votes
3answers
639 views

What means mapping in terms of programming

My question is what means a mapper and the action of mapping something? For example, I often hear things like: Mapping the classes Mapping the objects from the database Mapping the objects Mapping ...
2
votes
1answer
217 views

Using prototype/non-Spring managed beans in Spring Web application

I have been working on few web applications/REST web services recently (Spring IoC/MVC/Data JPA etc) and they usually follow the same pattern: Controller classes --> Service classes (which have number ...
0
votes
1answer
67 views

static method, helper function or in the controller, where does this go?

I'm working on a piece of functionality that simply allows a guest user to perform an action a certain number of times before requiring them to login\create account. In this instance, they can vote on ...
1
vote
1answer
69 views

Modeling specific objects interaction

I want to model an interaction between classes, e.g. there is a general class Hero and he can have some items. (I came up with this analogy so it is easier to understand) Some of them are e.g. potions ...
1
vote
1answer
95 views

What is the difference between ADTs and objects? [closed]

This question was answered in "Understanding Abstract Data Types (ADTs)", and the top voted answerer (by Frank Shearar) is currently as follows: Objects are not ADTs (*) [editor's note: Links to "...
2
votes
3answers
260 views

C++ Virtual destructors used only when there are virtual functions

This is from Effective C++ (Meyers): Classes not designed to be base classes or not designed to be used polymorphically should not declare virtual destructors I don't understand why non-...
0
votes
1answer
101 views

When to use “is a” or “has a”? [closed]

In my node.js application, I have a queue class which has push and pop methods and a data property. I have an Event class which handles an event and pushes it on to the queue. If I think object ...
9
votes
2answers
480 views

Interface Segregation Principle: What to do if interfaces have significant overlap?

From Agile Software Development, Principles, Patterns, and Practices: Pearson New International Edition: Sometimes, the methods invoked by different groups of clients will overlap. If the overlap ...
2
votes
1answer
42 views

How to implement Singleton on a Resource / ResourcesManager case?

This is a design pattern academic question exercise. We have a Resource class and a pure fabrication class ResourcesManager to manage objects w/ type Resource. The question is Given the following two ...
3
votes
2answers
365 views

Implementing “buy one get one for free” coupon logic for shopping cart

Trying to solve bogo coupon logic with proper design pattern, but having trouble identifying one. Use case: "Buy iPad get SmartCase for free" Suppose we have the following objects: Product: - ...