3
votes
1answer
170 views

OO design choice and single responsibility principle

I'm currently refactoring an application which periodically downloads content from various sources (http, ftp, sql, etc). There is a schedule which controls the times during which the application can ...
1
vote
2answers
122 views

Using the Decorator pattern to add public methods to an object

The Decorator pattern is usually used to extend the functionality of an object by extending one of it's current methods. To illustrate, please consider an object object and a decorator decorator. ...
-1
votes
0answers
59 views

Java: Singleton Event Driven Design [closed]

I have a singleton class ( I make this as immutable ). This class is present in the base module. It has a static method getInstance() which will initialize a new object based on the data stored in a ...
-2
votes
0answers
58 views

What are the benefits of decoupling the View from the Model? [duplicate]

I have recently learned about the MVC design pattern, and have created a small application implementing it. I've been thinking about the MVC concept and it's benefits, and currently I think that ...
0
votes
1answer
122 views

Singleton: Why is a global point of access bad? [duplicate]

Most people here and on StackOverflow agree that Singletons are evil. The main explanation I've come across against the use of Singletons, is they fact that they provide a global point of access to ...
2
votes
2answers
130 views

Refactoring sought for replacing shared data types in .NET component

I am in charge with updating a software product that is made up of two components the Controller process and the UI process. The Controller and the UI communicate via XML messages. Furthermore, the ...
0
votes
1answer
112 views

MVC in a desktop application - can the View ever hold a reference to the Model?

(I'm specifying this is a desktop application so people wouldn't refer specifically to web implementations of MVC). The title says it all pretty much. In an MVC structure - can the View ever hold a ...
3
votes
2answers
149 views

MVC design decision: two controllers or two models? [closed]

I'm planning to create a small program for simple encryption and deciphering of text. Both the deciphering mode and the encryption mode use the same GUI. I think an MVC structure would be very ...
3
votes
0answers
188 views

Dependency Inversion Principle: Understanding how both low level components and high level components depend on abstractions

I'm learning about the Dependency Inversion Principle. It states that: High level modules should not depend upon low-level modules. Both should depend upon abstractions. For a while I tried to ...
4
votes
3answers
281 views

Dependency Inversion Principle vs “Program to an interface, not an implementation”

I'm trying to understand how the Dependency Inversion Principle differs from the "program to an interface, not an implementation" principle. I understand what "Program to an interface, not an ...
1
vote
2answers
86 views

Initialization of objects in a system using dependency injection

This is a follow up question to the following post: Injecting dependencies (DI) in c++ applications In a system that uses DI, someone, somewhere should be responsible to create the various objects ...
2
votes
2answers
150 views

Injecting dependencies (DI) in c++ applications

I am playing with dependency injection, but i am not sure I am doing it right. Especially, I am not sure what should be the correct way to build classes with injected dependencies. Say I have a class ...
1
vote
1answer
41 views

Removing dependencies on subclass-specific behavior

I have a Message class which can contain multiple types of payloads (or sometimes no payload), each derived from a common Payload class. However, this becomes problematic because the Message class ...
0
votes
3answers
129 views

Need advice on design in Ruby On Rails

For personal educational purposes I am making a site for a conference. One of the object that exist in a conference is a session, which has different states and in each state it has slightly different ...
2
votes
4answers
274 views

Understanding “programming to an interface”

I have come across the term "programming to an interface instead of an implementation" a lot, and I think I kind of understand what it means. But I want to make sure I understand it's benefits and ...
4
votes
1answer
203 views

Which relationship is more natural?

Have a quick question on how to best structure something for my Java project: I'm a user. I can work at one or more places. At those workplaces, I have one or more roles. For each of these roles, I ...
2
votes
3answers
247 views

Empty virtual method on base class VS abstract methods

I couldn't find a question that was not too specific to some case, so I'll try to make this very generic. We need an extractor base class to a set of documents, for example. Each document has its ...
1
vote
4answers
449 views
+100

How do I deal with global variables in existing legacy code (or, what's better, global hell or pattern hell)?

So... We have this fairly big project (~5k LOC, but there's duplicated code so it's hard to tell) with literally hundreds of global variables. The project has more dependencies on other projects, and ...
6
votes
3answers
342 views

Are “Stocks” a TDD/Unit testing anti pattern?

From Martin Fowler's Mocks Aren't Stubs he states that Stubs provide canned answers to calls made during the test while Mocks objects pre-programmed with expectations which form a specification of the ...
2
votes
2answers
161 views

Pattern for multiple datasources

I've already read this question on CodeReview. I was hoping for general advice. I'm writing a service which will go to numerous data sources. Each source requires getting copious amounts of data ...
0
votes
1answer
561 views

Is this proper OO design for C++?

I recently took a software processes course and this is my first time attempting OO design on my own. I am trying to follow OO design principles and C++ conventions. I attempted and gave up on MVC for ...
1
vote
3answers
152 views

Should I consider loosely-coupling for class methods as well? [duplicate]

I'm a fan of Dependency Injection, however I don't know how much both public and private methods inside a class should be loosely-coupled. Just to picture it better, when I have both projectId and ...
37
votes
9answers
3k views

Do we need Logging when doing TDD?

When doing the Red, Green & Refactor cycle we should always write the minimum code to pass the test. This is the way I have been taught about TDD and the way almost all books describe the process. ...
18
votes
2answers
2k views

How to improve upon Bloch's Builder Pattern, to make it more appropriate for use in classes that may be extended and sub-extended many times over?

I have been greatly influenced by Joshua Bloch's Effective Java book (2nd edition), probably more so than with any programming book I've read. In particular, his Builder Pattern (item 2) has had the ...
4
votes
2answers
282 views

What is Component Oriented Programming, and how is it different from OOP? [closed]

What exactly is Component Oriented Programming, and how is it different from Object Oriented Programming? Thanks
2
votes
2answers
289 views

Front controller in PHP

When you are reading about web application development, "front controller" and "single point of entry" are frequent words you are confronted with. To my understanding, the point is to provide a single ...
2
votes
1answer
108 views

What design route should I take?

So I've taken on a project at work that I'm having a hard time attacking, and I'd love some feedback and suggestions. I work for an online retail store where we have an old, +7k-line script that we ...
2
votes
1answer
65 views

scoping concern when dealing with coupling

I'm learning ruby (and OOP in the process) and I find keep having to write the same patterns when logging progress so I want to wrap this up in a logging library that my other code can then just pass ...
0
votes
2answers
126 views

Best way to display domain object summary information efficiently and in an OO way from a large inheritance tree?

I've provided only simplified code as it's more of an abstract design question. So I have many, many nested business/domain event objects, e.g. public class Event { //bunch of properties and ...
14
votes
2answers
615 views

Which is better: a bunch of getters or 1 method with a selection string parameter?

Our knowledge domain involves people walking over a pressure-recording plate with their bare feet. We do image recognition which results in objects of the 'Foot' class, if a human foot is recognized ...
5
votes
5answers
507 views

Martin Fowler's Refactoring book: switch statement is using other object's data, why is that bad ? A deeper explanation is sought for.

In the code sample below the Rental object is using Movie's fields to do a switch statement. Martin says : this is a bad idea but he does not give any deeper explanation as to why ? Of course, you ...
1
vote
1answer
137 views

Optimizing mindmaps by finding the least amount of redundancy

When using mindmaps, you order them based on how you think it fits best. So for instance (tab means subtree) requirements dinner food forks spoons breakfast food forks this ...
2
votes
3answers
240 views

Framework in which views are defined in the database - design flaw or reasonable?

I'm working with a framework where the fields displayed on each web page are defined in the application database. Administrators can add new fields to pages or hide/completely delete old fields. The ...
5
votes
2answers
356 views

Game server code design

I'm designing a multiplayer game server where the players are in rooms. Right now I have classes to take care of the client, networking, etc. I'm struggling however to find a design for this Room ...
0
votes
1answer
104 views

Why aren't Entities allowed to reference other entities inside an aggregate except the root?

I have read in several places this following rule concerning Aggregates: Entities in one aggregate can hold references to any other Aggregate Root, but never to an Entity or Value Object inside ...
4
votes
1answer
158 views

How can I structure my code when I have orthogonal arrays of features?

Example: You have a game with different schools of magic (fire, ice, etc). Each school has a set of properties that pertain to independent features of the game, such as: strings to be displayed on ...
0
votes
3answers
131 views

Design for a template class

I have an abstract class abstract class MathFunc that is used to implement the mathematical functions Rastrigin, Griewangk and Rosenbrock in their specific classes final class Rastrigin extends ...
5
votes
2answers
365 views

Is this a correct implementation of an Immutable class in Java?

public final class ImmutableClass { private StringBuffer name; public ImmutableClass(StringBuffer name) { this.name=name; } public StringBuffer getName() { return ...
4
votes
1answer
165 views

OOP, domain models, and the user

When developing domain models, I can see two major ways of thinking about the user: The first one assumes that a program is a kind of "simulation" of what happens in the real world, and the user is ...
2
votes
5answers
434 views

Good design for a recreation of pokemon

I'm currently working on a group project to recreate the original Pokemon Yellow version in Java. We've only just started planning it out but they way we've drawn out the design right now is to have ...
4
votes
5answers
495 views

How to model an address type in DDD?

I have an User entity that has a Set of Address where Address is a value object: class User{ ... private Set<Address> addresses; ... public setAddresses(Set<Address> ...
1
vote
3answers
413 views

C# vector class - Interpolation design decision

Currently I'm working on a vector class in C# and now I'm coming to the point, where I've to figure out, how i want to implement the functions for interpolation between two vectors. At first I came up ...
4
votes
4answers
285 views

Should single purpose utility app use a class

When writing a small utility app, that does just one thing, should that one thing be encapsulated in a seperate class, or just let it be part of whatever class/module is used to start the application? ...
3
votes
3answers
152 views

Help with design structure choice: Using classes or library of functions

So I have GUI Class that will call another class called ImageProcessor that contains a bunch functions that will perform image processing algorithms like edgeDetection, gaussianblur, contourfinding, ...
3
votes
2answers
215 views

Semantic coupling vs. large class

I have hardware I communicate with via TCP. This hardware accepts ~40 different commands/requests with about 20 different responses. I've created a HardwareProxy class which has a TcpClient to send ...
2
votes
5answers
163 views

Designing a single look up entity

In almost every application you have this look up entity that provides a dynamic references. This are things like type, category, etc. These entities will always have id, name, desc So at first I ...
2
votes
4answers
138 views

How to handle status columns in designing tables

How to handle multiple statuses for a table entry, for example an item table may have an active, inactive, fast moving, and/or batch statuses. And I wanted to handle them in single column with VARCHAR ...
5
votes
4answers
447 views

How do I decide to which class a method should belong

I have TopicBusiness.class and PostBusiness.class. I have no problem with deciding into which class methods such as addPostToDatabase() or getAllPostsFromDatabase() should go. But what about ...
6
votes
4answers
515 views

Rails: Law of Demeter Confusion

I am reading a book called Rails AntiPatterns and they talk about using delegation to to avoid breaking the Law of Demeter. Here is their prime example: They believe that calling something like this ...
0
votes
0answers
18 views

Rails: The Law of Demeter [duplicate]

I am reading a book called Rails AntiPatterns and they talk about using delegation to to avoid breaking the Law of Demeter. Here is their prime example: They believe that calling something like this ...