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.

2
votes
0answers
111 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 ...
1
vote
3answers
158 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 ...
3
votes
2answers
112 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
418 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)) ...
2
votes
2answers
191 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
75 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
169 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
220 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
230 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
124 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
136 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
118 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
264 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
230 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
217 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
87 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
78 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 ...
5
votes
3answers
119 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
56 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
95 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
81 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
379 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
126 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
195 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
191 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
123 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
83 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
196 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
47 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
239 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
45 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 ...
3
votes
2answers
167 views

How to design users class

I have been developing Cloud Broker system so I have Users. Users can register with phone number and code. How should I design the User class? Class User { public string User_Name{get;private set;} }...
2
votes
0answers
76 views

Creating bindable input handler in C++ spanning two separate modules

I have a wxWidgets application. This is the first, main module. The second module is an openGL engine. It's a model-view-(controller) structure, where application is the view (and the controller), ...
0
votes
1answer
116 views

Variable vs value in a user interface label as a method parameter

Imagine I have updated a user interface label with a value. Since this is a label, end user cannot update the value directly and can only be changed through code. Lets say the value is X. X could be ...
2
votes
0answers
62 views

Memento and releasing resources

Let's suppose we have a class whose state has to be saved and later restored, and we resorted to the Memento pattern for that. What if the state includes resources that have to be explicitly ...
2
votes
1answer
162 views

Designing a pause'able & resume'able task handler

I don't think the title describes the situation exactly. I apologize for the poor description. I'm trying to write a software system, in C++, that will have a heavy job (scanning the file system for ...
0
votes
1answer
101 views

Memento for inherited class

I have the following question. I have an abstract class that manages graphic elements. Let's call it GraphicHost. Something like that: class GraphicHost { class GraphicHostState { List&...
3
votes
5answers
315 views

Using a variable to indicate object type

The use of instanceof or getClass() is largely considered code smell. Is using a variable to indicate the type of object you're using also considered code smell? Suppose if I had an enum called ...
0
votes
2answers
122 views

When methods could be applied to more than one object

I was reading on this slide show presentation about Elder Scrolls 6. The author writes: Add some different directions to swing your weapons, more tactical options, feinting, parrying, literally ...
2
votes
2answers
153 views

Input based data fetch optimization

Is there a cleaner/ better readable way to maintain and iterate many-many mapping rather than multiple if conditions ? (One way would be to store the mapping of ReportType -> DataSet Req. in the ...
1
vote
3answers
221 views

Rethinking inheritance when subclass implements interface

Suppose if I have an abstract Weapon class, and the subclass ReloadableWeapon which implements the interface Reloadable. interface Reloadable { void Reload(); } public abstract class Weapon{ @...
1
vote
1answer
88 views

How to define a system class?

My course notes have stated that a system should have a system class which coordinates the behaviour of all other objects in the system and should be one which is instantiated only once. In many ...
2
votes
2answers
72 views

Is ER model used in database design and software design the same thing?

ER model appears in both database design and software design. I was wondering if ER models in both designs are the same concept? If not, what are their differences? Thanks.
0
votes
0answers
212 views

Preferred way to implement protobuf-based classes in Python?

I'm working on a distributed application that will use protocol buffers as it's core interface definition language. While am amazed how pleasant protobufs are to work with in a networking context I'm ...
0
votes
0answers
81 views

Game Model Architecture?

Just for background, this is a project using Swift and GameplayKit. I've dealt with MVC and simple design patterns and architecture. Shout out to this thread(What architecture should I use for my game ...
1
vote
1answer
74 views

Resolving Higher/Lower level component dependency

I have a .NET application (actually this can be a problem for any N-Tiered application) which has 3 separate components. ClassLibrary Has Cross Cutting Concerns like logging, authentication and IoC ...
7
votes
6answers
1k views

How to know when to use dependency injection?

The question might sound a little weird, and I guess it is. I'm came up with the question while browsing through some design patterns. I came to the notorious state / strategy pattern and I came up ...
1
vote
1answer
97 views

How to fetch data based on id from isolated code cleanest way?

I'm working on client-server application. Client architecture (class hierarchy) looks like this: System (name is of course different, more descriptive) - represents whole system Module A - a class ...
0
votes
0answers
48 views

Creating a central repository for repositories with related data?

I am building a website for a fruit company. In my database I have a list of countries, and for each country, a list of distributors that sell my fruit products. The country and distributor are ...
0
votes
1answer
231 views

Subclassing a Singleton class

When do we need to subclass a Singleton class or in other words, is it good to subclassing a Singleton? If its generally allowed what would be the pros and cons and how to handle or get instance from ...