Posts

Showing posts with the label DSL

Builder Pattern in Rust

Image
Builder Pattern is useful when we need to create complex objects(structs in rust case). Also if you want to do a fluent DSL Builder is a useful pattern for that as well. Today I will show how we can implement this Pattern in Rust, so I have a simple POC to show and also a video. So Let's get started! 

Kotlin DSL

Image
DSL is an expressive way to declare data and even business rules or configurations.DSLs can either be internal or external. Kotlin has interesting support for building internal and external DSLs. 12 days of Kotlin is a great way to learn more about kotlin-idiomatic solutions. Today I will be exploring the 12 days of kotling posts  in regards to DSL we will understand how they work and what options does kotlin provide to build rich DSLs.  So I recorded a video and also coded the sample of the 12 days of kotling post. So Let's get started.  The Video The Code https://github.com/diegopacheco/kotlin-playground/tree/master/kotlin-dsl-fun Cheers, Diego Pacheco

Immutables Builders

Image
Fluent Interfaces(Internal DSL) are a nice and sweet way to code. However, make a builder in Java all the time can be a bit verbose and time-consuming. Immutables Builders is a very interesting library that can help us with the heavy lifting.  Immutables can generate builders which are Type-safe, null-safe, and thread-safe. They are super easy to use and serialization ready. Immutables make your code clean and fun. So today I want to share a java video made about Immutables Fluent DSL in Action. So Let's get started. 

Having fun with the Jenkins DSL

Image
Jenkins it's a outstanding deployment tool. I love Jenkins, i use for a very long time.  I remember when was called Hudson.  There are several things that made Jenkins one for the most used solutions for deploys. Jenkins has a awesome community with more than 1k plugins . For this post i will cover a specific plugin called Jenkins Job DSL . This plugin gives you a Groovy DSL to code your Jobs, yes Code not XML. :-) This is good for lots of reasons. First of All in a DevOps context this allow you to automate the job creation which is tedious and manual. Moreover the DSL is great because it allow you to create a massive number of job, so in a microservices context lets say you have 50 microservices and all run in they own jetty and they code is on GitHub and build is done using maven. You can automate all that and create a JOB using the DSL this job will create the other jobs. Even if you have one job only for me it makes sense because you have it automated. We will ...

Groovy Power: Flexibilidade, Simplicidade e Código Legível

Image
Eu um post anterior comentei sobre a importância de se escrever um código mais fluente, ligível e auto-explicativo. Muitas vezes são com pequenas ações que podemos melhorar este aspecto sobre o código que escrevemos. Estas pequenas ações são caracterizadas com um bom disgn coeso e pouco acoplado, bons nomes de classes e métodos, variáveis com nomes significativos e código fluente e claro. Criar código fluente e claro pode ser especialemte desafiador. É facto que certas linguagens facilitam ou dificultam esta tarefa, Java não é a linguagem mais fluente do mundo mas existem alternativas. No post anterior eu ensinei a criar uma DSL com Java sem nenhum framework e com batsante fluencia. Neste post quero comentar sobre a linguagem dinamica Groovy que é a referência padrão de linguagens dinamicas para a JVM. Existem outras bem funcionais e interessantes como JRuby, BeanShell, Jython, Scala e tantas outras. Em especial hoje vou falar de Groovy, por que? Por que como desenvolvedor Java ...

A importância do Código Fluente em Java

Image
Não é de hoje que desenvolvemos software. Não é de hoje que temos cada vez mais facilidades para desenvolver mas ao mesmo tempo mais complexidade existe no software que produzimos. Ainda nos dias de hoje é comum achar código que não é fácil de entender. Java é a linguagem mais utilizada no mundo atualmente e é a que possui mais programas prontos rodando diariamente, mas este código Java é simples? Fácil de ler? Rápido de dar manutenção? O que ocorria antes na era do maiframe era que existia uma preucupação muito grande em "dizer" ao computador o que fazer então a grande preucupação era em fazer o computador entender o que você quer e as precupações da época eram mais com processador, gerência e otimnização de memória, etc... Mainframe De lá para cá as coisas mudaram. Na verdade sempre vamos ter mudanças, hoje em dia vejo que é muito importante você escrever um código fácil de ler, rápido de dar manutenção do que o código mais otimizado por que como já dizia o Donald...

De força ao Usuário com o Drools parte 3

Nos posts anteriores falei sobre o Drools e como ele poderia ser uma boa solução de BRMS. Agora vou mostrar outra forma de expor uma regra de negocio do seu sistema. A idéia agora é expor as regras com a linguagem do usuário. Isso possibilita que usuário com menor conhecimento de tecnologias consigam modificar o comportamento do sistema de uma maneira segura e eficiente. Recomendo que você leia os dois posts anteriores para uma melhor compreensão deste post: De força ao Usuário com o Drools parte 2 De força ao Usuário com o Drools parte 1 Utilizarei boa parte do código do exemplo anterior. A DSL pode ser internacionalizada para outros idiomas, isso seria útil se o seu sistema roda em diversos países e você tem pequenas variações nas regras de pais a pais. Mas o que é um DSL? D omain S pecific L uanguage são linguagens para domínios bem específicos. Você pode estar pensando que nunca usou isso ou nunca vai usar, se esse for seu caso você não esta ligando o nome a pessoa. E...