I want to create a "singleton-factory class" to retrieve my specialized objects. It is possible to create such a class and does it give me some performance surplus over a simpler solution like a static factory?
Or are there any other solutions?
This class would be a key component of a data intensive application dealing with constant dat...
Are there advantages to either approach? If I need to traverse List items and perform an action on each one, should I use the traditional foreach loop mechanism or move on to List.ForEach?
Matthew Podwysocki @ CodeBetter.com wrote an interesting article about the anti-for campaign. This got me thinking about the problem a loop is tr...
Martin Fowler's Refactoring discusses creating Null Objects to avoid lots of
if (myObject == null)
tests.
What is the right way to do this? My attempt violates the "virtual member call in constructor" rule.
Here's my attempt at it:
public class Animal
{
public virtual string Name { get; set; }
public virtual...
I was reading an article put together by Martin Fowler regarding Composed Regular Expressions. This is where you might take code such as this:
const string pattern = @"^score\s+(\d+)\s+for\s+(\d+)\s+nights?\s+at\s+(.*)";
And break it out into something more like this:
protected override string GetPattern() {
const string patte...
We have a solution with two different projects, one with the requirement that it be done using the .Net 2.0 framework. The other uses .Net 3.5, and we follow MVVM, though I suspect this is less about MVVM than good patterns.
The .Net 2.0 has several different objects (let's say of type Fruit) which could potentially require a different ...
Given a class hierarchy like this one:
a package tree
would it be a good idea to have a class that helps in creating the objects? E.i. a class with methods that correspond to each class that can be created (method equals() returns a CompareCriteria eg).
The advantage I see is that it would hide away the complex inheritance structure and ...
Hi,
Sorry I can't find a question answering this, I'm almost certain someone else has raised it before.
My problem is that I'm writing some system libraries to run embedded devices. I have commands which can be sent to these devices over radio broadcasts. This can only be done by text. inside the system libraries I have a thread whi...
Actually i'm pretty confused about this terms and how they relate to each other. A read something about every one of them but i don't uderstant the work flow..
DTO - Data transfer object - object to transport values
BO Business object - object in domain model. object to make Business logic with
POCO - no idea, i've read a definition on ...
I have lots of (hierachical) data that I show in a TreeView (could be around 20K items or more, including children items). The peculiar problem with my data is that each object shown in the treeview can exist in many treeview items. What I mean by that is that I might have an hierarchy like this one:
Item_A -> Item_B -> ItemC
Item_B ->...
What is the difference between strategy pattern and delegation pattern (not delegates)?
...
What is alternative patterns of using for Entity Framework ?
Some I know are:
"Plain" EntityFramework - aka Unity of Work
using (Data.Model c = new Data.Model())
{
var z = c.Users.Where(x=>x.Name=='John');
}
Repository pattern
//Model implements IRepository
User user = Model.Instance.Get<User>(u => u.Name == "John");
What else...
Say you have 5 or 6 variables in the model which a certain View is interested in, do you write different functions for each, such as
int a;
int b;
int c;
void setA( newA ) {
a = newA;
notifyAObservers();
}
void setB( newB ) {
b = newB;
notifyBObservers();
}
void setC( newC ) {
b = newC;
notifyCObservers();
}
Or do...
I've been trying to implement a singleton for shared data in an iPhone app, and I've used both the macro found here:
link text
and I've tried transplanting the code from the macro to straight .h/.m files and I can Build and Debug just fine, but once I try to run instruments I get an immediate crash with no helpful information (before t...
I don't seem to find this in usage scenarios for the visitor pattern (or maybe I don't get it). It's also not hierarchical.
Let's use an authentication example. A UserAuthenticator authenticates credentials given by a user. It returns a result object. The result object contains the result of the authentication: authentication succeeded,...
Alternate course is something when user doesn't do what you expected, e.g. key in wrong password, pressing back button, or database error.
For any programming project, alternate course accounts for more than 50% of a project timeline. It is important. However, most computer books only focus on Basic Course (when everything goes fine).
...
Hi Folks,
does someone knows some good examples for an PHP Application using those 4 "Layers"
ServiceLayer
-> Model
--> DataMapper --> DAO
Iam not sure if it makes sense, when i use such a design i have to do the following to create a new Record in my Database :
$servcie = new Service(new Mapper(new Dao));
$service->save($data)
th...
Which pattern could be used in web projects?
I am developing a wiki project with ASP.NET. In my structure every wiki entry could have
comments.
Which way is the best :
wikiEntry.AddComments(newComment);
wikiEntry.Comments.Add(newComment);
entryManager.AddComment(wikiEntry, newComment);
...
While reading a revision history here at stackoverflow I noticed a great usability pattern: a list of revision entries.
I like this approach since it is both easy to use and easy to implement. Now I'm wondering about a catalog of usability patterns for web applications.
...
In an ASP.NET MVC application implementing the repository pattern I am curious if it is appropriate to place non-data related methods in the repository if they still pertain to the general focus of a given repository. For example, suppose a ProductsRepository that has methods for adding and deleting ProductImages which have a partial rep...
In his book "Patterns of Enterprise Application Architecture", Martin Fowler talks about persistence patterns which are commonly found in software development and particularly in relation to ORMs.
Is there a pattern that Hibernate adheres to most closely?
...