A message from our CEO about the future of Stack Overflow and Stack Exchange. Read now.

Questions tagged [object-oriented-design]

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

Filter by
Sorted by
Tagged with
-2
votes
0answers
24 views

Two data source, build one object based on the runtime parameter

I have two data sources, both contain same tables with different columns and primary keys. For both data sources, different models are defined in a library. Lets say i will fetch the data from DB ...
1
vote
0answers
71 views

Removing duplicate code with multiple APIs

I have multiple APIs doing the same thing but the code is copied for each API. The names of fields and formats of certain fields like dates are different between the various APIs, but everything is ...
0
votes
0answers
62 views

How to design for optional dependency / optional functionality

Let's say for a Net Core library that I will deliver to the customer The library define a Interface like IGetData and also a default GetData class. The library also define a ICacher interface with a ...
0
votes
4answers
118 views

Design pattern for embedding constructor arguments into classes/structs

I am still quite new on here so I hope I am posting in right forum. I am currently writing a small library where I realized I could use some kind of design pattern which lets one pass constructor ...
8
votes
3answers
930 views

Definition of “Behaviour”?

What is exactly meant when software-engineers talk about "behaviour" in contrast to "state" (Definition of "state")?
1
vote
2answers
61 views

Composite Design Pattern with unequal weightage

You have a video game in which upon killing final boss you get coins that get distributed based on whether you are: Person(individual) Group(consists of individuals or groups) If reward for killing ...
-2
votes
4answers
334 views

Is judicious & plausible selection of class fields a valid refactoring step?

I'm a great fan of refactoring but I've been wondering about the issues raised by refactoring. Fowler advises refactoring to make code readable to all users to make the code structure more sensible, ...
0
votes
1answer
83 views

What is the best practice to insert two similar records in sql server db table which will be sent to two different destinations?

I am working on parsing a file and inserting records into SQL Server DB.The database table structure will be something like this: A Users table which contains (id, name, address, destinationName,...
1
vote
4answers
320 views

forEach over branching over null check?

I was watching Zoran Horvat's "Making Your C# Code More Object-oriented" on pluralsightpaywalled. And he says that instead of : if(obj != null) { obj.DoSomething(); } We should have a list that has ...
0
votes
3answers
93 views

Software design/architecture of a patient simulator with multiple mathematical models

I am working on a simulator which simulates patients, so specific processes can be validated on "virtual" patients, before testing on real patients. The simulator is essentially a mathematical model ...
-2
votes
1answer
38 views

Creating one or multiple objects based on the input

I am designing the software to calculate employees' hours among others. To simplify my problem let's say that I have Activity class, which has a property Type. This type could be for example "Standard ...
1
vote
1answer
21 views

Preferable design for overriding sealed trait method in Scala case classes/objects

Say I have a sealed trait Person that requires the definition of a method work :: Unit -> Unit. I then have three case objects Accountant, Doctor, and Lawyer. I can think of two ways to implement ...
4
votes
4answers
261 views

How to find the classes in an object oriented project?

I'm a bit confused by some object-oriented analysis and design (OOA&D) concepts. In OOA&D, what recommendations should be followed in order to produce a viable conceptual Domain Model? How ...
1
vote
1answer
83 views

How to simplify work with class inheritance when a lot of arguments needed to be passed to c-tor?

Let's say I have class that used inside another class and uses inside some nested fields of it. To simplify the example I'll use trivial types. In reality it's something like DataType dataType, Status ...
0
votes
1answer
83 views

Simple Poker Simulation - How to design it well

I trying to create a little poker Texas Holdem simulator .. In my solution have some class : Premise : I know about Fisher Yates algorithm. I will implement it later Keep in mind that the next ...
0
votes
0answers
21 views

Succinct API design for supporting both Push and Pull-style Stream operations

I have a C# interface that represents an image-file (photo, logo, etc) that's been loaded into memory. I have different implementations (using System.Drawing, ImageMagick.NET, test stubs, etc) - a ...
1
vote
1answer
80 views

Designing low fault software rest API calls to achieve data synchronization between two different systems

I have been looking for a better design approach and will be providing my problem statement here with a similar example. As I don't have logic already in place but have the solution in mind which I ...
2
votes
3answers
221 views

What is the name of this concept/design pattern for blocking another component from running?

Description of Desired Behaviour I have the following scenario: Component A can run freely as long as it is not blocked. Any other component can block the component A from running at any time. ...
-1
votes
2answers
97 views

What is the name of this “query builder” pattern I am looking for?

I have a microservice I am designing for getting "Book" information, and one of the capabilities is to query Solr and fuse it with some DB results that I queried. I am looking for, what I am calling ...
6
votes
2answers
336 views

How to avoid changing dozens of classes and interfaces when adding an argument to a method used in dozens of classes and interfaces?

On several occasions, I was faced with the following design issue that I don't know how to resolve. Imagine, for instance, an application which at some point receives a JSON object from an API. Before ...
2
votes
2answers
146 views

How to design different moves of different pieces of a Chess game using OOP principles?

I am trying to design a Chess game where each piece of the game inherits from an abstract Piece class. The piece just does a few things: It tells which color it is (White / Black) It tells what type ...
34
votes
7answers
9k views

Should I still follow “programming to an interface not implementation” even if I think using concrete class members is the simpler solution?

According to Understanding "programming to an interface", as I understand, I think I should depend on abstract class only. However, in some case, for example, Student: public class Student {...
0
votes
2answers
88 views

Design pattern or structure for when the value of different variables are related

Is there a design pattern or structure that helps to organize code with variables whose values are related? For example, let's imagine I have an object with three properties (gonna use some pseudo ...
0
votes
2answers
96 views

Designing a tiling grid

I am implementing a grid-like game. The initial state is shown here: +++===+++===+++===+++===+++===+++ | | | | | | | | | | | | +++===+++===+++===+++===+++===+...
0
votes
0answers
121 views

Designing reusable game/chat server

I'm encountering difficulties with making a reusable design for a game server in C#. Are there better architectural or design patterns that could be used here? If I group similar system functionality,...
1
vote
0answers
74 views

Appropriate way to organize dependency with external class avoiding high coupling

I was design a server communication module of native application. As starting point for now I have 3 classes: HttpSession — class which contain all necessary data for sending requests. ...
3
votes
0answers
55 views

How would I approach collecting statistic across a method call chain?

Let's say I have an processing pipeline. It receives a file, converts the file to data, interprets the data, and then persists it. At every step of this way, I would need to collect statistics, so I ...
0
votes
1answer
120 views

Is injecting user input dependency class to menu class appropriate?

I am currently designing classes for the User Interface (UI) of my application. When defining the interface of a class MenuTabSelector I faced a design decision of whether I should inject the user ...
11
votes
3answers
2k views

What are the pros and cons of using final methods (in abstract classes)

For the purpose of writing a coding styleguide, how should final methods in software design be judged? By final I mean the Object-oriented sense that a class that can be subclassed provides methods, ...
1
vote
1answer
83 views

How to add supporting information to the existing java object?

Is there a way or design pattern to add supporting information to the existing java object? Example I have a model class Parent and it has child models. Its nothing but hibernate entities with parent-...
3
votes
4answers
480 views

What are the advantages of a 'pure' object oriented language over a non-pure object oriented language?

My first programming language is C++. C++ is a multi-paradigm programming language. One of the paradigms C++ supports is Object Oriented Programming. I want to say I get the general idea and benefits ...
5
votes
5answers
318 views

How to avoid many objects in constructors when many steps are performed by a class

I have a process which must do 8 steps, in a particular order. One of the step involves sending an email, another one going on a distant FTP server, another one querying a database, and so on. Now to ...
1
vote
2answers
42 views

Create object(s) to cater for two data sets that are the same entity but one has an additional element

When I call an API endpoint I have a class to create an object with the response. The object directly maps the endpoint elements so I have all values, with properties, getters, and setters. In my ...
1
vote
2answers
195 views

Clean Architecture - How to pass request data towards inner, domain level Use Cases?

Use Case Interactor: We can see it in this picture how does a request cross the layers until it reaches the Use Case Interactor. How does the controller pass the request towards the Use Case ...
1
vote
2answers
99 views

which layer must check if something(like account etc) exist in database

I am implementing a web api and i have crated three layers,data access layer,business layer and presentation layer. In data access layer I have a method which create a user.I use a transaction which ...
1
vote
1answer
106 views

Should i create a Core library for all business applications ? or each one individual?

I was find many companies which creating entities and models for each business applications So all these apps not reusable. Now, some clients of the company for example. needs 3 kind of software. ...
0
votes
1answer
38 views

How to handle the getting of information from Model

I'm doing a Java software engineering team project in school and my team has decided on a Finance Tracker application, which contains the main components of Expense, Budget, Statistics, Suggestions ...
4
votes
1answer
86 views

Coupling and shared entity classes

I am currently working on a problem that has a central controller that is handling inputs and outputs between various modules and maintaining a number of entity classes as these change. When working ...
0
votes
2answers
104 views

Reduce DRY for different classes which have the same data model

I have 2 "user" classes which are essentially the same except one is immutable without setters and one is mutable with setters. I have a separate factory for creating each object. ImmutableUserDto - ...
5
votes
5answers
394 views

Implicit reading/writing of state in OOP hurts readability, maintainability, and testability. Good way of mitigating this damage?

OOP makes state reads and writes implicit. For instance, in Python: class Foo: def bar(self): # This method may read and/or write any number of self.attributes. # There is no way ...
2
votes
2answers
128 views

Is it clean to place method for comparing 2 objects of same class into that class?

Let's say I have class Car (just for illustration) class Car { ... boolean isRed(); ... } where to place methods which acts with objects of same class, in my example Car, but not just on ...
0
votes
1answer
120 views

Representing mathematical tree structures using software in a compact manner

In my work I frequently come across systems of interdependent equations. I have contrived a toy example as follows. The terminal values w, x, y and z are given: e(y) = A+B A(y) = x*log(y)+y^z B(y) =...
1
vote
2answers
239 views

Clean Code: Avoiding “Order Matters” without passing member variables to private methods?

I am trying to implement some of the principles laid out in Clean Code by Robert C. Martin. I had a class that was heavily suffering from the ordering problem. I have solved most of this by ...
0
votes
0answers
42 views

Where to put property change callback code so I can handle the previous value of the property without using something different than BindableBase?

I have this uncompilable code below, it uses the code in this answer. In it gv means "the old value of a group's name", where a group is a group of clocks, and a clock is a timer or alarm. It ...
2
votes
2answers
148 views

Field variable VS method variable

hey i have a difficult question. class DatabaseHelper { Database db; String defaultShema; public DatabaseHelper(Database db, String defaultSheme) { this.db = db; this....
4
votes
4answers
390 views

Object Oriented Design and Relational Databases: Where to place behavior that pertains to more than one tables?

I have been trying to learn Object Oriented Design, but I find it very difficult to model objects that access a relational database and do JOINs. For example, I am building a REST API, it has User, ...
0
votes
1answer
163 views

What is the correct architecture for 4 MVVM synchronized collections related to groups and filters inside a WPF application?

I have a small architectural problem with MVVM. In this question I will note Model through M and ViewModel through VM. I have 4 collections that must be synchronized, and the items in them must have ...
1
vote
1answer
64 views

Modeling objects that behave in different ways so that they can be stored in a collection?

Suppose I have a Player class with an Inventory: public abstract class Player { private final List<GameObject> gameObjects; public Player(){ this.gameObjects = new ArrayList&...
3
votes
3answers
112 views

Should new fields and operation of logical entity be in one single class even the existing class has thousands of existing lines

In a legacy Java project, when adding a new feature - an existing email field can be editable or not editable on base of its parent system, a developer added a new feature by adding a new class, which ...
9
votes
5answers
2k views

Too much abstraction making code hard to extend

I'm facing problems with what I feel is too much abstraction in the code base (or at least dealing with it). Most methods in the code base have been abstracted to take in the highest parent A in the ...