Skip to main content

Posts

Variance concepts in the context of parametric programming with Java

Variance concepts in the context of parametric programming with Java By Obed Rios (5/7/2023 ) Revision 1.0 Abstract In Java, the concepts of variance are related to how the type parameters of a class or interface are related to each other when the class or interface is sub-typed or implemented. The key difference between invariant and covariant in the context of Java generics is how they handle sub-typing relationships. Invariant types do not allow assignments between different type parameters, while covariant types can accept a specified type or any of its sub-types. In addition contravariance enables you to use a more general type (super type) in a generic type or method that would normally require a more specific type (sub-type). In this work, we show explicitly the concepts of variance in the context of Java Generics. Introduction Parametric variance refers to the relationship between the type parameters of a class or interface and their subtypes. It defines how subtyping is i...
Recent posts

Solid Principles in Object Oriented Programming

SOLID Principles in Object Oriented Programming Solid Principles in Object Oriented Programming Introduction SOLID is an acronym that represents five principles of object-oriented programming and design, aimed at making software systems more maintainable and scalable. The SOLID principles are: Single Responsibility Principle (SRP) - A class should have only one reason to change, meaning that a class should have only one responsibility. Open-Closed Principle (OCP) - Software entities should be open for extension but closed for modification, meaning that a class should be easily extendable without modifying its existing code. Liskov Substitution Principle (LSP) - Subtypes should be substitutable for their base types, meaning that objects of a derived class should be able to replace objects of the base class without affecting the correctness of the program. Interface Segregation Principle (ISP) - Clients should not be forced to depend on interfaces they do not use, meaning tha...