Coffee Talk: Java, News, Stories and Opinions


February 20, 2019  4:35 PM

Here’s how to get by without Concurrent Mark Sweep

RamLakshmanann Profile: RamLakshmanann
Uncategorized

As part of JEP-291, the popular Concurrent Mark Sweep garbage collection algorithm has been deprecated by Java Development Kit 9. This decision was made to both reduce the maintenance burden of garbage collection (GC) code and to accelerate new development.

As a result, if you launch an application from Java 9 or later with the -XX:+UseConcMarkSweepGC argument to activate the Concurrent Mark Sweep GC algorithm, you will see the following warning:

Java HotSpot(TM) 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.

Why was Concurrent Mark Sweep deprecated?

If there’s a lot of baggage to carry, especially in Java code, it’s hard to move forward. With Concurrent Mark Sweep, this feature is exactly what led to its demise. It is a highly configurable, sophisticated algorithm and adds a lot of complexities to the GC code base in the Java Development Kit (JDK). However, it’s only when a JDK development team can simplify the GC code base, can it accelerate and innovate in the GC arena.

Let’s explore the number of Java Virtual Machine (JVM) arguments that can be passed to each GC algorithm to to demonstrate how complex they are:

  • Common to all: 50
  • Parallel: 6
  • CMS: 72
  • G1: 26
  • ZGC: 8

There are around 50 GC-related arguments that can be passed to any JVM. On top of these 50 arguments, CMS alone can pass 72 additional arguments, which is a significantly greater number than any other GC algorithms. This increase adds significant coding complexity for a JDK team to support all these arguments.

If you currently use CMS as your GC algorithm, what are your options?

The three most compelling options are:

  1. Switch to the G1 GC algorithm
  2. Switch to the Z GC algorithm (Early access in JDK 11, 12)
  3. Continue with CMS, and deal with the deprecation warnings

Switch to G1 GC algorithm

G1 GC has become the default GC algorithm since Java 9, and you may safely consider an application move to this algorithm. It could provide better performance characteristics compared to Concurrent Mark Sweep, and it’s much easier to tune this algorithm because it contains a smaller number of arguments. Also, it provides options to eliminate duplicate strings from memory. If you can eliminate these duplicate strings, it can help you reduce the overall memory footprint.

Switch to Z GC algorithm

Z GC is a scalable, low-latency garbage collector with a main goal to keep GC pause times less than 10 ms. Early access of the Z GC algorithm is available in Java 11 and 12, so if your application runs on one of those releases, you can consider this as a Concurrent Mark Sweep alternative.

Continue with Concurrent Mark Sweep

For certain applications, Concurrent Mark Sweet delivers better results compared to the G1 GC algorithm, even with a lot of tuning. If you’ve explored the alternatives and seen that Concurrent Mark Sweep provides the best result for your applications, you should just stick with your current GC algorithm.

There have been discussions about keeping Concurrent Mark Sweep alive in the OpenJDK JDK9-dev mailing list, so it may not be gone forever. Certain features and APIs that were deprecated 20 years ago in Java 1.1 are still used in modern day applications, which means that  deprecation isn’t always the end of the road. You can continue to run on Concurrent Mark Sweep, but be aware that it may be removed completely in any future release.

Note that each application is unique and different, and don’t get carried away by journals and other literature that talk about GC tuning and tweaking. When you instrument a new GC setting, you should complete thorough testing, denote benchmark performance characteristics and study key performance indicators to make an informed decision.

February 19, 2019  5:55 PM

A simple Java Function interface example: Learn Functional programming fast

cameronmcnz Cameron McKenzie Profile: cameronmcnz

If you want to master functional programming, the best place to start is with the Java Function interface. This example will show you four different ways to implement this functional interface in your code — starting with how to use an actual class, and how to create very concise code with a lambda function.

The Java Function interface is quite simple. It takes a single Java object as an argument, and returns a single Java object when the method concludes. Any method you can conjure up takes an object and returns an object that fulfills the Java Function contract.

How to use Java’s Function interface

For this Java Function interface example, we will provide a single method named “apply” that takes an Integer as an argument, squares it and returns the result as a String. Before we begin, let’s take a quick look at the official JavaDoc for java.util.function.Function:

java.util.function.Function
Java Interface Function<T,R>

Parameter Types:
T - the input given to the function
R - the result running the function

Popular Subinterface of Function: UnaryOperator<T>

The JavaDoc also indicates that the Function interface has a single, non-default method named apply which takes a single argument and returns a single argument:

R apply(T t)

People often mistake that there is something magical about the interfaces defined in the java.util.functions package, but there’s not. They are just normal interfaces, and as such, we can always create a class that explicitly implements them.

class FunctionClass implements Function<Integer, String> {
  public String apply(Integer t) {
    return Integer.toString(t*t);
  }
}

The FunctionClass defined here implements Function and provides an implementation for the apply method. We could then use this in any class with standard syntax rules.

Function<Integer, String> functionClass = new FunctionClass();
System.out.println(functionClass.apply(2));

When you run the above code, the output would be four.

Java Function interface example

Similarly, we can write a Java Function example that uses an inner class to implement the apply method:

Function<Integer, String> innerClass = new Function<Integer, String>(){
  public String apply(Integer t) {
    return Integer.toString(t*t);
  }
};
System.out.println(innerClass.apply(3));

When you run the inner class example, the output would be nine.

Java’s Function and lambda expression example

Of course, the whole idea of the functional interface is to incorporate lambda expressions into the mix. Here’s the Java Function example implemented with a rather verbose lambda expression:

Function<Integer, String> verboseLambda = (Integer x)-> { return Integer.toString(x*x); };
System.out.println(verboseLambda.apply(5));

This implementation will print out the value 25. Of course, this implementation is also very wordy. With a Java lambda expression, the object type isn’t required on the left hand side, and if the lambda expression is one line long, both the brackets and the return keyword can be omitted. So a more concise lambda expression that implements this Java Function interface would look like this:

Function<Integer, String> conciseLambda = (Integer x)-> { return Integer.toString(x*x); };
System.out.println(conciseLambda.apply(5));

When the code implements Java Function with a concise lambda expression runs, the program prints out 25.

That’s all you really need to know about the java.util.function.Function interface. It is a very simple component that simply requires the implementation of one method — named apply — that is passed in a single object, runs to completion and returns another Java object. It’s just that simple.

Don’t overcomplicate Java’s Function interface

Some people can find the simplicity of the Java Function interface to be a bit confusing. After all, a method that takes something and returns something else seems to be so incredibly vague and abstract that is almost seems meaningless.

However, seasoned Java developers know that sometimes the simplest of language constructs can turn out to be the most powerful, as is the case with object models designed with abstract classes and interfaces. Power through simplicity is exactly the point when it comes to the various components listed in the java.util.function package.

Java Function Example

The Java Function interface is used in many parts of the java.util.function API package

You will run into the Function interface in a variety of places, especially when you start advanced functional programming with the Java Streams API. Powerful methods such as map, reduce and flatMap all take a Java Function as a parameter. So if you plan on any map-reduce programming with Java, Functions will become one of your biggest friends.


February 13, 2019  5:37 PM

Don’t struggle to learn new programming languages

George Lawton Profile: George Lawton

Modern applications developers are often tasked to learn new programming languages and patterns to improve their skills. The classic do-it-yourself approach with books or tutorial videos is great, but it still requires the developer to set up a programming environment to out that newfound knowledge in a more practical setting.

Fahim Ul Haq and Naeem Ul Haq created a new interactive platform called Educative that makes it easier to learn new programming language skills inside of a pre-built development environment. I caught up with Fahim Ul Haq to find out what they have discovered about how developers try to learn new languages faster.

How did you come up with the idea for Educative?

Fahim Ul Haq: The idea for Educative evolved in a couple of phases. We’re obviously developers ourselves, so we really felt the struggle of trying to update our skills with the currently existing tools.

We first dabbled with interactive learning for developers when we launched a mobile app to teach developers as a side project. The app became popular and we would sometimes receive requests from developers to create more content like this. But with our day jobs at Facebook and Microsoft, that wasn’t possible.

Then in 2014, one of the largest publishers in America approached us to write a book for software engineers, building on the app we’d developed. We wanted to create a free companion website with interactive learnings, but the publisher wasn’t interested in that. Even though they rejected the idea, it gave us the inspiration to create a platform where developers could learn interactively.

Once we started exploring the idea and talking to potential authors, we got one unanimous piece of feedback: authors liked the idea of creating interactive training for developers, but it seemed like a lot of work, compared to making a video tutorial.

So we came up with Educative: a platform that provides interactive learning for software developers, powered by an authoring platform that makes it extremely easy to create content.

How does Educative build on the work of other interactive training programs or approaches to provision fully configured training environments like CodeEnvy or what Sensei has done with security training?

Ul Haq: I think all these different solutions come out of a simultaneous recognition of the same need: a developer learning resource that tracks with all the advances in technology we’re seeing today. That’s really the underlying theme here. Educative and the two tools you mentioned are applying similar approaches — but to different niches. That makes it somewhat difficult for us to build directly on their work, but we’re keeping a close eye on them and would love to see what we can learn from each other.

What are your thoughts on how to measure the results of this sort of training method to quantify the speed of learning compared to other approaches?

Ul Haq: This is something we want to do in the very near future. I think it’s just a case of the current metrics we have on demand for our product and the anecdotal evidence for its effectiveness being so strong, that we haven’t yet felt a need to objectively study its benefits. It will become more urgent as we scale up.

What have you learned about on how to organize software training programs that improve the process to learn new programming languages?

Ul Haq: There are no one-size-fits-all solutions for how anyone learns anything, particularly for how developers learn to program. This applies on two levels. The first one is more obvious: trying to learn to code through videos is just frustrating for so many people. There’s an assumption that people progress more or less at the same linear pace — so going back and forth in a video, re-watching parts or skimming through parts, is just so cumbersome. This is where our platform really helps.

However, the second level is that even on our platform there’s a need for different levels of difficulty on the programming problems. For example, some people will inevitably learn quicker, and just find our practice problems too easy. That’s why we’re planning to launch adaptive learning in the future — to put such people on personalized accelerated tracks. As they answer practice problems, we’re able to get data on how they’re performing and adjust the level of problems they’re served up accordingly.

What are the biggest stumbling blocks that developers face when they learn new programming languages?

Ul Haq: I would say they’re largely the same ones anyone faces when trying to learn a new skill. It’s time-consuming and puts you out of your comfort zone. It’s so much easier to just stick with what you know and not pursue further learning. This effect is magnified in the developer world, where the resources for learning new skills are sometimes highly technical and unfriendly. Those are roadblocks that we are working to overcome with Educative.

What advice might you give prospective course authors?

Ul Haq: Just keep it simple. Teach like you talk normally. Sometimes when someone knows a subject backwards and forwards, it’s very easy to forget what it felt like to be a new learner and just start speaking in this abstract jargon. High-level programming languages get very abstract, very quickly. We encourage authors to use real-world examples to put those abstract concepts in a more easy-to-understand context. Ideally, you want your learners to not just know something, but know how to apply it.

How do you expect the kinds of interactive training tools for developers to evolve, not just for Educative, but for software development in general?

Ul Haq: I expect that interactive tools like Educative will become the new norm, not just for customers, but for corporations as well. Too many smart people are investing too much time and money for outdated methods to survive forever. I think that in the future people will be taught by machines that know exactly what kind of content it takes to keep them engaged, and serve up personalized, interactive material to optimize for their growth. It sounds scary, but it just makes too much sense to not do.


February 4, 2019  7:29 PM

A quick look at inferred types and the Java var keyword

cameronmcnz Cameron McKenzie Profile: cameronmcnz

The biggest language change packaged with the Java 10 release, aka JDK 18.3, was the introduction of the inferred type. This addition, combined with the ability to use the long reserved Java ‘var’ keyword in your code, will have a significant impact on how programs are both read and written.

The case for the Java var keyword

Java has always had a weird syntax to declare variables. A manifest type declaration on the left side must polymorphically match up with the object type provided on the left hand side of the equation. This creates a somewhat verbose and dare I say it, clunky syntax for what is an exceptionally common task.

Java declaration

Java variable declaration without the var keyword

A Java var keyword example

As you can see from that simple code snippet, traditionally developed Java code lends itself to verbosity. But with the use of the var reserved work and the type inference, the code can be cleaned up quite a bit.

Java var keyword

The use of Java inferred types with the var keyword.

With this new syntax, the object type does not need to be explicitly declared on the left hand side of the initialization. Instead, the object type can simply be inferred if you look at the right hand side of the equation, thus the term inferred type. Of course, the right hand side of the equation always has the final say on what type of object is created, so this Java 10 feature doesn’t really change how the Java language works, nor will it have any impact on how code will be interpreted.

In the end, the language change simply drives towards the goal to make Java, a language often criticized for being far too verbose, more readable.


January 31, 2019  7:49 PM

Compare, contrast your image recognition tool options

YanaYel1na Profile: YanaYel1na
Uncategorized

If you’ve been presented with an opportunity to work with machine learning tools with advanced image recognition functionality, you’d be wise not to pass it up, even if you’re new to this technology. An array of high-profile tech giants have developed their image recognition tools for developer use, and without the need to build a neural network from scratch.

Here’s an overview of three mature image recognition and detection tools from some tech giants for you to consider, and help choose the optimal one to meet your development needs.

Google Cloud Vision

With Google’s visual recognition API, you can easily add advanced computer vision functionality to your application:

  • Face, landmark and logo detection helps recognize multiple faces and related attributes such as emotions or headwear (note that facial recognition is not supported here), natural and handmade structures as well as product logos within one picture. A user can perform image analysis on a file located in Google Cloud Storage or on the web.
  • Optical character recognition (OCR) can be used to spot and extract text within a file of various formats, from PDF and TIFF to PNG and GIF. The tool also automatically identifies a vast array of languages and can detect handwriting.
  • Label detection and content moderation allows a user to establish categories and also spot explicit material — such as adult or violent content — within an image.
  • Object localizer and image attribute functionality helps identify the exact place and type of object in an image as well as detect its general attributes such dominant colors or cropping vertices.

After you enable the Cloud Vision API for your project, a user can start to implement it with a variety of programming languages via client libraries. The image recognition tool also offers AutoML Vision, which lets you train high-quality custom machine learning models without the need for prior experience.

Clarifai

Clarifai’s API is another image recognition tool that doesn’t require any machine learning knowledge prior to implementation. It can recognize images and also perform thorough video analysis.

A user can start to make image or video predictions with the Clarifai API after they specify a parameter. For example, if you input a “color” model, the system will provide predictions about the dominant colors in an image. You can either use Clarifai’s pre-built models or train your own one.

Clarifai video analysis processes one video frame per second, and provides a list of predicted concepts for every second of video. The user will need to input the parameter to begin, and split a video into different components if it exceeds maximum size limits.

Clarifai also offers additional tools for further experimentation and analysis. Explorer is a web application where you can introduce additional inputs, preview your applications and also create and train new models with your own images and concepts. The Model Evaluation tool can provide relevant performance metrics on custom-built models.

Amazon Rekognition

Amazon Rekognition is another image recognition tool to consider. Rekognition provides similar functionality as its counterparts, and also adds in facial comparison and celebrity recognition from a variety of pre-built categories, such as entertainment, business, sports and politics.

With Rekognition Image, the service can measure the likelihood of a face appearing in multiple pictures, and also verify a user against a reference photo in near real time.

Apart from image recognition, Amazon also offers near real-time analysis of streaming video. The system automatically extracts rich metadata from Amazon Rekognition Video and outputs it to a Kinesis data stream to detect objects and faces, create a searchable video library and carry out content moderation.

Which tool should you choose?

Each tool provides its own set of features that can potentially meet your image recognition demands. Here is a chart that compares Cloud Vision, Clarifai and Rekognition on several important parameters.

  Google Cloud Vision Clarifai Amazon Rekognition
Face analysis
Facial recognition x
Object and label detection
Explicit content identification
OCR
Video analysis and scene recognition x
Activity detection x
Image attributes
Client libraries Python, Ruby, PHP, C#, Java, Go, Node.js, Objective-C, Swift Python, Ruby, PHP, C#, Java, JavaScript, Objective-C, Haskell, R Python, Ruby, PHP, Java,  JavaScript, Node.js, .Net
OS Linux, macOS, Windows, iOS, Android Linux, macOS, Windows, iOS, Android, IoT

 

Linux, macOS, Windows, iOS, Android, IoT
Multilingual

The image recognition tool space is crowded with tools that can potentially enhance your product. Weigh all of your options and compare their different features before you make a decision. If one of these tools doesn’t fit, consider some alternatives such as Watson Visual Recognition from IBM or Ditto Labs.


Yana Yelina is a Technology Writer at Oxagile, a custom software development company with a focus on building machine learning solutions. Her articles have been featured on KDNuggets, ITProPortal, Business2Community, to name a few. Yana is passionate about the untapped potential of technology and explores the perks it can bring businesses of every stripe. You can reach Yana at yana.yelina@oxagile.com or connect via LinkedIn or Twitter.


January 31, 2019  7:08 PM

Step-by-step guide: How to install Git on Windows desktop computers

cameronmcnz Cameron McKenzie Profile: cameronmcnz

As distributed version control systems continue to supplant centralized systems like Subversion and CVS, more and more developers have made the move toward SaaS-based version control platforms such as GitHub, GitLab and BitBucket. Of course, these are all Git based systems, which means developers must first locally install Git on Windows or Linux computers to interact with them.

In this Git tutorial, we will demonstrate how to install Git on Windows. We will then use the five basic Git commands every developer should know to verify that the DVCS tool was installed successfully.

How to install Git on Windows in 10 easy steps:

Here are the steps to follow to install Git on Windows:

1. Download the executable Git file from git-scm.com/downloads
2. Run the installation file with Administrator rights
3. Choose an appropriate installation location such as C:\_tools\git
4. Install the default components, including Git GUI Here and Git Bash Here
5. Choose your preferred Git default editor. We recommend Notepad++.
6. Allow Git to be added to the Windows PATH
7. Accept the default line ending conversion for Unix and Windows compatibility
8. Chose the extra option to enable system caching
9. Click Finish to complete the install.
10. Choose to open a Git Bash shell and start using Git!

Windows Git install

Step by step Windows Git installation

Test the Windows Git install

You can test the veracity of your Windows Git install by issuing the five basic Git commands every developer should know. Those basic Git commands are:

  1. init
  2. add
  3. config
  4. status
  5. commit

Before you run Git init, first create a new folder named repos off the C:\ drive:

windows@install-git MINGW64 /c/repos
$ git init
Initialized empty Git repository in C:/repos/.git/

In the newly created folder, add a file named windows-git-install.txt:

windows@install-git MINGW64 /c/repos
$ touch windows-git-install.txt

Then add the file to the Git index:

windows@install-git MINGW64 /c/repos
$ git add .

Configure the Git user’s email address and username:

windows@install-git MINGW64 /c/repos
$ git config --global user.name "Cameron McKenzie"
windows@install-git MINGW64 /c/repos
$ git config --global user.email "mail@example.com"

Commit the new file to the new Git repository:

windows@install-git MINGW64 /c/repos
$ git commit -m "New Windows git install commit"
[master (root-commit) 5b8f1f4] New Windows git install commit
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 windows-git-install.txt

And finally, check the status of the newly installed Git repo:

windows@install-git MINGW64 /c/repos
$ git status
On branch master
nothing to commit, working tree clean

Windows Git test

How to verify a Windows Git installation

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thus concludes the task to install Git on Windows, and ensure that the DVCS tool is properly configured to manage source code and interact with SaaS-based tools such as GitHub, GitLab and BitBucket.

Basic Git commands

How to run five basic Git commands


January 10, 2019  5:48 PM

Why developers don’t stay in management for IT career change

BobReselman BobReselman Profile: BobReselman

There’s a saying in the life insurance industry that goes like this:

“The minute you become successful your first inclination is to stop doing all the things that made you successful. You stop making the phone calls, you stop scheduling the sit downs.”

This dynamic isn’t confined to life insurance. It happens in IT all the time. The moment an engineer gets anywhere close to good at developing code, the next step is an IT career change to management. In fact, for many developers, it’s an aspiration. Sadly most don’t have the skill or experience to make the leap. If I had a hundred dollars for every gifted engineer who went on to be a crappy manager, I’d be moderately well off.

Believe me, I know. I was one those people. Why? For me it was mostly a matter of money and prestige. I succumbed to the perception of being “just a developer.” I wanted to be more than just anything. My need for status needed to be satisfied. And, I wanted the bucks. Maybe if I had a better self-esteem, things would have turned out differently.

So I ended up in management, for a while anyway. What I came to realize is that most activities in middle-management are akin to sitting at the information kiosk at Grand Central Station and directing people to the right train track. But, in addition to providing the platform number and departure time, I had the added responsibility of making sure that everyone got on the train when they were supposed to.

Test the management waters

I had moderate success with my IT career change and foray into management. I actually accomplished to get some stuff out the door, no pun intended. But, after a while I came to realize that I was happier to learn new technology and make things with what I learned. That’s the good news.

The bad news is that it took me a long time to come to this point of self-awareness. The lure of the money and prestige that goes with management was hard to resist.

If I had ambitions to work in a bigger software company, maybe things would have turned out differently. Bigger companies understand that to stay viable in the long term, their culture needs to give the same status and compensation to creative talent as it does to management. For example, Microsoft has parallel career tracks for individual contributors and management. A Distinguished Engineer has the same rank and status as a Vice President. The compensation is the same too, and ranges anywhere from $900K to $1.25M a year. Google, Facebook, Apple and other large tech companies all have similar structures. It’s good work, if you can get it.

But, life at Microsoft or one of the FANGs isn’t always a true representation of life in IT. Jobs in technology are mostly about ensuring that the phones work, inventory is maintained, orders are filled and that employees and bills get paid. These companies worry more about an operational digital infrastructure than talent that ascends to the heights of Distinguished Engineer. As a result, the career path for many in IT is to end up in management.

Then one day some of these folks who made the leap to management wake up with a sense of emptiness that can’t be assuaged by directing people about in the IT career change. They started out with a desire to make stuff that made a difference only to end up with HR on their backs about employee reviews. Fortunately, despite episodes of existential angst, many management skills are transferable.

Tech is different. The details count a lot. Some of those in tech that stay true to the creative imperative and continue to make stuff come to a different conclusion in their mid-life. They battle to keep up with new technologies that are, for the most part, reinventions of something that was created a decade ago and are thus unknown to the growing workforce of the twenty-somethings that fill the room. While the younger employee can pull the all-nighter, by the time you hit 45, it’s not that you can’t do the all-nighter, it’s more that you know that there will always be another one, so why set the precedent and cooperate now?

Aging managers might question the value of their work. Aging developers wonder if they made the right decision to stay with hands-on work. At the age of 45-50, many wonder if it would be better to go into management and leave the creative work to the younger generation. They fear the prospect of being old in tech. But being old in tech isn’t something to be ashamed of. It should be worn like a badge of honor. There’s something respectable about continuing to be creative and to write code while many in management have long since retired.


January 9, 2019  7:59 PM

How your team will benefit when you hire a full stack developer

charlesdearing Profile: charlesdearing

Full stack developers are some of the best developers on the market. They understand every layer of software from the back-end to the front-end. Full stack developers have a hand in every development stage, from database implementation to the finishing touches on front-end layout.

Great full stack developers can be hard to find. Developers and engineers with such a broad and intimate knowledge of software processes and structures can be nearly impossible to find. A vast array of skills like those possessed by full stack developers is exceedingly rare.

Since full stack developers are in such high demand, they’re quite expensive to keep on your payroll. Competitive compensation packages can be difficult for small startups to offer. However, even the smallest startups should consider hiring full stack developers. They add tremendous value to the team and can provide invaluable insight into the development process.

The jack-of-all-trades

Top full stack developers immediately understand software engineering. They have a working knowledge of every layer. This level of understanding makes full stack developers extremely valuable to teams comprised of diverse specialists. They can act as liaisons for software development teams, and help teams collaborate and communicate more openly.

Full stack developers can translate areas of concern from one specialist to another, and serve as team leaders or translators for various software issues that can occur across the stack.

These IT pros have the Swiss-army knife of skill sets. They are active in every step, and that makes their input about design and implementation invaluable to the team.

Full stack developers boost productivity

The top full stack developers can help round out a team of specialists. They can help everyone communicate more efficiently and effectively. The cohesiveness as a team is increased substantially. Team morale is boosted, increasing motivation, determination, and passion for the project.

Top full stack developers help the entire team become more efficient. They facilitate communication and foster collaboration, which greatly increases a team’s productivity as a whole.

It’s important to remember that great full stack developers are not only expert engineers, they are also superb team players with exceptional social skills. They speak concisely, openly and are eager to help other team members.

As leaders, they can help the team remember overarching goals and meet software requirements. While all full stack developers have an incredible technical ability, it only serves them if they have the soft skills to match.

Full stack developer benefits

These well-rounded professionals can be an incredible addition to any team. Startups can benefit from experienced full stack developers because of the insight, perspective, and expertise they can bring to the table.

Dedicated full stack developers can also enhance the efficiency of a software development team. Since they have a comprehensive understanding of the development process, full stack developers can help address potential blind spots and bottlenecks.

Software creation is more of an art than a science. Specialists can only write so much source code and abstract so many actions into algorithms. Team members can only communicate so much since they operate on different levels of the stack. Full stack developers can help bridge these knowledge gaps.

Software engineering is never an easy feat. However, it is one that can be enhanced by reducing waste and creating greater paths to efficiency. Full stack developers can help guide the rest of your team on this quest.

However, these people are exceedingly rare. They have an incredible skill set that allows them to understand every layer of software.

Since full stack developers possess a deep understanding of software creation, they’re in short supply and often quite expensive. Young startups low on cash might want to begin their search for an experienced full stack developer who can help make their software development teams more productive.

Companies, especially nascent startups, should consider full stack developers as well. They can help with any number of software issues, and work with front-end engineers or back-end developers to open up more direct lines of communication to boost efficiency.

When you hire full stack developers, team morale boosts, productivity increases, and inefficiencies decrease. While spending on such lavishly expensive salaries can seem overwhelming or risky, it is one of the best investments you can make for your company.


January 6, 2019  8:27 PM

How Atomist’s Rod Johnson works with pull requests

George Lawton Profile: George Lawton

Pull requests play an important role in any large software development project. They facilitate efficient code review, reduce bugs, track progress, and help coordinate a shared understanding of large code bases. Some type of pull request mechanism is built into every version control system and they can be integrated into a wide variety of notification systems including email, chat, issue trackers, and project management systems. However, there is not a lot of information on best practices for making pull requests work smoothly and efficiently as part of different styles of application development workflows.

I recently caught up with Rod Johnson to learn more about best practices for getting the most out of Git and GitHub pull request workflows. Johnson created the Spring Framework, and more recently Atomist, a framework for software delivery infrastructure.

What are some of the different ways you use pull requests in your app dev workflow? i.e. what tools do you integrate to consume pull requests and facilitate better communications among your team?

We use the GitHub Review mechanism, with Atomist to facilitate communications via GitHub and Slack. You’ve forced me into a product plug here, but since we started using Atomist ourselves, we haven’t looked back!

When we raise a PR, we typically choose reviewers using the GitHub UI. We have Atomist running on our GitHub org and community Slack team, so reviewers will get direct messages in Slack to let them know. We all tend to live in Slack, so that works a lot better for us than email alerts. Atomist attaches labels to the PR. Of course, you can do that with other tools, too. I think it’s a good practice for automations to add information that helps speed review.

Atomist is based around handling events, and a PR is an important event that we can add custom code to handle at team level rather than individual repo level. This enables consistent policy.

In our teams, Atomist auto-merges PRs when reviews are complete and automatically updates the change log on merged PRs. It automatically runs code quality checks and linting on all pushes, even before a PR is raised.

I don’t think integrating a host of tools into your software configuration management makes sense. It’s better to plug in one portable thing that gives you a rich model for handling events. The same approach works on GitHub, BitBucket and GitLab. Instead of managing a number of integrations, you just integrate Atomist and use its programming model. For example, our “autofixes” are doing more and more things over time and saving us a ton of work. Initially we just did linting. Now we add missing license headers, format imports etc. And it’s easy to add further things like this without changing any GitHub setup. Our customers use this to integrate tools like SonarQube.

You can see the output of this at https://github.com/atomist/sdm and in our community Slack (join.atomist.com).

Do you find that one style of pull request workflow works best across a single organization or are different workflows better for different types of development?

We use PRs and try to keep branches short-lived. Any branch that lives longer than a day or two is questionable IMO. The default branch should always be fairly up to date.

What would you consider to be best practices for improving the use of pull requests to speed development, improve quality, and keep teams on the same page?

I think it’s good to review PRs. It can help with quality, but it also ensures that knowledge is clearly communicated in the team and makes it easy for people outside to follow. In open source, the latter is important as you’d love to inspire and empower people to contribute. I think tone is important in reviewing PRs. I don’t believe in accepting all PRs, but it’s crucial to be clear and respectful in comments. The PR mechanism can be an amazing way of working toward a better solution than any individual envisaged when setting out.

What kind of challenges have you encountered in making pull requests work smoothly?

Every challenge we’ve had involved long-lasting PRs, where you get into rebasing hell, where you need to continually rebase a long-lived branch from master, potentially resolving conflicts

What do you think of useful ways of thinking about pull requests as more than just a communications feature baked in to Git, GitHub, etc. and as part of streamlining the app dev to production lifecycle?

I like it when the default branch is deployed to production and you can use PRs to drive promotion. Of course, that isn’t appropriate for all organizations–some need a separate formal promotion mechanism–but it’s great if it is possible.


January 1, 2019  3:16 PM

How to use Java’s functional Consumer interface example

cameronmcnz Cameron McKenzie Profile: cameronmcnz

Quite often a Java Stream or other component needs an object passed to it in order to perform some type of calculation or process, but when the process is complete, nothing gets returned from the method. This is where Java’s functional Consumer interface comes in handy.

According to the JavaDoc, the Consumer interface accepts any type of object as input. The java.util.function.Consumer class has one non-default method named accept which takes a single object as its argument and has a void return type.

java.util.function.Consumer<T>
Consumer function type Parameters:
T - object type to be passed to the Consumer accept method

Consumer function methods:
void accept(T t)  This method operates on a single object passed in as an argument.
default Consumer<T> andThen(Consumer after)  Returns a functional Consumer interface 
that can be daisy chained in sequence.

The Consumer's non-default accept method takes a single argument and does not return a result.

Functional programming with a Java Consumer

Sometimes programmers new to lambdas and streams get intimidated by the components defined in the java.util.function package, so I always like to remind developers that all of the interfaced defined in this package follow all of the standard, pre Java 8 rules for implementing interfaces. As such, you can incorporate the functional Consumer interface into your code simply by creating a class that implements java.util.function.Consumer, or by coding an inner class.

Consumer example tutorial

Here is the Java code used in this Consumer function example tutorial.

Implement a Consumer with a Java class

Here is the Java Consumer function implemented using a Java class instead of a lambda expression:

class SimpleConsumerExample implements Consumer<Long> {
  public void accept(Long t) {
    System.out.println(t*t);
  }
}

Inside of a main method or any other piece of Java code, the SimpleConsumerExample class can be instatiated according to traditional Java syntax rules:

/* Java Consumer example using a class */
SimpleConsumerExample sce = new SimpleConsumerExample();
sce.accept(new Long(2));

Similarly, an inner class can also be used:

/* Functional Consumer example using inner class */
Consumer<Long> innerConsumer = new Consumer<Long>() {

  @Override
  public void accept(Long t) {
    System.out.println(t*t);
  }
};

innerConsumer.accept(new Long(4));

Lambda and Consumer interface example

As you can see, there is nothing special about the interfaces defined in the java.util.function package. They are regular Java interfaces that comply with all of the traditional rules of syntax. However, they also work with lambda expressions, which is where functional interfaces really shine. Here is the functional Consumer interface example implemented using a somewhat verbose lambda expression:

Consumer<Long> lambdaConsumer = (Long t) -> System.out.println(t*t);
lambdaConsumer.accept(new Long(5));

I like to use a verbose lambda syntax when demonstrating how they work, but one of the reasons for using lambda expressions is to make Java less verbose. So the lambda expression above can be written in a much more concise manner:

Consumer<Long> conciseLambda = t -> System.out.println(t*t);
conciseLambda.accept(new Long(10));

Sample Consumer interface use cases

The functional Consumer interface is used extensively across the Java API, with a number of classes in the java.util.function package, such as ObjIntConsumer, BIConsumer and IntConsumer providing extended support to the basic interface.

Furthermore, a variety of methods in the Java Stream API take the functional Consumer interface as an argument, inclusing methods such as collect, forEach and peek.

There are only a few key intefaces you need to master in order to become a competent functional programmer. If you understand the concepts laid out in this functional Consumer interface example, you’re well on your way to mastering the update Java APIs.

Consumer tutorial code

Here is the code used in this tutorial on how to use the Consumer.

package com.mcnz.lambda;
import java.util.function.*;

public class JavaConsumerExample {

  public static void main (String args[]) {

    /* Java Consumer example using a class */
    SimpleConsumerExample sce = new SimpleConsumerExample();
    sce.accept(new Long(2));

    /* Functional Consumer example using inner class */
    Consumer<Long> innerConsumer = new Consumer<Long>() {
      @Override
      public void accept(Long t) {
        System.out.println(t*t);
      }
    };
    innerConsumer.accept(new Long(4));

    /* Implemented Consumer function with verbose lambda expression */
    Consumer<Long> lambdaConsumer = (Long t) -> System.out.println(t*t);
    lambdaConsumer.accept(new Long(5));

    /* Concise lambda and Consumer function example */
    Consumer<Long> conciseLambda = t -> System.out.println(t*t);
    conciseLambda.accept(new Long(5));

  }
}

/* Class implementing functional Consumer example */
class SimpleConsumerExample implements Consumer<Long> {
  public void accept(Long t) {
    System.out.println(t*t);
  }
}

 

 


Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to: