Intelligent Web Site Page Generation

Started by Darren Dirt, July 18, 2006, 01:55:50 PM

Previous topic - Next topic

Darren Dirt

Intelligent Web Site Page Generation

http://www.cs.usfca.edu/~parrt/course/601/lectures/page.generation.html

Quote
Static web sites are a collection of HTML files. Dynamic sites like Amazon.com, on the other hand, require that you generate pages on the fly. This essentially means that your site becomes an application instead of a bunch of text files. Your web server must now map a URL to a snippet of executable code that spits out HTML rather than mapping to a file.

The best approach is servlets + a template engine. A template engine is usually an MVC (model-view-controller) based scheme where a template (the view) has "holes" it that you can stick values, computed by your business logic (the model). The "holes" are typically restricted to just attribute references or simple computations/loops to avoid re-inventing JSP. The web server + page code executed for a URL embody the controller. There are a million of these engines such as Velocity, FreeMarker, StringTemplate, Tea, ...

To understand why the servlet + template engine approach is superior, it helps to look at the path all developers seem to follow on their way to template engines.

(...more thought-provoking and/or brain-hurting verbiage...)




See also related: "The Role of Template Engines in Code Generation"
^ Speaker: Terence Parr, professor, Computer Science, University of San Francisco (and the guy behind "stringTemplate")




Dangit, just when I thought I knew what I was doing... ;)
_____________________

Strive for progress. Not perfection.
_____________________

Darren Dirt

#1
I found this "recent**" thread somehow during a Search.

And I realize that, 11 years later, I really would have liked to have gotten "on board" with proper MVC app dev, etc. Now I feel so left behind vs. all the young 'uns.

Posting this cuz kinda feeling "stuck" right now. My best friend here at work is leaving in July (moving to "I.T." in same place, instead of "I.M." :sigh: ) and much of the development he had on his plate is moving onto mine... and most of that is JSP glued together by about 8 different developers over the last 10 years :sigh:

Change is part of life, having Job Security is a good thing, I will get through this, etc. etc. Keep saying this to myself, keep saying this to myself...

Or with my youngest kid turning 16, and the ex-wife getting remarried, maybe deep down inside a part of me is looking for a change in my safe career path? Hmmm... must resist urge to resist honest self-evaluation and introspection...


** PS: holy crap, http://www.stringtemplate.org/about.html still exists! And, ironically, what is the example of "bad ideas" mentioned in that about page? *JSP*! Convoluted code and brand new IDE tools and process, here I come! :-\

_____________________

Strive for progress. Not perfection.
_____________________

Mr. Analog

MVC isn't hard to learn, conceptually it's about creating layer boundaries so you can more easily maintain / change them

Model: Is all about maintaining data. This is the guts of your system; business functions, database access, CRUD
View: This is all about the GUI, how data is displayed and interacted with; web pages, scripts, etc
Controller: Routes activity between the View and the Model

Let's say you have a Website for Widgets

The Model:
-A database to store Widget information
-A data access layer that defines POJOs (Plain Old Java Objects) that map the tables to classes
-A business layer that handles CRUD, business classes / methods that populate the POJOs, this is where things Get Done(tm)

The View:
-Web Pages that display the contents of a POJO passed to it based on a request
-Web Pages that have form elements a user can use to interact with model data
-Scripts that add the ol' Razzle Dazzle

The Controller:
-Routes requests based on paths
    e.g. widget.egg/home/login -> routes to the login class for the login web page
-Serializes form data into POJOs and makes an appropriate Model call
    e.g. widget.egg/home/save?form=data;blah=this;blah=that;
           call controller home class save method with params from HTTP GET
           map input values into POJO
           call Business class to commit POJO to DB

Now the good news is you don't have to roll your own MVC pattern anymore if you don't want to, particularly if you float in Microsoft circles. In fact its really easy to get setup with the basics with online tutorials like this: https://www.asp.net/mvc/overview

Take a few days and explore it, you'll find the mystery unravels pretty quick. Just gotta set aside time to do it!
By Grabthar's Hammer

Darren Dirt

Great summary.

Pretty sure the patchwork JSP I will be inheriting is about as anti-MVC as humanly possible.

To be maintained within RAD. Which is apparently about as slow and cumbersome as humanly possible. That's where my time focus is gonna be this week -- learning how to use the dev tools. The codebase I will pick up on as needed.

BTW that "still alive" about page sums up MVC pretty well too -- and is a nice summary of how web app dev needs eventually got to there. Which is what got me thinking/feeling stuff about it, and my lack of experience with it... Future hasn't yet been written though,  so who knows.
_____________________

Strive for progress. Not perfection.
_____________________

Mr. Analog

I haven't touched Java in a while, not since 2008 or so at least, we were using Eclipse and it had a lot of wiring for an MVC pattern implementation.

Our model was using IBM Content Manager as a repo, that was hell...
By Grabthar's Hammer

Tom

I've been doing a lot of java, and getting into "Clean Architecture" and MVVM/MVC based app development.

Given most of my work is Android, I use Android Studio, which is based on InteliJ, which is actually not too bad. I'd say I prefer it over eclipse.
<Zapata Prime> I smell Stanley... And he smells good!!!

Mr. Analog

Eclipse with plugins used to be my jam but it's pretty fussy now, wanted to try InteliJ but the urge to Java is low in this crazy mixed-up MS World 2012 R2 SP3
By Grabthar's Hammer