If you're interested in functional programming, you might also want to checkout my second blog which i'm actively working on!!

Friday, March 28, 2014

Ceylon: modularity

What is modularity?
*********************
Source: Wikipedia
*********************
Modularity is the degree to which a system's components may be separated and recombined.
In software design, modularity refers to a logical partitioning of the "software design"
that allows complex software to be manageable for the purpose of implementation and maintenance.
The logic of partitioning may be based on related functions, implementation considerations,
data links, or other criteria.
***************
In practise:
***************
Let's say you have a project which has 2 immediate dependencies:
- Dependency A version 2.1 (logging)
- Dependency B version 1.4 (persistence)
BUT library B in its turn also has a dependency on A but version 1.8. So the total dependencies become
- Dependency A version 2.1 (logging)
- Dependency B version 1.4 (persistence)
- Dependency A version 1.8 (logging)
Currently all dependencies are thrown in 1 big bag and the classloader picks 1 class from that bag.
It might however pick the wrong version.
So we need a way to enable modularity, where we are guaranteed the correct version of the class is used.
For Java "Project Jigsaw" will eventually enable this kind of modularity.
For Ceylon, Modularity is at the very core of the language, SDK and tooling.
view raw gistfile1.txt hosted with ❤ by GitHub
/**
In Ceylon, you create modules and each module specifies its own dependencies.
Just like with a maven repository, modules can be shared. You can browse which Ceylon modules are available
at http://modules.ceylon-lang.org/
A nice thing is that you can even get autocompletion from within the IDE.
If you start typing "import " and press ctrl-space you get all available modules.
Below an example of what a module descriptor looks like.
**/
module pelssers.learningbyexample "1.0.0" {
import ceylon.file "1.0.0";
import ceylon.collection "1.0.0";
}

No comments:

Post a Comment