JEE5 Application Architecture Best Practice.

Hi Everybody
I am going to redesign a moderate size application (not v big but larger then normal).
Now I have few Question in my mind.
I am using JSF as front-end, EJB3 Session Bean for Business Logic and last but not the least JPA as domain model.
1 - With JPA we have a domain classes. Now its better to use entity as manage-bean for JSF or manage bean should be saperate.
2 - Using DTO (Data Transfer Object) is good practice or not in JEE5.
3 - Simplicity or Complexity but with EntityManager I feel no need of DAO but I am used to with DAO pattern. So again as best practice I have to make 1 session bean as DAO and call it from all the session bean where I write business logic or forget about DAO session bean and call EntityManager from all session bean everywhere.
4 - For initializing EJB JNDI is 1 way other way is
@EJB EJBCLASSNAME ejbclassobject; //this auto initialize and create object.
Initializing like above is standard or it is an extended support from some app server.

Hi,
Follow my opinion:
1 - With JPA we have a domain classes. Now its better to use entity as manage-bean for JSF or manage bean should be saparated.
>> I think that Managed-Bean must be separated, because you can need to bind you Visual Components to it too.
2 - Using DTO (Data Transfer Object) is good practice or not in JEE5.
>> You can put your Entity as a member of you Managed Bean.
3 - Simplicity or Complexity but with EntityManager I feel no need of DAO but I am used to with DAO pattern. So again as best practice I have to make 1 session bean as DAO and call it from all the session bean where I write business logic or forget about DAO session bean and call EntityManager from all session bean everywhere.
>> For CRUD operation I don't create a additional class, but for complex business logic, you can use a separated class (Business Manager)
Best regards

Similar Messages

  • Logical architecture+best practice

    Hi,
    what does these mean for you regading Oracle applications :
    1-logical architecture
    2-best practice
    Regards.

    1-logical architecture -> I assume the technical architecture for deployment of Oracle Applications (Single node, multi node, HA, DMZ configuration etc)
    2-best practice -> Best Practices in each function within maintaining and implementing Oracle Applications.. like best practice for Upgrades, Coning Patching etc
    Sam
    http://www.appsdbablog.com

  • Internet Sales application 2007 - Best Practice

    Hi Gurus
    Has anyone completed a successful CRM 2007 Internet Sales (ISA not ICSS) configuration exercise.
    If anyone has completed the set-up please could you inform me of the documents you referenced in order to achieve this.
    Many Thanks
    Babu.

    SAP has confirmed to me that there is NOT a CRM6/7 ISA Best Practices guide.
    We used the C14_BB_ConfigGuide from our CRM4 Best Practices install and made some assumptions on what had changed.  I do not think this is still available here and am not sure if I am able to send it to anyone.  Someone from SAP or an Admin can tell us.
    I also found here the following docs that have bits and pieces of the puzzle.
    ECO_Authorizations.CRM5.0  - I think I found this on Sateesh's site, but probably a link around here for it. - CRM E-Commerce Authorizations
    Release 5.0
    SAP_ISA60_DevAndExt  - SAP E-Commerce
    6.0 u2013 Landscape, Basics and Concepts.
    Web AS  - Web Application Development
    Title: Working with Java Server Pages and Servlets
    Benny Schaich

  • Web application security best practice?

    Hi guys,
    I am developing web app using JSF + Spring + Hibernate. I got a user backing bean which handling user login and logout session. Hence if user sign-in successfully, I will just set userLogIn=true in the userBean.java. I really don;t know if this is the best practice for handling user login session. Any security probelm here? Please advice, Thanks !
    regards,
    kmthien

    hi
    you can also find a lot of info about security handling and JSF if you search the forum.
    thanks.

  • Application communication - Best practice

    Hello
    I am eager in understanding the best ways to create communication between applications (Server to client) in Java.
    In the past, I have attempted to make applications using the Socket and ServerSocket class. The concept works of course, but I was wondering if this technique is also being used on enterprise level.
    I would be most interested in:
    - A system that does not rely on request & response, so that the client can receive information without requesting any.
    - The ability for users to send and recieve String messages. (e.g. server announcements).
    - The ability for users to send and receive objects. (e.g. sending or receiving user information).
    - (optional) Security (e.g. encrypted information).
    - (optional) Possible communication with clients using different technologies (e.g. .NET client) while using a server in Java.
    Any information about this is greatly appreciated.
    Vincent

    A system that does not rely on request & response, so that the client can receive information without requesting any.Datagram
    The ability for users to send and recieve String messages. (e.g. server announcements).Ditto. Investigate Multicast also.
    The ability for users to send and receive objects. (e.g. sending or receiving user information).RMI.
    (optional) Security (e.g. encrypted information).SSL.
    Possible communication with clients using different technologies (e.g. .NET client) while using a server in Java.SOAP.
    I think you should spend a bit more time with Google, or better yet buy a book or three on Java networking. This one is good: [http://www.amazon.com/Fundamental-Networking-Java-Esmond-Pitt/dp/1846280303|http://www.amazon.com/Fundamental-Networking-Java-Esmond-Pitt/dp/1846280303]

  • Application Server Best Practice Config.?

    Hi All
    We currentely have an R3 System with 7 application servers which I want to check are running optimally. I have been looking around for some documentation on the best config settings and windows settings, but I have not been very successful.
    Does anyone have any documentation, notes or links that will help?
    Thanks in advance
    Phil

    A system that does not rely on request & response, so that the client can receive information without requesting any.Datagram
    The ability for users to send and recieve String messages. (e.g. server announcements).Ditto. Investigate Multicast also.
    The ability for users to send and receive objects. (e.g. sending or receiving user information).RMI.
    (optional) Security (e.g. encrypted information).SSL.
    Possible communication with clients using different technologies (e.g. .NET client) while using a server in Java.SOAP.
    I think you should spend a bit more time with Google, or better yet buy a book or three on Java networking. This one is good: [http://www.amazon.com/Fundamental-Networking-Java-Esmond-Pitt/dp/1846280303|http://www.amazon.com/Fundamental-Networking-Java-Esmond-Pitt/dp/1846280303]

  • Application resize best practice

    Hello, I have one question when making a chromeless application. In my application I have several different states where each state is different in dimension. For now I have been resizing the application window whenever a state change occurrs but since I have several different states this is starting to get confusing to change the width and height whenever a side tab opens or whenever a login panel slides down. Am I doing this the right way or can I start with a dimension that is the size when the application is at it's maximum and forget about changing the dimension every time? Since it is chromeless, you don't actually see the application background anyway..... I thought that if the application is set to a certain dimension then it will take up that amount of space on the desktop regardless of whether it might only have one button inside.....

    I assume you've already found an answer for this old question.

  • WS application configuration - best practice advice

    Hi there,
    I'm a newbie on web services.
    I'm currently developing a Web Service using JAX-WS 2.1 and deploying on Tomcat 6.
    I'm wondering where to put my application's configuration. If I was developing a standalone java application I would put it in a Java Properties file or perhaps use the Java Preferences API.
    But this is not a standalone java application, it is something that runs in a container, in this case Tomcat.
    I have a fealing that web.xml is the intended place to put this information but I've also read posts discouraging this. I'm also in the dark as to how to access the information in web.xml (Context parameters section) from within my web service.
    Basically I would like to use a solution which is a much standard as possible, i.e. not tied to any specific container.
    Thanks.
    Changed typo: "have" changed to "how"

    What is the model number of the switch?
    Normally a switch that cannot be changed does not have an IP address.  So if your switch has an address (you said it was 192.168.2.12)  I would assume that it can be changed and that it must support either a gui or have some way to set or reset the switch.
    Since Router1 is using the 192.168.1.x  subnet , then the switch would need to have a 192.168.1.x  address (assuming that it even has an IP address), otherwise Router1 will not be able to access the switch.
    I would suggest that initially, you setup your two routers without the switch, and make sure they are working properly, then add the switch.  Normally you should not need to change any settings in your routers when you add the switch.
    To setup your two routers, see my post at this URL:
    http://forums.linksys.com/linksys/board/message?board.id=Wireless_Routers&message.id=108928
    Message Edited by toomanydonuts on 04-07-2009 02:39 AM

  • Where to put java code - Best Practice

    Hello. I am working with the Jdeveloper 11.2.2. I am trying to figure out the best practice for where to put code. After reviewing http://docs.oracle.com/cd/E26098_01/web.1112/e16182.pdf it seemed like the application module was the preferred spot (although many of the examples in the pdf are in main methods). After coding a while though, I noticed that there were quite a few libraries imported, and wondered whether this would impact performance.
    I reviewed postings on the forum, especially Re: Access service method (client interface) programmatically . This link mentions accessing code from a backing bean -- and the gist of the recommendations seems to be to use the data control to drag it to the JSF, or use the bindings to access code.
    My interest lies in where to put java code in the first place; In the View Object, Entity Object, and Am object, backing bean.....other?
    I can outline several best guesses about where to put code and the pros and cons:
    1. In the application module
    Pros: Centralized location for code makes development and support more simple as there are not multiple access points. Much like a data control centralizes services, the application module can act as a conduit for different pieces of code you have in objects in your model.
    Cons: Everything in one place means the application module becomes bloated. I am not sure how memory works in java -- if the app module has tons of different libraries are they all called when even a simple query re-execute method is called? Memory hog?
    2. Write code in the objects it affects. If you are writing code that accesses a view object, write it in a view object. Then make it visible to the client.
    pros: The code is accessed via fewer conduits (for example, I would expect that if you call the application module from a JSF backing bean, then the application module calls the view object, you have three different pieces of code --
    conts: The code gets spread out, harder to locate etc.
    I would greatly appreciate your thoughts on the matter.
    Regards,
    Stuart
    Edited by: Stuart Fleming on May 20, 2012 5:25 AM
    Edited by: Stuart Fleming on May 20, 2012 5:27 AM

    First point here is when you say "where to put the java code" and you're referring to ADF BC, the point is you put "business logic java code" in the ADF Business Components. It's fine of course to have Java code in the ViewController layer that deals with the UI layer. Just don't put business logic in the UI layer, and don't put UI logic in the model layer. In your 2 examples you seem to be considering the ADF BC layer only, so I'll assume you mean business logic java code only.
    Meanwhile I'm not keen on the term best practice as people follow best practices without thinking, typically best practices come with conditions and people forget to apply them. Luckily you're not doing that here as you've thought through the pros and cons of each (nice work).
    Anyway, back on topic and off my soap box, as for where to put your code, my thoughts:
    1) If you only have 1 or 2 methods put it in the AppModuleImpl
    2) If you have hundreds of methods, or there's a chance #1 above will morph into #2, split the code up between the AppModuleImpl, ViewImpl and ViewRowImpls. Why? Because your AM will become overloaded with hundreds of methods making it unreadable. Instead put the code where it should logically go. Methods that work on a specific VO row go into the associated ViewRowImpl, methods that work across rows in a VO go into the ViewImpl, and methods that work across VOs in the associated AppModuleImpl.
    To be honest which you ever option you choose, one thing I do recommend as a best practice is be consistent and document the standard so your other programmers know.
    Btw there isn't an issue about loading lots of libraries/imports into a class, it has no runtime cost. However if your methods require lots of class variables, then yes this will have a memory cost.
    On a side note if you're interested in more ideas around how to build ADF apps correctly think about joining the "ADF EMG", a free online forum which discusses ADF architecture, best practices (cough), deployment architectures and more.
    Regards,
    CM.

  • BI Best Practice for Chemical Industry

    Hello,
    I would like to know if anyone is aware of SAP BI  Best Practice for Chemicals.And if so can anyone please post a link aswell.
    Thanks

    Hi Naser,
    Below information will helps you in detail explanation regarding Chemical industry....
    SAP Best Practices packages support best business practices that quickly turn your SAP ERP application into a valuable tool used by the entire business. You can evaluate and implement specific business processes quickly u2013 without extensive Customization of your SAP software. As a result, you realize the benefits with less Effort and at a lower cost than ever before. This helps you improve operational efficiency while providing the flexibility you need to be successful in highly demanding markets. SAP Best Practices packages can benefit companies of all sizes, including global enterprises creating a corporate template for their subsidiaries.
    Extending beyond the boundaries of conventional corporate divisions and functions, the SAP Best Practices for Chemicals package is based on SAP ERP; the SAP Environment, Health & Safety (SAP EH&S) application; and the SAP Recipe Management application. The business processes supported by SAP Best Practices for Chemicals encompass a wide range of activities typically found in a chemical industry
    Practice:
    u2022 Sales and marketing
    u2013 Sales order processing
    u2013 Presales and contracts
    u2013 Sales and distribution (including returns, returnables, and rebates, with quality management)
    u2013 Inter- and intracompany processes
    u2013 Cross-company sales
    u2013 Third-party processing
    u2013 Samples processing
    u2013 Foreign trade
    u2013 Active-ingredient processing
    u2013 Totes handling
    u2013 Tank-trailer processing
    u2013 Vendor-managed inventory
    u2013 Consignment processing
    u2013 Outbound logistics
    u2022 Supply chain planning and execution Supply and demand planning
    u2022 Manufacturing planning and execution
    u2013 Manufacturing execution (including quality management)
    u2013 Subcontracting
    u2013 Blending
    u2013 Repackaging
    u2013 Relabeling
    u2013 Samples processing
    u2022 Quality management and compliance
    u2013 EH&S dangerous goods management
    u2013 EH&S product safety
    u2013 EH&S business compliance services
    u2013 EH&S industrial hygiene and safety
    u2013 EH&S waste management
    u2022 Research and development Transformation of general recipes
    u2022 Supplier collaboration
    u2013 Procurement of materials and services (Including quality management)
    u2013 Storage tank management
    u2013 E-commerce (Chemical Industry Data Exchange)
    u2022 Enterprise management and support
    u2013 Plant maintenance
    u2013 Investment management
    u2013 Integration of the SAP NetWeaver Portal component
    u2022 Profitability analysis
    More Details
    This section details the most common business scenarios u2013 those that benefit most from the application of best practices.
    Sales and Marketing
    SAP Best Practices for Chemicals supports the following sales and marketingu2013related business processes:
    Sales order processing u2013 In this scenario, SAP Best Practices for Chemicals supports order entry, delivery, and billing. Chemical industry functions include the following:
    u2022 Triggering an available-to-promise (ATP) inventory check on bulk orders after sales order entry and automatically creating a filling order (Note: an ATP check is triggered for packaged material.)
    u2022 Selecting batches according to customer requirements:
    u2022 Processing internal sales activities that involve different organizational units
    Third-party and additional internal processing u2013 In this area, the SAP Best Practices for Chemicals package provides an additional batch production step that can be applied to products previously produced by either continuous or batch processing. The following example is based on further internal processing of plastic granules:
    u2022 Purchase order creation, staging, execution, and completion
    u2022 In-process and post process control
    u2022 Batch assignment from bulk to finished materials
    u2022 Repackaging of bulk material
    SAP Best Practices for Chemicals features several tools that help you take advantage of chemical industry best practices. For example, it provides a fully documented and reusable prototype that you can turn into a productive solution quickly. It also provides a variety of tools, descriptions of business scenarios, and proven configuration of SAP software based on more than 35 years of working with the
    Chemical industry.
    SAP Functions in Detail u2013 SAP Best Practices for Chemicals
    The package can also be used to support external toll processing such as that required for additional treatment or repackaging.
    Tank-trailer processing u2013 In this scenario, SAP Best Practices for Chemicals helps handle the selling of bulk material, liquid or granular. It covers the process that automatically adjusts the differences between the original order quantities and the actual quantities filled in the truck. To determine the quantity actually filled, the tank trailer is weighed before and after loading. The delta weight u2013 or quantity filled u2013 is transmitted to the SAP software via an order confirmation. When the delivery for the sales order is created, the software automatically adjusts the order quantity with the confirmed filling quantity.The customer is invoiced for the precise quantity filled and delivered.
    Supply Chain Planning and Execution
    SAP Best Practices for Chemicals supports supply chain planning as well as supply chain execution processes:
    Supply and demand planning u2013 Via the SAP Best Practices for Chemicals package, SAP enables complete support for commercial and supply-chain processes in the chemical industry, including support for integrated sales and operations planning, planning strategies for bulk material, and a variety of filling processes with corresponding packaging units. The package maps the entire supply chain u2013 from sales planning to material requirements planning to transportation procurement.
    Supplier Collaboration
    In the procurement arena, best practices are most important in the following
    Scenario:
    Procurement of materials and services:
    In this scenario, SAP Best Practices for Chemicals describes a range of purchasing processes, including the following:
    u2022 Selection of delivery schedules by vendor
    u2022 Interplant stock transfer orders
    u2022 Quality inspections for raw materials, including sampling requests triggered
    by goods receipt
    Manufacturing Scenarios
    SAP Best Practices for Chemicals supports the following sales and
    Manufacturingu2013related business processes:
    Continuous production u2013 In a continuous production scenario, SAP Best Practices for Chemicals typifies the practice used by basic or commodity chemical producers. For example, in the continuous production of plastic granules, production order processing is based on run-schedule headers. This best-practice package also describes batch and quality management in continuous production. Other processes it supports include handling of byproducts,co-products, and the blending process.
    Batch production u2013 For batch production,
    SAP Best Practices for Chemicals typifies the best practice used by specialty
    chemical producers. The following example demonstrates batch production
    of paint, which includes the following business processes:
    u2022 Process order creation, execution, and completion
    u2022 In-process and post process control
    u2022 Paperless manufacturing using XMLbased Process integration sheets
    u2022 Alerts and events
    u2022 Batch derivation from bulk to finished materials
    Enterprise Management and Support
    SAP Best Practices for Chemicals also supports a range of scenarios in this
    area:
    Plant maintenance u2013 SAP Best Practices for Chemicals allows for management
    of your technical systems. Once the assets are set up in the system, it focuses on preventive and emergency maintenance. Tools and information support the setup of a production plant with assets and buildings.Revenue and cost controlling u2013 The package supports the functions that help you meet product-costing requirements in the industry. It describes how cost centers can be defined, attached
    to activity types, and then linked to logistics. It also supports costing and settlement of production orders for batch and continuous production. And it includes information and tools that help you analyze sales and actual costs in a margin contribution report.
    The SAP Best Practices for Chemicals package supports numerous integrated
    business processes typical of the chemical industry, including the following:
    u2022 Quality management u2013 Supports integration of quality management concepts across the entire supplychain (procurement, production, and sales), including batch recall and complaint handling
    u2022 Batch management u2013 Helps generate batches based on deliveries from vendors or because of company production or filling, with information and tools for total management of batch production and associated processes including batch  derivation, batch information cockpit, and a batchwhere- used list
    u2022 Warehouse management u2013 Enables you to identify locations where materials
    or batch lots are stored, recording details such as bin location and other storage information on dangerous goods to help capture all information needed to show compliance with legal requirements
    Regards
    Sudheer

  • ADF Deployment Granularity - Best Practices

    Hi People,
    If anyone can spare some time to discuss this, I would like some pointers about ADF applications deployment best practices. For example, we have some customers that complain about having to re-deploy the entire application EAR just to add a field "rendered" condition on a single page, and also having to re-deploy the ADF BC model JARs even though the application has only been changed on the view layer.
    What level of deployment granularity can we JDeveloper + ADF developers provide to our customers, without the risk of having inconsistency or dependency problems? So far, our strategy is to deploy the BC Model layer to separate JARs and the View Layer in a WAR file, packaging everything in an EAR. Is it feasible to allow the developers to change one single page and generate a deployment archive for just that single page? If not, which arguments can i provide in a discussion to support the single-deployment point of view?
    Thanks for your time, and regards!
    Thiago

    Hi Thiago
    Interesting question and one that comes up from time to time with JEE applications. I've been doing some research on this issue, and recently blogged about how OC4J and BEA Weblogic handles this scenario. Hopefully the post and reference to the OTN post gives you more information, though I'd be interested if you're research reveals a different approach.
    I'm also hoping this issue comes up at the OOW ADF Methodology chat among the JDev experts, it would be good for the experts to share their different approaches to this common issue.
    I know this doesn't give you a direct answer but hopefully will be useful.
    Cheers,
    CM.

  • Best use of framework events in application architecture

    Hello,
    I apologize in advance if this is not the appropriate forum to be posting about Flex framework questions.  I considered the Cairngorm forum, but thought the question applied more broadly to all flex frameworks. That, and it seems that the Cairngorm forum isn't really very active.
    My question is about using frameworks for application architecture. Reading the "Introducing Cairngorm" document,  I see that it specifically says that Cairngorm events are just those events that will handle business logic (things like grabbing data from a server, committing data to a server, etc).  So then, how does a view interact with a controller when changing state?
    Let's say I have two or three different views of the same data and I have a buttonbar to switch to the view I want. Is it then typical to dispatch a Cairngorm (or Mate/Swiz/Pure MVC, etc..)  event to the controller to change the view state of the application?  Does this effectively mean that for every button a user can click on, we'll have an event and a command associated with that event to perform some change of state or business logic? With a moderately complicated application, with several different screens, a few forms, a couple of lookups, i.e. lots of buttons for user input, that seems like an awfully huge number of events/commands...? Or do you dispatch a regular old flash Event to handle this? Or does the view data bind to the model to change the view state?
    Obviously there's never any single correct answer to application architecture questions, but I'd like to know if there's any general best practices that I should follow. I don't want to under-architect OR over-architect my app.  I'm new to Flex programming and would like not to code something egregiously ugly.
    Thanks,
    Cory

    Hi,
    Consider this, there is no such thing as an enterprise level RIA, the whole concept behind thin client was to restrict the enterprise requirements to the backend, that being said if we assume that a flex application is specifically for the client end and can maintain its own state and that MVC frameworks are more about enterprise solutions then the whole framework argument becomes what it is, academic BS.
    <start rant>
    Its really simply, in half a century nothing has changed, you have rules and requirements(model), you have access to that(view) and you wrap it up as a program/application(controller) so  why do you need convoluted multilayer abstraction of functionality to make things work ? maybe so those that can't get a real development job can run around and preach at conferences, how else could they feed their adopted kids.
    So all those nice buzzwords, design patterns(the new age terminology for modular architecture), model/view/controller, borg coding(resistance is futile) is all very fine if you want to act smart but producing quality code actually means you are smart. As you may have guessed I am not a strong proponent of MVC frameworks, and I don't even need to get into the argument that everytime a 'framework' expert gets control of a project that isn't done in their MVC  poison of choice it gets a rewrite, clients really love those associated costs and retesting requirements.
    </end rant>
    You only need 1 framework for flex and thats the flex framework.
    Have a read this blog, the section on MVC and Flex is very interesting if not overly polite.
    http://www.herrodius.com/blog/216
    David

  • EFP and Intranet Portal - Best Practices for architecture

    Hi All,
       We are planning to create a portal for our partners  (b2b scenario). This portal will provide anonymous  and user specific access. We also have a intranet portal with ESS and MSS.  I have some doubts around implementing EFP and Intranet portal.
       1) What is the best practice solution architecture around portal instances? Is it suggested to implement both intranet and internal portals on same portal instance? Do you implement them as 2 seperate instances (and 2 seperate boxes) one for intranet and another for internet?
       2) There are couple of functions shared between inranet and internet portals. Has any one attempted   a FPN connection between a internet portal and intranet portal?
       3)  What is the best practices around an external portal connecting to ECC directly?
    Any suggestions are greatly appreciated.

    Hi Pallayya,
             We are implementing a similar kind of thing for our client.I can explain that so you find some glimpse out of it.
    We have decided twp ways.
    1) We are having one instance of the portal that will be accessed both in Intranet & Internet.We are using two different URL for intranet & internet.We have a reverse proxy in the picture also,coz it will increase the security of the portal in the Internet.The reverse proxy will be available in the DMZ Zone.We have integrated ECC & BW with the portal and some web dynpro application(For intranet only).
    Now the user comes from the Internet will hit the reverse proxy first->then it will go to EP Server->in EP it will be decided which kind of request client is asking ->
    If it is a ECC request->Portal Server sends back the request to Reverse Proxy->RP will send it to web dispatcher->Then it will go to ECC.
    If it is a BW request ->Portal server sends the request to BW Server.
    2) There will be two different URLS for the portal in Intranet & Internet
         For that we used two reverse proxy
    regards
    Indranil

  • Best Practice in regards to adding showing SkinnablePopUp from the Main application file of Mobile A

    Hello,
    I want to display a SkinnablePopUp when the user presses the back key when the current view is the first view to ask if he wants to quit.
    The logic (checking if the key pressed was the back key && the current view is the first view) is in the main application file and if those two conditions are true then the exit() method is called.
    I want to show the confirmation popup. Should I move all that in the first view mxml component or is it OK to instantiate the SkinnablePopUp in the main app file?
    Thank you.

    so do I, or did, well still do but less than before
    it seems best practice is to seperate mxml and AS3
    have a look at this
    http://tv.adobe.com/watch/max-2010-develop/flexactionscript-30-architecture-and-dependency -injection-frameworks-overview/

  • Best practices for JavaFX architecture and patterns?

    Hi,
    I want to write reusable, easy to maintain JavaFX code for a larger UI project and wonder what are the best practices doing so.
    1) Are there preferred UI patterns? MVC, MVP, Presentation Model, ...?
    2) Does it make sense to use FXML to separate View from Logic? Or should I use 2-3 Java classes instead (one for View, one for Logic, one for Domain Model, depending on the pattern)
    3) How to organize all the views? Should I use Dependency Injection? Or Singletons for each view? Spring or Guice framework, if at all?
    Currently I use singletons for most views, so that I can use them from anywhere in my application. If a window is closed and opened again, I use the same instance for that, which still resists in memory.
    For patterns, I try to lean on Presentation Model, since this is what I know from Flex development: Having a View layer, which contains all the UI stuff and an abstract view layer, which holds properties, that describe the View, e.g. submitButtonDisabledProperty. The View knows the abstract layer (Presentation Model), but not vice versa and the UI elements are bound to its properties.
    I am unsure if this is appropriate for JavaFX, too (for Flex or Silverlight it is).
    What are your recommendations / experiences for large UI projects?

    You are correct that in 'pure' MVP the View should know as little about it's presenter implementation as possible. The view should just notify one or more 'listeners' that something has happened.
    You can use event listeners for this, but I would highly recommend not exposing your Control-specific GUI events and instead create your own. So for example, don't expose ActionEvent or MouseEvent as these expose too much detail about your View's implementation, instead create 'semantic' events, so you might have something like 'sayHelloRequested' or 'printOptionSelected' (whatever naming system you want). This hides how the option is implemented, so you might have a 'print' button, a 'print' menu option, a CTRL+P print shortcut, or a double tap anywhere on your screen to print. The listener knows only that the view thinks 'print was requested by the user' - decoupling achieved.
    Once you start doing this however you end up with an explosion of event listener interfaces. So say a view has 10 callbacks it wants to notify about, then you end up with 10 interfaces, and if you're being really pure you also end up with 10 'Event' beans (or DTOs) to encapsulate the details of that event. It starts to get ungainly even for a semi-purist like me. So the logical progression from there is usually just to define all 10 callbacks in one interface and call it something like MyViewListener.
    There are two common ways to implement listeners, the traditional way is to allow an arbitrary number of listeners to be added. Whereas another option is to allow only a single listener to be added. In JFX you will notice that Button for example has a setOnAction() method not a addOnAction() method - it allows a single event handler only and let's face it this is generally fine in 95% of cases. For the remaining 5% you can just write your own aggregate event handler that dispatches the event to multiple listeners.
    So if we go down the road of single event listeners, using an interface for all of the callbacks and not bothering with full 'Event' objects, you end up with something like this:
    public interface MyViewListener {
        void printRequested();
        void doSomething(int someParam);   
        void doSomethingElse(String someOtherParam);   
    }And if you look closely at the 'Purist' option in my MVP pattern where I define interfaces for everything, then you will see that this is pretty much the exact interface I've created for the 'Presenter'. You could just as easily rename this interface to MyViewListener in this pattern and have the same outcome.
    So to wrap all that up, yes, the Presenter should be decoupled and I highly favour the 'purist' option in my blog and would definitely use it if FXML didn't dictate a impure design pattern (there are some ongoing discussions about this on the OpenJFX discussion group). And, yes, my 'purist' option could be even more pure if you went for the full-blown event callback model and if you go down that road you will have an extremely clean architecture but also an extremely large code-base - totally your call whether it's worth it.
    It's also worth remembering in all this, that there are a lot of people from a lot of different backgrounds using JFX and some people hate (passionately) even my semi-pure option - especially those coming from other, less heavy-weight languages. They just don't get why you wouldn't build it all into one class and reduce the overheads. So what you have in my blog is my thoughts on it, other people will most definitely differ. I'm a big fan of developer's choice, and that's why I did the smorgasboard approach even though I personally would never use some of those implementations.
    Also this video on GWT is an awesome reference on GUI design patterns: http://www.youtube.com/watch?v=PDuhR18-EdM
    JFX Flow draws a lot from GWT as I think it is a very clean architecture (just such a shame that they put all that effort into hiding the horrid, sordid mess that is the web+html+css, instead of making something proper, like JFX).
    Hope that helps,
    zonski

Maybe you are looking for

  • Can't take screenshot on iPhone 5, iOS 8.1.3 - tried everything already

    Help! My screenshot function is not working too. I have a iPhone 5, oh an iOS 8.1.3 software. I've done everything in previous threads with similar issues. I've pressed it correct and even tried hard reboot by pressing both home and power buttons. I'

  • Un able to install Scan to Email app on Color LaserJet Pro MFP M177fw

    Hello! I recently purchased  Color LaserJet Pro MFP M177fw as my home printer. Main thing i was looking for was Scan to Email feature. As I read in specifications provided in this product description I see: http://www.shopping.hp.com/shopping/pdf/cz1

  • Hardware Configuration: SATA2 and SAS on oracle 10g

    Hi We are currently operating an in-house server with 2xSata2 drives running OS and applications and 5xSCSI disks for data index and log partitions. We're trying to transfer the database to a hosting service and are considering using a 2xSAS disk con

  • Dreamweaver CS4 Cannot get Spry.Data.NestedXMLDataSet with XML to work

    Please help! I've created a page in Dreamweaver CS4 with a spry dataset. This works great. I've downloaded Spry.Data.NestedXMLDataSet and installed it but I keep getting an error that nested datasets are not supported. Thoughts solutions. Thanks, M

  • IMovie auto shortening clips, cant re-size

    I convert stills into clips and then use these as transitions. However as I add more transitions and video clips, iMovie keeps shortening all the actual video clips in the project to the point where they are only 1 second if that. If that wasn't bad