<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Coding on Henry Du Blog</title>
    <link>https://www.henrydu.com/categories/coding/</link>
    <description>Recent content in Coding on Henry Du Blog</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <lastBuildDate>Sun, 09 Jan 2022 00:00:00 +0000</lastBuildDate>
    
	<atom:link href="https://www.henrydu.com/categories/coding/index.xml" rel="self" type="application/rss+xml" />
    
    
    <item>
      <title>Golang Inversion of Control Design Pattern</title>
      <link>https://www.henrydu.com/2022/01/09/golang-inversion-of-control/</link>
      <pubDate>Sun, 09 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2022/01/09/golang-inversion-of-control/</guid>
      <description>Golang Inversion of Control IoC Introduction Inversion of Control (IoC) is a programming design pattern which follows Dependency Inversion principle (DIP). It achieves decoupling the control logic and business logic. For instance, we normally will add control logic in the business logic, because it is very common in terms of human beings thinking logic. For example, we may add toggle-switch object when implement light bulb. We may also implement customized toggle-switch when making another electric device.</description>
    </item>
    
    <item>
      <title>Golang Decorator Pattern</title>
      <link>https://www.henrydu.com/2022/01/05/golang-decorator-pattern/</link>
      <pubDate>Wed, 05 Jan 2022 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2022/01/05/golang-decorator-pattern/</guid>
      <description>Golang Decorator Pattern Decorator pattern is the one of twenty-three well-known design patter from Gang of Four design patterns. It is categorized in structural design pattern, along with Adapter pattern, Proxy pattern etc. The decorator pattern allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class.
It tries to resolve the problem that single responsibility, following the Single Responsibility Principle, should be added to or removed from an object dynamically at run-time.</description>
    </item>
    
    <item>
      <title>Golang Interface Source Code Brief Look</title>
      <link>https://www.henrydu.com/2021/02/07/golang-interface-brief-look/</link>
      <pubDate>Sun, 07 Feb 2021 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2021/02/07/golang-interface-brief-look/</guid>
      <description>Golang Interface Source Code Brief Look Based on go v1.13, there are two struct definition for go interface: eface and iface.
type eface struct { _type *_type data unsafe.Pointer } type iface struct { tab *itab data unsafe.Pointer } eface The eface represents the interface which does not have any method: interface{}.
The eface has two fields: _type and data. data is actually a pointer to point to real data. _type is defined as follows:</description>
    </item>
    
    <item>
      <title>Add Subtract Coding Problem</title>
      <link>https://www.henrydu.com/2020/11/29/golang-add-subtract/</link>
      <pubDate>Sun, 29 Nov 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/11/29/golang-add-subtract/</guid>
      <description>Add Subtract Coding Problem Problem Write a function addSubtract to meet the requirement that, it will alternately adds and subtracts carried parameters.
For example:
add_subtract(7) -&amp;gt; 7 add_subtract(1)(2)(3) -&amp;gt; 1 + 2 - 3 -&amp;gt; 0 add_subtract(-5)(10)(3)(9) -&amp;gt; -5 + 10 - 3 + 9 -&amp;gt; 11 Solution The idea is to have a addSubtract struct to keep tracking the last add/subtract result and the count of function calls. If the count is even number, then use subtract operation, otherwise, use add operation.</description>
    </item>
    
    <item>
      <title>Golang Decoupling, Embedding and Exporting</title>
      <link>https://www.henrydu.com/2020/11/08/golang-decoupling/</link>
      <pubDate>Sun, 08 Nov 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/11/08/golang-decoupling/</guid>
      <description>Golang Decoupling, Embedding and Exporting Decoupling Golang does not have a concept of object-oriented programming (OOP), including the concept of class or a class-based inheritance. Rather, Golang has its own way to interpret the regular object-oriented languages - decoupling.
In traditional OOP design, one class contains member variables, either public or private. It also contains member functions, either public or private. In order to reuse the class member function, another class has to inherit the class.</description>
    </item>
    
    <item>
      <title>Go Channel Patterns</title>
      <link>https://www.henrydu.com/2020/10/27/golang-channels/</link>
      <pubDate>Tue, 27 Oct 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/10/27/golang-channels/</guid>
      <description>Golang Channel Patterns Golang channel allows us to transfer data structure between go-routine boundaries. It could be zero byte data struct{}{}, served as signaling purpose. In this use case, the channel is semantically a signaling, by which, one go-routine can send a signal to another go-routine, as a notification or an event.
Signaling without data serves the main purpose of cancellation. It allows one go-routine to signal another go-routine to cancel the channel.</description>
    </item>
    
    <item>
      <title>Go Routine Run as a Thread?</title>
      <link>https://www.henrydu.com/2020/10/26/golang-go-routines/</link>
      <pubDate>Mon, 26 Oct 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/10/26/golang-go-routines/</guid>
      <description>Go Routine Run as a Thread? Whether or not a go-routine run as a machine thread is always a question for me, until I finally have a chance to inspect it by gdb. First, We could write a simple go code to have a go func().
package main import ( &amp;#34;fmt&amp;#34; &amp;#34;time&amp;#34; ) func main() { ch := make(chan string) go func() { fmt.Println(fmt.Sprintf(&amp;#34;received the data &amp;#39;%v&amp;#39; from the channel&amp;#34;, &amp;lt;-ch)) }() fmt.</description>
    </item>
    
    <item>
      <title>Golang Pass Map Type Parameter</title>
      <link>https://www.henrydu.com/2020/09/13/golang-pass-map-value/</link>
      <pubDate>Sun, 13 Sep 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/09/13/golang-pass-map-value/</guid>
      <description>Golang Pass Map Type Parameter Observation When I read this blog section “But maps and channels are references, right?”, I realize that the following code should print true, because Golang pass the map by value, not map address.
package main import &amp;#34;fmt&amp;#34; func fn(m map[int]int) { m = make(map[int]int) } func main() { var m map[int]int fn(m) fmt.Println(m == nil) } Analysis This is running result. When the program starts run main function, the active stack frame in memory belongs to main.</description>
    </item>
    
    <item>
      <title>Local Postgres Container Setting Up</title>
      <link>https://www.henrydu.com/2020/09/12/docker-postgres-golang-db-ping/</link>
      <pubDate>Sat, 12 Sep 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/09/12/docker-postgres-golang-db-ping/</guid>
      <description>Local Postgres Container Setting Up This article has been done last couple of years, but it is still useful for developers who are during transition from old school services to the docker container world.
For example, we want to implement a service to access local Postgres DB. We can actually apt-get install, yum install or brew install a postgres DB service. However, since we don’t want our local OS has heavy load to run Postgres all the time, using Docker to have a Postgres is a better choice.</description>
    </item>
    
    <item>
      <title>New Start with Hugo</title>
      <link>https://www.henrydu.com/2020/09/05/new-start-with-hugo/</link>
      <pubDate>Sat, 05 Sep 2020 00:00:00 +0000</pubDate>
      
      <guid>https://www.henrydu.com/2020/09/05/new-start-with-hugo/</guid>
      <description>New Start with Hugo My previous blog was hosted by HostGator. It is a traditional LAMP server with WordPress. Since I have started to use AWS as a daily basis, maintaining a static website by using AWS S3 bucket will be a good choice. AWS provided the detailed document to show how to configure a static website using a custom domain registered with Route 53. AWS also provided the document how to host a static website.</description>
    </item>
    
  </channel>
</rss>