Patterns and all that new fangled stuff ...

Max M maxm at mxm.dk
Wed Jul 3 16:28:46 EDT 2002


Sean 'Shaleh' Perry wrote:

>if your new facade class is only used once, in one place there is little
>benefit.  However if this type of thing occurs in several places you have no
>limited your changes to one class rather than every call.
>
>A programmer must learn when to use a tool.  Just because you have a toolbox
>brimming with solutions does not mean you should use all of them on a single
>project.
>  
>


No i know that. But the advantage in using the facade class, which is 
used only once per page, are these:

- It uses the same approach on every page, making it easier to view at a 
glance what a single page does in a larger system.

- It is possible to have a minimum amount of code in the .asp page, and 
develop more of the code in an ide with better debugger etc.

- It is easier to unit-test the app, as the facade class is pure Python, 
and not dependent on .asp.

- It eliminates most of the bugs I get when writing linear code, and 
then inserting a new line of code in a place where something isn't 
initialised yet, as all the data structures gets initialised in the 
__init__() method.

- There are fewer namespace issues on long pages when using the facade 
with methods.

- If the page is a controller it's easier to make it clear where the 
updating of persistent data from forms takes place with code like this:

    page = PageFacade(sagsId, artId)
    if req.has_key('save'):
        page.update(req)

- In longer pages it is easier to se where the views are generated as 
they are always methods or attributes on the PageFacade object. In 
linear code it is not clear which one of the many variables that is also 
a view.

So I think there are many of advantages, but it's just that it gets so 
verbose

regards Max M

-- 

"Sorry I would Really Like To Help More On This Project,
But Am To Busy Doing Paid Work On A Tight Deadline"
    Max M









More information about the Python-list mailing list