Skip to content

Commit

Permalink
Merge pull request #7 from stepanvalyavskiy/migration
Browse files Browse the repository at this point in the history
Migration
  • Loading branch information
stepanvalyavskiy committed Mar 19, 2024
2 parents bd81811 + 823bf23 commit ca804fc
Show file tree
Hide file tree
Showing 21 changed files with 537 additions and 215 deletions.
39 changes: 0 additions & 39 deletions .circleci/config.yml

This file was deleted.

22 changes: 22 additions & 0 deletions .github/workflows/github-actions-CI.yml
@@ -0,0 +1,22 @@
name: CI
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '17'

- name: Build plugin
run: ./gradlew build

- name: Run tests
run: ./gradlew test
54 changes: 44 additions & 10 deletions .gitignore
@@ -1,10 +1,44 @@
# Project exclude paths
/.gradle/
/build/
/build/classes/java/main/
# User-specific stuff
/.idea/
/out/
/gradlew.bat
/gradlew
/gradle/
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/
.run/

### IntelliJ IDEA ###
.idea/
.idea/modules.xml
.idea/jarRepositories.xml
.idea/compiler.xml
.idea/libraries/
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Mac OS ###
.DS_Store
99 changes: 21 additions & 78 deletions README.md
Expand Up @@ -3,15 +3,19 @@
[![EO principles respected here](https://www.elegantobjects.org/badge.svg)](https://www.elegantobjects.org)
[![We recommend IntelliJ IDEA](https://www.elegantobjects.org/intellij-idea.svg)](https://www.jetbrains.com/idea/)

[![Build Status](https://circleci.com/gh/stepanvalyavskiy/Decorate.me.svg?style=svg)](https://circleci.com/gh/stepanvalyavskiy/Decorate.me)
[![Build Status](https://github.com/stepanvalyavskiy/Decorate.me/actions/workflows/github-actions-CI.yml/badge.svg)](https://github.com/stepanvalyavskiy/Decorate.me/actions/workflows/github-actions-CI.yml)
[![Hits-of-Code](https://hitsofcode.com/github/stepanvalyavskiy/decorate.me)](https://hitsofcode.com/view/github/stepanvalyavskiy/decorate.me)
[![JetBrains IntelliJ Plugins](https://img.shields.io/badge/jetbrains%20plugins%20repository-v1.3-blue)](https://plugins.jetbrains.com/plugin/14706-decorate-me/versions/stable/118855)
[![JetBrains IntelliJ Plugins](https://img.shields.io/badge/jetbrains%20plugins%20repository-v1.3.1-blue)](https://plugins.jetbrains.com/plugin/14706-decorate-me/versions/stable/505905)

**Decorate.me** is an auto-completion Intellij IDEA
20.1+
[plugin](https://plugins.jetbrains.com/plugin/14706-elegant-ide)
suggesting you a list of all available [decorators](https://en.wikipedia.org/wiki/Decorator_pattern) for your Java object.
You have to watch this [two-minutes video](https://youtu.be/ZPHrfJN6f9Q) first!

[Short demo](https://youtu.be/ZPHrfJN6f9Q) <br>
[Second one (Ru)](https://youtu.be/HDH0OlSIoZQ)



Features:

Expand All @@ -34,78 +38,24 @@ Install manually:

## Motivation

I watched [the speech](https://youtu.be/75U9eefFYoU)
and was struck by the beauty of an elegant object-
oriented code in comparison with the procedural one.
One of the main ideas is that classes should not have many methods,
there should be many classes with a minimal set of methods.
The proposed approach involves using composed decorators
(instead of methods) to configure the Object.
[See more](https://www.elegantobjects.org/) about Elegant Objects approach.

The Maintainability of such design is undoubtedly several times higher.
However, code maintainability consists not only of its design,
but also of tools that allow you to quickly and conveniently work with it.
[Elegant Objects approach](https://www.elegantobjects.org/) proposes using composed decorators
instead of utility classes with a bunch of static methods.

Modern IDEs as IntelliJ IDEA have completions for methods.
Developers should only type a dot to get completions in a few milliseconds.
Completions list contains all methods with their arguments and return type.
What about composed decorators?
Will IDEA complete me, if I want to provide new functionality
by decorating my Objects, instead of adding new methods?
No, it isn't.

So an absolutely reasonable [question](https://youtu.be/75U9eefFYoU?t=2498) was asked.
Developers do not have to remember the names of methods, but can rather quickly find them using completions.
This gives the utility class based approach a great advantage.
But neither IDEA nor other IDEs won't complete you with decorators.
To use [EO approach](https://www.elegantobjects.org/) you will have to remember the names of all existing decorators for each type.

Here is `Decorate.me` Intellij IDEA plugin tha eliminates the tooling difference between using methods and decorators.
Just type a dot after an object, just like you would to call a method, then `Ctrl+Shift+Space`,
and you will get all existing decorators bounded by a type that can be inferred from the context.
Choose one and press `Enter`.

Loose translation:

> What simplifies maintainability here if IDEs have completions
with methods and their descriptions,
but if I use small classes, I should learn all existing decorators?

> Very good question. IDEs are to blame
for the convenience of working in a procedural programming style.
Probably after a while IDEs will make some new completions.

This guy is absolutely right. So we have to deal with it!
I still don't want to pack dozens of methods
in utility classes only because IDE gives me suggestions and completions.
On the other hand, Developers, including myself,
are so spoiled by good development environments(IDEs)
that they don’t want to give up such powerful features.
Sure, No one wants to manually search for methods that can be called.
Not to mention decorators, which, unlike methods,
can be scattered on the project in a more chaotic order.
However, there is no place for Tools-Driven Development.
Don't let the IDE decide how your code looks! RESIST!
I offer our weapon in the struggle for Elegant Objects.
With it, we can elegantly design classes and at the same time
use all the conveniences of modern tools.

If you still find the problem a bit abstract and are looking for a
more concrete example, that's [it](https://youtu.be/LPLqLaSwSsI?t=6739)(in Russian).

It's easy to find and choose method, which you need,
when they are packed in one utility class.
You only have to type dot, and you instantly see all methods.
Also, you can have a look at its documentation or definition in a same tab.
Isn't it beautiful? Sure It is!
But what does then our class looks like?
At least it's just huge, not to mention other issues.
It seems like a trade off - the uglier the class, the easier it is for us
to work with it in the development environment.
This is no longer the case.
Let's have a look at object-oriented Java framework [Cactoos](https://github.com/yegor256/cactoos).
Consider its interface [Text](https://github.com/yegor256/cactoos/blob/master/src/main/java/org/cactoos/Text.java).
It's only can be converted to string by contract.
There is the Text [package](https://github.com/yegor256/cactoos/tree/master/src/main/java/org/cactoos/text)
which contains all implementations of Text interface.
They all are quite small.
If you want to do some operation with your text,
you should use decorators instead of methods inside this class.
Here is `Decorate.me` Intellij IDEA plugin tha eliminates the tooling difference between using methods and decorators.
Just type dot after a constructor, then `Ctrl+Shift+Space`, and you will get all decorators suggestions.
Choose one and press enter. That's it!
[More detailed description of the problem](problem.md)

## How It Works

Expand Down Expand Up @@ -137,19 +87,12 @@ and call smart completion (Ctrl+Shift+Space)
You can contribute by forking the repo and sending a pull request. You will need these tools
to be installed locally:

1. JDK 11
2. Gradle 6.3+
1. JDK 17
2. Gradle 8.2
3. Lombok plugin
4. Enabled annotation proccessing

Before sending a pull request, make sure all tests passed, and you covered your changes with new ones.
Intellij IDEA instance required for plugin tests, so I can't add them to pipeline on circleci.

Therefore, you need to run them locally.
For that you need to declare an absolute path to your local IntelliJ IDEA in `build.gradle` and run `gradle test`.
See [JB docs](https://jetbrains.org/intellij/sdk/docs/tutorials/writing_tests_for_plugins/tests_prerequisites.html?search=test).

Then we will review your changes and apply them to the master branch.

### Tips

Expand Down
56 changes: 0 additions & 56 deletions build.gradle

This file was deleted.

65 changes: 65 additions & 0 deletions build.gradle.kts
@@ -0,0 +1,65 @@
plugins {
id("java")
id("org.jetbrains.kotlin.jvm") version "1.9.10"
id("org.jetbrains.intellij") version "1.16.0"
}

group = "clueqva"
version = "1.3.1"

repositories {
mavenCentral()
}

// Configure Gradle IntelliJ Plugin
// Read more: https://plugins.jetbrains.com/docs/intellij/tools-gradle-intellij-plugin.html
intellij {
version.set("2022.2.1")
type.set("IC") // Target IDE Platform

plugins.set(listOf("java"))
}

dependencies {
// version 0.10.2 results in an exception
implementation("org.reflections:reflections:0.9.12")
compileOnly("org.projectlombok:lombok:1.18.30")
annotationProcessor("org.projectlombok:lombok:1.18.30")

testCompileOnly ("org.projectlombok:lombok:1.18.30")
testAnnotationProcessor ("org.projectlombok:lombok:1.18.30")

}
tasks {
withType<JavaCompile> {
sourceCompatibility = "17"
targetCompatibility = "17"
}
withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
kotlinOptions.jvmTarget = "17"
}

patchPluginXml {
sinceBuild.set("221")
untilBuild.set("")
changeNotes.set("""
v1.3.1<br>
Dependency versions updated.<br>
v1.3<br>
Type checking improved.<br>
v1.2<br>
Completions are also shown after method calls, string literals and class references.<br>
v1.1<br>
Cactoos is now used as a plugin logo and as a completions icon.<br>""")
}

signPlugin {
certificateChain.set(System.getenv("CERTIFICATE_CHAIN"))
privateKey.set(System.getenv("PRIVATE_KEY"))
password.set(System.getenv("PRIVATE_KEY_PASSWORD"))
}

publishPlugin {
token.set(System.getenv("PUBLISH_TOKEN"))
}
}
6 changes: 6 additions & 0 deletions gradle.properties
@@ -0,0 +1,6 @@
# Opt-out flag for bundling Kotlin standard library -> https://jb.gg/intellij-platform-kotlin-stdlib
kotlin.stdlib.default.dependency=false
# Enable Gradle Configuration Cache -> https://docs.gradle.org/current/userguide/configuration_cache.html
org.gradle.configuration-cache=true
# Enable Gradle Build Cache -> https://docs.gradle.org/current/userguide/build_cache.html
org.gradle.caching=true
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

0 comments on commit ca804fc

Please sign in to comment.