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

0
votes
2answers
81 views

Proper design for function doing one job but involving many little tasks

I have a class in Python that its only responsibility is receive text, a font path, max font size and min font size and print the text on an image if it fits. I have a function named word_wrap() and ...
3
votes
2answers
122 views

Proper design for models

I have a class called ReplaceRule this is used by 2 classes DocumentRuleViewModel and SectionRuleViewModel as a List<ReplaceRule> in both Question 1: In my database implementation I have 2 ...
0
votes
4answers
58 views

Returning cloned list and getSize

class A{ private List<Item> itemsList; public List<Item> getClonedItemsList{ return new ArrayList<Item>(itemsLIst); } public int getItemsCount{ ...
2
votes
1answer
121 views

Deciding the best way of modeling a timeslot or period of time for a schedule

I am making a sport events scheduler to calculate possible schedules out of initial data and configurations. There are three main domains: players, courts and timeslots. My question regards the latter....
0
votes
1answer
76 views

How to use link tables in backend code?

This is more of an open ended question regarding design best practice. Say I have two classes; one is a Vehicle, and the other is an InformationSource (for maintenance/repair information). An ...
4
votes
3answers
75 views

Verifying objects

If a method takes an object of class A as parameter and analyzes its properties somehow, performs calculations etc. to verify this object, is it okay for class A to have a boolean valid field? After ...
-1
votes
3answers
176 views

Modularity vs Polymorphism (OOD main concepts)

Booch gives 4 main concepts (principles) of OOD (see his book Object-oriented analysis and design with applications ): Abstraction Encapsulation Modularity Hierarchy Usually we encounter to these ...
2
votes
5answers
248 views

Constructor overloading or allow null?

Which is the preferred design to use, one constructor that allows null, or two constructors where one throws an ArgumentNullException on null? Two constructors with exception throwing public class ...
0
votes
0answers
43 views

How to save the differences between objects which are the result of random changes?

I keep a state object of the following form: class State { int num1, num2; List<String> strings; MyObject myObject; // A class I wrote // etc. } The state changes many times ...
1
vote
0answers
12 views

Refactoring Code into a MVC Pattern under the Constraint of a Library God Object [duplicate]

I have 1000 LOC that I plan to refactor into different files and functions. The goal is to be able to test the business logic independently from the visual display. Hence, I am considering an MVC ...
5
votes
1answer
153 views

Three classes and get methods

class A{ private List<T> list; public int getListSize(){ return list.size(); } } class B{ private A objectA; public int getSizeOfListInA{ return objectA....
6
votes
2answers
229 views

MVP (Supervising Controller) Does the view update the model?

I've been reading about MVP, specifically Supervising Controller. One thing I'm having difficulty wrapping my head around is how the View interacts with the Model. It was my understanding that the ...
1
vote
2answers
154 views

How to store state data when the data is related to another entity?

In order to increase the parallel-ability of my objects, I try to make them read-only and include only data that naturally belong to the entity. I have class Object { ... }; class Processor { ...
5
votes
2answers
110 views

Design pattern for too many ctor parameters within class hierarchy

Is there some design pattern for handling situation where class hierarchy constructors parameters force the most bottom classes to have too many parameters? Ideally this would be in C++, if language ...
-1
votes
1answer
102 views

Is there an official name for the “one object disease” anti-pattern (iterative single object operations on databases, services etc.)?

It is caused by the naive programming paradigm: focus on just a single object, do something with it, and if you have to work with many objects, you loop, iterate and traverse, repeating the operation ...
3
votes
4answers
238 views

Is Template Pattern a good way to implement DRY?

Here is my problem: I have and class structure like this: class Base { private: SomeType something; bool isSomeValue; public: virtual void myMethod() = 0; }...
4
votes
2answers
94 views

Should I use the same object for individual instances and collections?

One of the functions of an application I manage is to operate a fleet of vehicles. I have an object vehicle with which I can do tasks that are vehicle-related; getMileage(), setDriver(), etc. I also ...
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
238 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
73 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
52 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
54 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
692 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
118 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
72 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
301 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
72 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 can'...
0
votes
2answers
159 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
125 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
59 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
138 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
155 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
129 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 ...
5
votes
7answers
416 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
38 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
63 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
149 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
798 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 ...
38
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
140 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
115 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
90 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
132 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
173 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
108 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
202 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; } List&...
9
votes
8answers
829 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 ...