<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Billy Chan on Medium]]></title>
        <description><![CDATA[Stories by Billy Chan on Medium]]></description>
        <link>https://medium.com/@ccw_billy?source=rss-90e2965e2243------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*EEar_PzpnUzw-F4QrMtLdQ.jpeg</url>
            <title>Stories by Billy Chan on Medium</title>
            <link>https://medium.com/@ccw_billy?source=rss-90e2965e2243------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 11 Apr 2026 21:39:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ccw_billy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com" rel="hub"/>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day013, Inheritance]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day013-inheritance-e49568170110?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/e49568170110</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Thu, 27 Jun 2019 14:23:03 GMT</pubDate>
            <atom:updated>2019-06-27T14:23:03.169Z</atom:updated>
            <content:encoded><![CDATA[<p>All of us know half of the gene comes from mother, and the other half comes from father, that is the basic idea of inheritance. It should be the same in programming, right?</p><h3>What is Inheritance?</h3><p>Inheritance means that a subclass (or child class) inherit attributes and methods from another class (often call this class as super class or parent class). Notice that the child class is a kind of parent class, for example Dog is a Animal, Human is a Animal. But why we bother to use inheritance in programming? Why not just make class like Dog, Human, Animal as three separate and unrelated class? Let discuss in the following.</p><h3>Why Inheritance?</h3><ul><li>Organize object in hierarchy: Inheritance was is a relationship, a subclass is a kind of superclass. That means subclass is a more specific form of the superclass.</li><li>Pass common attributes and methods to subclass: Subclass could inherit attributes and methods from superclass (depending on access specifier in superclass, see more for <a href="https://www.tutorialspoint.com/cplusplus/cpp_inheritance.htm">C++</a> and <a href="https://www.tutorialspoint.com/java/java_inheritance.htm">Java</a>) Taking the advantage of inheritance to avoid defining duplicate attributes and implementing same set of method again and again.</li><li>Making object type more generic: Imaging that you want to write a method that will take any Animal as parameter. However, without inheritance we might need to overload the function with multiple Animal data types, not to mention the growing number of Animal subclass in later stage. With the help of inheritance we could just simply use Animal as input type, and other more specific Animal class (i.e. Dog, Cat, Human…etc.) inherit from it, all done!</li></ul><h3>When Inheritance?</h3><ul><li>Want to pass a generic type to function parameter: As discussed above! Also, there are other ways to handle this kind of generic programming, for example by using template, abstraction…etc.</li><li>More organized: Easier for others to understand the structure of the program!</li></ul><h3>What to Avoid in Inheritance?</h3><p>Outlier: For example a superclass Bird could have subclass like Eagle, Owl, even Chicken! However, what if I say Bird superclass have a method of Fly. But wait… Chicken nowadays don’t know how to fly… It don’t not make sense to include it in Bird class. What we could do in Java way is that flying Animal will implement a Flyable interface (see <a href="https://www.tutorialspoint.com/java/java_interfaces.htm">here</a> for details). The Fly method is put inside Flyable interface, and hence Animal implement Flyable can fly!</p><h3>C++ Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/a5b789a823bf7f40d37878a1cc78a02b">https://gist.github.com/billy1624/a5b789a823bf7f40d37878a1cc78a02b</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9WkCY0Q0ETxrVvRoKnU-SQ.png" /></figure><h3>Java Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/436a1f5893946c9c39458e5b20cae590">https://gist.github.com/billy1624/436a1f5893946c9c39458e5b20cae590</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFeQv0B0ncMzdCbZx8zUoQ.png" /></figure><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.27</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e49568170110" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day012, Debugging]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day012-debugging-5f40b5509af1?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f40b5509af1</guid>
            <category><![CDATA[programmer]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Sun, 23 Jun 2019 12:51:20 GMT</pubDate>
            <atom:updated>2019-06-27T14:24:18.850Z</atom:updated>
            <content:encoded><![CDATA[<p>Bug is annoying in real life, what’s more annoying for programmer is that we spend lot of time dealing with bug in programming! Killing the evil and virtual bug reside in the program is sometime hard and costly.</p><h3>Killing Bug!</h3><p>I believe most of you have the experience that piece of code you just type does not work as expected, however you have no idea why it failed.</p><p>Here are some tips for your debugging:</p><ol><li>Find the suspect: Try to run a few test case with the suspected block of defective code, and narrow down the scope of suspected code as much as possible</li><li>See what it’s doing: Use live debugging tool to see the line by line execution of the program, or simply print the value inside the variable</li><li>All done: You should have identify the root of bug and fixed it</li></ol><pre>// demo_buggy.py<br>arr = [2,3,6,6,5]	// array of marks ranging from 0 to 100<br>winner = -101		// mark of winner<br>runner_up = -102	// mark of runner-up<br>for n in arr:<br>    if (n &gt; winner):<br>        runner_up = winner<br>        winner = n<br>    elif (n &gt; runner_up):<br>        runner_up = n<br>print(winner)		// Output: 6<br>print(runner_up)	// Output: 6<br>// Hmmmmmm wrong answer for runner up! Why?</pre><p>The above Python code showing a simple program finding the marks of winner and runner-up in a competition. The program has an array of marks [2,3,6,6,5] as input, and it found the winner and runner-up have the same score! However, that is not what we want… we want the second highest score as runner-up score.</p><p>So, what’s wrong with our code? We can print the change in each if body, see below:</p><pre>for n in arr:<br>    if (n &gt; winner):<br>    	print(&#39;winner change from&#39;, winner, &#39;to&#39;, n)<br>        runner_up = winner<br>        winner = n<br>    elif (n &gt; runner_up):<br>        print(&#39;runner-up change from&#39;, runner_up, &#39;to&#39;, n)<br>        runner_up = n</pre><p>Then, we can quickly see the update of runner_up variable is not what we want!</p><pre>// demo.py<br>arr = [2,3,6,6,5]	// array of marks ranging from 0 to 100<br>winner = -101		// mark of winner<br>runner_up = -102	// mark of runner-up<br>for n in arr:<br>    if (n &gt; winner):<br>        runner_up = winner<br>        winner = n<br>    elif (n &gt; runner_up and n &lt; winner):<br>        runner_up = n<br>print(winner)		// Output: 6<br>print(runner_up)	// Output: 6<br>// Hmmmmmm wrong answer for runner up! Why?</pre><p>And we change the second if condition to exclude n == winner, now the bug fixed.</p><h3>Avoiding Bug!</h3><p>Unstructured and messy code is the breeding place of bug!</p><p>Where are these breeding place?</p><ul><li>God function: function that contain all the code in one function, that means lots of logic inside one function!</li><li>God class: similar to god function, class that contain all the program logic in single class, not a good OOP design!</li><li>Nested statements: such as nested if or loop, try to flatten the nested structure as much as possible</li></ul><h3>Learn From the Past!</h3><p>Practice makes perfect! Don’t afraid to make mistakes, the experience that you fix bugs will carry on to the future and to different programming language. However, different programming language might have different pitfalls for programmer! lollll Anyway, learn from the past and carry on!</p><p>Next, we will discuss what is inheritance and how to use it!<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day013-inheritance-e49568170110?postPublishedType=initial">Day013, Inheritance</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.23</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f40b5509af1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day011, Pro Tips on Multi-Line Select & Edit]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day011-pro-tips-on-multi-line-select-edit-bdb7fb1a027b?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/bdb7fb1a027b</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Tue, 11 Jun 2019 05:32:00 GMT</pubDate>
            <atom:updated>2019-06-23T12:53:06.578Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*FAyz2hC6pEP7gMDHjgWgbQ.gif" /></figure><p>Have you ever try to modify some code repeatedly or even use find &amp; replace all function? Here I introduce you multi-line select &amp; edit function! A safe and efficient way to edit multiple occurrence at the same time.</p><h3>Why Not Find &amp; Replace All?</h3><p>First, it is dangerous to use find &amp; replace without any source control (e.g. Git). Also, I think it’s difficult to track where it replace, especially for some editor that does not shown replace locations.</p><p>I’m not saying avoid using it, but use it with caution, commit your code to source control before directory-wide find &amp; replace all. So that you have a save point and you could view what it replace in source control change log.</p><h3>IDE or Text Editor Support</h3><p>Now comes to manual multi-line select &amp; edit, it requires IDE or text editor support. Most modern editors have this feature built-in, otherwise you can find online for such extension. For example, Sublime Text and VS Code have such feature built-in.</p><h3>How to Multi-Line Select &amp; Edit?</h3><p>Three step process to complete the act:</p><ol><li>What you want to change? (from what to what?)</li><li>Identify a unique keyword or pattern to select (can be a keyword or indentation or even line break!)</li><li>Make the changes!</li><li>Done!!</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*LcUGk5WcuVwHGilc_BcgOw.gif" /></figure><p>To illustrate the process, I will tell you how to change all print statement in C++ syntax to Java syntax:</p><ol><li>Select cout &lt;&lt; and change it to System.out.println(, then press Command + Right Arrow(MacOS)/ Control + Right Arrow(Windows) go the end of line, adding ) before ;.</li><li>Select &lt;&lt; endl and remove it, as System.out.println() already have line break</li><li>Select &lt;&lt; and change it to +</li><li>Done!!</li></ol><h3>What It Uses for?</h3><ul><li>Changing variable name, but might not applicable for short variable name e.g. i</li><li>Changing function name</li><li>Convert class fields to class constructor, demo below</li><li>Many other use cases!! Be creative!</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*DwPuuHj5V3Um8JflURN6uA.gif" /></figure><p>In the above demo I forgot to remove the , sign before int pint. Opppppsy…</p><p>Next, we will discuss how to debug!<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day012-debugging-5f40b5509af1">Day012, Debugging</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.11</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bdb7fb1a027b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day010, Readable Code Without Documentation]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day010-readable-code-without-documentation-c5f62d14238d?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5f62d14238d</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Fri, 07 Jun 2019 16:25:16 GMT</pubDate>
            <atom:updated>2019-06-11T05:33:25.367Z</atom:updated>
            <content:encoded><![CDATA[<p>To write readable code, comment and documentation are not the necessary component. How you structure the code is the core of readability. Meaning that how you format the code and do the naming will affect code readability!</p><h3>Code Formatting</h3><p>Format your code according to the general formatting rule such as indenting code block by scope, one line one statement, etc. However, the best practice of code formatting vary across different programming language, you can find online by typing the name of your favorite programming language followed by “formatting best practice”. Also, different organization might have different requirements on code formatting, so you better understand the convention before coding!</p><pre>// Sample 1<br>if (Code Unformat) Then... Reformat Code</pre><pre>// Sample 2<br>if (Code Unformat) Then...<br>	Reformat Code</pre><p>Even a small group of 2–3 programmer might have different convention! Assuming an if statement with only one line of code inside its body, then some programmer will simply put all in one line (Sample 1), or some will put it two line (Sample 2). For me I will write the code as Sample 2. So, one time I read my friend’s code and I’m not used to the way my friend write the code as Sample 1, so for me it’s quite hard to read.</p><h3>Naming of Variable, Function &amp; Class</h3><p>What programmer spend the most time on? Naming things!! We have many things to name, variables, functions and classes! Not to mention those intermediate variables!</p><pre>Boolean success = True<br>If ( success ) Then...<br>	Party Time &amp; Celebrate</pre><p>Naming should be short and intuitive. Take the above as an example, that usually how I name boolean variable, using the meaning that boolean variable representing for naming. The benefit of it being intuitive if condition when using the variable in it.</p><p>Also, my convention of naming function is based on its functionality and with a name in verb form. And for class and boolean, its name is in noun form.</p><pre>For (int i=0; i&lt;10; i++)</pre><p>In some cases, we might give variable a name that without any meaning (seems like). Like the counter variable in For Loop, we often give the name i or j to it. However, this is the convention of naming it, programmers are lazy lollll.</p><h3>Keep it Simple!</h3><p>Simple is the best! Try to make things as simple as possible.</p><ul><li>Avoid using multiple nested loop</li><li>Break long function into multiple simple functions</li><li>Extract common code across multiple function and put the common code into single utility function, then call to use the utility function</li></ul><p>Following sample code does not have any comments in it, see if it’s easy to understand or not!</p><h3>C++ Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/ac57881a66e0f1b846daf065da20fd57">https://gist.github.com/billy1624/ac57881a66e0f1b846daf065da20fd57</a></p><h3>Java Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/b3f511ee6c9bc3c8be2c3e63314e063b">https://gist.github.com/billy1624/b3f511ee6c9bc3c8be2c3e63314e063b</a></p><p>Next, I will tell you a small trick to enhance your productivity!<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day011-pro-tips-on-multi-line-select-edit-bdb7fb1a027b?postPublishedType=initial">Day011, Pro Tips on Multi-Line Select &amp; Edit</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.07</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5f62d14238d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day009, Comment & Documentation]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day009-comment-documentation-d37b39ea19a9?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/d37b39ea19a9</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[code]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Fri, 07 Jun 2019 10:33:33 GMT</pubDate>
            <atom:updated>2019-06-07T16:26:49.858Z</atom:updated>
            <content:encoded><![CDATA[<p>On a sunny afternoon, your friend call you up and ask for help on debugging the course assignment due at 12:59. Of cause you will say “Sure! Let me take a look at your code, send it to me”. However, when you open the source code you discover that the code is absolutely unreadable! No comment explaining what each block of code do! What a pain to read through over 1000 lines of code without any description…</p><h3>How to Comment?</h3><pre>// Single line comment</pre><pre>/* Single line comment */</pre><pre>/*<br>  Block comment<br> */</pre><pre>/**<br> * Block comment (Javadoc style)<br> */</pre><p>Above are some of syntax to put comments in code. Mainly there are two types of comment in every programming language, Line Comment &amp; Block Comment. Also, notice that each programming language have their unique syntax defining comments. For the example above, it shows the comment syntax in C++ &amp; Java. For other language, you might need to go online and double check the syntax for putting comments.</p><h3>Where and What to Comment?</h3><ul><li>Comment at the beginning of class definition, specifying the purpose and scope of this class, what will it do and what it model</li><li>Comment at the beginning of function definition, specifying the functionality of the function, together with the input parameters and return value of it</li><li>Comment at special if statement, such as some error checking if statement, specifying the purpose of this if statement</li><li>Comment at line or block of code that you think others will have difficulties to understand!</li></ul><h3>Comment Tags</h3><pre>// TODO: brbrbrbbrbr<br>// FIXME: brbrbbrbrbrbr</pre><p>Some useful tags for programmer such as TODO and FIXME, and many other useful tags. Some IDE will have special syntax highlight or even a panel for you to find the line containing the tag. For example, the TODO tag indicate some task needs to be done, and FIXME indicate something needs to be fix. Very intuitive, right?</p><h3>Comment &amp; Documentation</h3><p>There is some standard for putting comment on code, more specifically it called documentation. For example in Java, we have JavaDoc, you can see <a href="https://www.tutorialspoint.com/java/java_documentation.htm">here</a> for more info.</p><h3>C++ Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/0836b281af606bd2e1b21c1e0deeed27">https://gist.github.com/billy1624/0836b281af606bd2e1b21c1e0deeed27</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VSAjEcpL6XsEuojKHpok6Q.png" /></figure><h3>Java Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/b7d73d6fabb4ff514a32877392fa9694">https://gist.github.com/billy1624/b7d73d6fabb4ff514a32877392fa9694</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JFmuvVpB2wZfYCzc6-CJ-A.png" /></figure><p>Next, we will discuss how to write readable code without the help of documentation.<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day010-readable-code-without-documentation-c5f62d14238d?postPublishedType=initial">Day010, Readable Code Without Documentation</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.07</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d37b39ea19a9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day008, Object-Oriented]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day008-object-oriented-ee24f782fc12?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee24f782fc12</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Sun, 02 Jun 2019 15:56:55 GMT</pubDate>
            <atom:updated>2019-06-07T13:13:51.799Z</atom:updated>
            <content:encoded><![CDATA[<p>Every things in our daily life are object, each associated with some unique properties and actions. Such as a person has properties like name, age, date of birth, gender, skills, etc. And actions like run, sleep, read, speak, etc. But you may ask, how about object that will not move at all? Such as apple? For these static objects we will have properties for it but not actions. Apple could have properties of origin, weight, color, maturity, etc.</p><h3>Why Object-Oriented?</h3><ul><li>More intuitive and easy to understand, each object model the corresponding real-world object</li><li>Encourage collaboration, each developer implement a specific and well defined object; developers then combine the functionality provided by different object to build up the application</li><li>Promote simplicity and security! We will discuss in the following</li></ul><h3>Encapsulation (Simplicity &amp; Security)</h3><p>Encapsulation means the user can use the functionality provided by an object without caring how the object does that for you. For example, when you use ATM, you just need to provide the ATM card and the pin, then you just commend the ATM to withdraw cash for you. For simplicity, the user don’t need to know how the machine count notes and update bank account balance. And for the bank, because of security reason the user should not know how the ATM works.</p><h3>Class (Object Blueprint)</h3><pre>Class ATM:<br>	Property:<br>		boolean InService<br>		string Location<br>	Method:<br>		Withdraw(ATM Card, Pin)<br>		Deposit(ATM Card, Cash)<br>		CheckInService()</pre><p>Each object is created from the blueprint called Class. For the example of ATM object we discuss above, we have model a simple ATM Class. It contains a boolean value InService indicating the ATM in service or not, also a Withdraw Method (action), which take ATM Card and Pin as input. The user will only see that to withdraw money the ATM requires ATM Card and Pin, user have no idea how the Withdraw method implemented!</p><h3>Object Creation</h3><p>All objects are created by a class blueprint, each object have their own copy of Property but share same set of Method. Meaning that we can have two different ATM objects one located on A place and in service, another ATM object located on B place and out of service.</p><h3>Constructor (Object Initialization)</h3><pre>Class ATM:<br>	...<br>	Constructor:<br>		ATM(InService, Location)<br>        ATM()<br>	...</pre><p>During object creation, the initial state of the object is set by the constructor. Shown in the above code, a class could have multiple constructor, but only one constructor will be involved.</p><p>ATM(InService, Location), takes input of InService and Location, setting the input value to corresponding property.</p><p>ATM(), takes no input, it will set property to default value.</p><p>More explanation on below C++ and Java sample code.</p><h3>C++ Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/df7bda872b8ff75ca33a11025406243d">https://gist.github.com/billy1624/df7bda872b8ff75ca33a11025406243d</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*aVM0LhkKYCSAzo6ZAhrTKA.png" /><figcaption>C++ Sample Code Output</figcaption></figure><h3>Java Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/261a366b5d1bb0c25889afe358134591">https://gist.github.com/billy1624/261a366b5d1bb0c25889afe358134591</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*pVxmYPqRmwX3zY4SLZ1gfQ.png" /><figcaption>Java Sample Code Output</figcaption></figure><p>Next, we will discuss comments and documentation in programming!<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day009-comment-documentation-d37b39ea19a9">Day009: Comment &amp; Documentation</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.02</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee24f782fc12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day007, For Loop]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day007-for-loop-cfbbb6a8ac6f?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/cfbbb6a8ac6f</guid>
            <category><![CDATA[c]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Sat, 01 Jun 2019 15:58:30 GMT</pubDate>
            <atom:updated>2019-06-02T15:58:32.224Z</atom:updated>
            <content:encoded><![CDATA[<p>Hey, can you fold the star like origami for around 100 copies, filling the whole bottle with paper stars for me? Yeah… sure! It sounds repetitive, I could write a program and fold that for you!</p><h3>For Loop</h3><pre>For (Initial, Condition, Update)...<br>	Body</pre><p>A regular For Loop mainly consist of 4 parts:</p><ul><li>Initial: The initialization of variable that will be used in the for loop (mostly integer counter variable counting from 0 up to some point), executed once at the time of entering the loop</li><li>Condition: The condition that need to be satisfied in order to enter the loop Body after execution of Initial or Update</li><li>Update: The update statement that mostly update the value in loop variable</li><li>Body: The for loop body containing all statements that will be loop iteratively</li></ul><h3>Simple Example</h3><pre>For (i=1, i&lt;=100, i=i+1)...<br>	Fold star origami</pre><p>Back to the case of folding 100 star origami. Inside the Body we fold one star origami each time. Setting Initial of integer variable i=1. Condition of i less than or equal to 100. Every time we finished folding the star origami (inside Body) we Update the variable i by adding 1 to it, making i counting from Initially 1 all the way to 100. Finally after folding the 100th star, the value of i will become 101 and not satisfied the Condition, making the for loop end.</p><h3>For Each Loop (Range-based For Loop)</h3><pre>For (i : Array arr)...<br>	print value of i</pre><p>Here we see a special kind of for loop, which many modern programming language has it. The simple use of this For Each Loop is to loop through all elements in an array. The arr array contain many integer number, then by the statement above each time we put single value inside variable i and do this for every elements in the array. We will see the actual implementation of for each loop in the following sample code.</p><h3>C++ Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/bfaad22ee1918a314bdb1e9015b21784">https://gist.github.com/billy1624/bfaad22ee1918a314bdb1e9015b21784</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*0lXFnHp9T8IrIcgm9CfX3w.png" /><figcaption>C++ Sample Code Output</figcaption></figure><h3>Java Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/43675459fb13d1cf37390497ce983ddc">https://gist.github.com/billy1624/43675459fb13d1cf37390497ce983ddc</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/938/1*cSjH3pH0v_Vqt91-b5eeDQ.png" /><figcaption>Java Sample Code Output</figcaption></figure><p>Next, we will discuss what is Object-Oriented concept, one of the most important concept in programming!<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day008-object-oriented-ee24f782fc12">Day008, Object-Oriented</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.01</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cfbbb6a8ac6f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day006, While Loop]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day006-while-loop-ad66d2a8985?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/ad66d2a8985</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Sat, 01 Jun 2019 10:14:54 GMT</pubDate>
            <atom:updated>2019-06-01T16:00:11.938Z</atom:updated>
            <content:encoded><![CDATA[<p>While the exam period still very far from now, as a college student, we often chilling and enjoying our time being a student. Doing part-time job, hangin out, or just simply spending the whole day at dormitory. Loop through all these till few weeks from the exams and start to work hard again lollll. We can describe the cycle using while loop!</p><h3>While Loop</h3><p>So, when the exam period come then we need to study. Here, Exam Period is a boolean value or expression, when it&#39;s True then we study otherwise hangin out and have fun!</p><pre>While (Exam Period) Then...<br>	Study</pre><h3>Do… While Loop</h3><p>Notice that in the above example we will first check the condition Exam Period before Study. How about we want to always Study for once first before checking the condition?</p><p>Wellll, we have Do… While Loop for this special case! Every time we will Study once then checking the condition, if the condition Exam Period hold then keep studying!</p><pre>Do...<br>	Study<br>While (Exam Period)... </pre><h3>Infinite Loop</h3><p>In the above two example, either the condition satisfied, and thus keep studying, or the condition unsatisfied, and study once or none. Infinite loop will occur if the condition satisfied forever , which means keep studying! Which is not good… At some point we need to take a break!</p><pre>While (Exam Period) Then...<br>	Study<br>	If (Study for 2 hours) Then...<br>		Take short break<br>		Continue...<br>	If (Done revision) Then...<br>		Break...</pre><p>So if we study straight for 2 hours then we should have a short break and then Continue the loop of studying. Also, if we are done with revision then we take a pause and Break from the studying loop.</p><p>Continue, will resume the loop and execute the first statement in the while loop body, here we have Study as the first statement.</p><p>Break, will stop the loop and exit the loop immediately.</p><h3>C++ Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/5a47248eda75d84c2fc56597f6463b29">https://gist.github.com/billy1624/5a47248eda75d84c2fc56597f6463b29</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*7PkDoj0pgtgdcRzYb9b1Dw.png" /><figcaption>C++ Sample Code Output</figcaption></figure><h3>Java Sample Code</h3><p>Code: <a href="https://gist.github.com/billy1624/4ae6d3c561224df0646cb8685efba640">https://gist.github.com/billy1624/4ae6d3c561224df0646cb8685efba640</a></p><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*a0gAzldEgHpefy9mKIxMBg.png" /><figcaption>Java Sample Code Output</figcaption></figure><p>Next, we discuss another common type of loop, for loop<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day007-for-loop-cfbbb6a8ac6f">Day007, For Loop</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.06.01</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ad66d2a8985" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day 005, If… Else… Condition]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day-005-if-else-condition-ce8f6f6fd3a8?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/ce8f6f6fd3a8</guid>
            <category><![CDATA[java]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[c]]></category>
            <category><![CDATA[code]]></category>
            <category><![CDATA[program]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Sat, 09 Feb 2019 17:15:35 GMT</pubDate>
            <atom:updated>2019-06-01T10:16:21.099Z</atom:updated>
            <content:encoded><![CDATA[<p>If else condition is simple to understand, right? If u are hungry then, u eat, otherwise don’t bother to eat. However, we usually have more complex condition than that… And also some trick &amp; tips for using if else condition.</p><h3>Boolean</h3><p>Boolean value is either True or False, generally True means Yes, and False means No. For example, to represent whether you are hungry, we can use True representing empty stomach, and False representing full stomach.</p><h3>If…</h3><p>By using the above Boolean value, we can make decision based on that.</p><p>Let say if you are hungry then, you will cook a cup noodles, we can write it in the following:</p><pre>If (Hungry) Then...<br>    Cook cup noodles</pre><h3>If… Else…</h3><p>On top of If, we could have an alternative decision. Here we have If… Else… Condition</p><p>Continue with the above example, when the If Condition is True, that is we are hungry, then we cook the cup noodles (i.e. True Portion); Otherwise, If Condition is False, that is we have a full stomach, then we won&#39;t cook and watching movie on phone (i.e. False Portion).</p><p>Notice that either one action will be done, either the action on True Portion or False Portion will be done.</p><p>We can represent it in the following way:</p><pre>If (Hungry) Then...<br>    Cook cup noodles<br>Else...<br>    Watch movie on phone</pre><h3>If… Else If… Else</h3><p>The final variation of If Condition, the combination of If Condition and If Else Condition.</p><p>If… Else If… Else Condition is a series of ordered If Condition and end with an Else.</p><p>Still… Adding on top of above, after we decided to cook or not, we also want to drink lemon tea if we are thirsty.</p><p>Furthermore, I will get nervous if my phone is low on battery, so I will recharge it when low.</p><p>Notice that only one portion of the consecutive If Condition will take action.</p><p>Representing the statements in the following:</p><pre>If (Hungry) Then...<br>    Cook cup noodles<br>If (Thirsty) Then...<br>    Drink lemon tea<br>If (Phone Low Battery) Then...<br>    Recharge the phone<br>Else...<br>    Watch movie on phone</pre><h3>Boolean Operator</h3><p>We can make decision based on combining multiple Boolean values by Boolean Operator.</p><p>Boolean Operator is operator for Boolean value, including AND, OR, NOT, these three are the basic operators.</p><p>When we have Boolean value A &amp; Boolean value B, combining the two Boolean value by the operators…</p><ul><li>A AND B: Resulting True when both A &amp; B are True; Otherwise, when either A or B is True, or none of them is True will resulting False</li><li>A OR B: Resulting True when both A &amp; B are True, or either A or B is True; Otherwise, when none of them is True will resulting False</li><li>NOTA: Special operator that unlike AND / OR that take two operand, Not only take one operand. It simply reverse the Boolean value of A, resulting True when A originally is False; Resulting False when A originally is True</li></ul><h3>Boolean Expression</h3><p>Boolean expression is a statement that combining multiple Boolean values by Boolean Operator, which after evaluation will become a Boolean value.</p><p>For example, If I’m hungry AND thirsty I will eat congee. Representing in the following:</p><pre>If (Hungry AND Thirsty) Then...<br>    Eat congee<br>If (Hungry) Then...<br>    Cook cup noodles<br>If (Thirsty) Then...<br>    Drink lemon tea<br>If (Phone Low Battery) Then...<br>    Recharge the phone<br>Else...<br>    Watch movie on phone</pre><h3>Order of If Condition</h3><p>Notice that the order of If Condition is important, in the below example, even the Boolean value of both Hungry &amp; Thirsty are True, I will never have a chance to eat congee. Because If (Hungry) Then... &amp; If (Hungry) Then... placed ahead of If (Hungry AND Thirsty) Then....</p><pre>If (Hungry) Then...<br>    Cook cup noodles<br>If (Thirsty) Then...<br>    Drink lemon tea<br>If (Hungry AND Thirsty) Then...<br>    Eat congee<br>If (Phone Low Battery) Then...<br>    Recharge the phone<br>Else...<br>    Watch movie on phone</pre><h3>C++ Sample Code</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ac21fda82a3d9ccfe9a9cfcdee27aed9/href">https://medium.com/media/ac21fda82a3d9ccfe9a9cfcdee27aed9/href</a></iframe><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*QJzOxjwofFwNF6wGaRVmYg.png" /><figcaption>C++ Sample Output</figcaption></figure><h3>Java Sample Code</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/47cfd6811441cd110dd2917a76e949df/href">https://medium.com/media/47cfd6811441cd110dd2917a76e949df/href</a></iframe><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/860/1*7LRGhoBR6gLDrcPWkvKhAQ.png" /><figcaption>Java Sample Output</figcaption></figure><p>Next, we will discuss While Loop.<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day006-while-loop-ad66d2a8985">Day006, While Loop</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.02.10</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ce8f6f6fd3a8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CodeNewb2Pro: Day 004, Data Types]]></title>
            <link>https://medium.com/@ccw_billy/codenewb2pro-day-004-data-types-66fd4efa0137?source=rss-90e2965e2243------2</link>
            <guid isPermaLink="false">https://medium.com/p/66fd4efa0137</guid>
            <category><![CDATA[c]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[java]]></category>
            <dc:creator><![CDATA[Billy Chan]]></dc:creator>
            <pubDate>Thu, 31 Jan 2019 11:55:28 GMT</pubDate>
            <atom:updated>2019-06-01T09:14:18.575Z</atom:updated>
            <content:encoded><![CDATA[<p>Why bother to deal with multiple data types? Why not just treat all data as the same type? Oh, by the way what is data type?</p><h3>Why Multiple Data Types?</h3><p>Different real life data should be categorized according to their usage and categoristics. For example, a number “123” can be an Integer (number without decimal places) or a String (text or set of characters).</p><p>But which data type is more suitable? If we want to calculate the number in our program, maybe it is a price of some product, then we should use Integer, as Integer data can be used in math calculation but not for String data. However, if the number is not for calculation, like Student ID or Credit Card Number, then there is not point to store the number as Integer and in this case we should treat it as String.</p><p>Another reason of having multiple data types is the differences of characteristics across data type. For example, Integer and Decimal both represent numeric data. But only Decimal can contain decimal points.</p><h3>Data Types in General</h3><p>Almost all programming language have 4 main kind of primitive data types, and all other data types are considered as non-primitive data types.</p><h4>Primitive Data Types</h4><p>There are 4 main kind of it:</p><ol><li>Integer: numeric value <strong>without</strong> decimal place</li><li>Decimal: numeric value <strong>with/ without</strong> decimal place</li><li>Character: single character, like &quot;A&quot; or &quot;b&quot;</li><li>Boolean: binary value, <strong>only</strong> True (usually represented by 1) or False (usually represented by 0)</li></ol><h4>Non-Primitive Data Types</h4><p>All data types other than primitive data types are non-primitive data types.</p><p>For example:</p><ol><li>Object</li><li>Array</li><li>…</li></ol><p>Object: Is a data type that serve a specific purpose, and each Object is created by its blueprint called Class. We will have an in depth discussion in later post on Object &amp; Class. For now, we just need to concern how we gonna use the Object. Actually, we have overcome an Object, that is String. We simply don&#39;t care how String itself store the data. We as the user just put the text inside String and it will do the trick for us, as simple as that, for now.</p><p>Array: Is a set of data with the same data type. For example, a set of Student ID attaining the same course.</p><p>Let’s try and see the data types in programming languages. Feel free to copy &amp; paste onto your local machine and do some experiments yourself!</p><h3>C++ Data Types</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3856ca3a73651f34e471451015b27073/href">https://medium.com/media/3856ca3a73651f34e471451015b27073/href</a></iframe><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*T7-W4pvXkDJ9zyiUmw15lw.png" /><figcaption>C++: Sample Output</figcaption></figure><h3>Java Data Types</h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/055575ab8c419e7e2d8749763e14eb20/href">https://medium.com/media/055575ab8c419e7e2d8749763e14eb20/href</a></iframe><p>Sample Output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/734/1*48aoGmPcLxyiQz2Fi19kjQ.png" /><figcaption>Java: Sample Output</figcaption></figure><p>Next, we will discuss the if…else…condition.<br>Next Post: <a href="https://medium.com/@ccw_billy/codenewb2pro-day-005-if-else-condition-ce8f6f6fd3a8">Day 005, If… Else… Condition</a></p><p>More post coming soon~ Follow and stay tuned. See u in the next post! Happy Coding!! Feel free to ask me any questions down below, comments, corrections &amp; suggestions are welcomed!</p><p>Billy :)<br>2019.01.31</p><p>— — <br>GitHub: <a href="https://github.com/billy1624">https://github.com/billy1624</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66fd4efa0137" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>