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

1
vote
2answers
168 views

Trying to come up with a mapping convention for C# objects

so this is C# but it could apply to any OO language where different sets of objects exist across different layers of an application. We have been trying to come up with a convention within the team ...
1
vote
5answers
180 views

Coupling business logic with class definitions

Perhaps it is my scripting background, but my perspective is that the purpose of an object should be to contain data. Classes are necessary in that they provide templates and standard ways to classify ...
1
vote
1answer
54 views

Adding new functionality to all of shelve.Shelf's subclasses in Python

In order to avoid the overhead associated with the shelve module's writeback option I'm interested in putting together a shelf class that only accepts hashable values, with hashability being a proxy ...
1
vote
1answer
129 views

How to structure a program into classes [on hold]

So after a while of working in programming field I still haven't figured it out how exactly should programs be structured, in a large set I mean. Which I think it's also because of working in an ...
1
vote
3answers
257 views

Why shouldn't an object reference have access to a static member in C#

Context of my question: I am reading C#. Trying to understand Static keyword. I understand that when Static is applied to a member of a class, it can only be modified by the class and not the class ...
3
votes
2answers
95 views

System state design composition

Consider the following Java code: public class HumanStateImpl implements HumanState { private boolean alive; private Color skinColor; // getters and setters, other state fields ...
4
votes
3answers
144 views

Is it a good idea to return a default value if a field in a query cannot be found?

At the place I work we are using a SafeReader class that wraps an IDataReader. One of the 'features' is that if the field you are trying to access wasn't in the query then it just returns a default ...
0
votes
0answers
34 views

Reporting Logic vs Domain Logic

Should the reporting logic to extract domain data in a certain format reside in domain objects or separate reporting objects? The reporting logic needs to: select entities/data which match selection ...
2
votes
3answers
436 views

Functional programming strategies in imperative languages

I've been convinced for awhile now that some strategies in functional programming are better suited to a number of computations (i.e immutability of data structures). However, due to the popularity of ...
2
votes
1answer
170 views

How should object identification be managed?

I have a java/swing application in (hopefully good) MVC structure. Here is a overview of my model classes: One or more workers may work at one working location and one worker may work at different ...
1
vote
1answer
47 views

DDD with entities with no relations

Disclaimer: I'm not 100% sure I understand some of the practices and concepts in DDD, so this question may actually be answered by clarification of the ideas I'm working in a legacy system (written ...
1
vote
1answer
72 views

Should state machine with synonym states be shown explicitly?

I am new to state machine modeling and while trying to model a system, I have a question. An example will explain it better: Considering a system that does calling (probably a customized cell phone ...
0
votes
1answer
140 views

Technical example of modeling a domain with OOD?

Considering favoring composition over inheritance and looking at various design patterns there are multiple approaches to modeling a domain. Say you have some Entities which are very similar in some ...
0
votes
2answers
64 views

putting methods in base class that doesnt make sense/belong there [closed]

I've been lately thinking over design principles and patterns and a question did strike me. Let us say, I want to design a racing game. I want to design the classes for a variety of cars. each car ...
0
votes
1answer
159 views

Object Oriented Design of a Small Java Game

This is the problem i am dealing with. I have to make a simple game of NIM. I am learning java using a book so far i have only coded programs that deal with 2 classes. This program would have about ...
1
vote
1answer
85 views

Liskov substitution principle with abstract parent class

Does Liskov substitution principle apply to inheritance hierarchies where the parent is an abstract class the same way if the parent is a concrete class? The Wikipedia page list several conditions ...
3
votes
3answers
205 views

is it valid that a state machine can have more than one possible state for some transition?

I have a requirement for a workflow which I am trying to model as a state machine, I see that there is more than one outcome of a given transition(or activity). Is it valid for a state machine to ...
3
votes
3answers
251 views

How to safely copy an object?

This question is going to be a little long. Please bear with me. Something that happened in a project of mine made me think about how to safely copy objects. I'll present the situation I had and then ...
1
vote
1answer
200 views

Confused about implementing Single Responsibility Principle

Please bear with me if the question looks not well structured. To put you in the context of my issue: I am building an application that invoices vehicles stay duration in a parking. In addition to ...
0
votes
1answer
95 views

Should interface only be used for behavior and not to show logical data grouped together? [duplicate]

Should an interface only be used to specify certain behavior? Would it be wrong to use interface to group logically related data? To me it looks like we should not use interface to group logically ...
1
vote
2answers
150 views

Three variants of circular references between objects: how to choose?

I'm designing an object dependency graph of my program and one ambiguity between design variants appears from time to time. Imagine two objects having a reference to each other. Obviously, at least ...
2
votes
1answer
202 views

How to design the relation between a Game and a Player in a game?

I am currently attempting to make a Trading Card Game and I have got a whole array of features working already, yet I am stuck now at the portion where one player can attacker another player (more ...
0
votes
0answers
54 views

Import data and modify

I should build an importer in PHP. So below you can see how it should work or how it currently works. This is only a small example, the real importer is much bigger so the import() method is also ...
0
votes
2answers
97 views

Buyer vs Seller on UML Model

I'm modeling an Online Classified System where, naturally, who sells also can buy and vice-versa. The question is: should I have two different Actors, Buyer and Seller or I could have, say, an actor ...
3
votes
1answer
79 views

Access items of a container with a pattern

I've two C++ classes with a relation: a container class which has a list of items. For example a library has got many books. The classes are the library and the book. Now from the external world I ...
2
votes
2answers
76 views

static set and non-static get method

I've the following Interface. public interface ValueInterface { long getValue(); } And the class: public class ValueCreator implements ValueInterface { private static long value = 0; ...
0
votes
1answer
48 views

overriding implemented base class methods

I read somewhere that the chain of inheritance breaks when you alter a behavior from derived class. What does "altering a behavior" mean here? Is overriding an already implemented method in base class ...
6
votes
3answers
274 views

How to adhere to the open-closed principle in practice

I understand the intent of the open-closed principle. It's meant to reduce the risk of breaking something that already works while modifying it, by telling you to try to extend without modifying. ...
0
votes
3answers
90 views

Wrapping a map with instance or static method

I have a java.util.Map<String, Object> object which different types of values in it. I don't want to cast whereever I do a get operation over this. To do this, I created different classes ...
1
vote
3answers
105 views

Reason to treat internal class variables and functions inside a class as “separate” entities

Note: there is a similar question that addresses my subject: Better style for member variables? ... but that question does not address "dealing with large legacy code base and comprehension of ...
7
votes
4answers
256 views

Is inheritance that adds rules bad? [duplicate]

I got into a debate on this question which distilled to if it is a good idea for a specialization of a class to add business rules. Unfortunately this point got trampled in the comments so I'm asking ...
73
votes
13answers
6k views

Why would Square inheriting from Rectangle be problematic if we override the SetWidth and SetHeight methods?

If a Square is a type of Rectangle, than why can't a Square inherit from a Rectangle? Or why is it a bad design? I have heard people say: If you made Square derive from Rectangle, then a Square ...
1
vote
2answers
117 views

Describe business logic with diagrams

I am currently developing a web application for my thesis.I was asked by my professor to make diagrams to describe the business logic. Since I don't have a prior experience, I am pretty confused with ...
1
vote
4answers
130 views

Dealing with similar objects with different method signatures

I am fairly new to OO design and have problems with the design of some software and looking for a pattern or a combination of patterns that could help me solving my problem. I have a type that has a ...
5
votes
5answers
213 views

How to enforce implementation of interface to behave a certain way

Suppose you had the following interface public interface IUserRepository { User GetByID(int userID); } How would you enforce implementers of this interface to throw an exception if a user is ...
1
vote
0answers
118 views

Should we encapsulate everything in a try{} block in a Try object?

Why can't I make a class for a Try including what I try and then run that in the try {} block? Why is it impractical? class DBConnectTry extends Try { TryResponse response[] attempt(TryObject ...
5
votes
1answer
309 views

Design review: how well does my object oriented design fit the SOLID principles? [closed]

This thread will be long, but I will try to make it as short as I can. Thank you. I have recently implemented a relatively simple program. What this program does is generate a simple piece of music ...
2
votes
2answers
93 views

Is retaining intermediate objects as member fields a good idea in this case?

I'm currently writing a series of classes in java that are meant to translate a regular expression (written with the formal definition, not language-specific shortcuts) into a deterministic finite ...
0
votes
2answers
110 views

How to design this better?

I'm developing a system using .NET which will be used by multiple users. Because of that, I need to identify on the database which data belongs to each user. Explaining with an example, imagine I have ...
3
votes
1answer
100 views

Different scoring algorithms for different competition elements

I am creating a scoring system for a competition that is somewhat obscure, but it resembles the Olympics in terms of its high-level structure. Therefore, I will ask my question in terms of an ...
1
vote
3answers
128 views

Relative encapsulation design

Let's say I am doing a 2D application with the following design: There is the Level object that manages the world, and there are world objects which are entities inside the Level object. A world ...
1
vote
2answers
139 views

Can the DDD repository modify entity in the DB without an entity object?

Say I have an aggregate root Entity with some flags which are represented by an encapsulated object EntityFlags: class Entity { /** @var EntityFlags */ private $flags; ... } I have a ...
0
votes
2answers
50 views

Can I use a package visible constructor for creation?

I need a class where this can be done: // user program elder_tales.Player p = elder_tales.generate_player(); elder_tales.level_up_player( p ); but not: // user program elder_tales.Player p = new ...
0
votes
1answer
32 views

How to measure the quality of my use cases?

When I'm coding something I know that there are many ways to see if my code is good or not. First is testing: I can do unit tests or even test the software by myself and see that it works or not. ...
2
votes
3answers
189 views

Best Practices - separation of concerns and inheritance issues

Here's the situation: I have a "common" Data Access assembly that contains classes used in all my projects. Some of those are abstract classes that are only implemented by my data access layers for ...
0
votes
0answers
115 views

API Client Design

I'm designing a client to the Tomtom WEBFLEET.connect API in PHP. (You can read more about the API through the full documentation here: ...
0
votes
2answers
61 views

OO Design when using communication

I have 2 applications one is written in C++ and one is written in Java. the applications communicate by passing byte arrays which represent a serialized object. each communication object represent a ...
1
vote
2answers
106 views

System Communication: Avoiding Including a Large “HAS-A” Hierarchy Which Isn't Used

The situation: System A Huge, complicated system. Uses an important Message object with many other Message objects attached, many of which have further Message objects attached. In total, this is ...
2
votes
2answers
270 views

What should a repository really do?

I've heard a lot of the repository pattern, but I quite didn't understand what a repository should really do. When I say "what a repository should really do" I'm mainly concerned about which methods ...
51
votes
6answers
4k views

What really is the “business logic”?

I'm working with web development since 2009, when I started with PHP. When I moved to ASP.NET I've heard a lot about DDD and OOAD where a lot of focus is given to this "business logic" and "business ...