CodeSOD: Flip to a Blank Page

This post was originally published on this site

The Daily WTF

You have a web application, written in Spring. Some pages live at endpoints where they’re accessible to the world. Other pages require authentication, and yet others require users belong to specific roles. Fortunately for you, Spring has features and mechanisms to handle all of those details, down to making it extremely easy to return the appropriate HTTP error.

Unfortunately for you, one of the developers on your team is a Rockstar™ who is Officially Very Smart and absolutely refuses to use the tools your platform provides. When that Certified Super Genius leaves the organization, you inherit their code.

That’s what happened to Emmer. And that’s how they found this:

List<String> typeList = getTypeList (loginName); if(CollectionUtils.size(typeList) > 0){ return viewRepository.findBySubmsnTypeList(typeList, pr); } else{ return viewRepository.findEmptyPage(pr); }

This doesn’t look too bad, does it? It’s not great- why are roles called “types”, why are we representing them with strings, why

To read the full article click on the 'post' link at the top.