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.

9
votes
2answers
1k views

In DDD, is a Domain Service essentially just a Facade and/or Mediator Pattern?

In Domain Driven Design, the Domain Layer can have several (traditional) services. For example, for the User domain, we may have: A UserFactory, that builds User objects in different ways A ...
0
votes
1answer
199 views

A term to describe the opposite of “an extension of a class”

Say we have a class "Felidae", and a class that extends it, "Felis". Felis is an extension of Felidae, but what is Felidae? Is it the inheritor (or inheriter) for Felis, in common terminology? Given ...
1
vote
4answers
190 views

How to refactor this legacy code snippet to make it extensible? [closed]

I've come across a method resembling the below snippet. public void process(Data row) { Value value1 = row.getValue1(); Value value2 = row.getValue2(); boolean saved = false; if (...
13
votes
2answers
2k views

Stack extending LinkedList. A violation of Liskov Substitution Principle?

A class LinkedList exists with functions such as add_first(), add_last(), add_after(), remove_first(), remove_last() and remove() Now there is a class Stack that provides functionalities such as push(...
1
vote
2answers
809 views

Design pattern to force client of a class to call a method

I have a large class with complex properties. I'd like to introduce a default implementation, allow the user to override part of the default implementation and also make sure the user calls a sync ...
9
votes
5answers
1k views

Is it a violation of the Open-Closed Principle to update a constant representing a real-world value?

I have a class calculating workers' net yearly income. It has a constant representing a tax percentage. But one day the tax rate has changed, so I need to fix the code. Does the act of fixing this ...
2
votes
0answers
233 views

Balance between aggregate boundaries and domain consistency in DDD

Designing an Aggregate and choosing an Aggregate Root getting tricky for me all the time especially when it comes to ensuring right transactional contexts and consistency constraints so I'm wondering ...
1
vote
1answer
163 views

Design pattern for modeling a PC

I have a type of "PC" (i.e. personal computer) that I need to model in C++ (can use language standards as new as C++11, but no newer than that). In short, we have a lot of granularity for components ...
7
votes
1answer
1k views

Updating nested objects in DDD Aggregate by example: delegation or direct access from the root?

The example domain problem There is a student attendance tracking system that keeps records of student attendances of ExerciseGroups. Course is a top-level component, AR, describes a generic info ...
5
votes
1answer
184 views

Where to add the role based access logic in domain model aspects? For Library Management System

The biggest difficulty I am having is finding where to house the responsibilities of each object identified by me in the system( say on problem space). I am posting a very simplified description of a ...
4
votes
1answer
204 views

Is this contract on an API user is inevitable?

I am designing a UI framework in Java. Every UI component, represented by the class Component, in the framework is identified by a non null unchangeable String key. So I get the key in the constructor ...
-5
votes
1answer
180 views

Finding object relationships [closed]

Description Its a follow up question of writing use cases. Taking from nouns defined in my user story and requirement I found the following candidates to be classes: User Question Session Attempt/...
0
votes
1answer
168 views

Which creational pattern should be applied in this scenario?

This is the scenario in which I have to apply some creational pattern. Build a fleet of 10 cars with the following features. Five cars should have all the features and five should be built without ...
4
votes
3answers
248 views

Architecture for a Customer/Project/Quote/Order system

I am working on figuring out the architecture for putting together a complex modular system that has Orders, Customers, Projects and Quotes. The customer can have multiple projects. For each project ...
3
votes
1answer
189 views

Best design for classes that draw objects but do not inherit from JPanel

I'm doing the exercise 10.1, page 476 from the book Java: How To Program, Early Objects by Paul and Harvey Deitel (10th Edition). Modify the MyLine, MyOval and MyRectangle classes of GUI to create ...
2
votes
2answers
149 views

Is Chaining of Composition the right approach?

I'm working on some code where the structure looks like: Class A { Client client; B b; void process(request) { data = fetchData(client, data); b.process(data); } } class B { C c; ...
4
votes
4answers
385 views

Is it better to generate a large list during the constructor or when it's accessed?

I've got a class member function that generates a large list and puts it into a private member variable so it can be accessed through a getter. The generation of this list is a rather intensive ...
0
votes
1answer
120 views

Workaround for overriding a limited set of methods of an interface

I have an interface that has ~30 methods and has two different implementations. I am trying to create another implementation which will have some custom logic and at times it will call one of those ...
2
votes
1answer
81 views

How to add extra functionality to an existing method class dynamically with DI?

I am looking for the best pattern to apply in my problem. I have an interface that defines my service class functionality interface NegotiationInterface { abstract public function ...
0
votes
2answers
109 views

How to the refactor the following parallel code to avoid redundant checking?

In the following code sample, the processes are assigned to different contexts. And each App object will be bound to only one context. Though all the processes run the same code, only those belonging ...
3
votes
2answers
628 views

Design pattern for applying different taxes based on many different factors

I've been given the task to design a system that has a product's price have different amounts of different taxes based on different factors. For example in the US you would get a few - one based on ...
3
votes
1answer
80 views

How to parse two file where one file contains the values of variable in another?

I have two files : file1 : contains the value of the variable. file2 : contains collection of steps (subset of collection of file1 ) to follow. Step contains the set of instructions. - > ...
1
vote
2answers
177 views

Design Pattern for a weather rating feature

I am in a software engineering class and I need to pick a design pattern to use for a 'feature'... I have two features, and one of them is to have a feature where a user can enter a zip code and time ...
1
vote
1answer
570 views

Limits of dependency injection

I use dependency injection with Guice and most of the time, I'm rather happy with it. But sometimes, it's difficult to get the dependencies to where they're needed and sometimes, it's plain impossible....
3
votes
1answer
842 views

Can a class achieve abstraction without implementing an interface or extending an abstract class?

I've read a lot of definitions of abstraction and how it is achieved in programming languages such as Java and C++ using interfaces (Java only) and abstract classes. I understand that abstract ...
-1
votes
1answer
87 views

Should I have one class with multiple variables and a TYPE variable or a few subclasses?

I am developing a web based vehicle tracking application. Clients buy GPS devices and the company I work for mounts it on their vehicles. The client then gets a user name and a password for the ...
2
votes
2answers
159 views

Is it better to build three separate dialog boxes for separate functionality (add/edit/delete item) or one that can do all three? [closed]

I have made a custom DialogBox that accepts a key in the constructor then sets itself up based on the key. It functions as a box for adding editing or deleting objects depending on which key is ...
0
votes
2answers
186 views

State ownership cover everything for a class to be thread safe

As mentioned by Java_author, When defining which variables form an object's state, we want to consider only the data that object owns.... In many case, ownership and encapsulation go together—...
0
votes
1answer
62 views

Design tables and models for shipment and changes and keep it normalized

Our company buys second hand valuables (item) from clients and resell them for them. In order to do the client comes to our site and ask for a shipment he may choose the time that the delivery man ...
-2
votes
2answers
316 views

Understanding design patterns using Arrays.sort() [closed]

If we have an array in Java like this- int[] arr = new int[10]; Then, it's sorted like this- Arrays.sort(arr); Instead of this, if we had a LinkedList- LinkedList <Integer> ll = new ...
5
votes
3answers
493 views

Refactoring and documenting a big monolithic system

I have started working on a new project and to my surprise its written by a single developer with almost no tests at all, the remaining tests are either buggy or feel error prone throwing a lot of ...
29
votes
3answers
5k views

What happens with methods' tests when that method become private after re-design in TDD?

Let's say I start developing a role game with characters that attack other characters and that kind of stuff. Applying TDD, I make some test cases to test the logic inside Character.receiveAttack(...
3
votes
2answers
152 views

Separating Read / Write Responsibilities of a DB

We're working on a reporting system which has a clear write and a read path. For example writes will only happen after consuming events from a queue and reads will only happen when serving requests ...
0
votes
4answers
162 views

Java object containing non related member variables [duplicate]

I often end up with methods with long number of arguments (up to 5 arguments). for ex - public void doSomething(obj1, obj2, obj3, obj4, obj5) obj1 to obj5 are unrelated to each other I thought of ...
2
votes
3answers
97 views

Finding object responsibilities while designing a book reader

The biggest difficulty I am having is finding responsibilities of each object identified by me in the system or so called problem space. I am positing a very simplified description of a book reader. ...
-5
votes
1answer
82 views

Will you call this pattern an Abstract Factory Pattern or Factory Pattern

Problem Statement: Write a program to build a house, house can be of the following types: Apartment, Individual House, Bungalow. Kitchen is customizable: ItalianKitchen, ModularKitchen, ...
0
votes
1answer
162 views

The usefulness of java util classes to call a service (to create a model) as opposed to using that services's impl

Example I will explain the paradigm below but I am specifically talking about Liferay's Service Builder code for anyone who knows that platform. Basically in Liferay you can definite a model and it'...
2
votes
2answers
526 views

Does Strategy pattern involve modifying every subclass?

Consider a super class Animal, inherited by multiple subclasses(Dog / Bird). On their instantiation, objects have their local state & behavior: wiki says: The strategy pattern defines ...
3
votes
2answers
209 views

Difference between composing Factory and inheriting

I'm reading about "Factory method" design pattern from "Head First Design Patterns". So, there is a class public class PizzaStore { SimplePizzaFactory factory; public PizzaStore(...
0
votes
1answer
85 views

Modify variable from different libraries

I am working on a legacy C++ code with two libraries. Library1 is the main and Library2 uses classes from Library1 (so there are some #includes "HeaderFromLibrary1" in Library2). Deep in the code of ...
1
vote
2answers
70 views

Set return method to boolean to determine if next method should execute

I am curious on if this design is considered good or bad practice. I have a dispatcher and a service class. Dispatcher I have the following: public void doBeforeUpdate(Map<Id,sObject> ...
0
votes
2answers
58 views

Class For Summarised List Of Complex Objects

Assume I have a class that represents a complex domain object with dozens of properties, such as a pension policy. The GUI lists all pensions in a summary table that only contains a small subset of ...
0
votes
0answers
179 views

How to make a proper argument manager for CLI Software?

I thinked about an ArgumentManager class working like this: A constructor with argc & argv(or std::vector) as parameter. getCount() => Returns argc. getArgLit(argLit) => Return true if the ...
1
vote
1answer
245 views

Should I be creating more objects in Java?

I am very new Java and have been messing around with a program that essentially prints a random line of characters based on random char values and array manipulation. I am having a lot of trouble ...
6
votes
6answers
1k views

Coding to Interfaces vs Abstract Inheritance

Inheritance vs coding to an interface is something I have wondered with respect to proper architecture design but actually have not run into an problems when using abstract inheritance over coding to ...
3
votes
2answers
118 views

Maintaining unique id for a number of entities

Description: Given an aggregator portal the user must be able to create, read and update the requested entity. The entity here are all of different types and live in different systems. The portal ...
6
votes
4answers
605 views

Properly re-design from Switch to Polymorphism (Open/Close principle)

I'm having major troubles trying to get rid of this switch statement. To put a little of context first, I'm working with asynchronous batch operations. These operations can be applied to any entity in ...
0
votes
1answer
139 views

Best practices for data deprecation

I have inherited a 10+ year old project that has been handed down through many developers. Needless to say, there are many instances where there is some class or object property that no one knows what ...
0
votes
2answers
338 views

How to design an architecture of a system as described by Uncle Bob? [closed]

As per the "Software Architecture" explained by Uncle Bob, your architecture should be able to defer the framework and DB related decisions as much as possible. Consider an example of a Payroll ...
0
votes
1answer
22 views

Design for record linking coordinator

I'm a summer intern at a small company tasked with developing a prototype for a (contact) record linking microservice. After some googling I understand that the first step should be cleanup / ...