Skip to content

Commit

Permalink
Merge pull request #93 from bartlomiej-gora/feature/84-tech-debt
Browse files Browse the repository at this point in the history
Feature/84 tech debt
  • Loading branch information
bartgora authored Jun 23, 2021
2 parents befdb0a + 6f70bf4 commit 50213b9
Show file tree
Hide file tree
Showing 29 changed files with 854 additions and 581 deletions.
55 changes: 47 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ It is based on Dijkstra Algorithm. (https://en.wikipedia.org/wiki/Reverse_Polish

[![javadoc](https://javadoc.io/badge2/com.github.bartlomiej-gora/RPNLibrary/javadoc.svg)](https://javadoc.io/doc/com.github.bartlomiej-gora/RPNLibrary)

Story
===
Couple years ago I read Joshua Bloch's "Java. Effective Programming".
I wanted to practice what I've learned.
I didn't want to create another CRUD like application, so I found that Dijkstra's algorithm would be good
to learn design patterns, and effective programming.
First version's were available on Sourceforge.
Couple years later I manage to publish my library on maven cetral repo.
Over the years I built a small ecosystem around this library.
Feel free to check my other projects that use this one.


Available functions:
===
+,-,*,/ with (), power(^)
Expand All @@ -26,27 +38,54 @@ example:
BigDecimal min = calc.calculate("min(10, 8) + 10");
```

To Customize use:
```java
static Calculator Calculator.Calculator createCalculator(RPNChecking checker, RPNExecuting executioner, final MathContext mathContext, final int scale);

}
```

Maven:
===
```
<dependency>
<groupId>com.github.bartlomiej-gora</groupId>
<artifactId>RPNLibrary</artifactId>
<version>4.0.0</version>
<version>5.0.0</version>
</dependency>
```


Changelog:
====

### Version 5.0.0:

- Moved to java 8
- Refactoring, split Calculator class into smaller pieces, using java 8 functional interfaces
- Added tests written in Kotest:

example:
```kotlin
class RPNFactoryTest : FreeSpec({

val tested = RPNFactory(RPNChecker(DefaultStrategyProvider()))
"should Return RPN" - {
val text = "( 2 + 3 ) * 5"
val result = tested.apply(text)
result shouldBe "2 3 + 5 *"
}
"should Return RPN for Function call" - {
val text = "sin ( 1 )"
val result = tested.apply(text)
result shouldBe "1 sin"
}
"should Return RPN for Function and equation" - {
val text = "sin ( 1 ) + 27 * 8"
val result = tested.apply(text)
result shouldBe "1 sin 27 8 * +"
}
"should Return RPN for two Functions call" - {
val text = "sin ( 1 ) + ctg ( 0 )"
val result = tested.apply(text)
result shouldBe "1 sin 0 ctg +"
}
})
```

### Version 4.0.0:

- Using big Decimal Math library (https://github.com/eobermuhlner/big-math)
Expand Down
81 changes: 66 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
<sonar.projectKey>bartlomiej-gora_RPNLibrary</sonar.projectKey>
<sonar.organization>bartlomiej-gora</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
<kotlin.version>1.4.30</kotlin.version>
</properties>
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.bartlomiej-gora</groupId>
<artifactId>RPNLibrary</artifactId>
<version>4.0.0</version>
<version>5.0.0</version>
<packaging>jar</packaging>

<distributionManagement>
Expand Down Expand Up @@ -93,7 +94,6 @@
<artifactId>sonar-jacoco-plugin</artifactId>
<version>2.3</version>
</plugin>

<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -141,14 +141,48 @@
</execution>
</executions>
</plugin>


<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
<source>src/test/kotlin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<includes>
<include>**/*Spec*</include>
<include>**/*Test*</include>
</includes>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>

</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
Expand All @@ -157,22 +191,39 @@
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<version>5.5.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.14.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.obermuhlner</groupId>
<artifactId>big-math</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>io.kotest</groupId>
<artifactId>kotest-core-jvm</artifactId>
<version>4.2.0.RC2</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>1.4.10</version>
</dependency>

</dependencies>

<reporting>
Expand Down
46 changes: 0 additions & 46 deletions src/main/java/com/github/bgora/rpnlibrary/CalculationEngine.java

This file was deleted.

Loading

0 comments on commit 50213b9

Please sign in to comment.