There are several differences between HashMap
and Hashtable
in Java:
Hashtable
is synchronized, whereas HashMap
is not. This makes HashMap
better for non-threaded applications, as unsynchronized Objects typically perform better than synchronized ones.
Hashtable
does not allow null
keys or values. HashMap
allows one null
key and any number of null
values.
One of HashMap's subclasses is LinkedHashMap
, so in the event that you'd want predictable iteration order (which is insertion order by default), you could easily swap out the HashMap
for a LinkedHashMap
. This wouldn't be as easy if you were using Hashtable
.
Since synchronization is not an issue for you, I'd recommend HashMap
. If synchronization becomes an issue, you may also look at ConcurrentHashMap
.
GZIP filter will reduce the initial load time significantly.
You can additionally implement a cacheFilter to bring performance of your screens at par with JavaScript based UI (https://stackoverflow.com/a/35567540/5076414).
For client side components, you can use Primefaces which is JQuery based UI.
Enable GZIP filter in JSF
Simply add this to your
web.xml
<filter>
<filter-name>gzipResponseFilter</filter-name>
<filter-class>org.omnifaces.filter.GzipResponseFilter</filter-class>
<init-param>
<description>The threshold size in bytes. Must be a number between 0 and 9999. Defaults to 150.</description>
<param-name>threshold</param-name>
<param-value>150</param-value>
</init-param>
<init-param>
<description>The mimetypes which needs to be compressed. Must be a commaseparated string. Defaults to the below values.</description>
<param-name>mimetypes</param-name>
<param-value>
text/plain, text/html, text/xml, text/css, text/javascript, text/csv, text/rtf,
application/xml, application/xhtml+xml, application/x-javascript, application/javascript, application/json,
image/svg+xml, image/gif, application/x-font-woff, application/font-woff2, image/png
</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>gzipResponseFilter</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
<dispatcher>ERROR</dispatcher>
</filter-mapping>
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/</location>
</error-page>
And the following to your
pom.xml
<dependency>
<groupId>org.omnifaces</groupId>
<artifactId>omnifaces</artifactId>
<version>1.11</version>
</dependency>
How to verify if my screen is using gzip
To see if your contents are already usign gzip and cache, In your Google Chrome Browser -> right click on your screen -> inspect -> click network tab -> refresh your screen. Click on the images, icons, stylesheets and see if you see following in response header
Content-Encoding:gzip
if the status of element is 200
Best Answer
The advantage of any framework like SEAM or Grails is that it's a higher level of abstraction. It takes care of underlying details for you and, if it's designed and written well, makes things easier.
The disadvantage of any framework like SEAM or Grails is that it hides a lot of details from you. If you don't ever learn what's going on underneath you can find yourself in a world of trouble if you get stuck and don't know anything about the code that's generated for you.
Another disadvantage is that the assumptions they build into the model might not always be what you want. But changing them means breaking the path that they've laid down for you, which isn't easy.
My advice would be to use the framework and appreciate the advantages it brings, but don't use them as an excuse to stop learning what's happening underneath. Be the person who could write the whole thing by hand, without the framework, but chooses to use it for the leverage it provides.