Object-oriented design is the process of planning a system of interacting objects for the purpose of solving a software problem.

learn more… | top users | synonyms

1
vote
1answer
39 views

Choosing the right class at runtime

This is a general software design question. My program is written in Java, but I suppose my question applies to any object-oriented programming language. The best way for me to explain my situation is ...
0
votes
2answers
59 views

Implementing a publicly-editable tree where each node must hold private implementation data

I am trying to implement a tree data structure that callers of my code edit for me to operate on. The idea is that the caller can hold a reference to nodes from the tree and modify their data (both ...
6
votes
5answers
143 views

Choose only one of several inheritances

I may look like a total idiot with such a question but nothing came up when I searched it, so I guess why not. Here is my problem: I'm doing the UML work for a C++ game, that will feature animals ...
-1
votes
0answers
111 views

When is class circular reference considered acceptable?

I asked this about a scenario in which I wanted to get rid of circular dependency among 3 classes. Initial reaction seems to indicate that my circular dependency is fine. I want to ask now when ...
1
vote
2answers
144 views

Help with getting rid of circular dependency

I have the following circular dependency that I'd like to eliminate. I think I must have a flaw in my design. And I'd much appreciate any feedback on how to fix this. My circular dependency comes ...
1
vote
1answer
77 views

Exposing capabilities with a collection of enum values or with boolean functions

High-level explanation I have an object with some methods: public class Foo { public void Bar() { } public void Baz() { } } These methods cannot be executed unconditionally, there is some ...
1
vote
2answers
99 views

Would it be good practice to separate a user entity and a user profile entity?

When designing a system that displays information about an entity (but where modification of the data is rare or restricted to few users - such as a user profile), would it make sense to have two ...
1
vote
1answer
137 views

Formulating a more sensible constructor method

This question is in the context of an Android application written in Java. I have this class which performs a specific action and returns the result of such action with a callback implemented in the ...
0
votes
1answer
45 views

Processing and sending processed data to super from child class constructor

I want to do some initialization in child class constructor and pass result to super(). But java doesn't allow any processing in child class constructor before super() call Whats a good way to solve ...
1
vote
0answers
58 views

Representing all possible values or a subset of values

I have a class that needs to return a set of values e.g public abstract class AbstractRule { public abstract String getName(); //Property is an example here. public abstract Set<Property&...
0
votes
1answer
76 views

Is this a good way to keep track of subscription cycles and figure out if we need to charge the subscriber?

I'm working in PHP and building a subscription management system from scratch. I'm trying to figure out the required functions for the Subscription interface (OOP) that need to be implemented by ...
2
votes
2answers
106 views

Implementing strategy pattern multiple variables?

I am trying to implement Strategy Pattern for handling my content serialization and deserialization. So I have four kind of requests namely CREATE, RETRIEVE, UPDATE, DELETE and for each request I want ...
0
votes
0answers
29 views

How to write unit tests for a project that does not follow object oriented principles? [duplicate]

I recently started working on a project and it does not follow object oriented principles. I'm not sure if there is a name for this kind of implementation. It's a web application that has 3 layers: ...
0
votes
1answer
87 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 ...
1
vote
2answers
60 views

Defining reusable components while having a specific application in mind

Over the past several months I have learned a lot in software design and practices across several languages and frameworks. To me, the most attractive and useful designs patterns are those that follow ...
6
votes
3answers
222 views

Which is the best design for callback implementation in C++?

I have a class "Parent". "Parent" class creates an object of class "Child" in my CPP module. The use-case is "Child" has to request for some information from "Parent". This can be done in several ways ...
0
votes
3answers
217 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) : ...
-2
votes
1answer
44 views

Domain model design

In your own opinion, which is a better design. A User object which contains an attribute Employee, and that Employee is being inherited by more specific job title. or is it better for the Employee to ...
2
votes
2answers
176 views

Is 20 Java classes for just making a REST call too much?

In an Android project, I am using dagger 2 for dependency injection, applying mvp design pattern, and I am writing interface for almost every class. Although it does achieved the separation of ...
2
votes
2answers
211 views

Design classes to prevent future code breaks

I'd like to design a robust version of this class (C++11): class Oscillator { private: std::vector<double> trajectory_; // Some numbers that are needed to get the trajectory ...
0
votes
1answer
133 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 ...
0
votes
0answers
130 views

What is the meaning of the different interface types in Ian Sommervilles's Software Engineering?

Reading Ian Sommervilles's Software engineering, he mentiones there are following interfaces: Paramater interface: data or functions are passed from one component to another Shared memory interface: ...
1
vote
1answer
165 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 ...
0
votes
1answer
81 views

Seeking advice on design strategy for Java application

I'm a very new programmer developing my first application in Java as a side project for my employer. I'm a part-time student working full-time hoping to eventually score a developer job, and my ...
0
votes
2answers
194 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 ...
4
votes
3answers
78 views

Associate selection from GUI with executable code

I am currently writing a GUI for a C# application that adheres to the following software requirements (and am struggling with the conceptual design): Have a GUI with some choices of different ...
2
votes
3answers
144 views

Is creating “shortcut methods” in the superclass of a controller Bad Practice?

Consider the following simplified example: abstract public class Controller { protected final boolean isUserAdmin() { return getServiceContainer().getUserService().isUserAdmin(); } ...
2
votes
4answers
182 views

Storing a straight line equation

How to store a straight line (infinite length, not a line segment) efficiently? This is not a duplication of How to represent a geometric line programmatically?, because the linked question is about ...
-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
2answers
160 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 ...
-1
votes
1answer
109 views

What is a good design pattern for monitoring a protocol handshake? [duplicate]

I am writing a program for monitoring communications between a server and multiple clients on a network. In particular Websocket protocol based communications. I construct monitoring objects for every ...
4
votes
1answer
428 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 ...
2
votes
1answer
89 views

How to keep IDs in sync when using Factory?

abstract class Product { public abstract Product createProduct(); ... } class OneProduct extends Product { ... static { ProductFactory.instance().registerProduct("ID1", new OneProduct(...
1
vote
1answer
86 views

Inner and outer class relationship: should outer class be friend of inner's?

Is this design bad? Does it break encapsulation? The structure class B is a component of class A. Therefore, class A needs access to class B's members. Let a house be class A. Let a housekeeper be a ...
0
votes
0answers
35 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 ...
1
vote
2answers
152 views

Is an empty class in some cases correct

I know it's generally a design flaw to have an empty class, yet I'm wondering whether there are some cases where it isn't to have an empty (abstract) class to group objects. Especially when ...
0
votes
1answer
168 views

Should I force “composition over inheritance” rule to class members?

As I know, according to "composition over inheritance" rule, we should avoid reuse a method by inheritance, but how about class members? Suppose I have parent and child classes: public class Animal{ ...
0
votes
2answers
95 views

How to remove circular reference when there is inter-dependence

I made an extensive research in previousv related questions, but since my questions is somewhat peculiar, I decided to create this new one. I am implementing a visualisation application (in JS). ...
2
votes
1answer
104 views

Writing a non-monolithic database wrapper

I have a SQL database to which I store and from which I read several objects into my C++ code. I wrote a single database wrapper which handles all the reads and writes to the DB. Of course this ...
4
votes
3answers
194 views

Role and importance of static method in OOP

Background Thinking about OOP I feel that it binds data and behavior together, taking the real world example we already have array data type which is a collection of homogeneous type but in Java we ...
1
vote
1answer
69 views

UML: do I use aggregation or composition in this case?

I would like to draw a UML sketch to communicate part of a software but the type of relationship between classes does not seem very clear cut to me. Let's say I want to periodically fetch the recent ...
1
vote
1answer
163 views

is this a good design

For example, I have a clan and a character. There's a character that is the leader. To give the clan a specific feature, some money from the character is required. I don't want to have too much tight ...
3
votes
3answers
182 views

optional data in the constructor, bad practice?

Currently I have a model class that represents a user. This class has a constructor that takes an object with all user properties, used for example, when creating the user. In this case I instantiate ...
0
votes
1answer
83 views

Example of class modeling

This is in the continuation of Small classes and methods, but code still difficult to maintain and follow as I have matured the problem and will rebound on people's answers. Here are all the elements ...
5
votes
3answers
155 views

Verbose Return Types

I've recently been writing some code that deals with 3rd parties -- obviously errors will happen so I'm using Either/Maybe monads where appropriate. As this is C# I'm also using async Tasks too. My ...
1
vote
1answer
155 views

Polymorphic constants in Java

I am designing some polymorphic code to perform mathematical operations. The idea is to abstract out the underlying representation of the data, as different use cases require different representations....
2
votes
1answer
41 views

Expose one whole object or several properties of that object?

I'm currently refactoring on an older project, which has classes that expose both a single object and also multiple properties from that object. Ex: public class Foo { private MyObj myObj; ...
3
votes
6answers
330 views

Mutability and getters

In the example below, I have a Person class and class B that holds a reference to a Person. Person has a public foo1 method that can alter its state (it's a mutable object). Suppose clients of class ...
2
votes
1answer
77 views

What design pattern(.Net) to use for multiple control design with multiple properties?

I have to design for a bunch of user control types, each of which share some common properties but some of which have special unique properties. For example, the common properties across all the ...
4
votes
7answers
566 views

Should I use static classes for methods that will do common tasks and would be called through out my application?

I have spent the last few hours reading up on the use of static classes and trying to figure out if I should be using them or not but still have not come to any sort of conclusion. It seems that the ...