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

0
votes
1answer
76 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
56 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 ...
5
votes
3answers
172 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
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) : ...
-2
votes
1answer
40 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
167 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
204 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
125 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
128 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
154 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
79 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
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 ...
4
votes
3answers
75 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
141 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(); } ...
1
vote
4answers
168 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
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 ...
-1
votes
1answer
98 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
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 ...
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
83 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
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 ...
1
vote
2answers
142 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
167 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
88 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
100 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
184 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
61 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
162 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
180 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
82 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
153 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
120 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
40 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
329 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
75 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
529 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 ...
1
vote
2answers
199 views

Design pattern for managing three different objects

I´m looking for the best way to solve following problem: I have three lists of different objects: AppleJuice, OrangeJuice & Juice. All Juice properties exists in AppleJuice & OrangeJuice ...
5
votes
1answer
127 views

Inheritance from children to parents?

Seeing this UML class diagram : FileHandler, Uploader and Deleter are abstract classes. The four bottom classes are implementations. They extend on FileHandlerInterface which requires a handle ...
4
votes
3answers
117 views

Passing a private member collection to another class

Suppose I have a Map which is a private member variable of my class A. In the same class I create an instance of class B, call it objB, by passing the map to B's constructor. Obviously this is ...
3
votes
1answer
122 views

Is there a good way to use the front controller pattern for command line applications?

I am a PHP developer and I used to build web applications with one PHP file per page for a very long time. This resulted in duplicated logic and messy code (even though I didn't know it at the time). ...
0
votes
3answers
148 views

Cyclic dependency in this project design

I have 2 modules (containing multiple classes). Let's call them Module A and Module B. Module B has a dependency on Module A: Module B -> Module A. Now, I have created an utility class C, which A ...
4
votes
2answers
118 views

Is there an elegant way to check unique contraints on domain object attributes without moving business logic into service layer?

I have been adapting domain-driven design for about 8 years now and even after all these years, there is still one thing, that has been bugging me. That is checking for a unique record in data storage ...
0
votes
0answers
48 views

Modeling a cookbook recipe with django

I'm trying to model recipes in a cookbook. Here's what I have so far: class Recipe(models.Model): title = models.CharField(max_length=255) class Ingredient(models.Model): class Meta: ...
2
votes
2answers
211 views

How to avoid circular reference in OOP Javascript?

I have a problem while working with entity framework in JavaScript. I have two classes Table and Column Class Table { Columns: Column[] } Class Column { Parent: Table } Everything works fine until ...
1
vote
1answer
220 views

Name for this design pattern?

Background Working as a software engineer in the field of electronics, I often find that none of the existing design patterns i.e. GoF typically fit the bill for what I need to do. One of the ...
5
votes
2answers
138 views

Recreating complex aggregates from a persistance source

I'm building a web application with C#, and I have an aggregate root which has several entities and value objects. Then I have a repository object which persists the aggregate to the database (I'm ...
0
votes
0answers
48 views

GUI - engine data exchange, design with C, getters or struct pointers passing?

Having quite big codebase and external libraries, in C application, what would be pros and cons of two approaches (or suggest other): (assume that there are NONE api provided calls for this) Edit ...
2
votes
0answers
87 views

Architecture design for Web API with single endpoint

Scenario: I have a situation where I need to refactor a Web service with a single API endpoint that uses complex logic to insert, update and fetch data from a database. The clients use one call, and ...
6
votes
2answers
237 views

Is the command design pattern a good way to reduce the number of dependencies in my class?

I recently realized that I have way too many dependencies in many of my classes. Now I am trying to solve that for the most important class. I think I have an idea how but I'm not sure if it is the ...