Posted By: pwzeus | Jul 5th, 2007 @ 1:39 PM
page 1 of 1
Comments: 14 | Views: 2395

I have always got good help from this forum so here I am back with a question.

I am developing an image processing app. Which DESIGN PATTERN I should use. I am really confused and need some help.

Here are the details.

Dropdownlist with Image name and ID

on selecting image id it will go to the database and grab the image.

I want to make gineric objects which can deside what kind of image request is coming in from UI and then grab from database. I do have standerd UI / Business / Data layer in place.

Thanks in advance

blowdart
blowdart
Peek-a-boo


Well that lends itself to MVC
pwzeus wrote:



I want to make gineric objects which can deside what kind of image request is coming in from UI and then grab from database. I do have standerd UI / Business / Data layer in place.



Factory? Quiite hard to tell from your description, are you suggesting you want a single interface that will have concrete implementations that perform slightly different functionality (say diff image formats)? And a class that knows how to create specific instances of that interface?

Or a facade if you have lots of different services (possibly web services) which currently don't have a common, but vaguely similar API.
blowdart
blowdart
Peek-a-boo
pwzeus wrote:
can you tell me more wtt u have in mind. Pardon my newbeness lol


Well you're not giving us much to go on Smiley

View renders the data from the Model in response to the request made to the model by controlled events made by user interaction.

Model View Controller is a design approach to separate the application object model from GUI, originally invented around 80s. Then later on it has become a widely accepted common design pattern. The main objective behind this pattern is to decouple the view of the data (presentation layer) from the actual data processing so that the same model can be used for various views. This is achieved by using three different types of objects that interact with each other in loosely coupled manner with their discreet set of tasks.
blowdart
blowdart
Peek-a-boo
OK factory patten for the generic object stuff.
MVC for the UI.
JohnAskew
JohnAskew
9 girl in pink sweater
Factory fetches/creates the image(s) for the request(s), no?

It is the controller-to-DAL link, I would guess.


BTW, Model/View/Controller is quickly being dropped for Model/View/Presenter; (MVC => MVP).

The Presenter handles all traffic between UI and BOL, a Controller doesn't handle BOL -> UI, is the difference. MVP came about to best support TDD, from what I've read.

There is a good architectural video series here on C9 that describes the "Presenter First" design pattern. We start in the middle with the Presenter and write to Interfaces forward and backward -- for UI and BOL. This gives a tight design, tight like a tiger.

Factory is not foundry, it can be a simple static class that cuts farts.
blowdart
blowdart
Peek-a-boo
JohnAskew wrote:
simple static class that cuts farts.


Errr ..... was that a mistype?
JohnAskew
JohnAskew
9 girl in pink sweater
blowdart wrote:

JohnAskew wrote: simple static class that cuts farts.


Errr ..... was that a mistype?


Actually, my wife calls me a static fart factory most evenings after bean soup and beers.
pwzeus wrote:
ok I can understand MVC here but i m not sure how factory pattern will be usefull. I will look into it....thanks


Think static method that returns a concrete implementation of an interface based on some criteria, sample pseudo here from top of my head ..

interface IImageHandler{ ... }

sealed class ImageHandlerFactory
{
    private ImageHandlerFactory {}

    public static IImageHandler Create( object criteria )
    {
           IImageHandler handler = null;
           switch( criteria )
           {
                 case X:
                   handler = new PngImageHandler();
                   break;
                 case Y:
                    handler = new GifImageHandler();
                     break;
            }
           return handler;
    }
}

Of course you could make it a lot more flexible by having the criteria match against configuration, dynamically load the implementation (and cache it).
JohnAskew
JohnAskew
9 girl in pink sweater

Factory pattern is a static class that asks the DAL for data and formats it for the UI to consume. A picture factory; not bricks and mortar, factories can be tiny, it's just a pattern, not a huge construct.

page 1 of 1
Comments: 14 | Views: 2395
Microsoft Communities