tags:

views:

2963

answers:

4

What is the difference between Atg and Struts?

+15  A: 

Struts is a framework for using within a J2EE web application that tries to provide web applications with an MVC-pattern based approach to coding. It includes some added utilities for form data validation etc. It is an open source project, and has been quite good at solving that particular piece of the web application puzzle, and is limited to only solving that particular peice.

ATG (ATG Dynamo), on the other hand, is an application platform - a solution and a framework - for building data- and content- driven web applications - largely for commerce and publishing. At the framework level, it is a Java based application platform for hosting web-based applications, as well as RMI accessible business components, with an ORM layer, a component container, an MVC framework, and a set of tag libraries for JSP. The component framework (The Nucleus) is a lightweight container for managing the life cycle and dependency binding (dependency injection) of Java component objects (beans). In that sense it is somewhat similar to the Spring bean container, and is the core of the ATG framework - all other services and frameworks are hosted within it. The ORM layer framework (Repositories) maps objects to and from relational databases (as you would expect). But it can also handles mappping with LDAP, XML and file system data ources using the same consistent data access API. The JSP tags for binding form elements on a page to values on business objects etc. are more elegent and cleaner than the form binding tags in any other framework I have seen. The mechanism of writing your own tag library equivalents (Droplets) is much more consistent with the Servlet API than standard J2EE tags.

The MVC framework (the basic Formhandler pattern) is somewhat similar to Struts Form and Action classes - but provides a much more basic framework that Struts does. Out of the box, and at the level at which most developers work, the ATG model is page-driven not controller-driven. Internally, it is certainly controller-driven with a pipeline approach to chaining dispatchers and controllers.

In addition, the framework at the basic level gives you an RMI container, distributed caching, distributed locking and distributed singletons, distributed events and messaging, a task scheduler, a rules engine and a mechanism for defining business workflows with custom actions and outcomes, a graphical editor for business workflows, support for versioned data, support for roles and rights, logging and auditing - all out of the box, and all using very coherent and consistent APIs

Then at the solution level, you have the components and the APIs for dealing with user profiling, identity management and personalisation, content authoring, versioning and publishing, content search, product catalogs for tangible and intangible goods, product search and guided navigation, pricing, tax calculation, promotions, shopping carts, gift lists and wish lists, payment types, shipping methods, order tracking, customer relationship management etc.

The extension points and integration points to ATG are usually very well designed and quite well documented. They support integration with pretty much anyone who is anyone in the e-commerce and publishing space for things like authoring and content management, identity management and security, product catalogs, search and guided navigation etc. Also, almost all areas of the framework are extensible and pluggable so you can write your own components to enhance or replace the ones out of the box.

It does not really make much sense to compare the two. However, given your question, I imagine what you are really interested in is the MVC part of ATG

For MVC, Struts gives you more than ATG does (but then Spring MVC gives you even more than Struts does). However, you tend to get bogged down in the mechanics of the framework far more with Struts than with ATG.

Personally, I think that ATG's formhandler based model is more elegant, cleaner and easier to work with than most other web MVC frameworks I have seen, and the APIs are more consistent with the Servlet APIs.

Bear in mind, also, that most 'web-MVC' frameworks are not like true MVC (i.e. the pattern used for GUI programming in Smalltalk or even Java Swing etc.). Neither Struts nor ATG provide (as designed) true MVC - though ATG actually comes closer. There is a lot of confusion about terminology.

For example,

  1. the Model in true MVC is not your data model nor your domain model objects. It is the model that represents all the data in a view. If that happens to be a domain model object then well and good - but more often than not, you will find that you need a different set of view or form objects. Also, the model is responsible for keeping itself updated - it is the Model that interacts with business services lower down. ATG tends to fuse the model and the controller into one component - the formhandler. Struts tends to keep the view data model distinct (the form object), but does not encourage its use as a model in the true MVC sense - it is not the form object that interacts with other business services to keep itself updated.

  2. the Controller in MVC is not your business controller. A controller in MVC is a conduit between the view and the model. It reacts to changes in the view, or to actions performed on the view, and instructs the model to update itself accordingly. In Struts the Controller they talk about is not an MVC controller at all - it is really a dispatcher. A lot of the code that belongs in a controller ends up in your Action class. But the way Struts is designed, the Action class is really meant to do what a Model does.

  3. the View in MVC should be populated by the model - it is a push mechanism with the model updating the view, not a pull mechanism with the view querying the model. In most web-MVC frameworks, the view (usually a JSP) pulls state from the model in order to display itself. This is particularly the case with ATG's page-driven approach. If you find that data is being fetched while your page is rendering it means something is wrong with your MVC design.

In Struts, the function of the MVC Controller is spread across the Struts controller and the Action, while the function of the MVC Model is spread across the Form object and the Action.

In ATG, the function of the MVC Controller and the MVC Model is all in the Formhandler

Having said that, due to the request-response nature of HTTP, the function of a Controller in a web-MVC framework is quite limited. With web applications, we tend to get a completely updated view on form submission rather than lots of small changes (e.g. each key press or mouse click, or each changed input field) as we would with a rich UI framework. The use of AJAX is changing that - and we have to think much more about implementing MVC correctly.

Remember, MVC is a design pattern - i.e. it is a design-time principle to be used when designing the GUI aspect of applications. Struts, and ATG are frameworks - i.e. they are classes and objects to be extended, implemented or configured when building your application. A framework cannot enforce the use of a design pattern - it can merely encourage it. Choosing to use a particular framework will not make you design your ciode better - at most it may encourage a certain discipline.

If you design your MVC well, it will not make a huge difference whether you use Struts classes or ATG classes to implement it or whether you. Likewise, if you design your MVC badly, hoping that your choice of framework will make up for your shortfalls, it will not make a huge difference whether you use Struts or ATG. If you understand and work with the design principles, you will find it very easy to switch back and forth between frameworks.

The best code will be that which adheres to a good design principle (say, true MVC) in the abstract, and implements it (realises it) using the right tools available in the chosen framework in the way they are intended to be used.

Coming back to your question;

If you are working on an ATG project, you should use the frameworks that ATG provides. It is certainly possible to shoehorn Struts into an ATG application - I have done this myself many years ago - but it is far more effort than it is worth - and you are giving up a lot of what ATG provides out of the box in terms of object lifecycle management, form data binding etc..

If you are about to start work on a new project and have a choice of frameworks to use - I would personally recommend an open source application server (like JBoss) and the Spring Framework - it gives you the best of what ATG and Struts provide. It has a Nucleus-like component container (the Application Context), it integrates with all good ORM solutions (such as Hibernate) and includes an MVC framework that in my opinion has far eclipsed Struts. In addition, I would recommend looking at Spring WebFlow for higher level GUI flow design.

Vihung
Wow. When I read the question, I thought "The answer to that question would be too long to write out." You proved me wrong!
Cameron
A: 

ATG Framework have any future, developer perspective what it is its growth,If he is working on ATG

+1  A: 

The main difference in the UK is that as an ATG contractor you can get £500 per day, but as a general struts guy your lucky to get £350.

Not that I'm bitter at all.

Gareth Davis
If your ATG portfolio includes Commerce Search, CSC, ACI, you can go even higher. Do not be bitter, join the eCommerce guild :-))
Miro A.
A: 

ATG is proprietary software... and resources are less ...

Sameer