Wednesday, February 4, 2009

GlazedLists is not "GUI-Lists"!

This is a post in Praise of GlazedLists - at least the concepts it embodies!

It took some time before I "got" GlazedLists.

I had read several articles about GL, and went to a JavaOne 2008 talk about it, but I still didn't actually grasp it: I feel that GL's presentations always centers around GUI aspects, in particular list-views and other boring stuff. This was not a good way to sell it to me: I weren't a particularly huge fan of "binding frameworks" and the like. However, I did see something through that GUI-haze, and when I finally did get down into GL, I pretty much immediately rewrote my current project to use it from the core outward! GL's concepts have nothing to do with GUI in themselves! It is just that the concepts are really very handy when it comes to several GUI aspects. I now believe GL have utility for any system which have a state consisting of a dynamic set of entities - not only for the "last mile", the actual display to the user, but as a core tool to build ones entity handling on.

The main concept of GL is actually not very "big" as such. I'll try to formulate a phrase that would have had me get the concept:

 " GL is at its core a modifiable List of objects, where sorting (reordering), selections (filtering) and transformations can be applied in a chain, resulting in new list views of the parent list, and the entire chain of lists is kept updated no matter where modification methods are invoked on that chain, by propagating the incremental change events internal to the chain, not needing an external event structure. "

Was that understandable?

Think about a system that has a List-of-Customers in the base. You then sort that list based on the customers' last name, getting a new list. Then you filter the list, for example selecting all the customers of age 40 or more. Yes? This resulting list is used often, so you keep a reference to it, "caching" it so to speak.

But then you get a new customer.

If you don't know GlazedLists, you now immediately think about some "NewCustomerEvent" that the container of the base list fires, on which the cache-holder listens, and upon receiving such events, it does the filtering, then sticks it into the list at the correct sorted position. Then you start thinking about customers that want to leave, and realize that you need a "CustomerDeletedEvent". And then, what if the customer was entered with the wrong name or age?

If you do know GlazedLists, you just smile! :-)

The base EventList gets the customer inserted, and sends an internal event up to the listeners, and first hits the SortedList. Here it is inserted at the correct position, but the sortedlist propagates the change further, up to the FilterList, which applies the filter, and now both the intermediate list and the age-40-filtered list is updated, "just like that". You may even change the sort-order, or the filter, and things are always correct.

You may also hook onto the event fire system at any point.

Now, this happens to be exceptionally useful for GUIs where it can keep different views "magically updated" when the internal state of the system changes, and GL also have lots of such utility classes that handle common "binding cases", but the main concept is useful for pretty much any stateful system that have dynamic set of entities as its state.

So, yes: Everyone should check out GlazedLists, not only the die-hard Swing/SWT GUI developers! It is definitely a tool that should be in any serious coder's tool chest blah blah..!

16 comments:

  1. Collagen là loại protein chiếm khoảng 30% tổng lượng protein trong cơ thể người, những thực phẩm bổ sung collagen cho da có chức năng chính là kết nối các mô trong cơ thể lại với nhau. Các nhà khoa học thường ví collagen giống như một chất keo dính các bộ phận trong cơ thể nhằm tạo thành một khối hoàn chỉnh.bổ sung collagen cho da bằng cách nào, sức khỏe và làm đẹp, bổ sung collagen bằng cách nào, Collagen là nguyên tố quan trọng giúp duy trì sự căng mịn và độ đàn hồi của da. Da mặt chúng ta có thể giãn ra và co lại theo hoạt động của các bộ phận trên mặt, là do sự chuyển động của cơ và độ đàn hồi của da. cách bổ sung collagen cho da, bao nhiêu tuổi thì cần bổ sung collagen, bổ sung collagen cho da bằng thực phẩm Da mặt có thể căng mịn, trắng sáng khi còn trẻ và chùng nhão, nhiều nếp nhăn, nám sạm khi về già là do sự thay đổi về chất và lượng của collagen, các loại thực phẩm bổ sung collagen, có nên uống thuốc bổ sung collagen, những thực phẩm bổ sung collagen cho da vì thế cần duy trì lượng collagen cần thiết bằng cách bổ sung kịp thời lượng thiếu hụt chính là nhân tố quan trọng nhất giúp duy trì sự trẻ trung, tươi sáng cho da.

    ReplyDelete
  2. Khi dành phần đời còn lại của mình bằng việc mang niềm vui đến cho mọi người thì những con người ấy đã tìm thấy niềm vui thật sự của cuộc sống, thuốc fucoidan họ nhận ra niềm vui và hạnh phúc đến một cách tự nhiên khi mình mang niềm vui đến những người khác, tác dụng của thuốc Fucoidan và thật kì diệu khi gần đến những ngày cuối cùng của số mệnh đã định trước họ chợt thấy mình vẫn khỏe mạnh chẳng có dấu hiệu gì là sắp chết, thuốc Fucoidan có tốt không rồi họ nhận ra cuộc sống đã cho mình một cơ hội nữa để làm lại cuộc đời sống những phút giây ý nghĩa mang lại niềm vui cho mình và tha nhân. các loại thuốc Fucoidan Nhật Bản và Mỹ Fucoidan kích thích khả năng miễn dịch của cơ thể, ngăn ngừa sự hình thành của khối u, đồng thời có tác dụng làm chậm quá trình oxy hóa, thuốc Fucoidan là gì có tốt không ức chế quá trình sự phát triển mạch máu mới của tế bào ung thư, từ đó loại bỏ nguồn cung cấp chất dinh dưỡng cho các tế bào ung thư.

    ReplyDelete
  3. Excellent Blog! I would like to thank you for the efforts you have made in writing this post. Gained lots of knowledge.
    Data Analytics Course

    ReplyDelete
  4. Your site is truly cool and this is an extraordinary moving article and If it's not too much trouble share more like that. Thank You..
    Digital Marketing Course in Hyderabad

    ReplyDelete
  5. Very informative Blog! There is so much information here that can help thank you for sharing.
    Data Analytics Training in Bangalore

    ReplyDelete
  6. What an incredible message this is. Truly one of the best posts I have ever seen in my life. Wow, keep it up.
    AI Courses in Bangalore

    ReplyDelete
  7. I am sure it will help many people. Keep up the good work. It's very compelling and I enjoyed browsing the entire blog.
    Business Analytics Course in Bangalore

    ReplyDelete
  8. This is my first time visiting here. I found a lot of useful information on your blog, Keep up the good work.
    Artificial Intelligence Companies in Bangalore

    ReplyDelete
  9. I think this is a really good article. You make this information interesting and engaging. Thanks for sharing.
    Data Science Course in India

    ReplyDelete
  10. I finally found a great article here. Quality postings are essential to get visitors to visit the website, that's what this website offers.
    Data Science Course in Indore

    ReplyDelete
  11. Very nice job... Thanks for sharing this amazing and educative blog post!
    Data Science Training in Lucknow

    ReplyDelete
  12. Wonderful blog post. It's absolute magic on your part! Hope you continue like this!
    Data Analytics Training in Bangalore

    ReplyDelete
  13. Hi, This article is probably where I got the most useful information for my research. Do you know of any other websites on this topic?
    Data Analytics Course in Jabalpur

    ReplyDelete
  14. Very informative Blog! There is so much information here that can help thank you for sharing.
    Data Science Training in Chandigarh

    ReplyDelete
  15. Very informative Blog! There is so much information here that can help thank you for sharing.
    Data Analytics Training in Bangalore

    ReplyDelete
  16. Very nice job... Thanks for sharing this amazing and educative blog post!
    Data Science Course in Chandigarh

    ReplyDelete