Tagged Questions

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

2
votes
1answer
42 views

DDD: Global unique identities vs surrogate

Let's start with an example: we have an entity: Book. It has unique identity: Isbn - a value object that wraps a String. This is an UUID. The Book entity also needs a surrogate id from the repo (sql ...
0
votes
0answers
33 views

DDD: storing additional data with the model

Our domain is operated within certain context. This context is described by some additional values, like a fooId - id that does not have a meaning in domain business, but it's more a flavor for the ...
0
votes
1answer
54 views

DDD: Alternative view of the Model?

I have a model class, let's say it's a Book. I need it to be displayed on the screen. I want to have an escaped version of it, so I do not need to escape fields manually. What should I do? I can ...
2
votes
3answers
128 views

Determining a class structure

I'm currently in the early stages of designing an e-commerce application. I'm working out some designs for my classes which have so far been fairly straightforward, but I've run into something of a ...
3
votes
2answers
154 views

Model object and additional attributes

I have a model e.g. Book. Besides 'natural' attributes of a book, I have some mandatory IDs I need to carry on, like companyId, groupId. They are related to which organization unit this book belongs ...
3
votes
1answer
196 views

How to store a potentially large amount of optional properties of objects?

I'm using Entity Framework Code First with ASP.NET MVC. This handles my database design based on the domain models within my application. As it stands, the engine I'm writing will have a website ...
0
votes
2answers
120 views

Should I have an object as attribute or primitive id?

I am wondering which principle should I use. Here is my situation. I have a class named TravelOffer. This class looks like this: public class TravelOffer { private final long id; private ...
0
votes
1answer
131 views

What should be in a PIMPL?

I am kinda trying to implement a windowing library in C++, the circumstances are forcing me to implement it all myself, that's not the point of this question however. My question is: What should be ...
-1
votes
2answers
129 views

Why is inheritance generally viewed as a bad thing by OOP proponents [duplicate]

I keep hearing the phrase "Favour Composition over Inheritance" from GoF which is being annoyingly mentioned repeatedly by my friend who thinks it is a valid blanket statement but is it not more ...
0
votes
1answer
109 views

Separating UI from logic

I'm trying to develop a little game and for this I'd like to separate the UI from the game logic. So I'm thinking of using an "Animator" class that will be responsible for rendering the objects, but ...
3
votes
0answers
117 views

Lightweight data modeling vs traditional classes [closed]

I've heard a lot of talk about using lightweight data modeling as of late. Especially in relation to the Clojure programming language. What is it and how it differs from traditional classes regarding ...
2
votes
1answer
53 views

Design Question - System Integration

Guidance on good application architecture / design is not in short supply however most of the examples focus on some business object, like Customer and its behaviour and persistence. There is little ...
1
vote
1answer
209 views

Designing classes the right way [closed]

I am trying to design my classes in the optimal way for the following scenario. A city has metro lines covering a number of stations.There are 4 lines represented by 4 colors.The user has to enter ...
2
votes
1answer
72 views

Is there a limitation when using the Bloch's Builder Pattern with mandatory fields?

Background I have a class TextDrawable which draws text on top of a shape. There are a number of properties that can be set while creating a TextDrawable object. Mandatory Properties: Text Shape ...
12
votes
2answers
2k views

Illegal in PHP: Is there an OOP design reason?

The below interface inheritance is illegal in PHP, but I think it would be fairly useful in real life. Is there an actual antipattern or documented problem with the below design, that PHP is ...
8
votes
3answers
644 views

Clean Code and Hybrid Objects and Feature Envy

So I recently made some major refactorings to my code. One of the main things I tried to do was split out my classes into data objects and worker objects. This was inspired, among other things, by ...
1
vote
2answers
125 views

Deriving from a class only to provide a special constructor

In our codebase, I encountered the following construct: There is a base class B, and then there is a class D which derives from B, but does not override or add any members. In fact, D is completely ...
0
votes
1answer
67 views

Logic based on modified fields of a Hibernate entity

I have a Hibernate entity object MyObject with several attributes and a service MyObjectService containing business logic dealing with MyObject. I also have a view model dealing with user input/output ...
26
votes
7answers
6k views

When writing object-oriented code, should I always be following a design pattern?

Is there a conceivable design pattern for any object-oriented program? I ask this because recently I saw an implementation of a Door class with a Lock. It was part of a test and the answer said that ...
1
vote
2answers
42 views

Class template specialization for implementing Automata

I'm implementing classes for simulating and generating different kind of automata. I'd prefer to use the same State and Transition classes for all the automata: NFA, DFA, PDA, etc. For a PDA a ...
-2
votes
1answer
190 views

Base Class, with method that returns Derived Class. design flaw?

I'm writing a Math equation solver in python (for fun). The first design that came to my mind: Expression: base class for every item in an equation (maybe bad name). BinaryExpression extends ...
1
vote
2answers
175 views

When should I refactor a private class into a package-private class?

When I began implementing a class in my system (let's call it A), I realized I needed some kind of object that does something. So I needed a new class (let's call it B), but I made it a private static ...
2
votes
4answers
480 views

When should something be a class? And are my chosen classes good OO design?

My background: I am new to programming. Python is my only programming knowledge. I program as a hobby, and I'm teaching myself by reading copious amounts of books. I understand enough about OOP to ...
1
vote
1answer
95 views

Ignoring the generic part of a type while an object is being passed

I have a message class that holds the name of a destination, and a generic variable acting as the message payload public class Message<T> { public string Destination public T Payload ...
2
votes
1answer
91 views

Should this interpretation happen in the Controller or the Model?

Imagine an application where the user is allowed to create his/her own musical scales. The user selects notes from a list, arranges them to a group and presses a button to create the scale. In an MVC ...
0
votes
1answer
113 views

Design pattern for modifying state and notifying the other modifiers without a loop

The idea is that I have a set of properties that represent possible options in the app. These options can be modified through a variety of different ways, such as from the UI, remotely, third party, ...
-1
votes
2answers
97 views

Class hierarchy question - do you implement separate classes for the same behavior? [closed]

NOTE: The language I am using is C#. I am currently working on a 'The Quest' mingame where there is a player and some enemies. My design so far involves a base abstract class called 'Mover' and an ...
1
vote
4answers
142 views

Is DDD not appropriate for my website or should I introduce a Query Layer?

I have inherited an ASP.NET website application and the previous developer has used what I believe are some DDD concepts. I am new to DDD and I have to admit I am struggling with the practical side of ...
2
votes
3answers
189 views

Is 'design with types first' ultimately the same as 'design with interfaces first'?

In Object Oriented Programming, we're taught to think in terms of Polymorphism (the idea that the implementation is decoupled from the interface - and that it makes sense to think of the interface ...
0
votes
2answers
177 views

Handling multiple packet types in Java 8

I have a Netty-based game server implementation that handles 40 or so distinct packets with their own serialization structure, for brevity I'll refer to them as FooPacket, BarPacket, ... These packet ...
1
vote
1answer
167 views

Basic PHP Object Oriented Design Review

I am attempting to learn object oriented programming by designing a simple web application related to the Catholic liturgical calendar. I have very little formalized training in programming, but I ...
4
votes
1answer
85 views

Is it better to put an event on the top object or closer to where it's local?

Take the following basic structured code for example: class Player { public QuestLog QuestLog { get; set; } } Let us consider that "QuestLog" has the ability to fire off some events when things ...
0
votes
1answer
99 views

The ViewController design in iOS vs MVC in tradiational web apps design

As I came from the background of webapps and move to iOS programming, I am wondering why we can't just apply the MVC design approach to native apps, i.e. in iOS, the view and controller are tightly ...
3
votes
1answer
231 views

Is my class structure good enough?

So I wanted to try out this challenge on reddit which is mostly about how you structure your data the best you can. I decided to challenge my C++ skills. Here's how I planned this. First, there's ...
1
vote
0answers
133 views

Why should ViewModel route actions to Controller when using the MVCVM pattern?

When reading examples across the Internet (including the MSDN reference) I have found that code examples are all doing the following type of thing: public class FooViewModel : BaseViewModel { ...
36
votes
5answers
4k views

Passing functions into other functions as parameters, bad practice?

We've been in the process of changing how our AS3 application talks to our back end and we're in the process of implementing a REST system to replace our old one. Sadly the developer who started the ...
5
votes
6answers
499 views

Requesting feedback on my OO design

I'm working on an application that creates music by itself. I'm seeking feedback for my OO design so far. This question will focus on one part of the program. The application produces Tune objects, ...
0
votes
3answers
145 views

How to change the state of a singleton in runtime

Consider I am going to write a simple file based logger AppLogger to be used in my apps, ideally it should be a singleton so I can call it via public class AppLogger { public static String file = ...
2
votes
2answers
601 views

One boilerplate class or many similar classes?

Lets say I'm trying to model a variety of objects that are virtually identical, the only difference being their class variables. Am I better off creating one boilerplate class and just calling the ...
1
vote
1answer
172 views

Design for object with optional and modifiable attributtes?

I've been using the Builder pattern to create objects with a large number of attributes, where most of them are optional. But up until now, I've defined them as final, as recommended by Joshua Block ...
1
vote
1answer
170 views

Passing in config values to a method using SOLID principles

I have an email helper class that has a method that sends email: private static class EmailHelper { public static void SendEmail(string from, string to, string subject, string message) { ...
2
votes
1answer
189 views

Poltergeist and factories [closed]

I've just come across the Poltergeist anti-pattern - and maybe it's because the morning coffee hasn't kicked in yet, but I read the description: a poltergeist (or gypsy wagon) is a short-lived, ...
0
votes
1answer
122 views

How to generalize a classes that has identical function plus some additional function

I have some designing problems with my project. To illustrate my problem, I'll use the following two classes from my project. public class RAM_UserManagement{ private Map<int,User> userList; ...
-4
votes
2answers
198 views

Is this a poltergeist or is it justified? [closed]

I've come to a point in re-design of my code where I face an imminent Poltergeist Anti-Pattern threat. A master application object has two "eye" objects. Eye objects have a "RenderHUD" function, which ...
1
vote
3answers
211 views

Is it considered bad practice to make a DAO call in an object's constructor?

I am trying to figure out the best design for instantiating an object which requires two separate calls to the data layer through a DAO. The object is not usable until these calls have been made ...
3
votes
1answer
84 views

When to declare @throws with a Scala annotation - abstract parent or concrete implementation?

In this StackOverflow question I asked about the behavior of the @throws annotation in Scala. Now that I understand how it works I want to ask about best practices with using it. Here's a repost of my ...
1
vote
5answers
187 views

Choosing a class abstraction when multiple viable approaches exist

I'm having trouble trying to design a class structure for some search functionality. It's quite possible that I'm approaching this incorrectly altogether, but putting that aside I'm curious how other ...
0
votes
0answers
89 views

What is a good way to structure my UI classes?

So, I have a program which has a swing GUI. (Java - duh!) I really, really don't think the way I'm structuring my classes now is good, so I am reorganizing from the ground up to follow best practices. ...
17
votes
11answers
2k views

When would you want two references to the same object?

In Java specifically, but likely in other languages as well: when would it be useful to have two references to the same object? Example: Dog a = new Dog(); Dob b = a; Is there a situation where ...
1
vote
1answer
141 views

Domain model for a notification system

I'm trying to build a modular notification service in a ASP.NET MVC web application. The application generates notifications and the service is responsible for delivering the notifications to the ...