ByteLegend Walkthrough Part III

Welcome to part 3 of this walkthrough!

We have conquered Method and Field in Java Island in the last part.

Now we are halfway to the end of Class and Object. Let’s go!

Java Island (Class and Object)

  1. (87 stars) NullPointerException Challenge 1. Hint: fix createNewCat(). Reading recommendation: https://stackoverflow.com/questions/218384/what-is-a-nullpointerexception-and-how-do-i-fix-it 
  2. (90 stars) NullPointerException Challenge 2. Hint: fix createNewCat().
  3. (93 stars) Reference and Value Challenge 1. Reading recommendation: https://www.geeksforgeeks.org/reference-variable-in-java/ 
  4. (96 stars) Reference and Value Challenge 2. Hint: check all three files to find the logic behind how values are passing via the references. 
  5. (99 stars) Reference and Value Challenge 3. Time to learn deep copy: https://www.tutorialspoint.com/what-is-deep-copy-explain-with-an-example-in-java 

Congratulations! You have finished Class and Object. Let’s keep exploring this island!

Java Island (Data Structure)

  1. (102 stars) Data Representation Challenge 1. Time to learn data types: https://www.w3schools.com/java/java_data_types.asp 

This is a sneaky question, don’t waste too much time on it. Answer: https://github.com/ByteLegendQuest/java-data-type-max-value/commit/4b2a64ab955a86b647a149cd2f3049129813029d 

  1. (105 stars) Data Representation Challenge 2. Time to learn type casting/conversion: https://www.w3schools.com/java/java_type_casting.asp https://www.geeksforgeeks.org/type-conversion-java-examples/ 
  2. (108 stars) Data Representation Challenge 3. To save you some time, try this precision: return Math.abs(a – b) <= 1e-10;

Reading Recommendations: https://www.baeldung.com/java-comparing-doubles https://www.geeksforgeeks.org/double-equals-method-in-java-with-examples/ 

  1. (111 stars) Type Conversion and Promotion Challenge 1. Hint: Revisit the readings in Data Representation Challenge 2. 
  2. (114 stars) Type Conversion and Promotion Challenge 2. There are many different ways, methods, or functions to complete this task. Here is mine for your reference: https://github.com/ByteLegendQuest/java-implement-type-casts/commit/623ab1975148b10bdc59d2b0338368bfe0130d77 
  3. (117 stars) Autoboxing and Unboxing Challenge 1. Hint: add some statement in compare(). Reading Recommendation: https://www.tutorialspoint.com/what-are-the-differences-between-an-integer-and-an-int-in-java 
  4. (120 stars) Autoboxing and Unboxing Challenge 2. Hint: Use Integer.parseInt(a) to change String a to integer; use String.valueOf(num) to change a number into String.
  5. (123 stars) Autoboxing and Unboxing Challenge 3. Hint and Reading Recommendation: https://www.baeldung.com/java-integer-parseint-vs-valueof 
  6. (126 stars) Java Array Challenge 1. Hint: Use array.length to check the length of the array.
  7. (129 stars) Java Array Challenge 2. Revisit the examples of parseInt and valueOf.
  8. (132 stars) Java Array Challenge 3. Hint and Reading Recommendations: https://www.geeksforgeeks.org/arrays-copyof-in-java-with-examples/ 

https://www.geeksforgeeks.org/system-arraycopy-in-java/

Congratulations! We have finished Data Structure!

This is the halfway point of this game. Java is not that hard, right?

To be continued…

ByteLegend Walkthrough Part II

Welcome to part 2 of this walkthrough!

For the past month, I was focusing on my capstone project and the rest 3 courses to graduate from my CS degree. Meanwhile, I explored some more tech about Flask in Python and database knowledge.

I am planning to finish this walkthrough in 6 parts, each part would cover about 40 stars. I will try my best to publish the remaining 4 parts before Christmas.

Thanks for your time and patience.

Java Island (Method and Field)

  1. (43 stars) Java Field Challenge 1. Create a Static Field. In this task, you are asking to create a static variable (public static String message = “Hello”;) in Challenge.java to understand what is a static field. For more details, I recommend you to read this: https://stackoverflow.com/questions/797964/what-is-the-exact-meaning-of-static-fields-in-java
  2. (46 stars) Java Field Challenge 2. Implement a SWAP function using static variables and then destroy the tower. Hint: create a temporary variable.
  3. (49 stars) Java Method Innovation. Learn the meaning of refactor, find the similarity and solve the puzzle, then destroy the tower. 

Recommended reading: https://refactoring.guru/refactoring

  1. (52 stars) Local Variable and Scope Challenge 1. Fix the compiling issue. Hint: like C++, declare the variable and then assign it a value. 

Answer: https://github.com/ByteLegendQuest/java-fix-local-variable-scope/commit/68ac8ca0626909c53fd8f7a90dd7b61c741291b6

  1. (55 stars) Local Variable and Scope Challenge 2. This is an easy but tricky task. Learn how to use constructor and “this” in a class. 

Answer Option 1: https://github.com/ByteLegendQuest/java-fix-local-variable-shadowing/commit/ec5f655d339670e58f03a828df6e1dbcd9126435 

Answer Option 2: https://github.com/ByteLegendQuest/java-fix-local-variable-shadowing/commit/dbb5b8309912e95476943b72dc5f0ad1304cfed9

  1. (56 stars) Now, go to Dungeon: Debugger. It is time to learn how to set a breakpoint to debug! Click on the “Debugger” Chest. Clone the project into your local IDE. Open Main.java, then click the space next to line number 29. It is the line to return the result variable. You should see a red dot like in the picture if you are also using IDEA.

Now debug this file by clicking on the bug button in the top bar or find it in the Run dropdown or simply press Ctrl + D and then find the result variable value in the right bottom window. Copy that string and submit it to earn a star. You should get a Chest key to earn 100 golds.

  1. (57 stars) Click on the “Conditional Breakpoint” Chest. Similarly, clone the project and open Main.java. This time, put a breakpoint at line 20. Then right click the red spot to add the condition. The rest of the steps are the same as the last task.
  2. (60 stars) Method Recursion Challenge 1. Go back to Java Island. It is time to practice some recursion algorithms. Have fun! 

Answer: https://github.com/ByteLegendQuest/java-fix-factorial/commit/4ac28744954f2539110edf79822946346ae035b1 

  1. (63 stars) Method Recursion Challenge 2. Fibonacci Question. 

Recommendation Reading: https://leetcode.com/problems/fibonacci-number/ 

Congratulations! You completed the Method and Field Section. Let’s move on!

Java Island (Class and Object)

  1. (66 stars) Class and Object Challenge 1. Learn what a class is in Java. 

Recommended Reading: https://www.w3schools.com/java/java_classes.asp 

  1. (69 stars) Class and Object Challenge 2. Learn what an object is in Java. Use the sword to destroy the tower.
  2. (72 stars) Instance Field. Hint: Check the Cat.java file in the pet folder.
  3. (75 stars) Instance Method. Hint: Use “this.name”.
  4. (78 stars) Instance Constructor Challenge 1. Time to learn constructor: https://www.w3schools.com/java/java_constructors.asp 
  5. (81 stars) Instance Constructor Challenge 2. Time to learn overloading constructor: https://www.geeksforgeeks.org/constructor-overloading-java/ 
  6. (84 stars) Instance Constructor Challenge 3. Hint: According to Home.java, you will need to design two overloading constructors in Cat.java.

To be continued…

Part III: https://blogs.oregonstate.edu/ligan/2022/11/23/bytelegend-walkthrough-part-iii/

PS: A typo found and reported to the development team:

Game Data Contributor: https://github.com/ByteLegendQuest/java-fix-local-variable-scope/tree/main?v=1669157188260#readme    English version contains CN chars

Transactions in Databases

I am in charge of the backend database part of our capstone project. Therefore, I am taking CS340, Introduction to Database, at OSU at the same time. In the design and implementation of our capstone project’s database, I start to understand the importance of database transaction.

When creating a database management system to store, retrieve, and run queries on data, we usually design the entity relationship diagram and the database schema based on the entities and attributes of the objects in a system. Then after the creation, a database transaction performs the unit level of update to this system to provide the data updates. For example, in an e-commerce system, users, products, and locations are entities; orders are the database transactions. Each order contains the information about which user requires what quantity of which products from which locations. Based on this order, the user will pay some amount of money; the store will receive such an amount of money; some amount of product A will be removed from location X; the exact amount of product A will then be delivered to the user’s address. A straightforward transaction record would ensure the database not to be interfered by multiple concurrent access and to cause some errors. Plus, even when an error did happen, the database could rollback based on the related transaction. Therefore, a set of properties of database transactions was concluded as Atomicity, Consistency, Isolation, and Durability.

Atomicity guarantees that each transaction is treated as a single “unit”, which either succeeds completely or fails completely.[1] This is similar to what happens when we fail to install something on our laptop. If an error occurred, no matter at the 1% or the 99% of the processing bar, every installation would be rolled back. This means a single transaction only runs in a whole. If the transaction contains actions related to multiple entities, every action will be consistently done; one action’s failure means the whole transaction never happened. 

Because of the transaction’s atomicity, the database will have the property of consistency. This is saying that after the creation of a database with only entities and attributes and without any data, i.e. this is an empty database, the database has been ensured to be integrated as a whole database. Then, both before and after a transaction was updated, the database will remain the integration, which means the wholeness of the database would be invariant. This property prevents illegal transactions.

Transaction isolation determines how transaction integrity is visible to other users and systems.[2] It guarantees the database management system to be able to handle concurrency controls by setting different isolation levels. The precedence of isolation levels is a big topic to study. I will leave this topic for now. Lastly, a database needs to be durable, which means two things. First, after each transaction is processed, the update to the data in this database is permanent. Second, this update will be recorded by the database management system and shouldn’t be lost under any circumstances.

In general, the study of transactions and the set of properties allow us to remember the importance behind database design. Personally, I would highly recommend everybody to revisit these concepts before starting a system design.

References

  1. https://en.wikipedia.org/wiki/ACID
  2. https://en.wikipedia.org/wiki/Isolation_(database_systems)

ByteLegend Walkthrough Part I

During the past whole year, I was learning CS courses at OSU. However, I have never touched Java before. Therefore, I decide to learn Java and I am using https://bytelegend.com/ to do so.

ByteLegend is an open source software project on GitHub: github link. It is a free HTML5 MMORPG game where players can learn real world programming knowledges and skills in Java. I found it half a year ago, saved the website link as a bookmark, and was hoping to play it someday to self learn Java.

While learning a new programming language through it, I am also trying to contribute to this OSS project as a game data contributor so that I could improve my skills in using Git.

Also, for some starters like myself, I decide to generalize a RPG game walkthrough in this blog.

There are 255 stars to be earned to get all the achievements. I will try my best to finish all of them by Christmas.

Walkthrough of ByteLedend

Java Island (Newbie Village and Foo Bar)

  1. Sign up with Github account
  2. Turn on/off music and choose your preferred language on the right up corner
  3. On the left up corner, you can see your mouse coordinator
  4. Click the book to see tutorials
  5. (1 star) First star: Star the project: https://github.com/ByteLegend/ByteLegend
  6. Enter the Foo Bar by clicking on the door
  7. (2 stars) Second star: install JDK on your laptop, then put “java -version” in your terminal shell, copy paste the output into the input box.
  8. Talk to the old man at the village gate and hand him the java/coffee.
  9. (5 stars) Click on the Request board to learn about GitHub Pull Request. Your action would be recorded in https://github.com/ByteLegendQuest/remember-brave-people. By completion of this task, you will earn 3 stars. Now you should have 5 stars.
  10. (6 stars) Install an IDE, I personally recommend IntelliJ IDEA Community Edition: https://www.jetbrains.com/idea/download/. Then copy the “about” content into the input box. This will award you one star and one key to open the chest for 100 coins
  11. If you go up, the soldier will ask you to wear a Git Amulet to pass. Therefore, you have to go to the star face NPC, pay 50 coins to go to Git Island.

Git Island

  1. (7 stars) Welcome to Git Island! Click on the chest and install Git. Type “git -v” to find your git version and copy paste that output into the input box to earn your seventh star and a chest key.
  2. Use the chest key to open the chest. Now you have got the Git Amulet.
  3. You shall not pass for now. So go back to Java Island. Yes, you have to pay the star face 50 coins again.

Java Island (Java Basic Structure)

  1. Click on the gate to learn how to clone and run a Java program.
  2. Open your shell. Create a new folder, name it whatever you want. I named it ByteLegend. In your shell cd to this folder.
  3. Type “git clone https://github.com/ByteLegendQuest/java-clone-switch-branch” to clone the project in the new folder.
  4. Open the pom.xml with your IDE, choose “Open as Project”, and then choose “trust the project”.
  5. Find the Main.java file under src/main/java/com/bytelegend.
  6. (8 stars) Click the run button next to line 7. You will see Base64 Encoding String in your window. Copy and paste that string into the input box to earn your eighth star and a door key for the gate.
  7. Click on the second gate to learn how to switch branch and run with a different JDK.
  8. In your IDEA, click the “main” at the right bottom corner and then choose origin/jdk17, and then click on “Checkout”. Wait for the project to sync and now you are in brank jdk17.
  9. (9 stars) Click the run button next to line 7. You will see another Base64 Encoding String in your window. Copy and paste that string into the input box to earn your ninth star and a door key for the second gate.
  10. (10 stars) Click on the bug to start this challenge. Open the “this simple Java program”, change the sign and then click on “Submit Answer” and then wait for a while to earn your tenth star and a knife to kill the bug. For beginners, I highly recommend you to follow the suggestions to practice this on your local IDE but it is not required. 
  11. (13 stars) For the following three challenges, you can do them in either sequence you want. This is for “Create a New Class”: In the online editor, open the Cat.java file and create a public class called Cat. Notice: if there is a style issue, like no new line at the end, you will only get 2 stars. Cheat: https://github.com/ByteLegendQuest/java-create-a-new-class/pull/767/commits/e38ea2849388b40a63e91c1c71bc83d6945698d2
  12. (16 stars) This is for “Import Class” Challenge 1: In the online editor, open the Home.java and add the import statements. Tip: be careful of typos. Cheat: https://github.com/ByteLegendQuest/java-import-class/commit/89130d7a169b0b7e0ac6c15581bc36e9803eec59
  13. (19 stars) This is for “Import Class” Challenge 2: Modify the code in Home.java. Cheat: https://github.com/ByteLegendQuest/java-import-class-with-same-name/commit/675584fee9e696763b28cd9abfdfa704c6d28f97
  14. (22 stars) This is for “Import Class from 3rd Party Package”. This is a hard challenge, it is OK you do not understand it for now, please check here for the answer: https://github.com/ByteLegendQuest/java-import-3rd-party-class/commit/9683c56df10bb992289fff9d29b20c65770d234f
  15. Now you should have three Gold Swords, use them to destroy the three towers to eliminate the alien.
  16. (Side Quest) Enter Dungeon: Comment & Javadoc.
  17. (25 stars) Comment. Change the comment from single line comments into multi-lines comments and multi-lines comments into single line comments. Open the chest for 100 coins.
  18. (28 stars) JavaDoc Challenge 1. Learn JavaDoc style, open the ChallengeEn.java doc, and edit the author part. This is an easy but IMPORTANT challenge to accomplish. 
  19. (31 stars) JavaDoc Challenge 2. Correct this JavaDoc. There is an obvious error. However, this is not a good challenge, for the other errors which are meant to be tricky. Please check the answer: https://github.com/ByteLegendQuest/java-fix-broken-javadoc/commit/f81b8d9df1ad1e75385c329b8c643d2648afe38a
  20. With the chest key, get another 100 coins.
  21. (34 stars) Java Methods Challenge 1. Learn what is a public static void method.
  22. (37 stars) Java Methods Challenge 2. Learn about data types.
  23. Destroy the defense tower with the gold sword.
  24. (38 stars) Method Overload. This is a challenging and rewarding challenge. Tip: do not make your method private like it should be. Cheat: https://github.com/ByteLegendQuest/java-write-overloading-methods/commit/bcc017593330abc779560ed90655f8986c19c0c8
  25. (40 stars) My personal beautiful solution above will only give you one star. To get three stars, pay attention to the coding style, you need this solution: https://github.com/ByteLegendQuest/java-write-overloading-methods/commit/64c1ef9a29bc21c783525706a21be66748c6cee2

To be continued…

Part II: https://blogs.oregonstate.edu/ligan/2022/11/23/walkthrough-of-bytelegend-part-ii/

Amazon Web Services

In 2022 summer, I did my intern backend prototype project to create personalized functionality for a huge customers database.

The project requires me to parse million to billion level of data and I learned a lot about Amazon Web Services. Therefore, I am planning to introduce you my experience with AWS tools.

From my perspectives, AWS is one of the best cloud platforms offering all kinds of featured cloud services. This cloud service offers features in analytics, application integration, database, developing tools, networking, security, storage, etc. In general, It offers everything.

Even though I believe AWS is the best cloud service, it is not easy to learn and use it. However, the high learning cost is a common issue for all cloud services. Amazon showed some level of effort in the reference doc. But we still need to google our questions and find most of it on stackoverflow.com.

On the other hand, AWS do offer a free tier account. You can create an account at https://aws.amazon.com/free/ with an email and a credit card (without charge). Most of the services are offered either 12 months free or always free. Some new and fancy services are offered a free trial.

I built a prototype workflow using AWS Step Function, Athena(MySQL), Lambda, and Simple Storage Service(S3 Buckets). I was impressed by AWS Athena because it handles 10 million lines of data in 4 seconds.

Some famous applications or services built with AWS are Netflix, Twitch, LinkedIn, Facebook, etc. Also, we should all remember in the final week of Spring 2022, Canvas was down for couple hours, that was because there were some issues with the AWS data center in east America. Generally, with AWS, we could build all kinds of services that is related to the Internet and it is free and easy to create an AWS account to start learning cloud services.

Welcome to my Capstone Project Blog!

This is Gan Li. This quarter, 2022 fall, is my last quarter at OSU as an online post-bacc CS student. 

  • What got you started with computers or software?

My first bachelor’s degree is from UCLA math department. I was doing Mathematics Olympiad Competition when I was in high school and I was one of the top students in my home province. But studying from Professor Terrance Tao and professor Ciprian Manolescu made me realize that I could never be like them genius. Therefore, I quit studying pure Math and became a Mechanics for U.S. Army. After honorable discharged, I moved to Seattle for my girlfriend, now she is my wife. As you can imagine, my friends in Seattle area gave me great peer pressure, so after couple years of struggling, I decided to change my career to software development.

  • Current job or internship

Just finished a summer internship and got a return offer. I have to say, it is not as easy as the past to get interviews. So I have to admit that I am somehow relieved.

  • Your future career

SDE then SDE II, then Tech Project Manager maybe?

  • Current interests

Exercise to lose some body weights.

  • Journey with OSU

I started 2021 fall. This is my 4th quarter and I am gonna graduate! Although it is a short journey, I am very thankful that OSU post-bacc program opened my mind and provided me the opportunity to start my career in software development industry.

  • Kids, pets, hobbies, sports, games, activities, etc

Me and my wife have a cat, a dog, and a chinchilla. We are 70% indoor and 30% outdoor person. I have hundreds of games on Steam. I also play a lot of Nintendo games. Speaking of sports, I am running for recent couple months. I occasionally go to the range to shoot some bullets, or go to do some indoor rock climbing. I am planning to start archery as my next new sport. 

Here are some pictures of my lovable pets:

I am still thinking about the content of blog posts in the future. Maybe a journey about me reading a coding book, or maybe about me contributing to a open source software, or maybe some other stories.

Please feel free to leave a comment and let me know what you wanna know more about me.

Finally, feel free to keep in touch: Gan’s LinkedIn

Let’s all have a great 2022!