Skip to content

podcast

Java: Variables are Always Passed by Copy

I am learning Java. One important concept to understand is whether function arguments are passed by copy or by reference.

Welcome to "Continuous Improvement," the podcast where we explore valuable concepts and strategies to help you enhance your skills and knowledge. I'm your host, Victor, and today we'll be diving into the intriguing world of function arguments in Java. Specifically, we'll explore the question of whether these arguments are passed by copy or reference. But before we get started, don't forget to hit that subscribe button so you never miss an episode. Now, let's jump right in.

So, one of the important things to understand when learning Java is how function arguments are handled. Are they simply a copy of the original variable or a reference to the actual variable? Well, in Java, variables are always passed by copy, and that's what we're here to discuss.

[Background Information]

Let's explore three different scenarios to demonstrate how function arguments behave in different contexts.

[Case 1: Passing Primitives]

First, let's consider passing primitives. In Java, when we pass a primitive variable to a function, a copy of that value is made. The original variable remains unaffected. Let me walk you through an example.

[Code Explanation]

We have a method called incrementValue that takes an integer argument. Inside the method, we increment this argument by one. Let's see what happens when we pass the original variable with a value of 10.

[Code Execution and Output Explanation]

As you can see from our execution, the original value remains unaffected. It remains at 10, even though we incremented the value inside the function. This is because the function received a copy of the variable, not the original variable itself.

[Transition]

Now, let's move on to our next scenario.

[Case 2: Passing Primitives Wrapped in Objects]

In this case, we'll consider passing primitives that are wrapped inside objects, like arrays. Unlike passing just primitives, passing primitives wrapped in objects involves passing a reference to the object. Let me explain further.

[Code Explanation]

We have a method called incrementValue that takes an integer array as an argument. Inside the method, we increment the value at the first index of the array by one. Let's see what happens when we pass the arOriginal array with a value of {10, 20, 30}.

[Code Execution and Output Explanation]

As you can observe, the original value did change this time! This is because the array is a complex object, and when we passed it as an argument, we actually passed a reference to the original object. Both references, the one inside the function and the one outside, pointed to the same memory location.

[Transition]

Lastly, let's discuss the behavior when passing Strings.

[Case 3: Passing Strings]

We all know that Strings in Java are immutable. So what happens when we pass a String as an argument to a function? Let's find out.

[Code Explanation]

We have a method called changeString that takes a String as an argument and assigns it a new value. Let's see what happens when we pass the original String with a value of "Original!"

[Code Execution and Output Explanation]

As you can see, even though we assigned a new value to the inFunction argument inside the method, the original String remained unaltered. This is because Strings in Java are immutable, and when passed as arguments, a new String object is created, leaving the original String unchanged.

[Closing Segment]

And there you have it! A closer look at function arguments in Java, where we've explored whether they are passed by copy or by reference. Remember, in Java, variables are always passed by copy, regardless of whether they are primitives or wrapped inside objects. It's important to understand these concepts to avoid any unexpected behavior in your code.

[Final Thoughts]

Thank you for tuning in to this episode of "Continuous Improvement." I hope you found this discussion on function arguments in Java useful for your programming journey. If you have any questions or would like us to cover specific topics in future episodes, feel free to reach out to us. Until next time, keep coding and continuously improving!

3 Reasons to Love React

Welcome back to another episode of Continuous Improvement! I'm your host, Victor, and today we have an exciting topic to discuss - React, a JavaScript library for creating user interfaces. I recently attended a meetup in Hong Kong where I heard a fantastic talk about React, and I want to share my insights with all of you.

But before we dive in, I would like to remind you to check out the blog post that inspired today's episode. You can find the link to it in the show notes. Make sure to give it a read for a more detailed understanding of React.

Now, let's get started. React serves as the 'view' in the MVC (Model-View-Controller) architecture. Developed by Facebook and Instagram, it's widely used in their production environments, including popular platforms like Facebook.com. So you know it's reliable and robust.

One of the primary reasons why React stands out is its use of components instead of traditional templates. As a former MeteorJS developer, I found templates limiting. But with React, you can build modular, reusable, and testable components that give you more flexibility in your UI development.

Another significant advantage of React is its performance. Thanks to the Virtual DOM, React offers impressive speed. Unlike traditional approaches where even small changes require the entire page to re-render, the Virtual DOM optimizes this process by updating only the parts of the DOM that have actually changed. This results in faster rendering and a smoother user experience.

Now, let's talk about managing dynamic data. UI development can be challenging, especially when it comes to state management. React solves this problem by adopting a one-way data flow. This means that data flows in a single direction, making it easier to track and manage. It improves maintainability and simplifies debugging, which is a game-changer when working on complex UIs.

In summary, React offers simplicity and power when it comes to building user interfaces. It allows you to create reusable, testable components, ensuring code reusability and reducing development time. Its impressive performance, thanks to the Virtual DOM, keeps your UI running smoothly. And the one-way data flow simplifies state management, making your code more maintainable and debugging easier.

That's all for today's episode of Continuous Improvement. I hope you found this discussion on React enlightening. If you have any questions or want to dive deeper into this topic, feel free to reach out to me on social media or leave a comment on the blog post.

Thanks for tuning in, and until next time, keep improving!

[End of episode]

Common npm Permission Issues

The Problem:

Welcome to "Continuous Improvement," the podcast where we discuss practical solutions to everyday tech challenges. I'm your host, Victor, and in today's episode, we'll be tackling a common issue that Mac users face when trying to install npm modules globally.

Have you ever encountered the dreaded error message: "Please try running this command again as root/Administrator" when attempting to install an npm module? You're not alone! In fact, many Mac users who have installed Node.js through the official website have come across this frustrating roadblock.

But fear not, my friends, for I have found a solution that doesn't involve using the sudo command. Today, I'll walk you through the steps to resolve this issue once and for all.

The first thing you need to do is avoid the temptation to rely on that sudo command. Although it may seem like a quick fix, using sudo to install packages can lead to bigger problems down the road. So, let's explore a more sustainable approach.

Step one is to determine your username. To do this, open your terminal and type the following command:

whoami

Once you have your username, which should be displayed in the terminal, we can move on to step two: changing the ownership of the node modules folder. This step is crucial to ensuring a smooth installation process without the need for elevated privileges.

To change the ownership, enter the following command:

sudo chown -R `whoami` /usr/local/lib/node_modules

Now, that might sound like a mouthful, but let me break it down for you. The chown command changes the ownership of a file or directory. By using the backtick operator followed by whoami within the command, we dynamically retrieve our username. Lastly, we specify the directory where Node.js stores its modules by default.

And there you have it! Once you've completed these two steps, you'll no longer need to use sudo when installing npm packages. Enjoy a smoother installation process without the hassle of elevated privileges.

That's all for today's episode of "Continuous Improvement." I hope you found this solution helpful in overcoming the npm module installation error. Don't forget to check out our website for more tips and tricks to enhance your tech journey.

Thank you for tuning in, and remember, continuous learning and improvement are the keys to success. Join us next time on "Continuous Improvement" as we dive into more exciting topics. Until then, happy coding!

Sublime Text 3: Using the OS X Command Line

The Problem

Welcome to "Continuous Improvement," the podcast where we explore ways to enhance our workflow and optimize our productivity. I'm your host, Victor, and in today's episode, we'll be discussing a solution to a common problem faced by Sublime Text 3 users on OS X Yosemite.

Let's dive right into it. Many Sublime Text users encounter issues with the command line tool called subl, which refuses to work after the initial installation on OS X Yosemite. This can be frustrating, especially when you rely on Sublime Text for your coding or editing needs.

Fortunately, I have a solution for you. After installing Sublime Text 3, you can create a symbolic link to resolve this issue. Here's how you can do it. Open up your terminal and enter the following command:

ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/subl

Let me break it down for you. The first path, /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl, represents the location where Sublime Text is stored in your Applications directory. The second path, /usr/local/bin, is where you want the symbolic link to reside. Once you've created this link, the command line tool subl should start working seamlessly.

But that's not all. If you want to set Sublime Text as your default editor for various commands that prompt for input, follow this next step. Configure your EDITOR environment variable by entering the following command:

export EDITOR='subl -w'

The -w flag ensures that the subl command does not exit until you've closed the file. This is handy when you're working on longer tasks or editing multiple files at once.

Lastly, if you're using Git and prefer Sublime Text as your default editor for commit messages and other Git-related activities, here's what you need to do. Use this command:

git config --global core.editor "subl -n -w"

This command sets Sublime Text as your default Git editor. The -n flag opens each file in a new window, ensuring a clutter-free editing experience. The -w flag, as we discussed before, ensures that the command doesn't exit until you're done editing.

And there you have it! A simple solution to get Sublime Text 3 up and running smoothly on OS X Yosemite. Don't let technical hurdles slow you down when you're striving for continuous improvement and peak efficiency.

That's all for today's episode of "Continuous Improvement." I hope you found this information helpful for optimizing your workflow with Sublime Text 3. Be sure to tune in next time for more tips and tricks to enhance your productivity. Until then, I'm Victor, signing off.

12 Things You Need To Know About ECMAScript 6

ECMAScript 6 is the next version of the JavaScript standard.\

Welcome to another episode of Continuous Improvement. I'm your host, Victor, and today we're going to dive into the exciting world of ECMAScript 6, the next version of the JavaScript standard. I'm going to share with you 12 cool things you need to know about ES6. So, let's get started!

First up, we have arrow functions. Similar to CoffeeScript, ES6 allows you to define a function using the fat arrow syntax. For example, you can write var square = (n) => n * n; to define a function that squares a number.

Moving on, we have arrow scope. In JavaScript, the keyword 'this' can sometimes be confusing as it refers to whatever invokes it. However, ES6 introduces arrow function expressions, which binds 'this' to the function itself. This resolves the issue and provides a clearer understanding of the context in which 'this' is used.

Now, let's talk about string templates. ES6 includes a string interpolation feature using the ${} syntax for variables. This means you can construct strings in a more concise and readable way. For example, with ES6, you can write var hello =My name is ${person.name} and I am ${person.age} years old; to build a string with dynamic values.

Next, we have let scope. The let statement in ES6 declares a block-scope local variable. This means that it doesn't override the value of the variable in the outer scope, giving you more control over variable scope and avoiding potential bugs.

Moving on, we come to destructuring arrays. Instead of declaring multiple variables one by one, ES6 allows you to assign them in one line using array destructuring. This is especially useful when working with arrays that contain multiple values.

Similarly, you can also use destructuring for objects. With ES6, you can easily extract values from an object and assign them to variables using object destructuring syntax.

Object literals are another cool feature of ES6. Instead of writing out key-value pairs explicitly, you can use shorthand notation to construct an object. This makes the code shorter and more readable.

ES6 also introduces default arguments. When defining a function, you can assign default values to arguments. This way, if an argument is not provided when the function is called, it will use the default value instead.

Next up, we have the spread operator. This operator, denoted by the three-dots (...), allows you to pass each element of an array as an argument to a function. It simplifies the process of passing array elements individually.

Classes are a fantastic addition to ES6. Similar to other object-oriented programming languages, ES6 allows you to define a blueprint for constructing objects using the new class syntax. This provides a more structured and organized way to create objects with consistent behavior.

With class inheritance in ES6, you can now extend a class by using the 'extends' keyword. This allows you to create specialized classes that inherit properties and methods from a parent class, giving you the power to build complex object hierarchies.

Last but not least, we have generators. Generators are functions that can be exited and later re-entered. Calling a generator function does not immediately execute its body. Instead, when the iterator's next() method is called, the generator function's body is executed up to the first yield expression. This provides a powerful mechanism for controlling the flow of execution and creating efficient asynchronous code.

And there you have it, folks! These were the 12 cool things you need to know about ECMAScript 6. This new version of the JavaScript standard brings a lot of exciting features and enhancements that will make your code more robust, readable, and maintainable.

Thank you for tuning in to this episode of Continuous Improvement. I hope you found this exploration of ES6 enlightening and inspiring. If you want to learn more about ES6, head over to the MDN website at [MDN link]. Stay tuned for more episodes where we'll continue to explore ways to improve our skills as developers. Until then, keep coding and keep improving!

My Review of Hack Reactor Remote Beta

I enrolled in the Hack Reactor Remote Beta as part of the second cohort in Hong Kong to improve my technical skills in JavaScript.

Welcome to "Continuous Improvement," the podcast dedicated to personal and professional growth through continuous learning. I'm your host, Victor, and in today's episode, we're going to be discussing a blog post titled "My Experience with Hack Reactor Remote Beta."

Today, we'll be diving into the first-hand experience of the author as they share their journey into improving their technical skills in JavaScript. They enrolled in the Hack Reactor Remote Beta program, which provided a well-structured curriculum and a variety of learning opportunities.

The author begins by mentioning how they learned about recursion, closures, and data structures, which laid a strong foundation for their programming knowledge. It's essential to have a solid grasp of the fundamentals before diving into more advanced topics.

Moving on, the author highlights the value they derived from learning various JavaScript frameworks such as BackboneJS, AngularJS, and NodeJS. They emphasize that these frameworks were taught by expert instructors, lending credibility to the program's quality of education.

To reinforce their learning, the author explains that they worked on multiple projects throughout the program. These projects allowed them to gain hands-on experience with new tools like ThreeJS and ReactJS. They specifically mention their thesis project, where they built a machine-learning server to recommend beers. It's inspiring to see how the program encouraged practical application of their new skills.

The author also highlights the collaborative nature of the program. They mention how they worked closely with other remote students, utilizing tools like Floobits for pair programming and Google Hangouts for daily stand-up meetings. The constant support and interaction with peers made the learning experience highly rewarding.

The instructors and staff members also receive praise from the author. They mention how the instructors were highly adept at teaching, making complex topics easily understandable, even for those who were not computer science majors. The instructors' commitment to providing a high-quality remote course is commendable.

In conclusion, the author highly recommends the Hack Reactor Remote Beta program to anyone interested in coding. They describe it as a five-star learning experience, showcasing the immense value gained from the program.

And that brings us to the end of this episode of "Continuous Improvement." I hope you enjoyed learning about the author's experience with the Hack Reactor Remote Beta program. If you're interested in improving your technical skills, be sure to check it out.

Remember, continuous learning is the key to personal and professional growth. Join me in the next episode as we explore more inspiring stories and strategies for continuous improvement.

Thank you for tuning in to "Continuous Improvement." I'm Victor, your host, signing off. Stay curious and keep growing!

Beer Recommendation Engine Using PredictionIO

The Problem:

Welcome to "Continuous Improvement," the podcast where we explore innovative solutions to everyday problems. I'm your host, Victor, and today we're diving into the world of beer and how technology is helping us make better choices.

Imagine this: you walk into a bar or a liquor store, excited to try something new and delicious. But suddenly, you find yourself overwhelmed by the countless options staring back at you. What should you drink next? Well, fear not, because today we have a solution to that beer dilemma.

In a recent blog post titled "The Problem and My Solution," we discovered that a Hack Reactor graduate took matters into their own hands and built a machine-learning server called OnTapp. This revolutionary app uses cutting-edge technology to recommend beers that match your taste preferences.

The app's creator implemented two main strategies: the content filtering approach and the collaborative filtering approach. Let's take a closer look at how each of these strategies works.

The content filtering approach uses various characteristics of each beer to identify its nature. It takes into account factors like the beer's style, alcohol by volume (ABV), and International Bittering Units (IBU). By analyzing these attributes, the app queries a database to find beers with similar qualities. Pretty cool, right?

Now, let's move on to the collaborative filtering approach. This method relies solely on past user behavior, specifically their beer ratings. By using matrix factorization techniques and the Alternating Least Squares (ALS) algorithm, OnTapp can create profiles of both beers and users. These profiles are then compared for similarities, resulting in personalized beer recommendations.

What's interesting about this approach is its ability to incorporate additional information. When explicit feedback, such as ratings, is not available, implicit feedback can be used. That means your browsing history and search patterns can also help determine your preferences. It's like having a virtual beer sommelier!

The OnTapp app is making waves in the beer community, providing beer lovers like us with a convenient way to navigate the ever-expanding beer landscape. No more aimless wandering through shelves or scrolling endlessly through beer menus. With OnTapp, you can get tailored recommendations and explore new flavors with confidence.

If you're curious to try out OnTapp and get personalized beer recommendations, head over to http://ontappapp.com/.

That's all for today's episode of "Continuous Improvement." I hope you've enjoyed diving into the world of beer and technology. Remember, there's always a solution to our everyday problems, and in this case, it's OnTapp. Join me next time as we explore another exciting innovation. Until then, cheers!

AngularUI: Handling Mouseover Events for Google Maps Markers

The Problem:

Welcome back to another episode of Continuous Improvement, the podcast where we explore strategies and techniques to continuously improve our skills and overcome challenges. I'm your host, Victor, and in today's episode, we'll be discussing a common problem that many developers face when working with Google Maps in AngularUI.

So, imagine you're working on a project that involves displaying multiple markers on a Google Map. You want to add mouseover events to these markers, but you realize that the AngularUI documentation is a bit vague on how to achieve this. This confusion led me to dive deeper into the problem and find a solution, which I'll be sharing with you today.

The initial approach specified in the documentation is straightforward for a single marker. You simply need to add the events property to the ui-gmap-marker directive in your HTML, like this:

<ui-gmap-marker events="marker.events"></ui-gmap-marker>

Then, in your controller, you can define the marker object with the desired event callbacks, such as mouseover. It looks something like this:

$scope.marker = {
  events: {
    mouseover: function (marker, eventName, args) {
      // Callback code here
    }
  }
};

This works perfectly fine if you only have a single marker. But what if you have multiple markers and you want to attach mouseover events to all of them? That's where the confusion kicks in.

After some trial and error, I discovered a workaround that allows you to add mouseover events to multiple markers on the Google Map using AngularUI. Here's what you need to do:

First, in your HTML, within the markers directive, add the following attribute:

events="clickEventsObject"

This attribute serves as a reference to an object that contains the event callbacks for your markers. Let's call it clickEventsObject for now.

Moving on to the controller, you need to define the clickEventsObject and specify your event callbacks. For example:

$scope.clickEventsObject = {
  mouseover: markerMouseOver,
  mouseout: markerMouseOut
};

function markerMouseOver(marker, e) {
  // Callback code here
}

function markerMouseOut(marker, e) {
  // Callback code here
}

By binding the events attribute in the HTML to the clickEventsObject, you can now attach the desired event callbacks to each marker.

And voila! You can now enjoy the benefits of mouseover events on multiple markers in Google Maps using AngularUI. It's a simple yet effective solution that gives you the flexibility you need.

And that concludes today's episode of Continuous Improvement. I hope this solution helps you in your own projects and saves you some confusion and frustration. As always, if you have any questions or suggestions for future episodes, feel free to reach out to me at victorleungtw@gmail.com.

Thank you for tuning in, and don't forget to keep improving every day. Until next time!

Hacking New Year's Resolutions for 2015

As the year draws to a close and a new one begins on January 1st, many people set New Year's resolutions. However, 92% of New Year's resolutions ultimately fail. Why is that? Welcome back, listeners, to another episode of Continuous Improvement. I'm your host, Victor, and today we're diving into a topic that has captivated my curiosity - New Year's resolutions. We all strive to better ourselves, but why do so many of our resolutions fail?

Studies have shown that only 8% of New Year's resolutions actually succeed. That's a staggering number. So, I embarked on a mission to understand why and discover how we can defy the odds.

Researchers suggest that relying solely on willpower to achieve our goals may not be enough. Willpower can be depleted, leaving us feeling disheartened and less likely to continue our journey towards self-improvement.

But fear not, my fellow growth enthusiasts! There is a way to break this cycle and achieve meaningful change. The key lies in setting simple and achievable goals.

Let's break it down. Instead of aiming for lofty ambitions, focus on the low-hanging fruit. These small wins can provide the motivation we need to keep going. Remember, excellence is not a one-time accomplishment but rather a habit formed through consistent actions.

To illustrate this, let me share with you my annual objectives – the daily habits I've incorporated to keep myself on track.

First and foremost, it's always important to keep coding skills sharp. I dedicate at least one hour each day to solving toy problems or tackling coding challenges. Trust me, even a single hour of focused coding can take you a long way.

Next, physical health. We've heard it time and time again, but it's true – a healthy body fosters a healthy mind. I prioritize spending at least 30 minutes a day jogging or engaging in other exercises that keep me active and energized.

Learning should never cease, my friends. I allocate an hour each day to immerse myself in enriching content – whether it's reading books or watching educational videos. The power of knowledge is remarkable, and by dedicating time to learn each day, we unlock endless potential.

Finally, never underestimate the power of human connection. Strengthening social bonds is vital for our well-being. I spend an hour each day connecting with my loved ones – be it over a meal, a video call, or simply catching up on their day.

There you have it, the secret to continuous improvement lies in setting achievable goals and turning them into daily habits. Remember, it's not about making grandiose resolutions that fizzle out by February. It's about focusing on those consistent, small actions that compound over time.

I encourage you all to reflect on what areas of your life could benefit from a little tweaking and experiment with implementing these daily habits. Trust me, the results will speak for themselves.

That's a wrap for today's episode of Continuous Improvement. Thank you for tuning in, and remember, the journey toward self-improvement is one we embark on together. Stay curious, stay hungry, and never stop striving for growth.

Until next time, this is Victor signing off. Take care, my friends!

Angular.js Factory: Handling $http Asynchronously

The Problem:

Hello everyone and welcome to another episode of "Continuous Improvement". I'm your host, Victor, and today we are going to dive into a common problem developers face while using the $http service to retrieve data from a remote API.

In a recent blog post, the author shared a code snippet where the $http service was used to get data from an API. However, there was an issue that prevented the data from being returned back to the controller. Let's take a look at the code:

myApp.factory('myFactory', function($http) {
  var data = { anArray: [] };

  $http.get('/api').success(function(response) {
    data.anArray.push(response);
  });

  return data;
});

The problem here is that the return statement is executed before the $http GET request finishes pushing data into the array. This is a common mistake that can lead to unexpected behavior.

Thankfully, the author also suggests a solution to handle this asynchronous data retrieval issue. Have a look at the updated code:

myApp.factory('myFactory', function($http) {
  return {
    getData: function() {
      return $http.get('/api');
    }
  };
});

myApp.controller('MyController', ['$scope', 'myFactory', function($scope, myFactory) {
  $scope.data = [];

  var handleSuccess = function(response, status) {
    $scope.data = response;
  };

  myFactory.getData().success(handleSuccess);
}]);

In this updated code, the factory returns an object with a getData method that performs the $http GET request. The controller then calls this method and handles the eventual response using the handleSuccess function. This way, the data is correctly assigned to the $scope.data variable when it becomes available.

It's important to understand the difference between synchronous and asynchronous operations in JavaScript. Asynchronous operations, like retrieving data from a remote API, take time to complete. It's crucial to account for this and implement appropriate handling mechanisms.

That's it for today's episode of "Continuous Improvement". I hope you found this topic interesting and that it helps you avoid similar issues in your own code. If you have any questions or feedback, don't hesitate to reach out to me by email at victorleungtw@gmail.com.

Thank you for listening and until next time, keep coding and continuously improving.