Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

-1
votes
0answers
40 views

Is defining a Service like this a good idea? MVC architecture [on hold]

This intends to represent a base service interface for services that act as an API for an Entity related operations. T -> the Entity class type ID -> the Entity Id class type DTO -> the Entity Dto ...
34
votes
7answers
4k views

How do you justify more code being written by following clean code practices?

I've been following some of the practices recommended in Robert Martin's "Clean Code" book, especially the ones that apply to the type of software I work with and the ones that make sense to me (I don'...
0
votes
0answers
21 views

Move operator for class that has a member with deleted move operator [migrated]

Class X has a deleted operator= X& operator=(X const&) = delete; Class Y looks like this: class Y { private: X variableX; public: Y(int p) { variableX= X(p); } } I'm ...
1
vote
3answers
111 views

Should we have one class for each responsibility?

Consider an Eg. of Library Management System, we can have a design where in a student can search for a book based on it's title from the list of books using a function, something like below (in c++) ...
-2
votes
1answer
108 views

What is the best way of implement a virtual world like a garden? [on hold]

I want to develop a virtual garden with a lot of kind of insects like ants, bees, etc... For example, if I want to create an area of 10x10m². I can implement this with ArrayList<ArrayList<...
-2
votes
0answers
24 views

Extending a data class consumed in various place because one of the consumers requires a new field [on hold]

I have a class A that is the return type of a process (let's call it M.getData()) that is consumed by several procedures through the code base (lets call them P1, P2 and P3). This class A is part of a ...
4
votes
2answers
175 views

Doesn't repository pattern in clean architecture violate Dependency inversion principle?

From what I have read and seen clean architecture assumes that you have some entities which know nothing about persistence though at the same layer as they reside there might be an interface which has ...
1
vote
4answers
283 views

Is dependency injection always a best practice?

Recently I started working on a rather large monolithic system. The solution has web, app and api parts and in general just a lot of stuff. It relies heavily on dependency injection and I noticed ...
3
votes
4answers
204 views

How to get a decoupled design without injecting repositories inside entities

I am facing the following situation: I have to develop a system that has to calculate the price of a car so i need to calculate the prices of all the Pieces that make up the car and then total them. ...
2
votes
2answers
134 views

Strategy pattern and different implementation

I am still learning Design Patterns and I have a situation in my hand. I am developing a simple employee management Python program. An employee can be a Developer, Senior Developer, Lead Developer, ...
0
votes
0answers
22 views

Ranking / Generating score card based on scoresheet details

I am busy with a score keeping app. And would appreciate suggestions/ help. I will try to be brief and hopefully have explained the main gist of the app below The app basically maintains some scores. ...
1
vote
4answers
402 views

Declaring unnecessary variables for readability

I know some languages (C comes to mind) its best to declare as few variables as possible. In a language with memory management like C# is it better practice to continue with this philosophy or should ...
1
vote
2answers
80 views

Transforming one collection of objects into a separate unrelated collection?

Say I have a customer class class Customer(name, age) somewhere in my code, I have a list of customers List[Customers] at some point, I need to transform this list of customers into a Map with ...
2
votes
3answers
305 views

Confusion on Single Responsibility Principle (SRP) with modem example?

I am currently reading through Robert Martins book "Agile Software Development" book and I am struggling to see how his modem example provides any benefit. He says that he has an interface that ...
0
votes
1answer
67 views

How to decide which of two “linked” objects should be contained in the other?

Are there any guiding principles of OO design to take into account when deciding which of two interacting and linked objects should be included as a component into the other (or referenced from it)? ...
3
votes
2answers
93 views

How to create a tree-hierarchical structure with unique behavior for every type combination?

Assume: There is some module whose interface is IA. There is some module B, that takes in a parameter an instance of IA, and whose behavior depends upon the type of that IA, meaning (pseudo code, no ...
0
votes
1answer
87 views

Structuring methods in classes [closed]

When implementing a class (in any language), I usually try to pack any associated code in small methods, may they be used only once or multiple times. Finally, I end up with a class consisting of a ...
0
votes
1answer
52 views

Defining object definition scope based on domain

I had an architecture question about how to manage objects with different properties based on the services they are in. Is it okay to have an object defined in to different places with similar ...
0
votes
1answer
90 views

Calling same method on different instance (Polymorphism)

I have situation that 3 different instances with the same method signature are doing their job repeatedly. interface IArgs{ //args stuff } interface IExample{ void Populate(IArgs); } class ...
0
votes
1answer
68 views

Should there not be methods intended to be only called from inside of the package, but from the outside of the class they're defined in?

Note: This is a follow-up to this question on StackOverflow. I have to write a wrapper in Python to an external API, accessible through HTTP. The code is supposed to be publicly available on GitHub. ...
-1
votes
1answer
55 views

How to build a custom intermediate operation pipeline in Java for a series of API calls?

I am working on a project which provides a list of operations to be done on an entity, and each operation is an API call to the backend. Let's say the entity is a file, and operations are convert, ...
0
votes
0answers
110 views

Decorator Pattern Java

This is an object-oriented design question that is specific to Spring Boot. I'm extending a Spring Boot application that has an interface that is being extended and used inside another service. The ...
0
votes
0answers
45 views

How would design a wrapper for a large, multi-response api like the one described below?

Let me explain. Lets say there exist some service at some organization that exposes information on a company's assets, from employees company-issued devices(laptops and issues) to the the large xerox ...
0
votes
2answers
153 views

ValueObject - too wordy?

So, I'm having some value objects in my domain, and when I'm using them in one of my builders it looks like this: .withSomething(Id.of(123), Specifiers.of(MySpecifier.of("233"), MySpecifier.of("23423"...
0
votes
0answers
81 views

Job Scheduling Software

I am designing a Job scheduling software. Users of the software will define the job definition in XML like format https://github.com/etingof/apacheconfig/: e.g. <job> job_name myjob &...
0
votes
1answer
91 views

Factory Design Pattern Implementation with multiple interfaces and base class

I know it is lot of code. But I am trying to understand the concept of Factory pattern with interfaces and base class. I have a base class of Car that implements an interface which will be implemented ...
0
votes
3answers
84 views

How can I do a step based design form my applicaiton?

I want to create an application that has some optional steps. But I could not decide how to do step plans. It looks like a workflow. I have a Work entity. This work includes specific business steps. ...
2
votes
1answer
270 views

Does it violate GRASP if a Character class checks if it can carry a weapon?

Before I ask my question, I'm aware of Eric Lippert's Wizard and Warrior series. I'm trying to understand GRASP, but I'm having a hard time determining if this class violates GRASP. Suppose if I ...
62
votes
12answers
9k views

Having a flag to indicate if we should throw errors

I recently started working at a place with some much older developers (around 50+ years old). They have worked on critical applications dealing with aviation where the system could not go down. As a ...
6
votes
4answers
419 views

Replacing Linq Methods with Extension Methods

So, I've fallen into the fad trap, and started replacing a large amount of linq queries with extension methods. For example: orders.Where(o => o.Status == ShippedStatus.Shipped).Select(o => o....
3
votes
1answer
247 views

How to handle a software design project when I am the only member of the team with any design experience

Some background I am the newest member of a small team of 3 developers. For the past two years I have been working with them on an application the two of them made roughly 5-6 years ago. This ...
8
votes
4answers
722 views

What is “premature abstraction”?

I've heard the phrase being thrown arround and to me the arguments sound completely insane (sorry if I'm strawmaning here, Its not my intention), generally it goes something along the lines of: You ...
0
votes
2answers
75 views

Designing a modular CLI tool

I am building a CLI tool which will potentially support many commands. Ideally, I want to abstract out each command to implement an interface that demands a "run" method. From there on, it would be a ...
0
votes
2answers
88 views

How to design an API wrapper with bulky operations on domain object? (Need guidance)

I need some guidance in designing an API wrapper for my backend APIs. I have tried to keep it as specific as possible. Context: We have a project which supports certain file operations like edit, ...
1
vote
4answers
106 views

Migration from Anemic Models to Rich Models

I am looking into improving my overall application architecture and (I think) I understand the issues my Anemic Models are causing. Here is my current architecture: Controller with injected Service ...
3
votes
1answer
181 views

Understanding interface injection

Quoting the definition of interface injection from Wikipedia : The advantage of interface injection is that dependencies can be completely ignorant of their clients yet can still receive a ...
2
votes
2answers
111 views

Best way to provide configuration parameters for objects far away from the starting point

We are developing complex application on the top of the ROS framework in C++ and recently ran into discussion how to provide parameters to the parts of code far away from the starting main(). The ...
2
votes
5answers
261 views

I feel like these constants should be in a different class?

I have a static class called RenderingUtilities that houses several useful methods and constants. Some of these constants are related to the Earth as an object such as the Earth's radius. I believe ...
1
vote
2answers
155 views

Why are classes named “class”? [closed]

Could it also have made sense to call it a "Form", as in the Platonic sense of the ideal form that represents the thing which earthly objects strive to emulate?
3
votes
2answers
130 views

Design pattern for similar classes that require different implementations

Edited: Update is at the bottom There could be a common or best practice for this scenario, but I am unfamiliar with it. However, it could very easily be a matter of subjective opinion on how one ...
2
votes
1answer
111 views

Design pattern for an indeterminate number and format of questions

In my application, I have a finite number of question types, but the order in which they're asked and whether they're asked at all is not known up-front. An example analogy is a hotel booking process,...
1
vote
3answers
396 views

Pitfalls of Domain-Driven Design with Entity Framework

A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar). On the web there are also attempts by a few people to create ...
2
votes
2answers
41 views

Create a new class with minimal data VS. using original class and setting non-necessary data equal to 0 or null?

I am using Scala for my example but I believe this probably could apply anywhere. Say I am using a class somewhere in my project that reads in data from a live stream of events which monitors where a ...
1
vote
2answers
172 views

SOLID break class

I have a legacy class XMLReaderWriter which I think I should break into two classes so that it doesn't break the SRP. Unfortunately the class is already in production and I have to maintain backwards ...
46
votes
3answers
7k views

Using a “Pass-through (God) Service” is bad, right? [duplicate]

My team has developed a new service layer in our application. They created a bunch of services that implement their interfaces (E.g., ICustomerService, IUserService, etc). That's pretty good so far. ...
1
vote
1answer
64 views

Utils, Service class and Persistence Layer

I have a method in API handler which does API validation, performs business logic and then makes a call to db. Is it a good idea to move the business logic to utility class or service class? IMO the ...
1
vote
3answers
74 views

Class methods that are never called and everything handled by the internals of the class itself

I have a class in my code and I'm not sure if the design I've implemented is correct or if there is a better way to do it. The class I have created have important useful methods that is used by each ...
7
votes
8answers
341 views

Unit test which asserts that current thread is the main thread

The question is does it make sense to write a unit test which asserts that the current thread is the main thread? Pros/cons? Recently I've seen the unit test which asserts the current thread for the ...
0
votes
1answer
62 views

Java convention - Implementing two similar functions for two different objects

I have two classes, let's call them Foo and Bar. They both extend different classes (Foo extends X, Bar extends Y), which have some common ancestor "way up" the inheritance tree, something like this: ...
38
votes
5answers
6k views

Why inherit a class and not add properties?

I found an inheritance tree in our (rather large) code base that goes something like this: public class NamedEntity { public int Id { get; set; } public string Name { get; set; } } public ...