In demand

ad1

Sunday, July 12, 2015

Separate Content, Presentation and Business logic

I have seen some absolutely terrible and incorrect explanations of  web application layer separation. Most of them are illogical and filled with mixed ideas due to semantics and trendy terminology used by "gurus".  Many are propagated by lack of  knowledge and understanding of PHP, the most popular server-side language for the web today.  The design and architecture of open source content management systems is also responsible since they are how many get their start in web development.




Dated and Confused


Even  Wikipedia is filled with stupidity like this:
HTML is mainly used for organization of webpage content, CSS is used for definition of content presentation style, and JS defines how the content interacts and behaves with the user. Historically, this was not the case though. Prior to the introduction of CSS, HTML performed both duties of defining semantics and style.
See how  the use of  "webpage content" and then following with "presentation style" and then "content interacts" is conflating  and confusing  web browser environment  and events with  the presentation of content and the content itself. How this obvious web programming paragraph made it into a computer programming section is also a bit suspect.

It's Simple 


There are three layers to be concerned with and nothing more. You can get as granular as you'd like but for the web these three are the only ones worth talking about.

Content =   strings, binary media eg.  images video
Presentation  =  html, css, javascript,  custom template language
Business logic =  code, programming language,  SQL,  datastore


What's in a name? 


"Structure" is an abstract and  not necessary because it brings with it other necessities like "page" or "document", things that are abstracts in a web browser. It's old thinking to use this type of semantic difference for something as simple as presentation. It confuses designers and developers into thinking that there is another layer, something called a "layout" or "page", terminology that comes from the print industry.


Content Management Systems


CMS's even the popular ones are built incorrectly because of these poor explanations. They do not properly end tasks and hand off  the  processes from one layer to the next correctly. This is why you find  HTML in code and business logic. There are programming patterns like  Model-View-Controller that help control the process and exchanges. But all too frequently the design pattern gets lost or buried in the complications and complexities of over-engineering. Over-engineering is when the software creators seek to include every possible scenario for requirements now and in the future. They heap on the "flexibilities" and leave it up to the end-user to later sort them.  


PHP 


PHP confuses the entire web developer community because it is both a programming language for business logic and a custom template language. This makes developers wonder why they are not seeing separation in  their processes. Worse is that they cannot see mistakes made in those processes and the mistakes are seen as harmless because of the nature and characteristics of the PHP language. Developers coming from other languages usually see this as a problem that needs to be fixed. They are responsible for many efforts to remove this confusion with creation of overlaying template languages like Smarty, Twig and dozens of others. These fixes are not necessary and the web would be better served if their creators would spend more time educating themselves and others about PHP's roots as a template solution.

Bad information


The situation is exacerbated  by poorly written and ill  conceived Wikipedia pages that are obviously written  by old school computer scientists that conflate  print media semantics with computer programming and  the web browsers environment.

https://en.wikipedia.org/wiki/Separation_of_presentation_and_content
https://en.wikipedia.org/wiki/Presentation_logic

Minimalist design


One of the easiest ways to get proper separation is to practice minimalism in design and architecture. This is what I have done with  the Content Connection Kit and why it's different from other content management solutions.
 


Today's Links

Post a Comment

Print this!