Featured FREE Whitepapers

What's New Here?

docker-logo

Getting Started with Docker

If the numbers of articles, meetups, talk submissions at different conferences, tweets, and other indicators are taken into consideration, then seems like Docker is going to solve world hunger. It would be nice if it would, but apparently not. But it does solve one problem really well! Lets hear it from @solomonstre – creator of Docker project!            In short, Docker simplifies software delivery by making it easy to build and share images that contain your application’s entire environment, or application operating system. What does it mean by application operating system ? Your application typically require a specific version of operating system, application server, JDK, database server, may require to tune the configuration files, and similarly multiple other dependencies. The application may need binding to specific ports and certain amount of memory. The components and configuration together required to run your application is what is referred to as application operating system. You can certainly provide an installation script that will download and install these components. Docker simplifies this process by allowing to create an image that contains your application and infrastructure together, managed as one component. These images are then used to create Docker containers which run on the container virtualization platform, provided by Docker. What are the main components of Docker ? Docker has two main components:Docker: the open source container virtualization platform Docker Hub: SaaS platform for sharing and managing Docker imagesDocker uses Linux Containers to provide isolation, sandboxing, reproducibility, constraining resources, snapshotting and several other advantages. Read this excellent piece at InfoQ on Docker Containers for more details on this. Images are “build component” of Docker and a read-only template of application operating system. Containers are runtime representation, and created from, images. They are “run component” of Docker. Containers can be run, started, stopped, moved, and deleted. Images are stored in a registry, the “distribution component” of Docker. Docker in turn contains two components:Daemon runs on a host machine and does the heavy lifting of building, running, and distributing Docker containers. Client is a Docker binary that accepts commands from the user and communicates back and forth with daemonHow do these work together ? Client communicates with Daemon, either co-located on the same host, or on a different host. It requests the Daemon to pull an image from the repository using pull command. The Daemon then downloads the image from Docker Hub, or whatever registry is configured. Multiple images can be downloaded from the registry and installed on Daemon host.Client can then start the Container using run command. The complete list of client commands can be seen here. Client communicates with Daemon using sockets or REST API. Because Docker uses Linux Kernel features, does that mean I can use it only on Linux-based machines ? Docker daemon and client for different operating systems can be installed from docs.docker.com/installation/. As you can see, it can be installed on a wide variety of platforms, including Mac and Windows. For non-Linux machines, a lightweight Virtual Machine needs to be installed and Daemon is installed within that. A native client is then installed on the machine that communicates with the Daemon. Here is the log from booting Docker daemon on Mac: bash unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH mkdir -p ~/.boot2docker if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi /usr/local/bin/boot2docker init /usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375 docker version ~> bash ~> unset DYLD_LIBRARY_PATH ; unset LD_LIBRARY_PATH ~> mkdir -p ~/.boot2docker ~> if [ ! -f ~/.boot2docker/boot2docker.iso ]; then cp /usr/local/share/boot2docker/boot2docker.iso ~/.boot2docker/ ; fi ~> /usr/local/bin/boot2docker init 2014/07/16 09:57:13 Virtual machine boot2docker-vm already exists ~> /usr/local/bin/boot2docker up && export DOCKER_HOST=tcp://$(/usr/local/bin/boot2docker ip 2>/dev/null):2375 2014/07/16 09:57:13 Waiting for VM to be started... ....... 2014/07/16 09:57:35 Started. 2014/07/16 09:57:35 To connect the Docker client to the Docker daemon, please set: 2014/07/16 09:57:35 export DOCKER_HOST=tcp://192.168.59.103:2375 ~> docker version Client version: 1.1.1 Client API version: 1.13 Go version (client): go1.2.1 Git commit (client): bd609d2 Server version: 1.1.1 Server API version: 1.13 Go version (server): go1.2.1 Git commit (server): bd609d2 For example, Docker Daemon and Client can be installed on Mac following the instructions at docs.docker.com/installation/mac. The VM can be stopped from the CLI as: boot2docker stop And then restarted again as: boot2docker boot And logged in as: boot2docker ssh The complete list of boot2docker commands are available in help: ~> boot2docker help Usage: boot2docker [] []boot2docker management utility.Commands: init Create a new boot2docker VM. up|start|boot Start VM from any states. ssh [ssh-command] Login to VM via SSH. save|suspend Suspend VM and save state to disk. down|stop|halt Gracefully shutdown the VM. restart Gracefully reboot the VM. poweroff Forcefully power off the VM (might corrupt disk image). reset Forcefully power cycle the VM (might corrupt disk image). delete|destroy Delete boot2docker VM and its disk image. config|cfg Show selected profile file settings. info Display detailed information of VM. ip Display the IP address of the VM's Host-only network. status Display current state of VM. download Download boot2docker ISO image. version Display version information. Enough talk, show me an example ? Some of the JBoss projects are available as Docker images at www.jboss.org/docker and can be installed following the commands explained on that page. For example, WildFly Docker image can be installed as: ~> docker pull jboss/wildfly Pulling repository jboss/wildfly 2f170f17c904: Download complete 511136ea3c5a: Download complete c69cab00d6ef: Download complete 88b42ffd1f7c: Download complete fdbe853b54e1: Download complete bc93200c3ba0: Download complete 0daf76299550: Download complete 3a7e1274035d: Download complete e6e970a0db40: Download complete 1e34f7a18753: Download complete b18f179f7be7: Download complete e8833789f581: Download complete 159f5580610a: Download complete 3111b437076c: Download complete The image can be verified using the command: ~> docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE jboss/wildfly latest 2f170f17c904 8 hours ago 1.048 GB Once the image is downloaded, the container can be started as: docker run jboss/wildfly By default, Docker containers do not provide an interactive shell and input from STDIN. So if WildFly Docker container is started using the command above, it cannot be terminated using Ctrl + C.  Specifying -i option will make it interactive and -t option allocated a pseudo-TTY. In addition, we’d also like to make the port 8080 accessible outside the container, i.e. on our localhost. This can be achieved by specifying -p 80:8080 where 80 is the host port and 8080 is the container port. So we’ll run the container as: docker run -i -t -p 80:8080 jboss/wildfly =========================================================================JBoss Bootstrap EnvironmentJBOSS_HOME: /opt/wildflyJAVA: javaJAVA_OPTS: -server -Xms64m -Xmx512m -XX:MaxPermSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true=========================================================================22:08:29,943 INFO [org.jboss.modules] (main) JBoss Modules version 1.3.3.Final 22:08:30,200 INFO [org.jboss.msc] (main) JBoss MSC version 1.2.2.Final 22:08:30,297 INFO [org.jboss.as] (MSC service thread 1-6) JBAS015899: WildFly 8.1.0.Final "Kenny" starting 22:08:31,935 INFO [org.jboss.as.server] (Controller Boot Thread) JBAS015888: Creating http management service using socket-binding (management-http) 22:08:31,961 INFO [org.xnio] (MSC service thread 1-7) XNIO version 3.2.2.Final 22:08:31,974 INFO [org.xnio.nio] (MSC service thread 1-7) XNIO NIO Implementation Version 3.2.2.Final 22:08:32,057 INFO [org.wildfly.extension.io] (ServerService Thread Pool -- 31) WFLYIO001: Worker 'default' has auto-configured to 16 core threads with 128 task threads based on your 8 available processors 22:08:32,108 INFO [org.jboss.as.clustering.infinispan] (ServerService Thread Pool -- 32) JBAS010280: Activating Infinispan subsystem. 22:08:32,110 INFO [org.jboss.as.naming] (ServerService Thread Pool -- 40) JBAS011800: Activating Naming Subsystem 22:08:32,133 INFO [org.jboss.as.security] (ServerService Thread Pool -- 45) JBAS013171: Activating Security Subsystem 22:08:32,178 INFO [org.jboss.as.jsf] (ServerService Thread Pool -- 38) JBAS012615: Activated the following JSF Implementations: [main] 22:08:32,206 WARN [org.jboss.as.txn] (ServerService Thread Pool -- 46) JBAS010153: Node identifier property is set to the default value. Please make sure it is unique. 22:08:32,348 INFO [org.jboss.as.security] (MSC service thread 1-3) JBAS013170: Current PicketBox version=4.0.21.Beta1 22:08:32,397 INFO [org.jboss.as.webservices] (ServerService Thread Pool -- 48) JBAS015537: Activating WebServices Extension 22:08:32,442 INFO [org.jboss.as.connector.logging] (MSC service thread 1-13) JBAS010408: Starting JCA Subsystem (IronJacamar 1.1.5.Final) 22:08:32,512 INFO [org.wildfly.extension.undertow] (MSC service thread 1-9) JBAS017502: Undertow 1.0.15.Final starting 22:08:32,512 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017502: Undertow 1.0.15.Final starting 22:08:32,570 INFO [org.jboss.as.connector.subsystems.datasources] (ServerService Thread Pool -- 27) JBAS010403: Deploying JDBC-compliant driver class org.h2.Driver (version 1.3) 22:08:32,660 INFO [org.jboss.as.connector.deployers.jdbc] (MSC service thread 1-10) JBAS010417: Started Driver service with driver-name = h2 22:08:32,736 INFO [org.jboss.remoting] (MSC service thread 1-7) JBoss Remoting version 4.0.3.Final 22:08:32,836 INFO [org.jboss.as.naming] (MSC service thread 1-15) JBAS011802: Starting Naming Service 22:08:32,839 INFO [org.jboss.as.mail.extension] (MSC service thread 1-15) JBAS015400: Bound mail session 22:08:33,406 INFO [org.wildfly.extension.undertow] (ServerService Thread Pool -- 47) JBAS017527: Creating file handler for path /opt/wildfly/welcome-content 22:08:33,540 INFO [org.wildfly.extension.undertow] (MSC service thread 1-13) JBAS017525: Started server default-server. 22:08:33,603 INFO [org.wildfly.extension.undertow] (MSC service thread 1-8) JBAS017531: Host default-host starting 22:08:34,072 INFO [org.wildfly.extension.undertow] (MSC service thread 1-13) JBAS017519: Undertow HTTP listener default listening on /0.0.0.0:8080 22:08:34,599 INFO [org.jboss.as.server.deployment.scanner] (MSC service thread 1-11) JBAS015012: Started FileSystemDeploymentService for directory /opt/wildfly/standalone/deployments 22:08:34,619 INFO [org.jboss.as.connector.subsystems.datasources] (MSC service thread 1-9) JBAS010400: Bound data 22:08:34,781 INFO [org.jboss.ws.common.management] (MSC service thread 1-13) JBWS022052: Starting JBoss Web Services - Stack CXF Server 4.2.4.Final 22:08:34,843 INFO [org.jboss.as] (Controller Boot Thread) JBAS015961: Http management interface listening on http://0.0.0.0:9990/management 22:08:34,844 INFO [org.jboss.as] (Controller Boot Thread) JBAS015951: Admin console listening on http://0.0.0.0:9990 22:08:34,845 INFO [org.jboss.as] (Controller Boot Thread) JBAS015874: WildFly 8.1.0.Final "Kenny" started in 5259ms - Started 184 of 233 services (81 services are lazy, passive or on-demand) Container’s IP address can be found as: ~> boot2docker ipThe VM's Host only interface IP address is: 192.168.59.103 The started container can be verified using the command: ~> docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES b2f8001164b0 jboss/wildfly:latest /opt/wildfly/bin/sta 46 minutes ago Up 12 minutes 8080/tcp, 9990/tcp sharp_pare And now the WildFly server can now be accessed on your local machine as http://192.168.59.103 and looks like as shown:Finally the container can be stopped by hitting Ctrl + C, or giving the command as: ~> docker stop b2f8001164b0 b2f8001164b0 The container id obtained from “docker ps” is passed to the command here. More detailed instructions to use this image, such as booting in domain mode, deploying applications, etc. can be found at github.com/jboss/dockerfiles/blob/master/wildfly/README.md. What else would you like to see in the WildFly Docker image ? File an issue at github.com/jboss/dockerfiles/issues. Other images that are available at jboss.org/docker are:KeyCloak TorqueBox Immutant LiveOak AeroGearReference: Getting Started with Docker from our JCG partner Arun Gupta at the Miles to go 2.0 … blog....
software-development-2-logo

The reuse dilemma

The first commandment that any young programmer learns is “Thou Shall Not Duplicate”. Thus instructed, whenever we see something that looks like it may be repeated code, we refactor. We create libraries and frameworks. But removing duplication doesn’t come for free. If I refactor some code so that instead of duplicating some logic in Class A and Class B, these classes share the logic in Class R (for reuse!). Now Classes A and B are indirectly coupled. This is not necessarily a bad thing, but it comes with some consequences, which are often overlooked. If Class A require the shared functionality to change, we have a choice: We make the change or we stymie Class A. Making the change comes at a cost of breaking Class B. If these classes are in the same Java package (or .NET Namespace), chances are that we will be able to verify that the change didn’t break anything. If the reused functionality is in a library that is used by another library that is used by a Class B, verifying that the change was good is harder. This is where Continuous Integration comes in. We check in our change to class R (for reuse, remember). A build is triggered on Jenkins, Bamboo, TFS or what have you. The build causes other projects to get built and eventually, we get a failing build where a unit test for Class B breaks. If we did our job right. Even with this failing test, we’re not out of the woods. A build system for a large enterprise may take up to an hour or even more to run. This means that by trying to improve Class R, the developers of Class A have made a mess for the developers of Class B at least for a good while. When organizations see repeated build breaks due to changes in dependencies, the reaction is usually the same: Lets limit changes to the shared code. Perhaps we’ll even version it, so that any change that you need will be released in the next version and dependencies can upgrade at their own pace. Now we’ve introduced another problem: We are no longer able to change the code. Developers of Class A will have to take Class R as it is, or at the very least go through substantial work to change it. If the reused code is very mature, this is fine. After all, this is what we have to deal with when it comes to language standard libraries and open source projects. Most reused code inside an organization, however, isn’t so mature. The developers of Class A will often be frustrated by the limitations of Class R. If the reused class is something very domain specific, the limitation is even worse. So the developers do what any reasonable developer would do: They make a copy of Class R (or they fork the repository where it lives), creating a new duplication of the code. And so it goes: Removing duplication leads to risk of adverse interactions between reusers. Organizations enforce change control on the reused code to avoid changes made in one context from breaking other parts of the system, resulting in paralysis for the reusers who need the reused code to change. The reusers eventually duplicate the reused code to their own branch where they can evolve it, leading to duplication. Until someone gets the urge to remove the duplication. The dilemma happens in the small and in the large, but the trade-offs are different. What we should do less is to reuse immature code with little novel value. The cost of the extra coupling often far outweighs the benefit of reuse.Reference: The reuse dilemma from our JCG partner Johannes Brodwall at the Thinking Inside a Bigger Box blog....
jetbrains-intellijidea-logo

Keyboard shortcuts in IntelliJ

I attended a talk by Hadi Hariri at JavaOne last week. He introduced a whole bunch of IntelliJ keyboard shortcuts I was not aware of. Very useful talk. I have listed some of the most useful ones below.Cmd-1: Move focus to the Project windowWhile there, type any class name (including using Camel Case e.g. HW to find HelloWorld), then git enter to have it open in the editor. F4 or Escape brings you to the editor.    Fn-Alt-Left arrow (Alt + ↖); Alt + Home also seems to work): Jump to Navigation Bar.The Navigation Bar is a quick alternative to the Project view, for navigating to and opening files for editing. Since I do not have a function key on my Kinesis Advantage keyboard, I reprogrammed this to be Cmd ‘ (Command and quote) Note that my preference is to hide the Navigation bar (View -> Navigation bar), and just call it on demand via Alt + Home (Alt + ↖ for Mac) shortcut. Ctrl-N (or Alt-Insert) can then be used to create a new class.Cmd-E: Show recent files Cmd-Shift-E: Show recently edited files Cmd-Shift-Backspace jump to the latest edit location These are all very useful and even allow you to turn of the use of tabs completely (Preferences -> IDE Settings -> Editor -> Editor Tabs -> Placement -> None).Editing shortcutsCmd-D: duplicate current line Cmd-Y: delete current line Ctrl+Shift+Up or Ctrl+Shift+Down: Move Statement Up/Move Statement Down. Note that if you place the caret at the method declaration, it will move the whole method for you. See more at https://www.jetbrains.com/idea/webhelp/adding-deleting-and-moving-lines.html Ctrl-W: select ever expanding blocks of text Alt-Backspace, Alt-Delete: delete to word start/endCmd-, Preferences Cmd-` Switch between projects Shift-Cmd-A Show shortcuts; this is a useful way to navigate to any IntelliJ commandReference: Keyboard shortcuts in IntelliJ from our JCG partner Shaun Abram at the Shaun Abram’s blog blog....
software-development-2-logo

The Estimates Land mine – use and misuse of estimates

After posting my last post – Estimate or #NoEstimate that is the question? – I felt a little as if I’d stepped on a land-mine. That is to say I had a few comments and a bit a mini-twitter storm. If I’m being honest I have been avoiding some of the estimates/#NoEstimates debate until now precisely because it is obvious feelings on the topic run high. Perhaps the thing that surprised me most was that a post intended to support making human estimates was interpreted by many Tweeters as part of the #NoEstimates movement! Maybe convergence between #NoEstimates and #NoProjects is already happening in the public mind.   In the meantime it seems to me that a lot of the problem with Estimates lies in what they are, what they are not, how they are used and how they are mis-used. As is so often the case it all depends on what we mean by the word, in this case “Estimate”. Generally I find it useful to agree with Humpty Dumpty: “When I use a word it means just what I choose it to mean—neither more nor less.” (Through the Looking-Glass, Lewis Caroll). After all, who can forget Bill Clinton saying: “It depends upon what the meaning of the word ‘is’ is.” While I am sometimes guilty of the use and misuse of words myself I find it helps to keep an open mind on just what someone means when they use a word or phrase. For example, if a developer says “Unit tests” I try not to jump to assumptions about what “Unit tests” actually are. The fact that such language is used is itself interesting but I also want to know what they actually mean by it. But back to the word “Estimates.” On occasions like this I like to check my dictionary, in this case the : “Estimate 1.        to form an approximate idea of (size, cost, etc.); calculate roughly 2.        to form an opinion; judge 3.        submit an approximate price for a job to a prospective client 4.        an approximate calculation 5.        a statement of the likely charge for certain work 6.        an opinion” (Collins Paperback English Dictionary 2001)My other usual source is Wikipedia which on this occasion gives: “Estimation is the process of finding an estimate, or approximation, which is a value that is usable for some purpose even if input data may be incomplete, uncertain, or unstable. The value is nonetheless usable because it is derived from the best information available.”From these definitions I define a sense that an estimate is:Approximate A statement of possibility Is based on available data which may itself be incomplete or variableMaybe all estimates should be accompanies by a statement of probability but as Kahneman and Tversky described in the planning fallacy, and has been proved repeatedly since, not only do humans underestimate time but humans are over confident in their estimates. Thus any estimate probability statement would probably itself be an over estimate of probability. Besides, very few of the “estimates” I’ve ever seen are accompanied by a statement of probability so I don’t think this suggest will get very far. More importantly these definitions also help tell us determine what an estimate is not:As estimate is not exact An estimate is not a promise, guarantee or commitment An estimate is not a target or deadlineAnd it is not several other things. Now in my previous blog post I introduced the idea of “Accurate Estimates” so I was actually sneaking in the idea that an estimate could have a high probability and could be an accurate indicator of what will happen. Perhaps I was guilty of something there. The trap I fell into is one that many fall into, that of accepting the general usage of the word “Estimate”. In general usage – in the software community – we misuse the word estimate. Firstly we automatically equate Estimate with “Effort Estimate”: effort (and therefore cost) estimate proliferate in software development but we overlook other estimates that might be useful, in particular Benefit Estimate. Second the inherently approximate nature of estimation is too often ignore, estimated are endowed with a sense of promise of what will be rather than recognising their inherent approximate nature. (And as noted in the Planning Fallacy, Vierordt’s Law and Hofstadter’s Law time estimates will always be under estimates.) This also leads to too much conversation about “Why was the estimate wrong?” – sometime blame may be implied. The answer to the question is really: “The estimate is not wrong because it was an ESTIMATE” That is to say: An estimate is never wrong because an estimate is an approximation and therefore is not binary “Right” or “Wrong”. Sure you can have a conversation about why the estimate was very different to what actually played out but the nature of that conversation is going to be different depending on what you will do with the findings of the conversation. For example, if the resulting information is used to refine future estimates it will be a very different conversation to one where the result will be punishment for someone. (Yes, people do get punished, I once saw a company where Project Managers were rewarded/punished based on the variance between estimated time spent on work and actual time spent.) In short too often an approximate estimates based on variable information is used as some kind of exact promise to meet a deadline. Software developers love to imagine it is evil managers who take their estimates, massage them to be politically correct, promise them to higher ups and then force poor coders to honour the number they first thought, but, big BUT, managers are not the only ones. Even in everyday life the Planning Fallacy, Vierordt’s Law and Hofstadter’s Law hold. Observe yourself next time you have to catch a bus, train, complete a tax return, hand in course work or do something (almost anything) with your kids. I would love it if I could wave a magic wand and reset everyones’ understanding of the word Estimate but I don’t see it happening. And I think – although Woody and Vasco might like to correct me – that a large part of the #NoEstimates movement is motivated by this problem. The way I see the logic is:Estimates are seldom recognised for what they really are and honoured as such. Estimates are misused and used as a stick to beat people and organizations. Therefore estimates have become a problem and it is better of finding a way or working without them.I’m not saying this is the whole #NoEstimates logic but it is part which strikes a chord with me. Incidentally, because I believe estimates are not a promise I don’t believe in Scrum commitment and because I believe they are approximate that in Xanpan I focus their use on the near term. And because I believe benefits should dictate deadlines not effort I refuse to use estimates as deadlines.Reference: The Estimates Land mine – use and misuse of estimates from our JCG partner Allan Kelly at the Agile, Lean, Patterns blog....
java-logo

JavaOne 2014 Observations by Proxy

I wasn’t able to attend JavaOne this year, but have been happy to see some online resources covering what happened at JavaOne 2014. In this post, I summarize some of the observations made at JavaOne 2014 and provide links to references providing these observations or providing more background details on those observations. The listed observations are in no particular order and many of them come from the JavaOne 2014 Keynote Addresses. Rapid Adoption of Java 8 The Oracle Press Release associated with JavaOne 2014 states, “Since its launch in March 2014, Java SE 8 has achieved record adoption rates. Overall, adoption is up more than 20 percent compared to the same post-launch time period for Java SE 7.”1 George Saab highlighted this rapid adoption with the observation in the Strategy Keynote that there are already eight Java 8 publications available in eight different languages.4. Intel and Java Intel was an “Innovation Sponsor” of JavaOne 2014 and, because of that, had a portion of the JavaOne 2014 “Java Partner Community Keynote” address. In this address, it was stated that Java runs 32 times faster on Intel since 20072. It was also announced that Intel has joined the OpenJDK as a Contributing Member.2,5 New OpenJDK Partners The Oracle Press Release for JavaOne 2014 mentions other recently added new partners to the OpenJDK team: FreeBSD Foundation, GE Digital Energy, and Microsoft Open Technologies, Inc.1 JDK Modularity / Project Jigsaw It was confirmed in the “Java Partner Community Keynote” address that Oracle does intend to deliver modularity with JDK 9.2,6 Modularization was scheduled for previous versions of Java, but has been kicked down the road from JDK 8 and from JDK 7 before that. The Oracle Press Release announcing JavaOne 2014 states, “Oracle has begun work on the JDK 9 Project in the OpenJDK Community. New features will focus on modularity, performance, stability, and portability.”1 Project Valhalla and Project Panama In the Community Keynote2,5, Brian Goetz cited Project Valhalla (experimental JVM and language features and not to be confused with a much older Project Valhalla) and Project Panama (“Interconnecting JVM and native code”). The promise of value types was also discussed in this part of the keynote.2,5 Eclipse’s Open IoT Stack The Eclipse Foundation announced the Open IoT (Internet of Things) Stack at JavaOne 2014.3 JavaOne 2014 Talks on Parleys.com It was announced that JavaOne 2014 talks will be on Parleys.com.5 Miscellaneous Java Usage Statistics Oracle likes to announce splashy statistics related to “Java” (the language and the platform). This year’s edition was no different1:9 million developers worldwide More than 3 billion devices are powered by Java technology More than 125 million Java-based media devices have been deployed Over 10 billion Java Cards have been shipped since its introductionDuke Has An Alias: Fang One of the more important revelations from JavaOne 2014 for some of us is that Duke was formerly known as Fang.5. JavaOne 2015 JavaOne 2015 will be October 25–29, 2015, in San Francisco, California. Online References to JavaOne 20141Oracle Press Release: Oracle Highlights Continued Java SE Momentum and Innovation at JavaOne 2014 2InfoQ‘s (Ben Evans‘s) Java One – Final Day and Community Keynote 3InfoQ’s (Ben Evans’s) JavaOne 2014 – Day One and Eclipse IoT Announcement 4Oracle’s (Timothy Beneke’s) JavaOne Strategy and Technical Keynotes Look to the Future 5IDR Solutions‘s (Mark Stephens’s) My Key takeaways from JavaOne Community Keynote 6Mark Stoetzer‘s JavaOne 2014 – Day 1 – Keynote 7JavaOne 2014 Keynotes VideosReference: JavaOne 2014 Observations by Proxy from our JCG partner Dustin Marx at the Inspired by Actual Events blog....
agile-logo

Small Internal Releases Lead to Happy Customers

If you saw Large Program? Release More Often, you might have noted that I said, You want to release all the time inside your building. You need the feedback, to watch the product grow. Some of my clients have said, “But my customers don’t want the software that often.” That might be true.  You may have product constraints, also. If you are working on a hardware/software product, you can’t integrate the software with the hardware either until the hardware is ready or that often.   I’m not talking about releasing the product to the customers. I’m not talking about integrating the software with the hardware. I’m talking about small, frequent, fully functional releases that help you know that your software is actually done. You don’t need hardening sprints. Or, if you do, you know it early. You know you have that technical debt now, not later. You can fix things when the problem is small. You see, I don’t believe in hardening sprints. Hardening sprints mean you are not getting to done on your features. They might be too big. Your developers are not finishing the code, so the testers can’t finish the tests. Your testers might not be automating enough. Let’s not forget architectural debt. It could be any number of things. Hardening sprints are a sign that “the software is not done.” Wouldn’t you like to know that every three or four weeks, not every ten or twelve? You could fix it when the problem is small and easier to fix. Here’s an example. I have a number of clients who develop software for the education market.  One of them said to me, “We can’t release all the time.” I said, “Sure, you can’t release the grading software in the middle of the semester. You don’t want to upset the teachers. I get that. What about the how-to-buy-books module? Can you update that module?” “Of course. That’s independent. We’re not sure anyone uses that in the middle of the semester anyway.” I was pretty sure I knew better. Teachers are always asking students to buy books. Students procrastinate. Why do you think they call it “Student syndrome”? But I decided to keep my mouth shut. Maybe I didn’t know better. The client decided to try just updating the buy-the-book module as they fixed things. The client cleaned up the UI and fixed irritating defects. They released internally every two weeks for about six weeks. They finally had the courage to release mid-semester. A couple of schools sent emails, asking why they waited so long to install these fixes. “Please fix the rest of these problems, as soon as you can. Please don’t wait.” The client had never released this often before. It scared them. It didn’t scare their customers. Their customers were quite happy. And, the customers didn’t have all the interim releases; they had the planned mini-releases that the Product Owner planned. My client still doesn’t release every day. They still have an internal process where they review their fixes for a couple of weeks before the fixes go live. They like that. But, they have a schedule of internal releases that is much shorter than what they used to have. They also release more often to their customers. The customers feel as if they have a “tighter” relationship with my client. Everyone is happier. My client no longer has big-bang external releases. They have many small internal releases. They have happier customers. That is what I invite you to consider. Release externally whenever you want. That is a business decision. Separate that business decision from your ability to release internally all the time. Consider moving to a continuous delivery model internally, or as close as you can get to continuous delivery internally. Now, you can decide what you release externally. That is a business decision. What do you need to do to your planning, your stories, your technical practices to do so?Reference: Small Internal Releases Lead to Happy Customers from our JCG partner Johanna Rothman at the Managing Product Development blog....
java-logo

Using Java API for WebSockets in JDeveloper 12.1.3

Introduction The latest release of JDeveloper 12c (12.1.3.0) along with WebLogic Server 12.1.3 came up with some new Java EE 7 features. One of them is support of JSR 356 Java API for WebSockets. Actually the WebSocket Protocol (RFC 6455) has been supported starting from 12.1.2.0 release, but it was based on WebLogic specific implementation of the WebSocket API. Now this proprietary WebLogic Server WebSocket API has been deprecated. However, it is still supported for backward compatibility. In this post I am going to show an example of using JSR 356 Java API for WebSockets in a simple  ADF application. The use case is about some sailing regatta which takes place in the Tasman Sea. There are three boats participating in the regatta and they are going to cross the Tasman Sea sailing from Australia to New Zealand coast. The goal of the sample application is to monitor the regatta and inform users about how it is going on, showing the positions of the boats on a map. We’re going to declare a WebSocket server endpoint in the application and when a user opens a page a Java script function opens a new WebSocket connection. The application uses a scheduled service which every second updates boats coordinates and sends a message containing new boats positions to all active WebSocket clients. On the client side a Java script function receives the message and adds markers to the Google map according to the GPS coordinates. So, each user, interested in the regatta, is going to see the same updated picture representing the current status of the competition. WebSocket server endpoint Let’s start with declaring a WebSocket server endpoint. There is a small issue in the current implementation, which probably will be resolved in future releases. The WebSocket endpoints can not be mixed with ADF pages and they should be deployed in a separate WAR file. The easiest way to do that is to create a separate WebSocket project within the application and to declare all necessary endpoints in this project:This is also important to set up a readable Java EE Web Context Root for the project:The next step is to create a Java class which is going to be a WebSocket end point. So, this is a usual class with a special annotation at the very beginning: @ServerEndpoint(value = "/message") public class MessageEndPoint {    public MessageEndPoint() {         super();     } } Note, that JDeveloper underlines the annotation with red. We are going to fix the issue by letting JDeveloper configure the project for Web Socket.Having done that, JDeveloper is going to convert the project into a Web project adding the Web.xml file and add necessary library:Furthermore, the endpoint class becomes runnable and we can just run it so as to check how it actually works:In response JDeveloper generates the following URL at which the WebSocket endpoint is available. Note, that the URL contains the project context root (WebSocket) and the value property of the annotation (/message). If everything is ok then when we click the URL, we’ll get the “Connected successfuly” information window:By the way, there is a typo in the message. And now let’s add some implementation to the WebSocket endpoint class. According to the specification a new instance of the MessageEndPoint class is going to be created for each WebSocket connection. In order to hold a bunch of all active WebSocket sessions we’re going to use a static queue: public class MessageEndPoint {     //A new instance of the MessageEndPoint class     //is going to be created for each WebSocket connection     //This queue contains all active WebSocket sessions     final static Queue<Session> queue = new ConcurrentLinkedQueue<>();    @OnOpen      public void open(Session session) {          queue.add(session);              }       @OnClose       public void closedConnection(Session session) {          queue.remove(session);       }           @OnError      public void error(Session session, Throwable t) {            queue.remove(session);            t.printStackTrace();        } The annotated methods open, closedConnection and error are going to be invoked respectively when a new connection has been established, when it has been closed and when something wrong has happened. As we have done that, we can use some static method to broadcast a text message to all clients:      public static void broadCastTex(String message) {         for (Session session : queue) {             try {                session.getBasicRemote().sendText(message);             } catch (IOException e) {                 e.printStackTrace();             }         }    } In our use case we have to notify users with new GPS coordinates of the boats, so we should be able to send via WebSockets something more complex than just text messages. Sending an object Basically, a business model of the sample application is represented by two plain Java classes Boat: public class Boat {   private final String country;   private final double startLongitude;   private final double startLatitude;  private double longitude;   private double latitude;    public String getCountry() {       return country;   }  public double getLongitude() {       return longitude;   }  public double getLatitude() {       return latitude;   }     public Boat(String country, double longitude, double latitude) {       this.country = country;       this.startLongitude = longitude;       this.startLatitude = latitude;   } ... and Regatta: public class Regatta {     private final Boat[] participants = new Boat[] {         new Boat("us", 151.644, -33.86),         new Boat("ca", 151.344, -34.36),         new Boat("nz", 151.044, -34.86)     };         public Boat[] getParticipants() {         return participants;     } ...For our use case we’re going to send an instance of the Regatta class to the WebSocket clients. The Regatta contains all regatta participants represented by the Boat class instances containing updated GPS coordinates (longitude and latitude). This can be done by creating a custom implementation of the Encoder.Text<Regatta> interface, or in other words we’re going to create an encoder which can transform a Regatta instance into a text and specify this encoder to be used by the WebSocket endpoint while sending an instance of the Regatta. public class RegattaTextEncoder implements Encoder.Text<Regatta> {   @Override   public void init(EndpointConfig ec) { }  @Override   public void destroy() { }  private JsonObject encodeBoat(Boat boat) throws EncodeException {       JsonObject jsonBoat = Json.createObjectBuilder()           .add("country", boat.getCountry())           .add("longitude", boat.getLongitude())           .add("latitude" , boat.getLatitude()).build();            return jsonBoat;    }    @Override    public String encode(Regatta regatta) throws EncodeException {       JsonArrayBuilder arrayBuilder = Json.createArrayBuilder();                       for (Boat boat : regatta.getParticipants()) {           arrayBuilder.add(encodeBoat(boat));       }      return arrayBuilder.build().toString();    }       } @ServerEndpoint(   value = "/message",   encoders = {RegattaTextEncoder.class })Having done that, we can send objects to our clients:     public static void sendRegatta(Regatta regatta) {         for (Session session : queue) {             try {                 session.getBasicRemote().sendObject(regatta);             } catch (EncodeException e) {                 e.printStackTrace();             } catch (IOException e) {                 e.printStackTrace();             }         }    } The RegattaTextEncoder represents a Regatta object as a list of boats using Json notation, so it is going to be something like this: [{"country":"us","longitude":151.67,"latitude":-33.84},{"country":"ca", ...},{"country":"nz", ...}]Receiving a message On the client side we use a Java script function to open a new WebSocket connection: //Open a new WebSocket connection //Invoked on page load function connectSocket() {    websocket = new WebSocket(getWSUri());      websocket.onmessage = onMessage;   } And when a message arrives, we’re going to loop over array of boats and for each boat add a marker on the map: function onMessage(evt) {   var boats = JSON.parse(evt.data);   for (i=0; i<boats.length; i++) {      markBoat(boats[i]);    }   }function markBoat(boat) {   var image = '../resources/images/'+boat.country+'.png';   var latLng = new google.maps.LatLng(boat.latitude,boat.longitude);      mark = new google.maps.Marker({            position: latLng,            map: map,            title: boat.country,            icon: image         }); }You can learn down here how to integrate Google maps into your applications. Run the regatta In order to emulate a live show we use ScheduledExecutorService. Every second we are going to update GPS coordinates and broadcast the update to all subscribers: private final ScheduledExecutorService scheduler =    Executors.newScheduledThreadPool(1); private ScheduledFuture<?> runHandle;//Schedule a new regatta on Start button click public void startRegatta(ActionEvent actionEvent) {    //Cancel the previous regatta     if (runHandle != null) {         runHandle.cancel(false);      }               runHandle = scheduler.scheduleAtFixedRate(new RegattaRun(), 1, 1,                                               TimeUnit.SECONDS); }public class RegattaRun implements Runnable {    private final static double FINISH_LONGITUDE = 18;     private final Regatta regatta = new Regatta();    //Every second update GPS coordinates and broadcast     //new positions of the boats     public void run() {                   regatta.move();        MessageEndPoint.sendRegatta(regatta);                 if (regatta.getLongitude() >= FINISH_LONGITUDE) {            runHandle.cancel(true);              }     } } Bet on your boat And finally, the result of our work looks like this:The sample application for this post requires JDeveloper 12.1.3. Have fun! That’s it!Reference: Using Java API for WebSockets in JDeveloper 12.1.3 from our JCG partner Eugene Fedorenko at the ADF Practice blog....
javaone-logo

JavaOne 2014: Conferences conflict with contractual interests

The Duke’s Street Cafe where engineers can have a hallway conversation on the street.                    Incompatible with contracting My eleventh JavaOne conference (11 = 10 + 1, 2004 to 2014) was splendid. It was worth attending this event and meeting all the people involved in the community. Now here comes the gentleman’s but. My attendance came at some cost beyond the financial obvious, hotel and plane ticket. It appears going to conferences are seriously incompatible with the motivations around business of contracts. One cannot have freedom and escape obligation to professional work. Despite, all of the knowledge that we have learned as professional developers, designers and architects, if your client requires you to be on site and you are not around, it can be taken that attending conferences like JavaOne 2014 in certain minds is taken as an illustrious and salubrious adventure for your own benefit. On the hand this is fair assessment, a client pays a contractor to be available, around for a burning need, and it is balanced with team work, morale; and deadline and commitments. At the back of mind, there are two schools of thought. One way is not to care too much about clients, but then a contractor will find they have a devalued reputation and lack of repeat business. The other way is never to take time off or away from project work for a client and then rely on contracts ending or finishing exactly before or after a major conference like JavaOne. So what to do in 2015? How can I resolve contracting and conferences? I believe the answer, obviously, to reduce the conferences that I actually attend to the minimum that I can unfortunately. It means that I will consider whether JavaOne 2015 is going to be viable or not. The keynote question and answer session with a Twitter hashtag, #j1qa, which obviously has long expired, featuring John Rose(far left), James Gosling (inner left), Brian Goetz (middle), Brian Oliver (inner left) and Charles Nutter (far right). The chair was Mark Reinhold.Ten years ago, when I worked investment banking in the good times. I could pretty much rely on 6 months J2EE contracts lasting as long as that term. At Credit Suisse bank, I managed six month contract renewals at a breeze as long as I perform and finished project work on time. In 2014, the climate is more restrictive, the pressure on high profile projects and the uncertainty of business means that contracts lengths are typically 3 months to start with and that cannot guarantee renewals, and if you think that permanent employment solves the dilemma then you are incorrect. A contract is a temporary and by definition that implies a contractor is treated as a temporary resource, but a permanent person can also be removed at short notice in the United Kingdom, if you have less than two years with the employer. When you think that the typical IT employment last about two to three years before somebody changes job, then you can see even permanent people have to be extremely careful with their holiday planning and entitlement. Yes you are entitled 25 days or more, but if you fail to give forewarning and mess around with the program delivery managers project plan too much, don’t be surprise if a ton of bricks eventually comes tumbling down. A picture with the Java Mascot to complete the collection. I wonder if Duke has a sixth sense and if she/he/it can sense the trouble ahead lurking in my subconscious.  Frustrating as it is, and still more than year from the next JavaOne conference, the next one is late October 2015, from Sunday 25th to Thursday 29th, I can’t say with real confidence that I will be there. I will, of course, submit some Calls For Papers, when the time approaches, but it will be dependent on client requirements if I can attend or not. If I do attend, then I probably cannot stick around California and see friends. Even for the UK and European conferences, I can only see trouble ahead with more conflicts. I already decided that I will not be at Devoxx in Belgium. There are also issues when the conference planning is late, the confirmations are validated less than three months before the event, project managers are already looking at their schedules for resourcing and if a contractor is going to disappear, then they are more easily replaced with somebody who will be around to fix their present pain, which is what work is more often than not about. I have found that client’s typical do not have the attitude of kindness, it is about the budget and time. That’s is the way the business world is running now, and the only conference speakers who can give up the time as the developer advocates, the people who paid to speak or promote at conferences. Independents are finding it harder and there will be no improvement in this situation. I just can’t find seem to find that benevolent, technology loving and business client, who understand me for what I am. These guys and gals at Alderbaran electronics with their NAO robots are inspirational. This is photo from the JavaOne demo grounds and exhibition.Reference: JavaOne 2014: Conferences conflict with contractual interests from our JCG partner Peter Pilgrim at the Peter Pilgrim’s blog blog....
java-logo

The Heroes of Java: Dan Allen

The “Heroes of Java” series took a long break. Honestly, I thought it might end in the middle of nowhere, even if there are still so many people I would love to include here. One of them is Dan. The first time I asked him to contribute is almost one and a half year back and with everything which happened in the meantime, I made my peace with not getting an answer anymore. But the following arrived in my inbox during JavaOne and was basically a birthday present for me. So, I open the Heroes of Java book again today and add another chapter to it! Thank you Dan! It is very good to call you a friend!     Dan Allen Dan Allen is an open source and standards advocate and innovator. He worked at Red Hat as a Principal Software Engineer. In that role, he served as the Arquillian community manager, contributed to various open source projects (including Arquillian, Asciidoctor, Awestruct and JBoss Forge) and participated in the JCP. He helped a variety of open source projects become wildly successful. He’s also the author of Seam in Action (Manning, 2008), has written technical articles for various publications and is an internationally recognized speaker. General Who are you? I’m an open source advocate and developer, community catalyst, author, speaker and business owner. Currently, I’m working to improve the state of documentation by leading the Asciidoctor project, advocating for better software quality by advocating for Arquillian, and, generally, doing whatever I can to make the open source projects to which I contribute, and their communities, wildly successful. After a long conference day, you’ll likely find me geeking out with fellow community members over a Trappist beer. Your official job title at your company? Vice President, Open Source Hacker and Community Strategist at OpenDevise, a consulting firm I founded with Sarah White. Do you care about it? I care more about this title, compared to titles I’ve had in the past, primarily because I got to define it. In general, though, titles can be pretty meaningless. Take my previous title, Middleware Principal Software Engineer. All titles like this really manage to accomplish is to communicate an employee’s pay grade. The honorary that follows “Principal” is “Senior Principal”. Then, what next? “Principal Principal?” What was I before? A Junior Insignificant Engineer? We might as well just use number grades like in the US government (e.g. GS-10). At least that’s a logical system. Like many of my peers, I’ve always sought to define my own title for my role. To me, the purpose of a title is to help others know your specialty and focus. That way, they know when you’re the one they need to seek out. That’s why I chose the title “Open Source Hacker and Community Strategist” I live and breathe open source, so the “Open Source” part of the title fits. If you want to discuss anything about open source, I’m always game. I also love community, especially passionate ones. I’m always thinking about it and how to make it work better. That’s where the term “community strategist” comes in. I enjoy getting people excited about a technology and then being there to help get them going when they find their passion to improve or innovate on it. It’s such a thrilling and proud experience for both sides. To me, that feeling is called open source. I simply work to reproduce it over and over as an “Open Source Hacker and Community Strategist”. Maybe one day people will recognize me as a “Serial Community Creator” ! Those of us in open source also identify ourselves by the projects we lead or help manage, if any. Currently, I’m the Asciidoctor project lead—​and it’s about as much as I can handle. Do you speak foreign languages? Which ones? I wish. I studied French in high school, but consider that experience purely academic. I’m challenging myself to read tweets in French to brush up on what I once knew. My real life experience with foreign languages comes from interacting with open source community members from around the globe and spending time in other countries. Even though I cannot understand other languages, I enjoy taking in the sounds and rhythms like music. There’s a certain amount of enjoyment I get from listening without the distraction of comprehension. My favorite foreign language experience was working with the translations—​and their translators—​of the Arquillian User Guides. Not only did it expose me to a lot of languages (over a dozen), it gave me a first-hand appreciation for how much language plays into a person’s identity and the feeling of pride for one’s country. The experience also pushed me to understand Unicode and fonts. I’m proud to say that I get the whole point of Unicode and how it works (at least from a programming standpoint). I look forward to working more with translations, rethinking how translations are managed and continuing to take in the sounds and rhythms of languages. One day, perhaps, I will be fluent in at least one of them. How long is your daily “bootstrap” process? A more interesting question might be “when?” since I keep some pretty odd hours. My daily goal is usually to get to bed before the sun comes up. That makes my breakfast and bootstrap process your lunch. That all depends on timezone, of course. As one of my colleagues pointed out, I’m surprisingly non-Vampirish at conferences. You may be wondering what’s with the crazy schedule. The thing about managing an open source project is that you never know when someone is going to be ready to participate. When someone shows up ready to participate, you need to jump on the opportunity. It could be a while (if ever) before they have time again. And that person could be in any time zone in the world. Truth be told, I like the night just as much as the day anyway. There’s a solitude at night that I enjoy and I often do some of my best work then. Other times, I just enjoy the silence. I look forward to the day too, especially when the view of the Colorado Rockies is clear. I do some of my best work against the backdrop of their purple or white peaks. You might say that I draw inspiration from both the day and night to feed my creativity. I only do coffee first thing in my “morning”, but I do the other bootstrap activities (like Twitter) several times a day. It takes me about an hour or two to sift through my e-mail and Twitter, with a pit stop at Google+. Twitter You have a twitter handle? Why? For sure. It’s @mojavelinux. I have a Twitter account:to be open to connect to discover to report to keep in touchWhen I first started using Twitter (over 6 years ago), many people thought it was ridiculous and pointless. I was drawn to it because it offered a way to communicate without any prior arrangements. It’s sort of like a global IRC channel with a contextual filter applied to it. Twitter has changed the way I do business, and the way I interact with my colleagues and community. Rather try to explain it, I’ll give two examples. When we were growing the Seam 3 community, we didn’t just wait for people to come join the mailinglist. We looked for people talking about JSF and Java EE on Twitter. One of the more vocal people at that time was Brian Leathem. When he posted feedback or a complaint about JSF, we would engage him by responding to him directly. That turned his post into the start of a conversation or design session. When it came time to hire someone for a related position, he was already a top candidate, and has since become a top employee. There are stories like Brian’s. It’s easy to conclude that we “hired someone we met on Twitter”. That misses the whole point. Twitter’s public channel gave us an opportunity to find someone who has deep interest and experience with a particular technology or platform. So public that we don’t even have to know where to look for each other (except on Twitter). The meetup is inevitable. Twitter has also eliminated the overhead of communicating with associates in your own company or even other companies. You just put out a broadcast on Twitter, usually planting a few trigger words or tags, and that person will see it, or someone will pass it on to that person. Either way, you cut out the whole hassle of an employee directory. There’s a global conversation happening on Twitter and we’re all a part of it. Now that’s open. Whom are you following in general? First and foremost, my fellow community members. As I mentioned, Twitter is how I keep the pulse on my community and communicate with them throughout the day. I follow a few company and project feeds, such as GitHub and Java EE, but mostly I like to know there is a person behind the account. I’m hesitant about following anyone I haven’t met, either in person or through a conversation online. I follow the same policy for LinkedIn and Google+ as well. Do you have a personal “policy” for twitter? One policy is to stay dialed in. I plow thorough my timeline at least once a day and try to respond to any questions I’m asked. As a community leader, it’s important to be present and participate in the global conversation. Some days, I iron out my agenda only after consulting my stream. I do make sure to not let it take over (sort of). When I find myself only reading or retweeting, but not sharing, I realize I need to get back to creating so that I have something to share (or just take a break). I’m very careful to post and retweet useful information. That’s an important part of my personal policy. I use tools like Klout, the Twitter mentions tab and the new Twitter analytics to learn what people consider useful or interesting and focus on expanding on those topics. I dialing down topics that get little response because I respect the time of my followers. Does your company restricts or encourages you with your twitter usage? The company policy is, use your own judgment. Public social networks have had a tremendously positive impact on open source, primarily because open source is both public and social. That makes Twitter pretty central to my position. We often discover new contributors (and vice-versa) on Twitter. We also use it as a 140 character limit mailing list at times (which, trust me, is a relief from the essays that are often found on real mailing lists). Simply put, I couldn’t do my job (in this day and age) without Twitter (or something like it). Work What’s your daily development setup? A tabbed terminal with lots of Vim and a web browser. Nearly all the work I do happens in these environments. Since I’ve been heavily involved in AsciiDoc and writing content in general, many of my Vim sessions have an AsciiDoc document queued up. I do all my Ruby development in Vim. I rely on syntax highlighting and my own intuition as my Ruby IDE. If you saw the number of times I split the window, it would frighten you. Don’t mimic what I do, it’s probably terribly inefficient, but somehow it works for me. When I need to do some Java hacking, I absolutely must fire up an IDE. Editing Java in Vim (without any additional plugins) is just a waste of time. I’m most comfortable in Eclipse because that’s what I used first in my career. However, I’m been firing up IntelliJ IDEA more often lately and I do like Netbeans on occasion. When I have to edit XML in the project, I flip back to Vim because copy-paste is much more efficient! The development tools in the browser are a life and time saver when editing CSS. I like to work out the CSS rules I want in a live session, then transfer them to the stylesheet in the project. It all begins with “Inspect element”. Which is the tool providing most productivity to your work? Vim. I’ve used Vim every single day I’ve been at a computer for the last decade. I couldn’t imagine life without it. Vim is my hammer. Your prefered way of interacting with co-workers? Primarily async communication, with a few face-to-face meetups a year. The async communication is a mix of mailinglists, social networks, emails and (on and off) IRC. Most personal emails with my close colleagues have been replaced by Google+ and Twitter private messages, since we all have too much email. You’d be amazed how much more effective those private messages are. Something certainly worth noting. We usually get face time at conferences like Devoxx and JavaOne. This time is so important because it’s when we form the impression of the person behind the screenname. After you’ve met someone, and heard their voice, you’ll never read an email from them the same again. You’ll hear it coming from them, with their voice and expressions. Those impression, and the bonds you form when in person, is what make the virtual relationships work. You also discover some other things to talk about besides tech (or your tech in particular). Occasionally, I get put on these teams that like to do phone meetings. First, will someone please kill conference lines? They are horrible and a buzz kill. Besides that, phone calls in a global company simply don’t work. No time is a good time for someone. When we finally do manage to get (most) everyone on the phone, no one knows when to talk (or shut up). It’s a circus. Return me to my async communication. If I do need to be “on the phone”, I prefer Google Hangout (when it works). I’m not exaggerating when I say it’s almost as good as being in person. What’s your favorite way of managing your todo’s? I did a lot of research in this area and decided on an online application named Nirvana. It adheres to David Allen’s GTD method more faithfully than any other one I evaluated. When I’m good about sticking to it, it serves me well. When I’m not so good, I fall back to my two anchors, a text file named WORKLOG and my email inbox. One trick I’ve used for years, which works great for context switching, is maintaining a WORKLOG file in each project that I work on. The tasks in this file aren’t perk pressing, but do remind me of what I want to do next when I have time to work on the project. It’s especially useful when you return to a project after a long break. If you could make a wish for a job at your favorite company, what would that be? I’m at the point now where my ideal job isn’t at someone else’s company, but at my own. One of the main reasons I love open source is the autonomy it grants. I don’t have problems finding ways to create value, but I do sometimes have problems convincing my employer to pursue that value creation. In my ideal job, which I’m now pursuing, I can create value anyway I want, I can judge when I’ve succeeded and when I’ve failed for myself, I can decide when growth is necessary and when it isn’t and I can defend the principles important to me. That’s why my wife and I took the step to create our own business. Our goals are pretty simple: survive, be happy & healthy, create value, work in open source and help clients be wildly successful. Java You’re programming in Java. Why? I’m a strong believer in portability and choice. And I believe the JVM provides us that freedom. The fact it’s one of the most optimized and efficient runtimes is just icing on the cake. I use Java because it’s the default language on the JVM. If another language replaced it as the default, I’d probably use that instead. Java is a means to and end to run and integrate code on the common runtime of the JVM. There are some compelling features that have made Java enjoyable, such as annotations and now lambdas and streams. However, if I have my choice, I prefer other languages, such as Ruby, Groovy and Clojure…​as long as the language runs well on the JVM! What’s least fun with Java? The ceremony and verbosity. It’s too much to type. I like code that can get a lot done in a little amount of space, but still be readable and intuitive. Java requires a lot of space. Java is also missing some really key features from the standard library that you find in most other languages. A good example is a single function that can read all the content from a file or URL. It’s a simple concept. It should have a simple function. Not so with Java. Also, getters and setters are dumb. If you could change one thing with Java, what would that be? Less ceremony for imports. I know, that’s not the first thing that comes to a lot of people’s minds…​that is unless you’ve done a lot of work in a dynamic language. One of the biggest differences between Java and dynamic languages not often mentioned is the number of types in the default language set and the number of import statements you need to get more. It may not seem such a big deal, especially since IDEs help manage the import statements, but you’d be surprised how much they still slow you down, and outright paralyze development without the help of an IDE. In Ruby (and to some extent, Groovy), you can write most simple programs without a single import (require) statement. That means you can just keep plugging away. Ruby also let’s you import a whole library so it’s accessible to all the files in your application with a single statement (a RubyGem). In Java, you have to import every single type you use (or at least every package that contains them) in every single file. That’s a huge number of extra lines to manage. My hope is that this improvement comes along with Java modularity. You can import a module into your application, then use the types from it anywhere. That would be game changing for me. Combined with the language improvements in Java 8, my efficiency in Java just might be able to catch up to my efficiency in Ruby. What’s your personal favorite in dynamic languages? Ruby. I’ve now written more code in Ruby than in any other programming language (https://www.openhub.net/accounts/mojavelinux/languages). (I’ve also explored the Ruby and Java interop extensively). I can attest that Ruby is very natural, just as the language designer intended it to be. I’m also a fan of Groovy and Clojure. I like Groovy for the reasons I like Ruby, with the added benefit that it integrates seamlessly with Java. Clojure is my “challenge yourself language”. I wouldn’t say it feels natural to me yet, but it pushes me to write better code. It’s true what they say about a LISP. It does expand your thinking. Which programming technique has moved you forwards most and why? Functional programming, no doubt. This is a popular response, but for good reason. It’s more than just a trend. From my experience working with Java EE, Seam and CDI, I believe I’m qualified to say that managing state in a shared context is difficult in the best cases and usually fallible or impossible. As isolated processes become increasingly rare, we must change our approach to development. Functional programming gives us the necessary tools. Higher order functions allow us to compose logic without having to rely on class hierarchy and the temptation of relying on shared state. Persistent collections and no side effects let’s us write code that is thread safe by default and, better yet, prepared to be optimized for multi-core and even distributed. Don’t take my word for it, though. Just listen to a few of Rich Hickey’s talks, then grab a book or tutorial on Clojure and start studying it. Your mind will convince you. What was the biggest project you’ve ever worked on? It was a J2EE web application that facilitated mortgage lending and automated appraisal services. The application was written in a somewhat obscure component-based framework that predated JSF that talked to an EJB2 backend and webMethods services. It had to be loaded on the bootclasspath of Weblogic in order for it to run for reasons I’ll never understand. In my time working there, the test suite never completed successfully and no one could figure out how to fix the behemoth. Debugging was a nightmare. It wasn’t pretty. Let’s just say I appreciated the need for a lightweight framework like Spring and changed my career path once I lost the stomach to work on this system. The nice part about that job was that I got experience using the XP development methodology (story cards, pair programming, continuously failing integration, etc). It’s probably the only reason the application was staying afloat and moving forward at all. Which was the worst programming mistake you did? Not documenting (and not testing). I’m always getting on myself for not documenting. We think of programming mistakes as logic or syntax errors, but the worst crimes we can commit are not passing on knowledge and stability. It’s like spreading land mines around a property, forgetting about them and then turning the property into a park. The mistakes are going to be made by the next person who isn’t aware of all those things you need to know to keep the system running securely. I’ll end with a variation on the most popular Tweet at this year’s OSCON to help encourage you to be a more disciplined programmer. Always [write documentation] as if the [person] who ends up maintaining your code will be a violent psychopath who knows where you live. — John Woods (source)Reference: The Heroes of Java: Dan Allen from our JCG partner Markus Eisele at the Enterprise Software Development with Java blog....
java-interview-questions-answers

Beginner’s Guide To Hazelcast Part 1

Introduction I am going to be doing a series on Hazelcast. I learned about this product from Twitter. They decided to follow me and after some research into what they do, I decided to follow them. I tweeted that Hazelcast would be a great backbone for a distributed password cracker. This got some interest and I decided to go make one. A vice president of Hazelcast started corresponding with me and we decided that while a cracker was a good project, the community (and me) would benefit from having a series of posts for beginners. I have been getting a lot of good information in the book preview The Book of Hazelcast found on www.hazelcast.com.   What is Hazelcast? Hazelcast is a distributed, in-memory database. There are projects all over the world using Hazelcast. The code is open source under the Apache License 2.0. Features There are a lot of features already built into Hazelcast. Here are some of them:Auto discovery of nodes on a network High Availablity In memory backups The ability to cache data Distributed thread poolsDistributed Executor ServiceThe ability to have data in different partitions. The ability to persist data asynchronously or synchronously. Transactions SSL support Structures to store data:IList IMap MultiMap ISetStructures for communication among different processesIQueue ITopicAtomic OperationsIAtomicLongId GenerationIdGeneratorLockingISemaphore ICondition ILock ICountDownLatchWorking with Hazelcast Just playing around with Hazelcast and reading has taught me to assume these things.The data will be stored as an array of bytes. (This is not an assumption, I got this directly from the book) The data will go over the network. The data is remote. If the data is not in memory, it doesn’t exist.Let me explain these assumptions: The data will be stored as an array of bytes I got this information from The Book of Hazelcast so it is really not an assumption. This is important because not only is the data stored that way, so is the key. This makes life very interesting if one uses something other than a primitive or a String as a key. The developer of hash() and equals() must think about it in terms of the key as an array of bytes instead of as a class. The data will go over the network This is a distributed database and so parts of the data will be stored in other nodes. There are also backups and caching that happen too. There are techniques and settings to reduce transferring data over the network but if one wants high availability, backups must be done. The data is remote This is a distributed database and so parts of the database will be stored on other nodes. I put in this assumption not to resign to the fact that the data is remote but to motivate designs that make sure operations are preformed where most of the data is located. If the developer is skilled enough, this can be kept to a minimum. If the data is not in memory, it doesn’t exist Do not forget that this is an in-memory database. If it doesn’t get loaded into memory, the database will not know that data is stored somewhere else. This database doesn’t persist data to bring it up later. It persists because the data is important. There is no bringing it back from disk once it is out of memory like a conventional database (MySQL) would do. Data Storage Java developers will be happy to know that Hazelcast’s data storage containers except one are extensions of the java.util.Collections interfaces. For example, an IList follows the same method contracts as java.util.List. Here is a list of the different data storage types:IList – This keeps a number of objects in the order they were put in IQueue – This follows BlockingQueue and can be used as alternative to a Message Queue in JMS. This can be persisted via a QueueStore IMap – This extends ConcurrentMap. It can also be persisted by a MapStore. It also has a number of other features that I will talk about in another post. ISet – The keeps a set of unique elements where order is not guaranteed. MultiMap – This does not follow a typical map as there can be multiple values per key.Example Setup For all the features that Hazelcast contains, the initial setup steps are really easy.Download the Hazelcast zip file at www.hazelcast.org and extract contents. Add the jar files found in the lib directory into one’s classpath. Create a file named hazelcast.xml and put the following into the file <?xml version="1.0" encoding="UTF-8"?> <hazelcast xsi:schemaLocation ="http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-config-3.0.xsd " xmlns ="http://www.hazelcast.com/schema/config " xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance">     <network>         <join><multicast enabled="true"/></join>     </network>          <map name="a"></map> </hazelcast> Hazelcast looks in a few places for a configuration file:The path defined by the property hazelcast.config hazelcast.xml in the classpath if classpath is included in the hazelcast.config The working directory If all else fails, hazelcast-default.xml is loaded witch is in the hazelcast.jar. If one dose not want to deal with a configuration file at all, the configuration can be done programmatically.The configuration example here defines multicast for joining together. It also defines the IMap “a.” A Warning About Configuration Hazelcast does not copy configurations to each node. So if one wants to be able to share a data structure, it needs to be defined in every node exactly the same. Code This code brings up two nodes and places values in instance’s IMap using an IdGenerator to generate keys and reads the data from instance2. package hazelcastsimpleapp;import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; import com.hazelcast.core.IdGenerator; import java.util.Map;/** * * @author Daryl */ public class HazelcastSimpleApp {/** * @param args the command line arguments */ public static void main(String[] args) { HazelcastInstance instance = Hazelcast.newHazelcastInstance(); HazelcastInstance instance2 = Hazelcast.newHazelcastInstance(); Map map = instance.getMap("a"); IdGenerator gen = instance.getIdGenerator("gen"); for(int i = 0; i < 10; i++) { map.put(gen.newId(), "stuff " + i); } Map map2 = instance2.getMap("a"); for(Map.Entry entry: map2.entrySet()) { System.out.printf("entry: %d; %s\n", entry.getKey(), entry.getValue()); } System.exit(0); } } Amazingly simple isn’t it! Notice that I didn’t even use the IMap interface when I retrieved an instance of the map. I just used the java.util.Map interface. This isn’t good for using the distributed features of Hazelcast but for this example, it works fine. One can observe the assumptions at work here. The first assumption is storing the information as an array of bytes. Notice the data and keys are serializable. This is important because that is needed to store the data.  The second and third assumptions hold true with the data being being accessed by the instance2 node. The fourth assumption holds true because every value that was put into the “a” map was displayed when read. All of this example can be found at http://darylmathisonblog.googlecode.com/svn/trunk/HazelcastSimpleApp using subversion. The project was made using Netbeans 8.0. Conclusion An quick overview of the numerous features of Hazelcast were reviewed with a simple example showing IMap and IdGenerator. A list of assumptions were discussed that apply when developing in a distributed, in-memory database environment. Resources The Book of Hazelcast. Download from http://www.hazelcast.comReference: Beginner’s Guide To Hazelcast Part 1 from our JCG partner Daryl Mathison at the Daryl Mathison’s Java Blog blog....
Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy | Contact
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.
Do you want to know how to develop your skillset and become a ...
Java Rockstar?

Subscribe to our newsletter to start Rocking right now!

To get you started we give you two of our best selling eBooks for FREE!

Get ready to Rock!
You can download the complementary eBooks using the links below:
Close