tailieunhanh - Embedding Perl in HTML with Mason Chapter 10: Scalable Design
Tham khảo tài liệu 'embedding perl in html with mason chapter 10: scalable design', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Chapter 10 Scalable Design So now that you know how to do things with Mason it s time to start thinking about how to do things cleanly scalably and maintainably. Mason is a good tool but it is not magic and you still need to think about design when you use it. Modules Versus Components This book was written before things like Catalyst MasonX WebApp and MasonX Interp WithCallbacks were available or widely used. The latter two modules were written to make it easier to move application logic out of components into modules. Catalyst is a full-featured framework which makes it easy to build a nicely architected MVC web application. You can use Mason as the templating piece the view with Catalyst quite easily and you re encouraged to check it out at http . Mason is a powerful tool for generating content. Its combination of easy templating syntax powerful component structures and features like autohandlers dhandlers and component inheritance all combine to make it much like Perl itself it makes easy things easy and difficult things possible. However exactly like Perl itself the facilities it provides can make it all too tempting to do things the easy way and Mason makes no attempt to enforce any sort of discipline in your design. Instead this is your responsibility as a programmer and application designer. This is where the responsibility always lies no matter what language or tool you are using. Though Mason is at its core a text templating tool it also provides much more functionality. One such piece of functionality is that individual components are almost exactly like subroutines. They can be called anywhere in your processing and they can in turn call other components generate output and or return values to the caller. And like Perl s subroutines variables defined inside a component are lexically scoped to that component. It is this similarity between components and subroutines that can lead to design trouble. As long-time Mason users we have come to
đang nạp các trang xem trước