Hi,
I am working on a website script, and currently I have a front controller, which determines what to load (e.g. what modules/extensions and controllers) based on the URI. Is this a good approach? I'm using PHP if that matters. I'm just wondering if that's not the front controller's job...
...
I want to track changes in my domain model. I know that NHibernate ISession is an inmplementation of UnitOfWork pattern, so it tracks this changes. Is there any way to pull out them, for example, before Commit() or Flush()?
...
I m writing interfaces for new project and would like to get some advice.
I have a class that have a subclass and it has a subclass. The tree of this classes is like this:
Class Car
{
Wheels Wheel;
}
Class Wheels
{
Rims Rim;
}
So to simplify: one car has one wheel and one wheel has one rim. (cant make up other better example,...
We are attempting to only make available certain functions to be run based on what request address is.
I was wondering how we could do this:
if(condition1)
{
$(document).ready(function() {
...
...
// condition1's function
});
}
else if(condition2)
{
$(document).ready(function() {
...
...
We all agree that the db is for storage and that the code shouldn't be tightly coupled with it. How do you achieve this when you store preferences in the db. Let me give an example.
Suppose that you are creating a little online poll. Each poll can have a "vote type". Here are some vote types:
Anonymous Voting
Ip based voting
etc.
...
The following is a well known implementation of singleton pattern in C++.
However, I'm not entirely sure whether its thread-safe.
Based upon answers to similar question asked here previously, it seems it is thread safe.
Is that so?
//Curiously Recurring Template Pattern
//Separates a class from its Singleton-ness (almost).
#in...
I'm developing a website in ASP.NET MVC where I would like to show different sections of a view for users with different security levels. In essence, the views are the same, but users with higher levels of security must be able to see sections that shouldn't be seen by users with security levels above of, for example, administrators.
I ...
I have an array of objects, and want the objects to be able to reference their 'neighbors' (the next and previous objects in the array). Is there an existing pattern to do that?
Perhaps the array should be wrapped in an object (since the object can be iterated just as well as the array). That's fine too, I'm just looking for an existing...
Apple describes the architectural pattern used by iPhone apps as MVC. However, virtually no modern application uses MVC (as described by Trygve Reenskaug). Modern operating systems, including iPhone OS, inherently handle controller responsibilities. What is mistakenly and commonly referred to as MVC is actually MVP.
Why does Apple sa...
When programming for the iPhone, I find that I often need to use the same instance of an object in multiple views. What is the best way to handle this? My strategy so far has been to create it as a member of the root view and pass it to subsequent views which retain it as a member. However, this does not seem like a very good approach...
In a project at work we have a certain value type class in our domain model that includes a very large number of attributes...
public class BigValueType {
private Foo foo;
private Bar bar;
private Baz baz;
//...
}
We've realized that we would like to "focus" this into a number of different, somewhat more specialized c...
Is this a legit tool or is it a crutch that I will eventually grow out of needing?
Update: By order of operations, I mean:
launch app
read prefs
calculate value from prefs
write prefs to file...
Right now, I draw diagrams at the method level as well as the app level when I'm having trouble visualizing the program flow.
...
Hello, I have to design a Data Access Layer with .NET that probably will use more than one database management system (Mysql and Sql Server) with the same relational design.
Basically, it has to be simple to switch from one database to another so I would like you to recommend me some web-sites or books that has been useful for you, with...
The following Java design allows an object to be extended without changing its interface to clients. The object can implement additional extension interfaces. Clients can ask the object for extension interfaces that it implements. I read about it in a blog post, but my Google skills failed to find the blog post again. I'm not advocat...
let's say I have
public delegate DataSet AutoCompleteDelegate(
string filter, long rowOffset);
can I make the following class to enforce that method signature? (just a conjured up idea):
public class MiddleTier
{
[Follow(AutoCompleteDelegate)]
public DataSet Customer_AutoComplete(string filter, long rowOffset)
{
...
The following code is a simplified version of what I use for event dispatching. The essential point is
that there is a static_cast<T*> on the argument of a template functor and another class makes
sure that the argument passed to the functor is what the static_cast casts to.
struct AbstractArg {
virtual ~AbstractArg() { }
};
struct...
When using Null Object pattern, how would you 'check' if a situation is invalid?
for e.g
when there's no item found in the repository, display message 'not found' to the user.
Do I have to do a glorified null check?
if obj.equals(new NullObject()) { showNotFound(); }
if obj.ID.equals( INVALID_ID) { showNotFound(); }
Those techniqu...
Extended problem
I would like to add a new problem in addition to the original problem specified below. One of the user controls in the application contains a list of objects that I need to access from another user control. How can this be done? (I don't believe the division into controls is very well performed, but I'd rather not chang...
Suppose I developed a wrestling game where all wrestlers fight with each-other.
So I designed the classes and interfaces like the following:
public interface IWrestler
{
void Attack();
}
public class Sumo : IWrestler
{
public Sumo()
{
}
public void Attack()
{
Console.Write("Sumo attacked the opponent....
One way to increase your understanding of design patterns is to discover how patterns are used in the .NET framework.
Have you found any examples of design patterns in the .NET framework? In your answer please give a short description of the pattern, and example of how it is used in the framework.
Example answer:
The Strategy Design P...