Disclaimer: This guide is intended for RBA 15 Mid-2019 (RZ09–03017EM2).

Image for post
Image for post

Coming from a top-of-the-line 2016 MacBook Pro, I have grown sick of its keyboard and thermal issues. The new 16-inch MacBook Pro is a great improvement but the price tag is way too high for what it is and I need my new laptop to be able to handle AAA gaming and video editing apart from blockchain and cross-platform mobile development. Eventually I settled on a Mid-2019 Razer Blade Advanced 15 with an RTX 2070 Max-Q.

I need macOS to do most of my development and Windows for gaming, yet the Advanced model only has one M.2 NVMe slot. Here’s how I achieved a perfect laptop Hackintosh running Catalina 10.15.5 + OpenCore and dual-booting Windows 10 with only one 1TB NVMe drive. …


Image for post
Image for post
Source: Harvard University

Bill Gates and Mark Zuckerberg. You know who they are, what they did, and what they built. Why did they drop out of Harvard? After spending two years at USC and now a CS senior with one more year to go before receiving my Master’s degree, I very much approve of the act of dropping out. Here’s why.

Hint: It’s mainly the difference between the theoretical and the practical.

Expectations vs. Reality.


CSCI-104 was one of the first CS classes I took when I transferred to USC. I had a few problems with it. I still do.

CSCI-104 was taught in C++. It was your typical data structures class with an artificially inflated difficulty to both hammer down the basics of programming as well as weed out anyone that couldn’t take the pressure. I’m completely fine with the difficulty of this class but I’m not fine with its promises and grading.

Unresolved Promise

The name of the class, “CSCI-104: Data Structures and Object Oriented Design”, suggests we are also taught how to design programs by properly utilizing objects and inheritance, which is technically true but honestly a lie. We were taught how inheritance and polymorphism works but not how to apply inheritance and polymorphism. We weren’t being taught how to write good code and utilize those patterns toward good software design. This directly resulted in CSCI-201, the class after CSCI-104 and the class that I’m the Head CP of, to be an increasing disaster with students writing spaghetti, unmaintainable, and un-reusable code. …


In the beginning of 2020, I decided to start writing about programming on Medium. But after wrapping up the first chapter, I left. Partly because I have zero discipline, but also because once the reader has gone past the nitty-gritty basics, there is a myriad of excellent intro-level tutorials out there. There was no point to reinvent the wheel.

End of excuse.

But when the world needed him most, he vanished.

I am lucky.

A lot of things happened since I last wrote anything on Medium. The SARS-CoV-2 outbreak has caused a complete paradigm shift in the way we interact with each other. Life moved online entirely, saving me my commute but also wasting away the pricey parking pass I purchased in the beginning of the semester. Stories of not only the elderly dying, but also younger folks having strokes circulated wildly on the Internet and a shortage of medical masks have made it impossible for quite a lot of people to venture outside at all, even to shop for food. I am lucky enough to have a car, an abundance of masks, and free of the virus despite spending a significant amount of time in the cesspool of a study lounge that is codenamed SAL before the lockdown. …


Image for post
Image for post
Read about the differences here!

Congratulations!

If you’ve read and coded along every single article in the JAVA-2* series, then congratulations! We now have a fully functional simple calculator that is relatively bulletproof. Despite the seemingly trivially simple logic in our calculator, we have learned and applied many principles in practice:

  • Got started with Java and the powerful IntelliJ IDE
  • Understanding types and variables
  • Asking users for input
  • Making decisions based on conditions
  • Making comparisons
  • Performing calculations
  • Making sense of classes and objects in this Object-Oriented Programming language
  • Extracted repetitive logic into methods that we can reuse
  • Understood the concept of scope
  • A glimpse of recursion, albeit one of the most powerful logical paradigms in…

Last time we talked about prompting the user again if the user has entered a numerical choice that is out of range. However, as we had shown, our simple calculator still hard crashes if the user inputs anything other than a number. Let’s go about fixing that!

Amazon Prime Video and Chill :)

Bonjour madame, I know we’ve just met but let’s Amazon Prime Video and chill at my place tonight :). We can watch three middle-aged men having some chance of falling over and catching fire. You take a shot for every time they fall over and I take a shot for every time they catch fire. Qu’est-ce que tu penses? Oui? Super!


Enough talk about concepts, it’s time to get back to our calculator and give it a nice polish. Until now, we built our calculator largely with one assumption: the user won’t make a mistake and enter something they shouldn’t. It isn’t a fair assumption. Just because I personally never make mistakes doesn’t mean other people never make mistakes… Making false assumptions about others is not a good thing to do.

Recall the current behavior of our program when the user enters something they shouldn’t:

if (arithmeticChoice == 1) {
result = number1 + number2;
} else if (arithmeticChoice == 2) {
result = number1 - number2;
} else if (arithmeticChoice == 3) {
result = number1 * number2;
} else if (arithmeticChoice == 4) {
result = number1 / number2;
} else {
System.out.println("Invalid arithmetic choice! Aborting…");
System.exit(7); …

We use Scanner in Java to obtain user input. However, not realizing the hidden dangers of Scanner can lead to hours of frustration. Frustrate no more! Because now I will tell you all about it.

Don’t Close Scanner!

When we use Scanner and leave it open, our IDE may complain that we have a resource leak. Even if the IDE does not complain, usually it’s a good idea to close something if we don’t need it anymore. The intuition, then, is to simply close it… Right? Consider the following code snippet:

public class Main {

public static void getInput1() {
Scanner scanner = new Scanner(System.in);
scanner.nextLine(); // Ask for user input
scanner.close();
}

public static void getInput2() {
Scanner scanner = new Scanner(System.in);
scanner.nextLine(); // Ask for user input
scanner.close(); …

We just had a baby! Yes, you and I just had a baby! Let’s not get bogged down by who’s the father, who’s the mother, or how we conceived it in the first place as these are just minor details. One of the most important things when it comes to a human being is blood type. The blood type is determined at birth (or maybe when the embryo was developing, but let’s not get bogged down by this minor detail) and never changes throughout someone’s life.

Getters and Setters

If we want to turn all of the above into code, we can start by creating a Human class. We don’t want anyone to modify the person’s blood type, so we can make the blood type variable private. However, obviously we still want to read it. …


Hope the last article wasn’t too difficult! Congratulations if you’ve made it through as the concepts we talked about were some of the most important ones in programming. This time, we will pick up where we left off and explain what “public” means. Before that though, we should talk about the concept of inheritance.

Image for post
Image for post
3 types of inheritance supported in Java. Tutorialspoint

Inheritance

Inheritance is a way to avoid code repetition and specify parent-child relationships between classes. To have a better understanding, let’s take a look at some examples.

TVs

Recall the TV class we made a few articles ago. Let’s bring it back:

public class TV {
int year;
String make;
String model;
String resolution;
boolean HDR…

About

Jack Boyuan Xu

Making programming accessible to everyone, as it should be. Java, Blockchain, and iOS Teaching Assistant @ USC Viterbi School of Engineering.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store