Bible, Lee, Data
Isaac S. Lee
A developer who has to know why
I like finding something I don't understand and working out why it behaves the way it does. This blog holds what I learn from software and data, and sometimes what I'm thinking about beyond it.
Engineering
How Does Java Decide Which Method to Call?
Java allows several methods to share the same name.A class can provide different methods for different parameter types, and a subclass can replace an inherited method with its own implementation. The first feature is called overloading. The second is called overriding.They are often introduced with two simple definitions:Overloading means using the same method name with different parameter lists..
Engineering
What Problems Do Design Patterns Actually Solve?
When design patterns are first introduced, they often appear as a list of names to memorize.Creational patternsFactory Method, Abstract Factory, Builder, Prototype, SingletonStructural patternsAdapter, Bridge, Composite, Decorator, Facade, Flyweight, ProxyBehavioral patternsChain of Responsibility, Command, Interpreter, Iterator,Mediator, Memento, Observer, State, Strategy,Template Method, Visit..
Database
How to Read SQL Execution Plans with EXPLAIN
When a SQL query is slow, the first instinct is often to add an index.That may solve the problem, but it may also miss the real cause. The query might already have a usable index that the optimizer decided not to use. The join order may be inefficient, the optimizer may have estimated the wrong number of rows, or the database may be sorting a large intermediate result.Consider the following quer..
Database
How Subqueries and CTEs Work in SQL
As SQL queries become more complex, a single table is often not enough to produce the result we need.Suppose we want to answer the following question:Which orders have a total amount greater than the average order amount?Before identifying those orders, the database must first calculate the average.SELECT AVG(total_amount)FROM orders;It must then compare each order with that value.SQL allows us ..
Database
Database Indexes and SQL Execution Plans
Suppose we have the following orders table:CREATE TABLE orders ( order_id BIGINT PRIMARY KEY, customer_id BIGINT NOT NULL, order_status VARCHAR(20) NOT NULL, ordered_at DATETIME NOT NULL, total_amount BIGINT NOT NULL);When the table contains only a few hundred rows, the following query returns almost immediately:SELECT *FROM ordersWHERE customer_id = 1001;The situation changes whe..