When programming in PHP I always try to create meaningful 'models' (classes) that correspond to tables in the database. I often encounter the following problem:
Assuming that I've created a database with two tables: authors and blogs, which both have a corresponding model in my application.
Let's say I want to print all the blogs along...
I've run across a number of cases where a pattern for accessing items in a keyed collection (like a dictionary) is encumbered by the fact that the type of the key is not a simple type (string, int, double, etc) and isn't something that you would want to promote to an actual named class.
C# 3.0 introduces the concept of anonymous types ...
In abstract factory you declare a type which is responsible for creating objects.
This would prevent requiring switch's like this:
if( type == ONE ) {
doOne();
} else if( type == TWO ) {
doTwo();
} etc.
Or the same:
switch( type ) {
case ONE: doOne(); break;
case TWO: doTwo(); break;
etc....
}
In...
I recently ran against a very interesting site that expresses a very interesting idea - the anti-if campaign. You can see this here at www.antiifcampaign.com. I have to agree that complex nested IF statements are an absolute pain in the rear. I am currently on a project that up until very recently had some crazy nested IFs that scroll...
I have got a method that takes a long time to complete and want to check regularly whether it is done. This is what I have come up with (simplified code, Delphi 2007):
type
IWaitForDone = interface
function IsDone: boolean;
end;
function TSomeClass.doSomethingThatTakesLong: IWaitForDone;
begin
Result := TClassThatDoesIt.Creat...
I have a control flow graph representing a single procedure of my intermediate language code. Nodes and Edges are annotated via vertex/edge properties and contain instructions resp branch information.
Now I want to perform data flow analysis on this graph and feed that graph into each data flow analysis module. Each module should be ab...
What are the relative advantages / disadvantages of chaining classes together (or rather; using the results of one class to generate another), compared to nesting classes?
I'm trying to restructure my user / authentication system and am wondering whether;
myAuthClass should act as a utility and if log-in is successful, simply create a...
I have a set of screens in C#/ASP where the user enters information. It's broken up into multiple parts to make it more user friendly. It used to be in separate pages, but that was very difficult to manage, as all the info is very related. So it was changed to be panels in one page that we show and hide based on the user's progress. ...
Hi:
When .NET 2.0 came out I was very impressed by the Provider Factory pattern used for several of the services that were rolled out at that time...and started using it everywhere.
But then I ran into real troubles with it:
On CE, there was no config system, so it couldn't easily be ported to that environment (and therefore causing...
In Chapter 14 of Designing Web Interfaces, authors Scott and Neil define the 'Periodic Refresh' pattern and cite Digg's DiggSpy as a canonical example.
I agree that the pattern and its manifestation are excellent ways of serving real-time information to the user.
I'm facing a similar challenge. I'd like javascript (and jQuery) to conti...
We all know the great book about design patterns known as Gang of Four, and the Patterns for Enterprise by Fowler.
I would like to propose this wikified question to collect unusual software patterns for obscure and nice situations, spanning procedural programming, functional programming, OO and AO programming. Give your imagination and ...
How can I abstract my database from my application so that it is unaware of the database type?
I have to design a .Net 3.5 WPF application that must support either SQL Server or Visual FoxPro as the data repository.
My design goals are to:
make the type of data repository invisible when writing code in the Data Access Layer
make it as...
I'm on a team that will use the Microsoft .NET Chart control, and want to build something that will allow us to plug in data and render the chart as a PNG. This will be saved to a binary HTTP stream (we won't be using the built-in Charting HTTP handler).
I don't want to hide any of the advanced features (since there will inevitably b...
In the application I am developing I am facing a situation; I want to know if there is a design pattern for this. It's as follows
User is presented on a web interface with different algorithms for a process
User selection is stored in the database.
Now, the application should perform computations differently depending on the algorithm...
Hello,
I am trying to write a C++ implementation of factory design pattern. I would also like to do it using shared objects and dynamic loading. I am implementing a function called new_animal() which is passed a string. If the string is "dog", then it needs to see if a class dog is registered in shared object and create a dog object...
Hello,
My question is:
Can I still do query's from within an object like this:
$result = mysql_query ($q,$dbc)
or
trigger_error("Query: $q\n<br />MySQL Fout: " . mysql_error($dbc));
by passing the global dbconnection variable $dbc to the constructor
or is there a better way?
Or creating a singleton class for...
I am (as I'm sure many of you are) pretty familiar with Rails' MVC design pattern as well as Django (and others') MTV design patter. I was wondering what other patterns other frameworks use for web application development. What are their strengths/weaknesses?
thanks
...
I want to refactor some code.
Basically the code I want to refactor is a Form (using System.Windows.Forms;)
The way it is setup now, depending on which radio button you selected it shows a different layout for the window: different labels, buttons, etc. Not always a big difference, but different. This is a lot of conditional statemen...
Hey All,
I'm designing an iphone application from a designer's POV so I'm unsure about some of the more complex interactions in the iphone SDK. Curious if anyone knows if this is possible:
I noticed that most text fields will open up the keyboard without any auto-suggest going on. I'm wondering if its possible for the textfield to open...
Suppose we have some project with next structure:
web
articles
main.jsp
sidearts.jsp
central.jsp
forum
main.jsp
css
js
WEB-INF
web.xml
Note that we don't have front controller at this point yet.
After deploying with some facet (let it be 'asdf') we can access our pages using next URLs:
http://localho...