Thursday, April 15, 2021

Refactoring some code

Work on refactoring some javascript.

Before:


const MyFunction = function (key) {
                        if (key) {
                            switch (key) {
                                case "ABC":
                                    return "Info 1";
                                case "DEF":
                                    return "Info 2";
                                case "GHI":
                                    return "Info 3";
                                case "JKL":
                                    return "Info 4";
                                case "MNO":
                                    return "Info 5";
                            }
                        }
                        return "";
                    };

After


const MyFunction = function (key) {
                        const data = {
                                        "ABC": "Info 1",
                                        "DEF": "Info 2",
                                        "GHI": "Info 3",
                                        "JKL": "Info 4",
                                        "MNO": "Info 5"
                                     };
                        return data[key];
                    };

Sweet~!

Sunday, April 11, 2021

Still Using Java: Inventory Service

 Today we want to continue creating the Inventory Service with Quarkus. Here is a simple idea.








The item lifecycle (I made it up)












Still using Java: Authentication Service (Part 1)

Today we will be building an Authentication Service. Starts with a simple REST service. 


v1

Saturday, April 10, 2021

Still using Java: 1

Yes. The year is 2021, and I'm still using Java. Recently we have Quarkus came out and things got even more interesting. It is like Java on steroids. I'll leave the experts to tell you how good/bad/whatever Quarkus is. I just want to write a series of post showing how I write a simple web application using the framework.


The application will have a frontend interacting with services in the backend. Tentatively, that's the big picture.

The story is simple.
1. User login into the system.
2. User browse the products from the inventory.
3. User adds some item into the shopping cart.
4. User proceed with the payment process.
5. Transaction recorded.

I'll research, learn, and share the knowledge as I work on the application. You people can benefit from it. 

Stay tuned for the upcoming post.