I want to create a factory for creation of objects implementing an abstract interface, which would return a reference to the object that is kept internally, and objects are not replicated. The idea is pretty much the same as in the log4cxx/log4j Logger class design. I would also like to hide as much details from the client as possible, i...
Hi,
I have a template that renders a chart according to a given list (retrieved from my domain layer). This template is displayed several times (with a different list) on a same page (let's say "home page") and in several pages as well.
For instance,
<g:render template="/template/chart" model="order: 'asc', orderBy: 'age', max: 5, dom...
Being confused again after reading about this anti-pattern and the many concerns about it here on SO.
If I have a domain model and capture the data that must be persisted in a data transfer object, does that make my domain model a wrapper around the data? In that case I would be using an anemic domain model. But if I add enough domain l...
Hi all,
I have multimedia files and its metadata stored in a RDBMS (actually, the actual media files are stored in the FS, but let's not dwell on that).
I would like to present a filesystem view of this information, so that users can work using Windows Explorer and similar stuff on the database. I intend this access to be read-only, wh...
Hi all,
I had spend some time on this Bridge pattern example from wikipedia, however, i still do not understand what is this bridge pattern trying to explain.
interface DrawingAPI {
public void drawCircle(double x, double y, double radius);
}
/** "ConcreteImplementor" 1/2 */
class DrawingAPI1 implements DrawingAPI {
public voi...
Hello,
I never read any headfirst book. I just borrowed 'Headfirst Java' from my friend. I've conflicting opinions.
C'mon I'm not a kid or or idot so stupid that I have to understand things from book filled with pictures and all that dude language.
But its fun to read. I absolutely love those pictures. Even my little sister in 6th gr...
Hi,
I am writing the following program and I am thinking of a good design for it in C++
Problem:
I am writing a graph library. There is Graph<E> class.
Different graph algorithms have different types of information stored on the edges (Potentials, Cost, color, flow values, capacities etc.) For each algorithm, there is a different Edg...
Whenever I find myself needing to serialize objects in a C++ program, I fall back to this kind of pattern:
class Serializable {
public:
static Serializable *deserialize(istream &is) {
int id;
is >> id;
switch(id) {
case EXAMPLE_ID:
return new ExampleClass(is);
//...
...
I am looking to make a networked board game based on Risk in C++. My idea was to have a central server which hosts a game lobby where users can connect and make/join games. The Observer pattern seems attractive in this case, since I could host all the game model/logic on the server, and the clients would just be observers to this and dis...
I'm working on a simple, internal ASP.NET app for a small company. I've designed the data access layer so it's database-agnostic.
I have the following:
IDataHelper - An interface requiring
methods such as FillDataTable(),
ExecuteNonQuery(), etc.
MySqlHelper - Implements IDataHelper
for MySQL, the only database I
support so far.
Stati...
How do you organize and manage your helper objects like the database engine, user notification, error handling and so on in a PHP based, object oriented project?
Say I have a large PHP CMS.
The CMS is organized in various classes. A few examples:
the database object
user management
an API to create/modify/delete items
a messaging obje...
Usually I do all what I can inside a class, in every method (try and catch). Am I doing it wrong? Recently I heard better way is handle error in program body...
What is good habit?
...
Hello, and thanks for any assistance
For:
public abstract class EntityBase
{
protected void Create(EntityBase c)
{
Log.Audit(c);
}
}
public class Customer : EntityBase
{
public void CreateCustomer(Customer c)
{
Create(c);
}
}
}
public class Car : EntityBase
{
public void Cre...
I have a class which has a member object (class variable). This object has some events. I'd like to expose these events directly in my class. What is the best way to do this?
...
Is there a way to use Flyweight objects with the hibernating persistence mapping? My data model contains many objects that will be the same. Instead of having a separate instance for each of those same objects I'd like to use the Flyweight Design Pattern and reference always the same physical object. How to achieve this in hibernate?
Bt...
I'm working my way through Fowler's Analysis Patterns and programming examples for myself in Clojure as way of developing a better understanding of both.
Putting persistence/durability issues to the side for the moment[1], it seems that Clojure refs with their synchronization would be the obviously best approach.
On the other hand, giv...
I studied few functional languages, mostly for academical purposes. Nevertheless, when I have to project a client-server application I always start adopting a Domain Driven Design, strictly oop.
A complex solution written in a .Net framework could get advantages using more than a language and sometimes more than a paradigm. Mixing C or ...
I have a User class in the model and need to send a password reminder email.
Does the controller instantiate a User and pass it (or values from it, rather) to a Email class in the view? In which case, would the controller then do the actual sending of the email?
Or would the controller call User::sendEmail() and there not even be a vi...
Hello,
I have an already existing order class with many properties and methods. I need to now create a suborder class which is a subset of the order class. It not only has many of the fields that order class has, it also would have many of the same calculation methods maybe with one or two lines of difference in some places. The orde...
What is the best method for using singleton design pattern in conjunction with the factory method pattern in PHP5? My simplest usage scenario for this is instantiation selective database connection only once for each database type.
...