Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
30 views

How to apply Single responsibility principle on spring MVC architeture?

Since service class will handle all business logic together, how do I separate the service class to fit the Single responsibility principle? It looks like they are opposite principle.
0
votes
3answers
123 views

Calculating the total price of items in a shopping cart

I am making a shopping cart. A shopping cart will have a total amount of money you've got to pay for the products you've selected. I'd like to approach the problem using both OOP (encapsulating it) ...
-1
votes
0answers
13 views

What architecture or design pattern fits for a API serving an application as retrieving data from content management system?

I want to create an app that gets data from content management system and serves an API to another app for using the content. So too many parsing objects and maybe manipulating them before serving in ...
1
vote
1answer
62 views

The main reason for using the command design pattern for game AI

I've been going through all the design patterns in context of game programming form this book, before starting my next big project. Apart from that I've been reading about them in more general context....
0
votes
0answers
12 views

Best way to design federated contribution and consumption of java modules

The problem I am trying to solve is, I am trying to write a platform where people can write and contribute certain tasks (java code following a contract to identify it as task) to the platform. And ...
7
votes
5answers
293 views

Information Hiding v.s. Static Type Safety

I'm working on a project with others and we have a discussion about information hiding and static type safety. Our scenario is described below. Language: C++11 Scenario: We want to create a tree-...
0
votes
1answer
61 views

How to model either relationship?

I am working on a project where a user can send email to either a contact from his directory (Internal) or type an email address explicitly (External Contact) or a mix of both. We also show the read ...
0
votes
2answers
73 views

In which layer should a microservice should send a message to another microservice

In our monolith application, the piece of code that used to handle sending SMSes and emails was written in our business layer. Now the responsibility of sending emails and SMSes is handled by a ...
0
votes
1answer
64 views

Design issue with delegation, inheritance and dependency injection

My question relates to usage of delegation together with inheritance and dependency injection. I have a MailerService class that requires a delegate in order to do its job. Furthermore, I have a ...
3
votes
2answers
108 views

Clarification about an example of the polymorphic open/closed principle

My question is regarding the polymorphic Open-Closed Principle. Say I have the following client: public class Client { private Server server; public Client(Server server) { this....
2
votes
3answers
214 views

Why is the Command desing pattern useful for game AI?

I'm trying to learn the Command design pattern and apply it to the game I'm working on. First I read about the general implementation, and I feel like I understand it pretty well. Now I want to know ...
4
votes
1answer
324 views

Why do we imlpement the Command design pattern like this?

I trying to learn the Command design pattern, I already know how it works and where it is used, but I'm a little bit confused about the implementation. So I know we need to set the context by ...
1
vote
0answers
52 views

How to represent a set of ephemerides?

I am writing software that deals with ephemerides—tables describing the positions and orientations of celestial bodies or spacecraft—and I am struggling with how to represent them in the ...
0
votes
1answer
79 views

Orchestrating Object Instantiation and Intercommunication

We have a C++ project managed by UML software, which generates code for instantiating and passing data between objects. Unfortunately, this software adds a lot of overhead to our builds and ...
1
vote
0answers
69 views

Expected behavior from client when thinking about design patterns?

I'm confused about the behavior I should expect from a client when thinking about design patterns. To be more precise, I'm reading the Head First Design Patterns book, and on the difference between ...
1
vote
2answers
205 views

Liskov Substitution Principle

I am trying to wrap my mind around a Liskov Substitution Principle and I came across this article. SOLID Class Design: The Liskov Substitution Principle In this article, the author gives an example ...
0
votes
1answer
79 views

How to interpret Dependency Inversion Principle

I am working on trying to understand the SOLID object oriented design principles. I was able to get the "SOL" pretty easily, though "L" required some hand holding because I am bad at definitions. I ...
2
votes
0answers
99 views

Is this an example of cyclic dependency?

I'm an undergraduate student and I have this assignment on a Discrete Event simulator. Currently I have completed to the end of v1.2 here. Attached also, is an algorithmic overview. I have wrote my ...
-2
votes
0answers
25 views

Should subscriber contain application logic?

Should subscriber/listener contain application logic? For example my subscriber is listening Post object for send mail. Manage for sending (setting the recipient, sender, subject and content and ...
0
votes
0answers
53 views

What would be the downsides of creating a derived interface of interface?

Would there be any downsides of creating sub-interfaces for virtual member functions that have different parameter types? A drawing of this is shown in the image attached. Apple and Orange do not ...
2
votes
2answers
94 views

How do entities, DTO, DOA work together and what’s their role within a system?

Most of my work is written in Java using Spring Boot. In a recent project my entities contained no business logic, Spring Data was used to handle repositories and I have service classes that ...
0
votes
2answers
162 views

What's the difference between Observer pattern and listeners?

I have used some kind of "listeners" where I have an interface implemented by classes that need to be notified of some event (e.g.: CurrencyListener, with a method currencyUpdated(Currency currency)) ...
0
votes
0answers
36 views

How to design my site solution correctly

I have a website that consists of users (more about the types below) and vacancies. Users can subscribe to vacancies and contact other certain types of users. While organizations and governments can ...
2
votes
2answers
182 views

What is the correct usage of the IEnumerable interface in C# to deal with collections?

When I am working in ASP.Net MVC or WebApi, I often find myself creating Views or return data structures that include 'List<>'s of objects. Meaning that I have a list of data objects that I want to ...
1
vote
3answers
73 views

Should a property be in an abstract class if not directly used

I have an abstract base class that is inherited by several different other types. They were all using a type injected into their constructor. So I moved this property in to the abstract base class. ...
1
vote
1answer
160 views

to ISP or not to ISP?

I've got a design problem, and I figure it's not something totally uncommon so there must be some good practices out there. I have 2 domain entities: Process and Task. A Process is essentially a list ...
4
votes
1answer
214 views

Is it worth considering State pattern in this case

I've got the following state diagram that can be seen in Webgraphviz: digraph reload_states { rankdir=LR; size="8,5" node [shape = doublecircle]; Requested; node [shape = circle]; ...
1
vote
3answers
227 views

Why using methods for database queries instead of raw queries?

What's the reason behind making methods for database queries instead of allowing raw queries? for example get(...)->where(...). Guess1_ We're repeating ourselves otherwise(DRY) ---> I don't think ...
0
votes
2answers
114 views

How to handle state of an object? And how to enrich the state transition logic?

I am designing a class that has a state. I wonder if I should expose that state in the interface in view of allowing a decorator to enrich the state transition logic. Shall my design expose ...
2
votes
1answer
129 views

OOP Encapsulation Philosophy

Is it fair to say that it is good practice to default everything to private up when defining a class? For example, for my public interface I would set my class something like this: class foo { ...
2
votes
2answers
110 views

Strategy/domain object responsibilities

Assume we are in the world of car rental application :) Let's say that I have 3 types of cars with 2 categories of price: Car type Price category ------------------------------ Sport ...
6
votes
4answers
246 views

Passing around large value objects vs converting to smaller value objects

Let's say I have a project that needs to do the following: Multiple calls to read from the database where each call is a different query and returns back a value object (just has getters/setters). ...
2
votes
3answers
211 views

Should a class constructor ever create objects of other classes? [duplicate]

Is it ever good or bad to have a constructor create new instances of classes that it needs versus passing in a reference that you want the new class to have ? So basically it's the difference between:...
3
votes
2answers
131 views

Are there any problems with using class variables in Java that can be accessed by any method?

So I've been coding in Java for a decent amount of time, but recently, I've started a class that cares about my coding design. In the past, if I had two methods inside a class that needed to edit the ...
1
vote
1answer
77 views

Where to put intermediary business logic in a backend

Consider you have a GravityLogic and a WeakForceLogic class. In themselves both provides tons of business logic. Now you want to create interactions between those which produce a complete different ...
0
votes
1answer
61 views

What is the correct granularity for events in the context of designing a rule-based decision system?

Introduction We need to design a system that, given a set of events that are happening in the source application, reacts to them and if some conditions have been met, actions can be triggered. Users ...
2
votes
1answer
56 views

How to untangle a data class where annotations from different frameworks mix?

The framework mix problem I'm using two frameworks -- PingIdentity's SCIM 2 SDK and Spring LDAP -- to deserialise a SCIM resource (i.e. JSON) to a Java object then write it to an LDAP directory, and ...
0
votes
0answers
50 views

Factory methods for converting one tree of objects to another

I have a tree of objects that I need to convert to a similar (but not isomorphic) tree of other objects and the creation logic is quite complex. The object types are in a hierarchy where only the ...
0
votes
0answers
93 views

How can I gracefully handle this addition of animation?

I have the following setup in a GUI library I'm making (for fun). Ignore the colors and positions being integers, it's just to serve the purpose of illustration. // Example program #include <...
1
vote
0answers
65 views

What Design Pattern to use to render PDF pages for a PDF Proposal?

I want to create a set of patterns to use for rendering a PDF Proposal (a set of PDF pages). I have made a good start, but not clear on how to proceed when more complexity is involved. I am using ...
1
vote
3answers
348 views

Is an OS kernel a singleton?

In my understanding, a singleton design pattern is where we have only one instance of an object in a system. I am not sure on this part of the definition, but I believe in an OS there is only one ...
0
votes
2answers
122 views

Pattern name for a class inheriting of a generic based on itself

I'm wondering if there is a name for the pattern of defining a generic class with one type argument where the type inherits the defining class. For example public class A<T> where T : A<T&...
3
votes
2answers
157 views

Object Oriented vs. Procedural Processes in Embeded System

I'm currently developing a controller for an industrial application which takes data inputs from various sensors and interfaces (ethernet, serial, etc.), does some minimal processing, and adjusts ...
2
votes
2answers
142 views

Which design pattern for combination of objects in Java?

I am looking for the best approach to design the following system : I have a class of object, called Compilers (C, Go..Etc) I have another class of object, called Protocols (HTTP, RPC, WEBSOCKET..Etc)...
4
votes
3answers
122 views

Create a single class to map different object to a target object?

I have a service (S) that receives an object of type 's', this service will be called by several classes (maybe 6) and each class has their own object a,b,c, etc. with the information necessary to ...
1
vote
2answers
56 views

Is NSNotification in iOS a good design?

Because of some essential C++ libraries, I have to mix Objective-C and C++ in my code. But the problem is that the callback between C and Objective-C is extremely hard to design and manipulate, so I ...
0
votes
1answer
103 views

Should services be used in a ViewModel

So I have a service which is injected in my controller via dependency injection. I can either use it in the controller multiple times to convert a value when assigning to a particular property in a ...
-1
votes
1answer
46 views

Best OOP practices for object accessing “aggregate object” members?

Is there a best practice for something like this? (Example in C++) class A { public: int usefulParameter; std::vector<B*> bContainer; }; class B { public: void ...
2
votes
5answers
235 views

How to pass command line parameters to various parts of program

Consider a large program with many different parts that have a single command line interface, as is the case with most applications. How best do I handle passing various command line parameters, that ...
0
votes
0answers
43 views

Check if exists user_id when create user

I have User class class User{ public User(string id){ this.User_Id = id; } public string User_Id{get;private set;} } When I create User in Application Layer.I am checking if exists any user ...