--- On Thu, 17 Jan 2002 17:44:46 +0800 Rafael 'Dido' Sevilla wrote: > On Thu, Jan 17, 2002 at 05:24:42PM +0800, Sacha Chua wrote: > > I want to learn so much more about what I do. I'd like to talk with > > people who really try to do the right thing. For example, in web apps, > > what are some patterns people find useful? I've gotten the hang of > > having nice, neat include files. I have a general pattern I use for > > sites with logins, access levels, whatever. But I want to know more > > about these things. How do people develop faster and better? >
Check out Zope's security model for an alternative to the flat security model we usually use. (see http://www.zope.org/Members/michel/ZB/Security.dtml ) As for the patterns you might want to use -- some things off the top of my head: Code/Application Reuse -- sometimes just doing a simple search for a module or application that already does what is needed before going off and implementing your own can save you lots of time and prevents the NIH (Not Invented Here) syndrome. Separate Application Logic from Presentation -- if you use PHP/ASP/JSP, keep them as simple as possible and put the processing logic somewhere else. Even better, use web page templating technologies like WebMacro or Enhydra's XMLC. Zope has something called Presentation Templates that does this as well. It is has been pretty much established that presentation usually evolves at a different rate from domain logic... Never duplicate code -- the holy grail of good design is that functionality should only be defined in one place. It makes things easy to change and debug. XP (Extreme Programming) has this thing they call 'code smells'. Your code 'smells bad' (as in 'rotten' ;^)) if you have lots of duplicated code. (see http://xp.c2.com/CodeSmells.html ) Refactor your code -- your initial implementation is usually never your best. Always give yourself the time to be able to change your design after you've coded it. There are always things you learn as you are coding your application and your application will always benefit from this hindsight. Your end goal should be a design that is simple and comprehensible. One good measure of design simplicity and comprehensibility is if others can discern your design intentions just from the code. (see http://www.refactoring.com/ for real life examples) Build good unit tests - As you refactor your code or fix bugs, you will never know if your refactoring or code fix affected another part of your application and created another bug unless you can test for it. (see http://www.junit.org on how to implement this in real life) > Actually, we just thought of this right now while attempting to debug a > really ugly CGI script that we are customizing for our internal use. At > its heart CGI programming really is functional programming, and one neat > way I think it can be done will be to think of every HTTP GET or POST as > a call to a function that will return HTML text based on the decoded URL > or postdata. > This is also the philosophy behind Zope (although more OO than functional) -- each URL is translated into a method call to an object (and can even include parameters). BTW, Zope stands for Z Object Publishing environment (where objects publish themselves via their methods) > If you had some good object-oriented language with the ability to > manipulate XML using DOM it might be very easy to implement such a > framework. Let the program make an initial call to register the > functions for each named action. Maybe I'll write a Perl module that > provides this cleaner method of thinking about CGI... Zope uses an persistent object database to 'register' the objects -- you end up creating a 'hierarchy' of objects (some objects act as containers for other objects) that reflect the structure of your website. Zope also has some support for XML documents and some add-ons to allow you to build and manipulate parts of documents as XML DOM nodes. You also might want to take a look at 'Bricolage', a open-source perl-based content management system built using HTML::Mason perl module (re the code/application reuse item above ;^)) (see http://bricolage.thepirtgroup.com ) HTH. Cheers, butch __________________________________________________ Do You Yahoo!? Send FREE video emails in Yahoo! Mail! http://promo.yahoo.com/videomail/ _ Philippine Linux Users Group. Web site and archives at http://plug.linux.org.ph To leave: send "unsubscribe" in the body to [EMAIL PROTECTED] To subscribe to the Linux Newbies' List: send "subscribe" in the body to [EMAIL PROTECTED]
