Skip to main content

Posts

Covariant Return Types - Java 6 or Greater

In OOP, a  covariant return type  of a method is one that can be replaced by a "specialized" type when the method is  overridden  in a subclass.  C# does not support return type covariance. Covariant return types have been (partially) allowed in the  Java language  since the release of JDK5.0, so the following example wouldn't compile on a previous release: // Classes used as return types: class Person { } class Guy extends Person { } // "Class Guy is more specific than class Person" // Classes demonstrating method overriding: class Department { public Person getPerson ( ) { return new Person ( ) ; } } class DepartmentOfGuys extends Department { public Guy getPerson ( ) { return new Guy ( ) ; } } More specifically, covariant (wide to narrower) or contravariant (narrow to wider) return type refers to a situation where the return type of the overriding method ...

Java NIO.2 - The Path Class - An overview

The Java NIO.2 is a new API for file manipulation. Added to the Java Platform 7. This API comes with many benefits, and new classes. Those classes bring new functionalities, and solve problems of the traditional I/O API, as well as allow a more robust and simpler code. In this article, we are going to talk about one of the base classes: The Path class, present in the java.nio.File package. This class is basically one of the entry class of the Java NIO API. The models the Path of File or a directory in a File System in a particular Operational System - Microsoft Windows, for example. As we are a bout to see, this class offers many facilities that make it very important and present in other I/O Operations, as well as, it plays an important role with other classes in the NIO API. Let us get started in the journey of the Path class and its use. 1. Intancing a Path The Path, is actually an Interface, that is instanced with a static factory method from the utility class Paths(java....

When to use NOSQL - An opinion based post of 2014...

In the last weeks, I've been hearing a lot about Cassandra, and other NoSQL Solutions that were candidates to one of the projects I am working on. Which is currently set to function properly with a RDBMS solution - Oracle 11g. I decided then to take a deeper look into those kind of solution, NoSQL solutions, and compare them with RDBMS solutions. This article is intended to help you understand NoSQL, and pick the solution that best fits your requirements and scenario. This article does not cover all the features of a Specific NoSQL solution, rather it shows the general scenario. In order to fully understand NoSQL, let us first see some key concepts of distributed computer systems and storage systems. What is NoSQL? A NoSQL or Not Only SQL database provides a mechanism for storage and retrieval of data that is modeled in means other than the tabular relations used in relational databases. Motivations for this approach include simplicity of design, horizontal scaling and fine...

Publishing a Soap-Based Service with the Endpoint class - Part 1

Hey there, For some developers, especially those that are not familiar with Web Services, it might be difficult to figure out how to start off creating Web Services. Today we are going to walk you through a simple tutorial, learning how to publish a Web Service, in your local machine, without a Web Server or an Application Server. A Web Service is a set of functions that are exposed and published over a networking, allowing the separation of the function-service from its execution environment. This leads enterprise softwares to an easier integration approach of different software components, written in different languages and running in different operating system as well as decoupling those components. Creating our Web Service We are going to use the  bottom-up model for designing a service, which means, we will not have a WSDL file first, but instead we are creating the classes, this model is also known as contract last, because de WSDL is created from the classes. A dev...