Tuesday, October 24, 2006

Do you really need a Persistence Layer?

Well that depends, but in many cases it's far more than what you really need...

Continuing from my earlier post about building an AJAX / SOAP App in 15 minutes, the only way to build an app this fast is KISS. If you're worrying about EJBs, Relational DBMS, or file storage, you've gone too far.

Here's a screenshot of the completed app (you can try a sample of the app yourself here):



For Sticky Notes, the only way to KISS was to stay entirely in the Object domain; that meant keeping a strict eye for only what was necessary, and not a bit more. Thus for the Server side, I chose Terracotta because:

  • I can code plain POJOs without having to worry about another code layer
  • With the Terracotta server in persistence-mode I get to stay in the Object domain, and persist my objects naturally.
I chose XFire, because:
  • It exposes SOAP services from simple POJOs - no work required.
  • It's a cinch to run standalone without a container (it uses Jetty)
For the Client side, I chose OpenLaszlo. A number of key factors influenced my decision:
  • interfaces with SOAP
  • easy to use definition language - no HTML or (sophisticated) Javascript required
  • it looks like they are going to have a number of new output formats real soon now (DHTML and Java ME) - hopefully I will get more bang for my buck using OpenLaszlo than trying to build something out of DHTML and any of the numerous Javascript AJAX toolkits out there...
There are good reasons for needing persistence - I'm not saying you'll never need it. If a customer gives you an order, you know you'll need to eventually put that in a database. On the other hand, while that customer was creating that order, it's probably overkill to keep every change in the database.

If you saw my Notes service version 1.0, it needed a few tweaks to implement the full app. I've updated the Notes project which is now at version 1.1.

In particular, I had to
  • add a "getNotes()" service, which just returns an array of integer ids representing the notes that are stored.
  • add a "deleteNote(int id)" service. This deletes a note given the input id.
  • beefed up the "setNote()" service. I added x, y, width, and height parameters. (Of course I had to add a Note object to store all of these values as well.)
  • beefed up the "getNote()" service. Obviously this now has to return x, y, width and height in addition to the msg.


NOTE THE CODE LINKED TO BELOW IS DEPRECATED! Terracotta is now Open Source, the code below will work fine but has not been updated to the recent versions of Terracotta. There is also a full Terracotta Forge available for projects.

The full source code is available at the Terracotta Project Site. In addition you can view a simple version of the app (which has all of the SOAP removed, so you can see it in action, but no persistence takes place) here.

17 comments:

Agustí Pons said...

I agree, in the no-persistence-layer approach, but I've developed a new protocol to access server-side code, instead of SOAP you can use microcalls. See the specification in www.microcalls.org

Gregory Pierce said...

Hmmm.... I disagree. I've built applications with that level of functionality that HAD a persistence layer in 15 minutes using JSR181 webservices and EJB3 entity beans.

Now that EJB3/JPA is nothing more than annotated POJOs I would have to seriously ask myself what I'm gaining by not having a persistence layer as opposed to what I'm losing.

fadzlan said...

"With the Terracotta server in persistence-mode I get to stay in the Object domain, and persist my objects naturally."

that my friend, qualifies as persistence layer. It helps you to persist no? EJB3 lets you to do something close to that, if you chose so...

Then again, thats what I think.

Taylor said...

I agree the distinction is rather subtle and there certainly is quite a bit of functional overlap between the two...

There is a key difference, however, and I think it's worth noting. Traditional persistence layers, even if they are now reworking their interfaces to be "POJO based" for the sake of simplicicty, are simply not pure POJOs - for lack of a better term they are POJO facades.

The Terracotta objects are a true extension of the Heap, you can even do synchronized wait/notify on them.

That Terracotta has a "persistence-mode" to make the objects survive a Terracotta server restart is simply an implementation detail - which your application does not depend on and is really a function of the operational requirements of your deployed environment.

Anonymous said...

(法新社倫敦四日電) 英國情色大亨芮孟的a片下載公司昨天AV片說,芮孟日成人影片前去成人網站世,sex享壽八十二歲;色情這位身av價上億的房地產開發情色電影商,曾經在倫敦推成人網站出第一場脫衣舞表av演。

色情影片
芮孟的財產成人影片估計成人達六億五千萬英鎊(台幣將a片近四百億),由於他名下事業大多分布在倫敦夜生活區蘇活區色情成人因此擁有「蘇活情色視訊之王」日本av的稱號。
部落格

他的成人電影公司「保羅芮孟集團」旗成人網站下發行多a片種情色雜av誌,包括「Razavzav女優leavdvd」、「男性世界」以及「Mayfai情色電影r」。色情a片
a片下載
色情
芮孟情色本名傑福瑞.安東尼.奎恩,父av女優親為搬運承a片包商。芮孟十五歲離開學校,矢言要在表演事部落格業留名,起先表演讀心術,後來成為巡迴歌舞雜耍表演av女優的製作情色人。


許多評論a片成人電影認為,他把情色表演帶進主流社會,一九五九部落格年主持破天荒的脫衣舞表演,後來成人影片更靠著在蘇活區與成人光碟倫敦西區開發房地產賺得大筆財富。


有人形容芮孟是英國的海夫納,地位等同美國的「花花公子」創辦人海夫納。

Anonymous said...

jI like your blog. Thank you. They are really great . Ermunterung ++ .
Some new style Puma Speed is in fashion this year.
chaussure puma is Puma shoes in french . Many Franzose like seach “chaussure sport” by the internet when they need buy the Puma Shoes Or nike max shoes. The information age is really convenient .
By the way ,the nike max ltd is really good NIKE air shoes ,don’t forget buy the puma mens shoes and nike air max ltd by the internet when you need them . Do you know Nike Air Shoes is a best Air Shoes . another kinds of Nike shoes is better . For example , Nike Air Rift is good and Cheap Nike Shoes .the nike shox shoes is fitting to running.
Spring is coming, Do you think this season is not for Ugg Boots? maybe yes .but this season is best time that can buy the cheap ugg boots. Many sellers are selling discounted. Do not miss . Please view my fc2 blog and hair straighteners blog.
.thank you .

I like orange converse shoes ,I like to buy the cheap converse shoes by the internet shop . the puma shoes and the adidas shoes (or addidas shoes) are more on internet shop .i can buy the cheap nike shoes and cheap puma shoes online. It’s really convenient.
Many persons more like Puma basket shoes than nike air rift shoes . the Puma Cat shoes is a kind of Cheap Puma Shoes .
If you want to buy the Cheap Nike Air shoes ,you can buy them online. They are same as the Nike Air shoes authorized shop. Very high-caliber Air shoes and puma cat shoes . the cheap puma shoes as same as other.

Maurice said...

清卡數,補習,補習,china mobile phone,珠寶設計繪圖入門,裝修,
遊船河,酒店,酒店,
模型,美容,網頁設計,
accounting,成立公司,
租車,清潔,美容,
裝修,EDM,fashion,
求職,斗地主,結婚,
醫療用品,傢俬,創業,
網站推廣,seo,seo,
seo training course,姻緣配對,投資,
日本代購商品,珠寶,
私人貸款,物流公司,
市場推廣,美容,
office furniture,Piano,

Maurice said...

poodle,印刷,地產,
Sai Kung property,廣告,
online shop,seo,潮流鞋類,
IVA,internat marketing,webdesign,
香港酒店,澳門酒店,曼谷酒店,
北京酒店,清邁酒店,
廣州酒店,香港酒店,
香港酒店預定,香港酒店,
hong kong hotel,星加坡酒店,
hotels,hong kong hotels,
日本酒店,韓國酒店,

Maurice said...

macau hotel,馬來西亞酒店,
台灣酒店,香港酒店,
拉斯維加斯酒店,墨爾本酒店,
芭堤雅酒店,布吉酒店,
上海酒店,新加坡酒店,
悉尼酒店,珠海酒店,
成立公司,租車,香薰,
補習,補習,單車,

Maurice said...

bicycles,單車,成立公司
,租車,地產,成立公司,
瘦身,冲孔网,成立公司,
成立公司,wholesale abercrombie,補習,
租車,裝修,中港車批文,
中港租車,租車,租車,
村屋,破產,破產,信用卡,債務舒緩,舒緩債務,免費債務諮詢,財務,債務重組,債務重組,債務重組,債務重組,債務重組,債務重組,財務,drp 債務舒緩計劃,美容,模型,搬屋,搬屋,金融,模型,sleepy,補習,瘦身,
藝術治療,冷氣,偵探,
跟蹤,歷史悠久偵探,
SEO

Maurice said...

成人用品,性玩具,陰唇刺激,
男女用緊束手套,成人性用品,
sex toy hk,性玩具

Ken said...

成立公司

Ken said...

成立公司 成立有限公司

Ken said...

成立公司

Movies Gallery 2011 said...

Nice post. Thanks for sharing. It was very interesting and meaningful.
Angry birds flash| Angry birds flash| airbnb clone|

tong720 said...

寵物美容
寵物店
寵物美容課程
Pet
狗酒店

物理治療
Clinical Massage
物理治療 physiotherapy
Physiotherapy
物理治療
看護

Recycling
Recycle Bags
五金回收
手挽袋
環保回收
Recycling 回收

seo
Online Marketing
seo hk
internet marketing
seo 優化
seo firm
seo marketing
E Marketing
廣告宣傳
網上推廣
seo marketing
seo網上推廣
seo hong kong
seo experts

減肥
纖體中心
纖體減肥
減肥瘦身
瘦身纖體
Weight Loss

tutor said...

【Monday Blue】為什麼我們總是討厭星期一?如何輕鬆地跟Monday Blue說拜拜?
Dion Wong, 1 month ago 1 min read 80
圖片來源

大家是不是很討厭星期一呢?又有沒有聽過Monday Blue呢?可能大家從星期日傍晚開始,已經感到焦慮,隨着時間的流逝,心情越嚟越郁悶,甚至已經陷入過度思考,無法真正地休息,導致身體十分疲累。然後星期一便難以高效率地工作,就是所謂的Monday Blue。不要緊!今日Tutor Circle尋補 的小編會向大家介紹五種方法,擺脫Monday Blue的糾結情緒!

1. 分配休息時間
圖片來源

呆在家裡, 在家, 地平線 的 免費圖庫相片
大家在星期日晚上盡量不要熬夜,好好享受休息時間
首先,小編相信有很多人都會把玩樂時間放在週末,畢竟平日工作繁忙,根本沒有時間在平日去各種新奇有趣的地方,只好在星期六、星期日去不同地方打卡。可是,如果我們忽略疲累,外出後,仍然通宵熬夜,自然在星期一沒有精力上班、上學,從而出現絕望,所以大家在星期日晚上盡量不要熬夜,好好享受休息時間,以免Monday Blue的情況出現!



2. 進食早餐
圖片來源

The Best All-Day Breakfasts in Hong Kong
吃早餐可以幫助我們調整狀態和情緒
然後,小編知道有不少人在早上急忙地趕上巴士,總是匆匆忙忙上班上學,而忽略早餐的重要性。其實早餐是十分重要,除了可以幫助我們開啟美好的清晨,還可以為我們提供能量,應付接下來的工作。假如我們沒有吃早餐,沒有攝取足夠的蛋白質,又怎能讓我們保持清晰的頭腦呢?因此我們切勿忽略早餐的重要性,吃早餐亦可以幫助我們調整狀態和情緒,克服Monday Blue,讓我們有力量去迎接新挑戰。



3. 養成持續運動的習慣
圖片來源

身體不舒服時,該不該持續運動? - 康健雜誌
養成持續運動的習慣,可以改善我們的精神健康
第三,假如我們養成持續運動的習慣,不但可以改善我們的精神健康,而且可以令我們在白天保持精力充沛,就算面對困難的工作,也可以順利完成,成為走得更遠、更高的優勝者。



4. 安排在星期一的中午與朋友聚會
圖片來源


flowclass補習社
補習免中介
搵補習
補習平台
補習老師

補習免中介
搵補習