Image for post
Image for post
Photo by Arteum.ro on Unsplash

Learning about JVM Garbage Collection and the mechanics behind each of the Collector Algorithms is as important as learning Java language features. High-level details of the algorithms give a perspective about the lifecycle of objects, the probable failures (like an out-of-memory exception, memory leaks etc.,) and how the failures can be averted.

Garbage Collection

Garbage Collection (GC) is a form of automatic memory management. The basic operations of any Garbage Collector are

  • Object memory allocation
  • Find objects that are in use starting from GC roots — Mark
  • Free objects that are not in use — Sweep
  • Compact the memory to prevent memory fragmentation —…

Image for post
Image for post
Photo by Taylor Franz on Unsplash

“Effective Java by Joshua Bloch” is a must read book for every Java programmer. Even the table of content is worth reading and remembering.

Classes and Interfaces

  • Minimize the accessibility of classes and members
    * In public classes, never expose mutable fields. Use accessor and mutator methods, instead.
    * In package-private classes, nothing inherently wrong with exposing its mutable or immutable fields
  • Minimize mutability
    Why to create Immutable objects?
    * Immutable objects are simple
    * They are inherently thread-safe
    * They can be shared freely
    How to make a class immutable? …

Reactivity is a programming paradigm that allows us to adjust to changes in a declarative manner.

Image for post
Image for post
Photo by Kyle Hinkson on Unsplash

JavaScript variables are not reactive by default. JS Proxy provide the mechanism to achieve the reactiveness. Vue 3 adds the necessary abstraction on JS Proxy and makes it native and simple. Vue 3 Reactivity package is available as a standalone package.

reactive and ref converts the regular values to reactive variables.

computed and effect are high-order functions which are executed when the values in the reactive variables change.

  • ref — Takes an inner value and returns a reactive and mutable ref object. The ref object has a single property .value

Image for post
Image for post
Photo by Patrick Fore on Unsplash

Object-Oriented Design (OOD)

  • Every application is a collection of code; the code’s arrangement is the design. Design is thus an art, the art of arranging code
  • Object-oriented applications are made up of objects and the messages that pass between them
  • Class provides the blueprint for the construction of similar objects. A class defines methods (definitions of behavior) and attributes (definition of variables)

🙇 Practical Object-Oriented Design in Ruby by Sandi Metz

The purpose of the design is to allow you to design later and its primary goal is to reduce the cost of change

Practical design does not anticipate what will happen to your…


Image for post
Image for post
Photo by freestocks on Unsplash

Vue implements a content distribution API inspired by the Web Components spec draft, using the <slot> element to serve as distribution outlets for content.

Slots

  • Slot Content — Content written within parent template. This content will get rendered in the allotted placeholder of the child template
  • Compilation Scope — Everything in the parent template is compiled in parent scope; everything in the child template is compiled in the child scope.
  • Fallback Content — Content provided by the child template. If parent template does not provide explicit content, then whatever is written within child template will be rendered.
  • Named Slots — There could be multiple slots within client template. To uniquely identify them, we need to provide value to the name attribute. …

Image for post
Image for post
Photo by K8 on Unsplash

“The more layers you peel away, the more you cry” by saghul 😆

Vue JS is simple but powerful library + framework. JavaScript developer could improve their skills by decoding the Vue code base. Vue anatomy blog is my attempt to decode.

Vue goes through four phases

  1. init — includes initialization, beforeCreate and created lifecycle hooks
  2. compile — convert template to internal functions
  3. render — returns a virtual DOM node
  4. patch — Compares the virutal DOM with last virtual DOM and renders the delta in your browser DOM

When we prefer to do quick prototype, we include Vue library (full build — runtime + compile) directly in html file. The downside of this approach is compile phase will be executed every time. …


2 minutes read version of the book “97 Things Every Programmer Should Know”. This book is a decade old one, but most of the points published are relevant even today. My version of “SHOULD KNOW”

Image for post
Image for post
Mind map of the book

Learning, Skills and Expertise

  • Continuous learning
  • Don’t just learn the language, understand its culture
  • Read code. Look for brilliant and readable open source projects
  • Reinvent the wheel often. Important to a developer’s education and skill
  • Know well more than two programming languages

Domain Thinking

  • Code in the language of the domain
    * As your understanding of the domain grows, domain model evolves
    * Prefer domain-specific type to primitive…

Transaction T1 reads x, and then a second transaction T2 updates x and y to new values and commits . If now T1 reads y, it may see an inconsistent state, and therefore produce an inconsistent state as output.

r1[x]…w2[x]…w2[y]…c2…r1[y]…(c1 or a1)

💡 How to read the shorthand notations? w means write, r means read, number(1 or 2) indicates transaction id, c means commit and a means abort/rollback

Example

Image for post
Image for post
Read Skew occurs in “READ COMMITTED” isolation level in Oracle
Image for post
Image for post
Read Skew does not occur in “SERIALIZABLE” isolation level in Oracle

Read skew is avoided in Oracle DB, provided there is a parent-child relationship between the tables which were read at different point-in-time.

💡Serializable isolation level in Oracle is actually a “Snapshot Isolation”

Transaction 1

Transaction 2


Transaction T1 reads a data item and then T2 updates the data item (possibly based on a previous read), then T1 (based on its earlier read value) updates the data item and commits

r1[x]…w2[x]…w1[x]…c1

💡 How to read the shorthand notations? w means write, r means read, number(1 or 2) indicates transaction id, c means commit and a means abort/rollback

Example:

Transaction 1

  • Read the price of “product b”
  • Increment the price by 10% — Assume some logic has been applied to the fetched data
  • Update the price of “product b”

Transaction 2

  • Updates the price of “product b” by 100%
Image for post
Image for post
Lost update occurs in “READ COMMITTED” isolation level in Oracle
Image for post
Image for post
Lost update does not occur in “SERIALIZABLE” isolation level in Oracle

💡Serializable isolation level in Oracle is actually a “Snapshot Isolation”

Transaction 1

Transaction 2


Transaction T1 reads a set of data items satisfying some <search condition>. Transaction T2 then creates data items that satisfy T1 ’s <search condition> and commits. If T1 then repeats its read with the same <search condition>, it gets a set of data items different from the first read.

r1[P]…w2[y in P]…c2…r1[P]…c1

Image for post
Image for post
Phantom read occurs in “READ COMMITTED” isolation level in Oracle
Image for post
Image for post
Phantom read does not occur in “SERIALIZABLE” isolation level in Oracle

💡Serializable isolation level in Oracle is actually a “Snapshot Isolation”

Transaction 1

Transaction 2

About

Prasad Jayakumar

Learner, Mentor, Developer and an Architect

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store