Skip to content

valentinsoare/wordtally

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

87 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔤 WordTally - Build Your Own wc Tool Coding Challenge

https://codingchallenges.fyi/challenges/challenge-wc/

wordtally - Unix wc tool replica


▶️ A wc tool replica made in Java 17 to print a newline, word, char and byte counts for each input file and a total number of lines, words, bytes and chars if more than one FILE is specified. A word is a non-zero-length sequence of printable characters delimited by white space.

▶️ In case there is no file as input, the app will read from standard input. Since this is a linux/unix command, this standard input, which is created by another tool and redirected with pipe (|), will be read from the stdin file descriptor of the process id of wordtally (/proc/PID-number/fd/0).


final-Small.png

Concepts/technologies used:

  1. Object-Oriented Programming Principles;
  2. Collections Framework — Array, ArraysList and HashMap;
  3. Lambda functions, Streams and Method references along with serialization into a JSON;
  4. Design patterns from the GoF: Singleton and Builder along with Dependency Injection and Inversion of Control;
  5. Spring Boot with CommandLineRunner interface and Lombok, Jackson and Apache Commons CLI dependencies;
  6. GraalVM for conversion from .jar into a binary file;
  7. Logging and banner were disabled (spring.main.banner-mode=OFF, logging.level.root=WARN) on Spring Boot along with Tomcat Server (spring.main.web-application-type=NONE);
  8. Asynchronous with Concurrency processing implemented with CompletableStage/CompletableFuture API to handle multiple files as input much easier and faster;
  9. IO and NIO libraries for input/output processing;

Note

Challenge is 💯 completed!


👨‍💻 How To:

✅ In the target directory in this repo you can find everything you need to run the app, the .jar and binary file made with GraalVM.

Screenshot-from-2024-04-21-07-46-08.png


✅ Use it with short options and files as input.


✅ Use it with short/long options with files or standard input.


✅ What happens when proper input is not provided (wrong options, files, etc).

👉 If you want to see the code and make additions, you can clone this repo and try it. In case you want a binary file as a final product, then you need to install SDKMAN from sdkman.io and then with sdk GraalVM (22.3.r17-nik). Please know that for this project I'm using Java 17 Corretto from Amazon. Before you start to build the binary file with Maven, make sure that Runtime Environment is set to GraalVM as you can see bellow:

[root@republic]# java --version
openjdk 17.0.5 2022-10-18 LTS
OpenJDK Runtime Environment GraalVM 22.3.0 (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM GraalVM 22.3.0 (build 17.0.5+8-LTS, mixed mode, sharing)
[root@republic]#

▶️ Current UML diagram:

WordTallyUMLDiagram.png


valentinsoare - wordtally stars - wordtally forks - wordtally

GitHub release License issues - wordtally

License

Released under MIT by @valentinsoare.