Given a domain object (say, for example, Person), should that object contain its Data Mapper (Person_Mapper)?
For example, I could have an inactivate action work in these two different ways:
$mapper = new Person_Mapper();
$person = $mapper->load(1);
$person->active = false;
$mapper->save($person);
Or like this:
$mapper = new Perso...
I'm trying to decide whether it is better to use static methods for loading/saving objects, or use constructor/instance methods instead.
So, say for object Project, the instance version would be
public Project(path) { // Load project here }
public void Save(path) { // Save project here }
And the static version would be
public static...
I am currently working on rewriting an application to use Data Mappers that completely abstract the database from the Domain layer. However, I am now wondering which is the better approach to handling relationships between Domain objects:
Call the necessary find() method from the related data mapper directly within the domain object
Wr...
Me and a colleague designed a system for our customer, and in our opinion we created a nice clean design. But I'm having problems with some coupling we've introduced. I could try to create an example design which includes the same problems as our design, but if you forgive me I'll create an extract of our design to support the question.
...
I want to create a static class in PHP and have it behave like it does in C#, so
Constructor is automatically called on the first call to the class
No instantiation required
Something of this sort...
static class Hello {
private static $greeting = 'Hello';
private __construct() {
$greeting .= ' There!';
}
p...
I'm designing a new application and I'm undecided if I should fill my object properties on the constructor
Public Sub New(UserId as integer)
' get database values
dr = DataReader
Me.FirstName = dr.fields(0)
Me.LastName = dr.fields(1)
End Sub
Or create a factory with a method for each object type?
Public Function getUs...
Just finished read this post by Greg Young, where he is talking about Microsoft recommending patterns with dumb data transfer objects. He implied that in the Java community, things are trending the other direction.
My question is how much logic should be in your entity objects? Our philosophy where I work (C# shop) is that if you can't ...
I'm looking for something similar to the Proxy pattern or the Dynamic Proxy Classes, only that I don't want to intercept method calls before they are invoked on the real object, but rather I'd like to intercept properties that are being changed. I'd like the proxy to be able to represent multiple objects with different sets of properties...
I have a tree control in my GUI (with naturally lots of GUI/platform specific functions to handle the nodes).
I have a data model with its own complex set of nodes, children, properties etc..
I want the tree to display a representation of the model, be able to send messages to the nodes inside the model and be told to redraw itself when ...
I have a requirement to save an image file in various formats.
The list of formats is subject to change quite often, so I wish the saving would be very extensible.
Also, the saving can take place in many places (hard disk, ftp, http, etc). The list of saving locations is going to change very often too.
I thought I would use a base Image...
I need to get the spring application context from a non bean object. In another thread in SO, the accepted answer suggests to use singleton to get the application context.
Getting Spring Application Context
But using singleton makes my code more coupled and less testable, the usual problems discussed in many threads (e.g. What is so bad...
Hi, I am having problems with implementing Observer pattern in my project.
The project has to be made as MVC in C#, like a Windows application.
In my domain model I have for example Country class and Country repository. I have a Country controller and views for seeing all countries(a list on a form), adding new country, and editing exis...
Does anyone know a good example of EventBroker/EventAggregator pattern implemented in ASP.NET application?
...
Aren't Design Patterns an extension to OOP principles? Why are these two concepts treated separately? Can we believe that if someone who knows Design Patterns would definitely be an OOP expert?
...
I've been interested in the Blackboard pattern for years (especially back when I was studying AI), however I still haven't been able to find a good implementation of it outside of academia, although it seems a very useful pattern for the current trends in software development, I can't think of any big framework built around the pattern.
...
DUPE: http://stackoverflow.com/questions/105049/what-are-the-best-design-patterns-books-you-have-read
I'm looking for an extensive list of books on Design Patterns. What are your favorites?
...
I need to write the code that would format the value according to the specified options.
Right now there is several formatting options that can be chosen: rounding/truncating the number with the specified precision, added prefix (e.g $) or postfix (e.g. %), grouping thousands (applying commas), adding numeric abbreviations (KMB).
So e....
I’ve been researching the difference between these two patterns.
I understand that facade encapsulates access to a sub system, and mediator encapsulates the interactions between components.
I understand that sub system components are not aware of the facade, where as components are obviously aware of the mediator.
I’m currently using...
When i see Update(),Fill() method of DataAdapter object I always think Is DataAdapter use facade pattern ?
It looks like behind the scenes It will create Command object, Connection object and execute it for us.
Or DataAdapter use Adapter pattern because it is adapter between Dataset and Comamand object ,Connection object ?
...
The JsonResult class is a very useful way to return Json as an action to the client via AJAX.
public JsonResult JoinMailingList(string txtEmail)
{
// ...
return new JsonResult()
{
Data = new { foo = "123", success = true }
};
}
However (at least according to my first impression) this really isn...