0
votes
1answer
31 views

How to deal with interactions between many objects

I've been working on a game in my spare time. I'm pretty much done defining the primitives and until today everything was pretty well segmented and encapsulated but now it's come time to implement ...
-1
votes
0answers
43 views

Functional programming equivalents for the following [duplicate]

I am trying to make the leap from functional programs for "hello world" equivalents to more real-world applications. As I come from a Java world and have been exposed to all it's design patterns, my ...
3
votes
1answer
81 views

Adding field to the class at runtime - design pattern

Imagine your customer want's to have a possibility to add new property (e.g. color) to product in their eshop in their CMS. Instead of having properties as fields: class Car extends Product { ...
0
votes
1answer
139 views

Implementing a strategy pattern with dependency injection

Okay, so the goal here is to implement a strategy pattern that can be tested using any sort of automated testing tool. I've been struggling with this problem conceptually for a few weeks now and I ...
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
2answers
129 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
41 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 ...
1
vote
1answer
151 views

Good pattern(s) for pointing to mutable state

I asked this question once here, but believe the question was unclear. However I'm having a hard time extracting the general problem from my specific case. UPDATE: I've answered my own question ...
3
votes
3answers
198 views

OOP what is meant by object-to-object communication

I've been reading in basic concepts of OOP,as i'm trying to make this shift from transactional scripts to more oop manner in php, and i often come across this definition : An object stores its ...
3
votes
1answer
79 views

reloading singleton classes and dependency

I have a singleton object. It's a DAO that looks somewhat like this (pseudoish code): class UsersDAO { public usersDAO init(string sDSN){ variables.sDSN = sDSN; return this; } public ...
4
votes
4answers
294 views

How much effort should I invest in creating loosely coupled designs?

I am currently learning about design patterns. I think most people would agree that these patterns are great tools, but should be used with moderation and not as the answer for everything. Using them ...
1
vote
3answers
127 views

Does this in the Observer pattern count as composition?

In a classic implementation of the Observer design pattern, the subject has a list of references to all of it's observers, and each observer might have a reference to it's subject. Is this considered ...
1
vote
3answers
138 views

How do I evaluate if an Orchestration is the appropriate design pattern for a given problem?

Say that you're doing a code review, and you find yourself faced with an orchestration pattern: class OrchestrationClass { private Configuration _configuration; private DataStore1 _dataStore1; ...
3
votes
2answers
155 views

Is it an acceptable practice to Get a property, that involve parsing binary, that might throw an exception?

I have a property that is loaded lazily, any time after the ctor is called. It is possible that the binary that my property relies on is invalid. If invalid I might have to throw an exception. ...
1
vote
4answers
447 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 ...
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
2answers
119 views

Where should the ACL handler be called in a MVC architecture?

Thinking about Access Control Lists bound to a web MVC architecture, I have a doubt on where the verification should be done. Within Models? Controllers? FrontController? Imagine a multiple module ...
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 ...
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 ...
1
vote
3answers
204 views

Pattern for costly precondition check before acting

Let's say I have a method DoTheThing() which requires the precondition-check CanTheThingBeDone() to return true. The latter method is time consuming as it accesses the database. I'm finding it hard ...
1
vote
4answers
176 views

available methods change with object state

I'm programming a graph object which can be in either a mutable or immutable state. In both states, it has a get method, but only in the mutable state is the set method allowed. The transition occurs ...
1
vote
1answer
98 views

Factory method - when objects need information to get initalized

Lets look on a simple example: assume that I have three classes implemeting IPersonRepository: SQLPersonRepository, WebPersonRepository, InMemoryPersonRepository. I also have PersonRepositoryFactory ...
0
votes
1answer
167 views

Need an OOP pattern or strategy for “pluggable” property

I'm using OOP and MVVM in a WPF c# application. The goal is for the resulting object (data-bound to user interface) to accurately represent a product. One specific area of the product is highly ...
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 ...
14
votes
4answers
515 views

Is it possible to loosely couple an application to its framework?

Let's say I'm developing a web application. My first choice is to use PHP with Fat-Free Framework (F3) and MVC pattern. Next year, I might decide I want to switch to Zend Framework, or maybe even ...
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 ...
4
votes
4answers
395 views

.NET Programming and POCO classes

I was having a think tonight while pondering over some application I need to change and it got me thinking. Entity Framework Entities are POCO (Plain old CLR Objects) and models used in ASP.NET MVC ...
3
votes
2answers
274 views

Base class should have no knowledge of its subtypes?

What's the OO principle that states (in sum): A base object should have no knowledge of its subtypes. I thought it was Liskov Substitution but after reading that wikipedia article I don't ...
2
votes
2answers
312 views

Factory Pattern and/or Dependency Injection?

I understand the concept and can use both the Factory Pattern and Dependency Injection, however they seem a little at odds with each other conceptually. Is it a case of using one over the other? Or ...
1
vote
3answers
293 views

Problems with Facades and then evolution in software

I initially started a project with Facades and Polymorphism as a way to create simple extensible design following SOLID Principles. Here is a sample code: public interface IInterface { void ...
0
votes
4answers
368 views

Problem regarding DRY principle and Polymorphism

I have a class that is 99% identical to its counter part. Sample code goes below: public abstract class BaseClass { void Method1() { } void Method2() { } void Method3() { } public ...
1
vote
3answers
310 views

MVC is a GUI Architecture or a Architecture to GUI and Domain?

Fowler refers to the MVC, as a GUI architecture: There have been many different ways to organize the code for a rich client system. Here I discuss a selection of those that I feel have been the ...
1
vote
2answers
333 views

Design pattern to handle queries using multiple models

I am presented with a dilemma while trying to re-designing the class structure for my PHP/MySQL application to make it more elegant and conform it to the SOLID principle. The problem goes like this: ...
0
votes
0answers
49 views

Separating Db from business with Inherited classes using multiple views

I have a software that has a car model that will be used in different views (listing, ads, detail page, carousel, up sell widget,etc). class CarModel extends DbModel{ } I look for a "nice way" (a ...
2
votes
7answers
477 views

Is there a pattern to restrict which classes can update another class?

Say I have a class ImportantInfo with a public writable property Data. Many classes will read this property but only a few will ever set it. Basically, if you want to update Data you should really ...
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 ...
1
vote
1answer
2k views

Is the Entity Component System architecture object oriented by definition?

Is the Entity Component System architecture object oriented, by definition? It seems more procedural or functional to me. My opinion is that it doesn't prevent you from implementing it in an OO ...
1
vote
1answer
112 views

how to model a connection to a resource, with rudimentary event processing

For my simple MUD client I'm using Apache Telnet (no, not ssh). A mud client is a strange beast: Generally, a MUD client is a very basic telnet client that lacks VT100 terminal emulation and the ...
4
votes
2answers
697 views

How does MVC work with the principle “Tell, Don't ask”?

Procedural code gets information then makes decisions. Object-oriented code tells objects to do things. — Alec Sharp So, when a view wants to display some information that is suppose to be ...
1
vote
1answer
290 views

a lot of small objects - OO pasta [closed]

In the code I am working on, there are a lot of really small objects like: class HasFieldLameSetter { public: HasFieldLameSetter(field& p_):m(_p){} void set(bool p2) ...
1
vote
3answers
150 views

Force user to extend class or use configuration

What is better practice: force user to extend abstract class or make class with configuration? Eg. pseudocode: ClassA{ this.name this.weight this.height this.width constr(config){ this.name = ...
3
votes
3answers
322 views

Alternative inheritance paradigms in object-oriented design

My apologies if a variation of this question has been asked before, but due to its nature it is hard to search for. I am having a discussion with a colleague about object-oriented design, and it ...
2
votes
3answers
380 views

Parallel Class/Interface Hierarchy with the Facade Design Pattern?

About a third of my code is wrapped inside a Facade class. Note that this isn't a "God" class, but actually represents a single thing (called a Line). Naturally, it delegates responsibilities to the ...
2
votes
2answers
248 views

Programming structural question, controlling lots of states and specific transitions between states case by case

This is a theory question for me just to try and write better code. I am pretty new so hopefully I am using terms like state in the correct way. How I should be thinking about this problem? I am ...
6
votes
3answers
1k views

Does MVC pattern negate other design patterns?

So usually when working with the MVC you have a controller that controls the input a model that process it and makes it ready for the user and a view that display the "result" to the user. Now when ...
1
vote
4answers
463 views

Explanation of the definition of interface inheritance as described in GoF book

I am reading the first chapter of the Gof book. Section 1.6 discusses about class vs interface inheritance: Class versus Interface Inheritance It's important to understand the difference between ...
2
votes
4answers
147 views

Subclassing to change default settings?

I have a class called Timeline. I want to allow several defaults in my code, such as a Timeline with a Start event (The details are not needed. All that matters is that I have a class, and I want to ...
2
votes
1answer
177 views

choice of design for OO-linear algebra library

I'm writing a library for sparse linear algebra computations as a backend for my thesis work and I've come to a bit of a crossroads. I'm using modern Fortran (don't groan, it's had inheritance and ...
1
vote
3answers
318 views

Does non-virtual-by-default lead us to composition-over-inheritance?

There are some design guidelines about testable code in “The Art of Unit Testing”. The first one is “Make methods virtual by default”. I’m curious to know your idea about non-virtual-by-default ...