DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Low-Code Development: Leverage low and no code to streamline your workflow so that you can focus on higher priorities.

DZone Security Research: Tell us your top security strategies in 2024, influence our research, and enter for a chance to win $!

Launch your software development career: Dive head first into the SDLC and learn how to build high-quality software and teams.

Open Source Migration Practices and Patterns: Explore key traits of migrating open-source software and its impact on software development.

Avatar

Carlo Scarioni

Software Arch at free

Surrey, GB

Joined May 2008

About

As a pasionate software developer, motivated by learning and appliyng innovative and interesting software development tools, techniques and methodologies, my professional objectives are the following. To be in a technology oriented enterprise where the technichal staff is the soul of the company. To be in an important IT team. Be able to design and develop state of the art software. Be able to apply new knowledge everyday, on innovative ways and with a great degree of freedom. To architect, design and develop software that uses the best practices of the field. Play with the latest technologies, learn everyday and participate in the research and innovation of the software products.

Stats

Reputation: 97
Pageviews: 422.7K
Articles: 3
Comments: 7
  • Articles
  • Comments

Articles

article thumbnail
Writing a Simple Pulumi Provider for Airbyte
Explore a simple example of writing a Pulumi provider for Airbyte. Instead of using the official Terraform provider, implement a Pulumi provider in Python.
July 8, 2024
· 1,333 Views · 1 Like
article thumbnail
Duck Typing in Scala: Structural Typing.
Scala offers a functionality known as Structural Types which allows to set a behaviour very similar to what dynamic languages allow to do when they support Duck Typing (http://en.wikipedia.org/wiki/Duck_typing) The main difference is that it is a type safe, static typed implementation checked up at compile time. This means that you can create a function (or method) that receives an expected duck. But at compile time it would be checked that anything that is passed can actually quack like a Duck. Here is an example. Let’s say we want to create a function that expects anything that can quack like a duck. This is how we would do it in Scala with Structural Typing: def quacker(duck: {def quack(value: String): String}) { println (duck.quack("Quack")) } You can see that in the definition of the function we are not expecting a particular class or type. We are specifying an Structural Type which in this case means that we are expecting any type that has a method with the signature quack(string: String): String. So all the following examples will work with that function: object BigDuck { def quack(value: String) = { value.toUpperCase } } object SmallDuck { def quack(value: String) = { value.toLowerCase } } object IamNotReallyADuck { def quack(value: String) = { "prrrrrp" } } quacker(BigDuck) quacker(SmallDuck) quacker(IamNotReallyADuck) You can see that there is no interface or anything being implemented by any of the three objects we have defined. They simply have to define the method quack in order to work in our function. If you run the code above you get the output: QUACK quack prrrrrp If on the other hand you try to create an object without a quack method and try to call the function with that object you would get a compile error. For example trying to do this: object NoQuaker { } quacker(NoQuaker) You would get the error: error: type mismatch; found : this.NoQuaker.type required: AnyRef{def quack(value: String): String} quacker(NoQuaker) Also, you don’t even need to create a new type or class. You could use AnyRef to create an object with the quack method. Like this: val x = new AnyRef { def quack(value: String) = { "No type needed "+ value } } and you can use that object to call the function: quacker(x) You can also specify in the function that expects the structural type, the the parameter object must respond to more than one method. Like this: def quacker(duck: {def quack(value: String): String; def walk(): String}) { println (duck.quack("Quack")) } There you are saying that any object you pass to the function needs to respond to both methods quack and walk. This is also checked at compile time. Under the covers the use of Structural Types in this way will be handled by reflection. This means that it is a more expensive operation than the standard method call. So use only when it actually makes sense to use it.
February 20, 2013
· 40,990 Views · 2 Likes
article thumbnail
Hadoop Basics—Creating a MapReduce Program
The Map Reduce Framework works in two main phases to process the data, which are the "map" phase and the "reduce" phase.
March 18, 2012
· 211,684 Views · 4 Likes

Comments

Injecting dependencies in Ruby

Mar 23, 2012 · Carlo Scarioni

hehe. Thanks for the comment... I am actually a full time Java developer doing Ruby in spare time, probably that is why I opted to do this solution. I think we (Java) have a lot to take from the Ruby Community as well. Which gladly is also the case. These are two great and rich communities.
Making Rich Domain Models in Ruby is Better than in Java

Mar 06, 2012 · Amilia Crux

hehe, I already said that I work with Java all the time (for 8 years now), so it is also MY Java. I could tell you that Just In Time compilation is an amazing feature of the Java VM, and nothing in Ruby matches it. That makes Java better in that particular regard. Threads are also way better in Java than Ruby. Both these statements and the one in the Post are not subjective, they are features better implemented in each particular language that are simply better than what the other language can offer, if it offers it at all. I didn't say you cannot do it in Java either I'm just saying that the Ruby way is cleaner. you can do almost anything in any language that doesn't mean that it won't be better doing it in some other language. With that argument an Assembler Programmer will say that any other language is crap because he can do it in Assmebler. And they guy that develops with 1 and 0 only will say that the abstraction of assembler is too much and he can do it with 1 and 0. Going back to Spring. Take a look at Introductions (you can fiind them as mixins as well). They tried to emulate something similar to what mixin modules in Ruby do.
Making Rich Domain Models in Ruby is Better than in Java

Mar 06, 2012 · Amilia Crux

I don't know what you mean with real life, but there are a lot of examples in real life that use Ruby and the technique explained in the Blog. Look at MongoMapper. Take a look at the Enumerable and Comparable modules just to name a couple. I don't know why you need complex examples to understand or give value to a concept. If you were to explain Dependency Injection to someone will you build a massive Spring/Hibernate/JAX-RS app? All the things you mention (ORM, Xml, Rest and Json) are supported in very nice ways either by Ruby or another framework (like Rails). I love the Spring framework myself, and if you try to see what they have been doing since the begginning is trying to simplify things for the Java world because they realise many things can be improved. Take a look at the Spring Roo project. They also acquired and invest heavily on Groovy.
Making Rich Domain Models in Ruby is Better than in Java

Mar 06, 2012 · Amilia Crux

Hi Jacek. The only one of those that seems to try and do something similar is @Delegate. However you can see that it is far less clean and involved to implement than the simple Module approach from Ruby. I have to say this all the time. I like Java and use it everyday, but that don't make me blind to see that there are more languages out there and some of them offer certain advantages that Java doesn't have. The same way Java has great advantages that make it the most used language.
Making Rich Domain Models in Ruby is Better than in Java

Mar 06, 2012 · Amilia Crux

Hi Jacek, Sorry but why the whole argument goes away?. Haven't use Lombok, but going through their site it looks like it can barely generate simple things for you like Getters, Setters and toString, and looks like their primary objective is to reduce the boilerplate in Java. Nothing to do at all with the Post. Please correct me if I'm wrong
Making rich domain models in Ruby is nicer than in Java

Mar 22, 2011 · Carlo Scarioni

Hi Jacek, I don't know what Java being faster has anything to do with the article. I myself work with Java every day, I'm learning and using Ruby only in my spare time to do some stuff and pointing one of the nice features that it has.
25 Even More – Sick Linux Commands

Dec 12, 2010 · Joseph Randolph

Great article. I love working with command line. Nice useful commands

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Send feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: