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

learn more… | top users | synonyms

4
votes
1answer
108 views

When to use traits, as opposed to inheritance and composition?

There are three common ways, AFAIK, to implement reusability when it comes to OOP Inheritance : usually to represent is-a relationship (a duck is-a bird) Composition: usually to represent has-a ...
2
votes
2answers
230 views

Best practice for using StringBuilder

I'm writing a camera control program which uses many methods for each of the different commands. One example is: public void CameraPan(int Id, string Direction, int Speed) { StringBuilder sb = ...
0
votes
1answer
58 views

Project structure for Web, Api, DAL and ViewModels

I have a ASP .NET WebApi and a Web Project. I'm about to create a DAL class library... Which will be my codefirst/POCO's or possibly edmx files. I'm wondering do I need to have another class library ...
4
votes
2answers
51 views

Referencing extendable ordinal numbers

I have a class that is basically a container (or composite) of 4 other objects. I'm trying to figure out the "best" way of referring to these objects, while still allowing it to be robust enough, so ...
2
votes
0answers
49 views

Mocking third party web service

I am working on a project to create a wrapper library which will be used to interact with a web service provided by the client's IT team. The reason for this library is that we interact with this ...
9
votes
4answers
676 views

How to argue against this “completely public” mindset of business object class design

We're doing a lot of unit testing and refactoring of our business objects, and I seem to have very different opinions on class design than other peers. An example class that I am not a fan of: ...
3
votes
1answer
115 views

Is it good practice to access database in mapping between object

Situation I receive message from a 3rd party, and these messages are use to create or update database information. Message and data to be updated can be de-serialize in object form, but are not ...
5
votes
1answer
71 views

How to design class with multiple modules

I have something like this Class App Module A Module B Module C Module D Each of the modules have a single responsibility and are pretty well encapsulated (public interface, private ...
1
vote
2answers
290 views

Multiple instance of the same class?

I have a class named "Category" to handle all the operations and data about my categories. Now, my class is created however I need to find a way to build an object for each of the categories in my ...
2
votes
3answers
71 views

Calculating a score and a breakdown of the score in different places - should I use the same methods?

I am creating a plugin that uses a metric to determine a score on one page and allows the user to click through to see a more detailed breakdown of the score on a separate page. The trouble is: I ...
0
votes
2answers
156 views

Should I create a new class?

Let's say I have a Car class. Objects of this class will be stored in a collection, and every object should know about other elements in the collection, because for each car there's a value to be ...
2
votes
1answer
123 views

Lower class count vs explicitness

To help with an application that manipulates and works from an XML structure to produce other information, I've created a class structure that closely follows the XML structure. So, the XML is: ...
0
votes
0answers
53 views

Test Utility in Spring: Singleton or Static

I'm working on Test Utility in a spring project, this utility contains a methods to convert an object to JSON object and vice versa..etc and I'm confused if it's better to make the methods as ...
1
vote
0answers
130 views

OOP - Modeling a Chat Design Review [closed]

Seeking thoughts on the following design. I know the design could be lot simpler if use Sockets. But I wanted to think of a design with pure POJO classes. User string id; string displayname; ...
1
vote
5answers
154 views

Can variable names match field names? [closed]

Microsoft suggested that variable names should not match field names. However I saw this extensively in Java (e.g., this tutorial), especially in setters and constructors. So, among these two styles: ...
0
votes
2answers
127 views

OO design: separation of concerns

I have a collection of classes which model Logical(Boolean) Expressions. There is a base abstract class LogicalExpression, and derived classes : UnaryLogicalExpression, BinaryLogicalExpression, ...
0
votes
0answers
39 views

Graphing Objects without invoking Domain Logic

I'm unsure of how to go about implementing a certain aspect of my objects. Given a model class that represents an object, with business functionality based on various events, how can we graph the ...
2
votes
0answers
79 views

Confused about how to 'design' my (leaflet.js) map application; OOP

I asked another question recently regarding constructors calling constructors in order to organise my code properly but the answers really ended up giving me more questions than answers (which is good ...
5
votes
7answers
408 views

Is it appropriate to not follow the O/C principle if you have unit test coverage?

I find it more convenient to 'modify'existing classes rather than extending them. Thus, I violate the open closed principle of 'not modifying the compiled and tested source code, instead extending the ...
3
votes
2answers
127 views

How do you handle sequentiallity in API's?

Consider a use case of the form: The system shows a list of potential filters (by name, by creation time...). User chooses a filter and supplies necessary parameters. System shows a list of ...
0
votes
1answer
37 views

Boolean flags in Presenters to control flow of execution

I can see people use boolean flags, especially in Controllers / Presenters, to control the flow of execution. For example, public void onButtonClicked() { hasButtonClicked=true // code here ...
2
votes
1answer
61 views

Initializing composite classes in Python

I am writing a Python system where I have a major class(PlayerModel) that has two another classes as members (StateModel and ActionModel). I was wondering, what is the correct way to initialize such ...
2
votes
2answers
133 views

Improving The Design Of A Simple Restaurant Client-Server Architecture (UML Diagram)

I have to design a simple server-client model for the billing system of some fictitious restaurant. After spending about 10-15 hours on the UML diagram, I haven't gotten that far. The main issue I ...
10
votes
1answer
769 views

Object lifetime invariants vs. move semantics

When I learned C++ long ago, it was strongly emphasized to me that part of the point of C++ is that just like loops have "loop-invariants", classes also have invariants associated to the lifetime of ...
37
votes
7answers
7k views

Why is chaining setters unconventional?

Having chaining implemented on beans is very handy: no need for overloading constructors, mega constructors, factories, and gives you increased readability. I can't think of any downsides, unless you ...
3
votes
0answers
130 views

Finite state machine menu design

I'm creating a FSM in python (it's a step sequencer and sample pad based on a Raspberry Pi 2). Right now there are two states and the third is the Menu. This is handled by a class System which ...
1
vote
0answers
109 views

Option<T> functional type implementation and scenarios

Have you ever being implementing Option<T> functional type? It is discussed here: https://app.pluralsight.com/library/courses/tactical-design-patterns-dot-net-control-flow/table-of-contents ...
2
votes
1answer
89 views

Message Mapper Design Considerations

Long question context, skip to tl;dr for the meat of it. I am designing an integration between two web applications, and have come to the conclusion that a message pattern would be an appropriate ...
0
votes
1answer
116 views

Can I enforce the overriding of GetHashCode() and Equals() methods for users of a generic container class?

I have a container class similar to the one below (with much of the logic omitted): class Container<T> { Dictionary<T, TWrapped> contains = new Dictionary<T, TWrapper>(); ...
6
votes
1answer
171 views

Software design: recommend approach to avoid slicing/type erasure here

Here is a concrete minimal example to formulate my question : In small ball game, you have a physics engine that moves the objects regularly: void move(set< PhysicalObject* > objets, Duration ...
0
votes
2answers
102 views

Which design pattern to choose when supporting multiple analytic tools?

I have spent quite some time learning all possible design patterns but I cannot find the ideal one for the following case. I am developing an iOS app where we are using multiple analytics tools like ...
9
votes
2answers
199 views

Programming to Data Oriented Interfaces

There is a portion of our codebase written in the following style: // IScheduledTask.cs public interface IScheduledTask { string TaskName { get; set; } int TaskPriority { get; set; } ...
9
votes
8answers
825 views

Designs and practices to guard against erroneous null entries from database

One part of my program fetches data from many tables and columns in my database for processing. Some of the columns might be null, but in the current processing context that is an error. This should ...
16
votes
8answers
3k views

Refactoring a long method which is based on large number of switch cases [duplicate]

We are using Java as a backend development language. One year back, we wrote a method which uses switch cases based on Enums values. Since we are continuously adding enum members and according adding ...
6
votes
3answers
1k views

How to solve circular dependency?

I have three classes that are circular dependant to each other: TestExecuter execute requests of TestScenario and save a report file using ReportGenerator class. So: TestExecuter depends on ...
24
votes
6answers
3k views

Is there a design pattern to remove the need to check for flags?

I'm going to save some string payload in the database. I have two global configurations: encryption compression These can be enabled or disabled using the configuration in a way that either only ...
2
votes
1answer
106 views

Pass request as argument to service client vs. pass service client as argument to request [closed]

I need a design recommendation: I have a class that send a http request via another class WebServiceHandler() I am hesitating between the following two implementations, which one to choose?which one ...
3
votes
1answer
110 views

Does my design break modularity and loose coupling?

I want to know if my implementation is modular and loosely coupled such that pieces can be replaced easily. Any concrete class that extends the abstract class HexGridLayout will be expected to ...
2
votes
2answers
112 views

Should the Vector type inherit from the Array type in an environment where both are first-class objects

I have created a programming language that is based on java for a personal project. The language already has generic classes and functions and the generics are completely compatible with primitive ...
0
votes
0answers
22 views

Which design pattern for interaction with miscoded project [duplicate]

I am actually working on JavaEE application (Spring, Hibernate). I have an old project which is not well coded. I have to not modify any line of code on it. And I have to add classes that uses this ...
5
votes
4answers
354 views

Dependency Inversion Principle and Hollywood analogy

Often DIP is known as the Hollywood principle: "Don't call us, we'll call you.". But doesn't always higher level module calls lower level module, whether there is dependency inversion or not? Then ...
1
vote
1answer
154 views

When should interface be owned by client?

In Agile Software Development: Principles, Patterns, and Practices, Uncle Bob talks about client owning the service interface. My questions are : Should client always own the interface or only ...
0
votes
0answers
100 views

Generic Type Parameters where one is itself Generic with a Type Parameter of the Other

I have a couple of classes with the following pattern that I am uncomfortable with. Is this the only way to do this, or are their other design patterns that would be more reliable. public class ...
2
votes
1answer
196 views

How to implement a facade correctly

I have read multiple websites on this topic but none of them gave me a 'good' solution for the problem I am having. The problem is described in the following (related) questions: How do I couple the ...
-2
votes
1answer
148 views

Is there a pattern to map a range of numbers to a string?

I need a function that will take the name of a town and return a specific range of numbers that is assigned to that town. I won't be using a database. The simplest way to do this is //Pseudocode ...
1
vote
3answers
142 views

How To Extend Parent Methods in Children Classes?

There is a parent class with a method which many children use but many children extend the method, what is the best way to extend it without violating DRY? Here are my 2 current solutions: 1: The ...
5
votes
1answer
103 views

Object-Oriented design to create Images in Python

I'm creating images with centered text. I use Python but I'm faced with many question regarding how to write my class. I know that A class must aim to do one thing and do it well. Well, the ...
0
votes
1answer
113 views

Should I hold an Id and the Item [duplicate]

Let's say I have a Customer which contains an Address class like: public class Customer { public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; ...
6
votes
5answers
1k views

Does this code solve the square/rectangle Liskov Substution Principle example?

I just wanted to check that I understand the LSP correctly and can solve it. I am taking the classic rectangle/square problem and attempting a solution: class Rectangle{ public $width; ...
3
votes
1answer
184 views

Why is abstract Decorator class needed in this example?

Why do we need ShapeDecorator in this design? Why can't we just have RedShapeDecorator implement Shape directly and inherit from Shape?