Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java Component based vs Request based frameworks

I was recently asked in an interview - In java, how do you compare component based frameworks to request based frameworks? I explained EJB as an example of Component based framework and Struts as a request based framework but was not convinced if I did justice to the question.

Any ideas on what interviewer meant and what should have been compared??

regards, avajurug

like image 725
user150014 Avatar asked Aug 08 '09 00:08

user150014


People also ask

What are component based frameworks?

The component-based framework we are using is called React. Developed by Facebook for its home page and released to the world's open source community in 2013, React is a framework that allows developers to make components for web pages that can be shared across teams.

What is action based framework?

Action Based Web Framework puts emphasis on request-response nature of HTTP protocol, where requests represent actions to be performed (in general: request URI maps to operation, request parameters/body maps to operation arguments). Here views are just a way of rendering the results of operations/actions.


2 Answers

They were most likely looking for examples of web frameworks - for example, JSF is a component-based framework, and Struts is a request-based framework.

Request-based frameworks generally make it clear through their APIs that they're working with parsing an HTML request / generating an HTML response, while Component-based frameworks attempt to abstract this away and treat the application as collections of components with renderers and actions to do things.

In my opinion, component-based web frameworks are more trouble than they're worth - their main purpose is usually to make the development of a web app "easier" for developers unfamiliar with web development, and closer to traditional desktop development. However, in practice, when something goes wrong, you need to develop custom components, you need to customize the framework for something that isn't "out of the box" functionality, etc. you need to understand both underlying "traditional" web development and how the component-based framework abstracts it - and if you're an experienced web developer and have existing solutions, utilities, libraries or snippets that worked in "traditional" web development, you'll waste time re-implementing them to work within the component-based framework.

like image 94
Nate Avatar answered Oct 21 '22 22:10

Nate


Request based framework is a web framework that gets user's request then determine what the system should do and give back the response back to the user. So the flow is pretty much linear. You're thinking in actions: what does user want (request) -> what user will get back (response). An example of Request based framework is Struts. The modern Grails is pretty much a Request based framework too.

Component based framework is not like that. There is actually no clear sense of the flow from front to back. An example of it is not JSF, because in some way JSF is pretty much quite the same with Struts (since the creator of Struts and JSF is the same). A good example of Component based framework Tapestry and Wicket. The paradigm in these two framework is different. You don't think in actions or request-response, but components and components. You define a component in your application, and you tell what the component does. But the flow does not have to be linear as in Request based framework.

like image 26
Joshua Partogi Avatar answered Oct 21 '22 23:10

Joshua Partogi