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
0answers
34 views

Avoiding instanceof vs abstract God Class. Do I have an alternative?

I have a large number of classes with an abstract base class (A) that contains behaviour that must be supported by all the sub classes say [B..I]. In my code, I end up with a collection of objects ...
2
votes
1answer
51 views

How do I structure my code to avoid tight coupling between my parent and child classes?

I'm using a third party product that has a class I can extend to provide a new way for that product to get data (the product is Sitecore but I don't think it's super relevant to the question). They ...
1
vote
3answers
49 views

How can I generalize multiple distinct classes as a single class, united by purpose?

I have a StringValidator. A StringValidator is either a Regex or a string pattern using '*' wildcards. I want the StringValidator.StringIsValid() to perform one action or a different one, depending on ...
-1
votes
3answers
166 views

Why not make everything private or public? [on hold]

In code there are private and public declarations. Why shouldn't I make everything private or make everything public?
1
vote
1answer
140 views

Must constructors of value objects not do work, even when class invariants prescribe so?

Today I had a discussion with a colleague. It is my understanding that a class has the responsibility to ensure that its objects have a valid state when interacted with from outside the class. The ...
4
votes
1answer
67 views

The bound mechanism by generics for a type variable to appear in its own bound

From Programming Languages: Principles and Paradigms By Maurizio Gabbrielli, Simone Martini The bound mechanism for type variables is fairly sophisticated and flexible. In particular, a type ...
6
votes
3answers
234 views

Parameterizing vs property assignment

Today I had a dicussion with a colleague. I tend to believe that a value in a property should be a meaningful part of the state of an object at any given time. This automatically almost always makes ...
0
votes
1answer
128 views

Is it OK to use class names in an interface definition?

I am creating interface in Java for custom error handler. Want to pass an argument error object but I need it to be child of Exception class. Is it okay to use my defined class name in an interface ?...
1
vote
1answer
76 views

Proper way to difference user types in OO

I'm designing an application where I have users and admins (further down in the future, I can have different sub-ranks, where each one can have access to some area of the application). Currently, I ...
3
votes
2answers
86 views

Is polymorphism appropriate for modeling natural language form (structure), or is there something better?

Let's take French and Japanese adjectives as simple examples. French adjectives have gender (masculine or feminine) and number (singular or plural), whereas Japanese nouns have neither. However, ...
6
votes
3answers
383 views

Clean code: consequences of short methods with few parameters

Recently during a code review I came across code, written by a new colleague, which contains a pattern with a smell. I suspect that my colleague's decisions are based on rules proposed by the famous ...
3
votes
5answers
411 views

Start Method vs. Setting up everything in constructor

The internal framework my company uses has a pretty pivotal Object that has a pattern of being instantiated as a member of a class with a no argument constructor but to be usable you have to call a ...
0
votes
1answer
57 views

Mutual observer

I want my Wire objects to be in connection with Port objects. That is Port has a list of connected wires and method Port.add(wire). Similarly, Wire has list of ports it is connected to and Wire.add(...
-1
votes
0answers
73 views

Scope of dynamic objects in switch statements? [closed]

I am writing a program that mimics the process scheduler of an Operating System. I create new processes dynamically based on my professor's input. I must be able to create objects at runtime so I ...
5
votes
8answers
723 views

Why don't constructor return bool to indicate its success or failure without having to throw an exception?

Take C++ constructors for example, we know they don't return values. Why did Bjarne Stroustrup in the beginning decide not to allow constructor returning 'false' to indicate it fails, so that the run ...
0
votes
1answer
65 views

Is this an example of Composition or Aggregation?

I understand the concept behind Composition ('has a') where the contained class is destroyed upon termination of the container class. Likewise, I get Aggregation which is a 'looser' relationship ...
3
votes
5answers
247 views

Design Pattern for interdependent abstract methods

I want to model some mathematical structures. For this purpose I want to define an interface, an abstract class for general purpose algorithms and concrete implementations of that class (I have three ...
4
votes
2answers
321 views

Is it ok to have an empty abstract class to make concrete classes polymorphic

BEFORE: I have an interface that has one method definition public interface IDockable { void Dock(DockerContainerConfig config); } Everything is ok for my first implementation public class ...
0
votes
0answers
41 views

Use Local Parameters If Global are empty?

Simplified Case with Immutable Class final class Secret implements IFoo { private $header; public function __construct(array $header = []) { $this->header = $header; } ...
-1
votes
1answer
78 views

abstract classes or other generalization classes?

i have a question about software engineering best practice. Let's consider a class "User", with 2 subclasses "Student" and "Teacher" if we need to specify some data for "University special council" ...
4
votes
3answers
131 views

Using Nested Classes for Input and Output to a Calculation Method

We have a large project that performs a lot of modelling and calculations. This code is being broken down into smaller, more manageable chunks, by shifting particular calculations into their own ...
4
votes
2answers
114 views

Why are dependencies typically reversed when representing complex objects as relational tables?

I'm going through some sort of phase where I over analyze and second guess every single decision I make when attempting to write software that has preventing me from getting anything done. I recently ...
0
votes
1answer
103 views

Do you put business logic in your service implementation ? <comment on my design>

Today at work a colleague was looking at a piece of module I had written a month ago as a reference implementation. I had written a WCF service which a Windows service was consuming. I have a single ...
3
votes
2answers
58 views

How is MPI related to “message passing”?

How, if at all, is Message Passing Interface (MPI) related to the general concept of "message passing"? Admittedly, the question does sound ridiculous. Surely, "Message Passing Interface" is an ...
2
votes
0answers
67 views

What sort of object represents a table row from a joined table query? [closed]

I have a conceptual problem here. When i query my database, i often do so with joins. So a result set row might look like +------------+--------------+------------+-------+----------+----------+------...
0
votes
0answers
37 views

Is using DBUnit fake Database Connection the only thing I need to do to remove a filesystem/SQLite Dependency in my Unit Tests?

Overview of my Situation I'm currently doing some heavy refactoring on a small vocabulary learning Project using Unit Tests, SQLite, Java and Maven. This is my first Project in which i use Unit ...
4
votes
5answers
139 views

Should a method that simply delegates to a constructor be created?

For example, if I have a method public void method(Pair<String, Object> pair){ ... } Should I create the method public void method(String str, Object obj){ this.method(new Pair<>(...
3
votes
3answers
133 views

Is there any point in using builders and fluid interfaces with object initialisers?

In Java and C#, you can create an object with properties that can be set at initialisation by either defining a constructor with parameters, defining each property after constructing the object, or ...
12
votes
3answers
3k views

Is this bad OOP design for a simulation involving interfaces?

I am designing my own little OOP program to simulate Vampires, Wolves, Humans and Trucks and am trying to implement my own limited understanding of Interfaces. (I am still abstracting here and have ...
2
votes
3answers
140 views

How to write classes to represent a domain model? [closed]

According to DDD and the clean architecture, entities should encapsulate data and related logic. So, how do you design a class to represent a particular real world entity? Two alternatives among ...
1
vote
3answers
177 views

Is the following example one of Composition?

I am trying to decide the type of relationship (or association) there is between the following two classes: Class Stable { private const int MaxStableRooms; private Horses[] Horses; public Stable(...
0
votes
1answer
90 views

Designing an Order service that accepts many types of orders

I've been having some trouble coming up with a design that would alleviate most, if not all, the issues I've been running into, and I'm wondering if it is my base design. Our company accepts orders. ...
0
votes
2answers
118 views

Using Static vs Passing Parameters

I'm implementing a state-pattern design in Java to calculate the current position of an object following a trapezoidal trajectory. The pattern consists of a Context, State and states classes. ...
0
votes
0answers
21 views

Way of filling collection in generated web service class without boilerplate

I have generated classes: class ServiceCatalogFilterType { protected IdentifierListType verticalIdList; protected IdentifierListType packetIdList; // many lists } class ...
4
votes
2answers
118 views

Design of a “storage object” - object used soley to store data

I have a file editor. It reads from a file, creates an object with the read data and can then write that data into a same (or another) file. Every time user opens a file a new tab is created and a ...
6
votes
5answers
658 views

How to explain to a layman the disadvantages of HardCoding and not using OOP principles?

I apologize in advance if the question is not directly involved in programming but I could not find a forum of programmers who deal with general questions. I am developing a cross-organization ...
0
votes
1answer
128 views

Should a method always be static if it can be?

I am using Typescript in Webstorm with Angular 2 and I am frequently getting warnings that a given method can be static. Yes, these specific methods do not depend on the state of the object they are a ...
2
votes
1answer
62 views

Protecting Invariants of Classes

I have a bit of a storm in a teacup at work, and I'm trying to figure out if I'm in the right, in the wrong or maybe a little bit of both. It all started out innocently enough; a developer from ...
1
vote
2answers
189 views

Proper practice on handling a large number of objects in simple OOP programs [duplicate]

(Please excuse the level of simplicity in this question, as it is very basic) I have been working with very simple Object-Orientated Programs and learning basic concepts. For example, my programs ...
1
vote
2answers
120 views

Trouble with circular dependency in state machine design

I am trying to develop the structure for a basic state machine that can also take in input and produce output. I've hit a bit of a mental block in trying to figure out how to model the relationship ...
3
votes
1answer
86 views

How is correct function method called at run-time?

Suppose we have a base class Aand derived class B. A implements a virtual method foo() which is overloaded in B. If we have an object test of type B, then the object would surely contain both ...
0
votes
1answer
89 views

Is there anyway I can store the static std::vectors of pointers of all my derived classes in my base class?

I currently have a program that has multiple derived classes. All instances of a derived class are stored inside of that class's static vector of pointers. I also have a static vector of pointers ...
3
votes
2answers
324 views

Design patterns for creating objects that have a list of objects that also have a list of objects

In terms of good OOP design, what is the best way to structure code that is just containers of list of objects that contains other lists of objects that also are just other containers? Example: A ...
1
vote
1answer
106 views

Principle of least privilege vs Interface segregation principle

What is the difference of Principle of least privilege and Interface segregation principle? As much as I understand ISP is just the projection of PoLP on the OOD plain.
6
votes
4answers
189 views

Should Exceptions Be Expressed on the Domain Model?

Let's say that we have a class PersonName and we throw an exception when some one try to create a instance of PersonName passing an invalid name to the constructor. Should the exception ...
7
votes
4answers
306 views

OOD - Is the Single Responsibility Principle context dependant?

This is more of an OOD problem and I have no specific code to post here. Can the same class violate the SRP in one context and be SRP compliant in other without changing a single line of code? In ...
1
vote
6answers
697 views

Refactoring if-else logic to reflect the OOP principles

I have read some of the related questions regarding how we can refactor a code based on if/else if statements to follow closely the OOP principles but I have difficulties to apply this to a concrete ...
9
votes
7answers
854 views

Implementation of object state in an OO language?

I've been given some Java code to look at, which simulates a car race, of which includes an implementation of a basic state machine. This is not a classical computer science state machine, but merely ...
1
vote
1answer
146 views

Switching algorithm for Parking Lot Software Design Problem

There's a common interview question that will be some variety of the Parking Lot simulation- the gist of which is you have a parking lot with parking spots of varying sizes (small, medium, large) and ...
0
votes
2answers
206 views

Is “Introduce Parameter Object” actually a good pattern?

I have a situation where I want to call a function which requires a number of parameters. This function is not called directly, it is called indirectly and the parameters are delegated several times. ...