RSS feed [root] /design /weblog



title search:


Mon Mar 14 15:40:26 AEDT 2022


(google search) (amazon search)
download zip of files only

Tue Jan 22 01:35:44 AEDT 2019 From /weblog/design/pattern


(google search) (amazon search)

Sun Nov 25 01:52:19 AEDT 2018 From /weblog/design


(google search) (amazon search)

Sun Nov 11 03:56:20 AEDT 2018 From /weblog/design/exception

Why use exception instead of error code

A detailed explanation -

What are exceptions? -

(google search) (amazon search)

Sun Feb 25 02:42:46 AEDT 2018 From /weblog/design/interview


Do the simple thing first.
Do fewer things better.
Upfront work but can pay huge dividends.
Don’t reinvent the wheel.
Nothing lasts forever.[..]-from-5-years-of-building-instagram.html

(google search) (amazon search)

Fri Feb 02 13:19:00 AEDT 2018 From /weblog/design/interview


(google search) (amazon search)

Thu Nov 16 12:55:26 AEDT 2017 From /weblog/design


I will prefer using static method as less as possible... there is some
side effect you are not expected, like, are you sure it thread safe? static
method easier to have thread problem.

You may take a look at[..]007/03/making-classes-unit-testable.html , and[..]Parent=7972&ixDiscussGroup=3&cReplies=29

Parameter passing vs static accessor: Should I press things around or get from public static instance? -

Reason of static method is not overrided -[..]thread/ec8b924d60dd4734/99b488aa1f8106c9

Another example of thread problem with static member -[..]=calendar_dateformat_and_multi_threading

How to mock static method code for testing -[..]ic-methods-are-death-to-testability.html

Factory is bad? -

(google search) (amazon search)

Sun Oct 01 19:19:43 AEDT 2017 From /weblog/design


A nice thread of discussing how to comment in code -

A Taxonomy Of Comments -[..]hniques/documentation/taxonomy-comments/

Everything have 2 sides -[..]s/documentation/comments-costs-benefits/

Example of comment haven't update freq enough -[..]even-good-code-comments-deteriorate.html[..]health-to-comment-or-not-to-comment.html

Putting comments in code: the good, the bad, and the ugly. -[..]e-good-the-bad-and-the-ugly-be9cc65fbf83

(google search) (amazon search)

Tue Aug 29 12:34:21 AEST 2017 From /weblog/design


Comment about the java document of jdk8 -[..]14/03/illuminating-javadoc-of-jdk-8.html

Thoughts On Comments -[..]ques/documentation/thoughts-on-comments/

The Art of Crafting Architectural Diagrams -

(google search) (amazon search)

Wed Aug 09 13:37:20 AEST 2017 From /weblog/design


Use present and absent rather than NULL -

Propose of enhancement, null handelers and null reference -[..]01/null-handelers-and-null-refere-1.html

How null breaks polymorphism -[..]s-polymorphism-or-the-problem-with-null/[..]orphism-or-the-problem-with-null-part-2/

Discussion about forbid NULL as parameter and return -[..]5/07/null-parameters-and-returning-null/

Default object in C# -[..]t/2012/09/25/Default-Objects-with-C.aspx

Discussion about using optional -

Some suggest about do something better than use null -

(google search) (amazon search)

Wed Jul 19 16:59:51 AEST 2017 From /weblog/design


Avoid circular dependencies between packages!

2 common approach, by function or by layer -

(google search) (amazon search)

Fri Mar 10 02:13:09 AEDT 2017 From /weblog/design


Someone saying that having private method is anti-pattern, here is the discussion -

Discussion of encapsulation -[..]/encapsulation-does-it-really-exist.html

My view on this is that most of the time there's little value in self-encapsulation. The value of encapsulation is proportional to the scope of the data access. Classes are usually small (at least mine are) so direct access isn't going to be an issue within that scope. Most accessors are simple assignments for the setter and retrieval for the getter, so there's little value in using them internally. -

(google search) (amazon search)

Thu Feb 23 19:14:03 AEDT 2017 From /weblog/design/interview


Interview with JOOQ founder -

(google search) (amazon search)

Tue Feb 21 20:44:20 AEDT 2017 From /weblog/design


A paper show the evolution of a DSL -

A stock trading order example of DSL -[..]05/designing-internal-dsls-in-scala.html

What is the difference between API / DSL if we don't write a parser for our language? From Martin Fowler's blog - , it is mentioned:
Piers Cawley makes the point that a key characteristic of DSLs is their narrow focus on a domain.
I think this is a very good summary, usually if most of the APIs are getXXX() , setXXX(), loadXXX() , createXXX() ........ Then we mostly design APIs that expose low level detail to the API user to work on, which, is work but user probably work nicer if we can come up with language like API that allow users to do their work in more descriptive level.

I think if API design like that usually it will reduce the code duplication, what ever real duplication or conceptual duplication. It probably already apply "Tell, don't ask" style -

A discussion about applying "Tell, don't ask" which lead to message passing architecture -[..]07/10/do_messages_want_to_be_asynchr.php

And other discussion about "Tell, don't ask"[..]/2008/11/demeters-law-tell-dont-ask.html[..]part-two-demeters-law-tell-dont-ask.html[..]rt-three-demeters-law-tell-dont-ask.html

One good sample with explaination -[..]-it-really-domain-specific-language.html

Few links -

From CRUD to DDD -[..]2/15/from-crud-to-domain-driven-fluency/

I like this: "XML abuse reduction (conducting an “XML Intervention”)" -[..]ps-internal-dsl-draft-outline-notes.aspx

DSL maybe the result of encapsulation -

Excellent implementation of extending java yourself -

How DSL method named -[..]he-java-fluent-api-designer-crash-course

(google search) (amazon search)

Thu Feb 16 03:03:22 AEDT 2017 From /weblog/design/pattern


(google search) (amazon search)

Mon Jan 23 21:33:07 AEDT 2017 From /weblog/design


Stealing thread -

Intel Guide for Developing Multithreaded Applications -[..]or-developing-multithreaded-applications

Difference ways to stop a thread -[..]ept_url=/hpc-high-performance-computing/

Interesting, I am not sure if I agree, but chrome ( which use fork ) are really cool in performance:
There’s another problem with Unix programming in Ruby that I’ll just touch on briefly: Java people and Windows people. They’re going to tell you that fork(2) is bad because they don’t have it on their platform, or it sucks on their platform, or whatever, but it’s cool, you know, because they have native threads, and threads are like, way better anyways.

Fuck that.

Don’t ever let anyone tell you that fork(2) is bad. Thirty years from now, there will still be a fork(2) and a pipe(2) and a exec(2) and smart people will still be using them to solve hard problems reliably and predictably, just like they were thirty years ago.

MRI Ruby people need to accept, like Python (you have seen multiprocessing, yes?), that Unix processes are one of two techniques for achieving reliable concurrency and parallelism in server applications. Threads are out. You can use processes, or async/events, or both processes and async/events, but definitely not threads. Threads are out.

1x1 win M*N -

Best number of threads:
N = number of CPUs
U = target CPU utilization (0 <= U <= 1)
W/C = ration of wait time to cpu time (measured through profiling)

threads = N * U * (1 + W/C) -[..]ratio-of-java-threads-to-cpus-on-solaris

Another post about tuning thread pool -[..]ortance-of-tuning-your-thread-pools.html

Threads Basics -

The Dos and Don'ts of Multithreading -[..]-26-09-low-level-threading-table-of.html

(google search) (amazon search)

Wed Jan 18 02:09:08 AEDT 2017 From /weblog/design


(google search) (amazon search)

Wed Dec 07 21:48:22 AEDT 2016 From /weblog/design

work with legacy

Simple ways to improve legacy code -

One approach to work with legacy code, instead of phrase by phrase or part by part, identify and improve the domain part first -[..]-efforts-to-replace-legacy-systems-fail/[..]egacy-applications-tests-modularization/

Note of common point for refactoring with legacy application -[..]/2016/10/unintentionally-obfuscated.html

(google search) (amazon search)

Tue Nov 29 03:12:57 AEDT 2016 From /weblog/design/interview


"They build their own infrastructure for performance, reliability, and cost control reasons. By building it themselves they never have to say Amazon went down because it was company X's fault. Their software may not be more reliable than others, but they can fix, debug, and deployment much quicker than when working with a 3rd party."

Shel Kaphan -

(google search) (amazon search)

Tue Nov 15 13:53:50 AEDT 2016 From /weblog/design

value object

Discussion of DTO -

Discussion of value object -

(google search) (amazon search)

Wed Nov 02 19:14:20 AEDT 2016 From /weblog/design/pattern


understanding-retry-pattern-with-exponential-back-off-and-circuit-breaker-pattern -[..]al-back-off-and-circuit-breaker-pattern/

(google search) (amazon search)

Wed Nov 02 19:13:31 AEDT 2016 From /weblog/design


10-ways-to-reduce-lock-contention-in-threaded-programs -[..]ce-lock-contention-in-threaded-programs/

Discussion about lock the form and prevent 2 user edit it in the same time and currupt the object, what is the possible drawback. -[..]-optimistic-locking-isnt-a-silver-bullet

futexes -[..]ds/browse_thread/thread/3c3608a779dc6731

Spinning -[..]ome/lock-free-algorithms/tricks/spinning

Locks for rarely changed data, sound like good suggestion -[..]pic/comp.programming.threads/dyrbRKsj4gw

Try to use non-blocking approach if possible -[..]1/locks-condition-variables-latency.html

Concurrency without lock, and even without correctness? -

Single write principle -[..].au/2011/09/single-writer-principle.html

Comparing difference kind of locks again -[..]11/stampedlocktryoptimisticread-and.html

10-ways-to-reduce-lock-contention-in-threaded-programs -[..]ce-lock-contention-in-threaded-programs/

(google search) (amazon search)

Sun Oct 16 04:52:15 AEDT 2016 From /weblog/design/interview


How yahoo use Hadoop for machine learning -

(google search) (amazon search)

Tue Sep 13 02:10:46 AEST 2016 From /weblog/design


*Do not use locks in the main transaction flow because they cause context switches, and therefore latency and unpredictable jitter.
*Never have more threads that need to run than you have cores available.
*Set affinity of threads to cores, or at least sockets, to avoid cache pollution by avoiding migration. This is particularly important when on a server class machine having multiple sockets because of the NUMA effect.
*Ensure uncontested access to any resource respecting the Single Writer Principle so that the likes of biased locking can be your friend.
*Keep call stacks reasonably small. Still more work to do here. If you are crazy enough to use Spring, then check out your call stacks to see what I mean! The garbage collector has to walk them finding reachable objects.
*Do not use finalizers.
*Keep garbage generation to modest levels. This applies to most JVMs but is likely not an issue for Zing.
*Ensure no disk IO on the main flow.
*Do a proper warm-up before beginning to measure.
*Do all the appropriate OS tunings for low-latency systems that are way beyond this blog. For example turn off C-States power management in the BIOS and watch out for RHEL 6 as it turns it back on without telling you!
*Macro-benchmarking is much more valuable than micro-benchmarking.
*Amazing results are achieved by truly agile companies, staffed by talented individuals, who are empowered to make things happen. Make sh*t happen is more important than following a process.[..]ughput-by-32x-and-reduce-latency-by.html[..]rything-you-know-about-latency-is-wrong/

How to monitor -[..]siness-value-from-performance-monitoring

How to measure latency -[..]/07/20/Latency-for-a-set-Throughput.html

Various cause of latency, and the solution -[..]Topics-in-High-Performance-Messaging.htm

(google search) (amazon search)

Fri Sep 09 18:00:46 AEST 2016 From /weblog/design/examples


How QQ deliver hotfix at Android -

(google search) (amazon search)

Wed Aug 17 02:06:59 AEST 2016 From /weblog/design/examples


How linkedin handle logs -[..]ould-know-about-real-time-datas-unifying

(google search) (amazon search)