February 27, 2018

Naming Conventions

Naming conventions

An Abstraction name encodes the meaning & context of the abstraction. The name consists of tags that are joined together to create a name.

Naming Convention (programming) (Wikipedia)

Discoverability & Unique vs Ambiguous Names

A name & tags in the name also acts identifiers to locate the usages of the abstraction in the codebase. This attribute is also known as discoverability.

Discoverability (Wikipedia)

Unique & Accurate names for abstractions help discoverability. Ambiguous names hurt discoverability.

Advantages for discoverable abstractions include:

  • easy searching for an abstraction used across the codebase
  • easier refactoring (e.g. a rename refactoring is a search/replace)
  • provides a more comprehensive & accurate model of the system in one's head

Ambiguous name Example — id

id fields with context are a good candidate to combine into a single tag.

Note that it's advantageous to name a field user.user_id instead of user.id because the abstraction user_id can be located though a search wherever it is used. The convention held by ActiveRecord in Ruby on Rails makes it difficult to find usages of the user_id abstraction, particularly when it is used in objects. In the user object, user_id is named id, which is ambiguous with all the other *_id fields used in all of the other relations. For reason of unambiguous distinction, it is advantageous to always use the same form for user_id.

Top-down & Bottom-up Design

Top-down and bottom-up design (Wikipedia)

One can communicate & gain design feedback on a system design by thinking in terms of top-down & bottom-up design. The typical naming convention in software systems is to have a top-down convention where the leftmost part of the name is the most global, becoming more local when moving rightward.

One can also think bottom-up by moving from the right to the left in a name. Thinking both top-down & bottom-up is often a useful exercise in understanding & discerning the naming of an abstraction.

Underscore_casing

Underscore casing separates each word in a tag with an underscore _. Underscores are also used to separate tags when multiple tags are combined to form a name.

CamelCasing

Camel casing is often used for variable & class names. While that works to identify a name tag, there are ambiguities when composing multiple tags together to form a name.

For example, the casing may be changed.

const btoaEncodeURIComponentUserJson = btoa(encodeURIComponent(JSON.stringify(user)))

Composing a camelCased tag with underscores removes this ambiguity:

const btoa_encodeURIComponent_user_json = btoa(encodeURIComponent(JSON.stringify(user)))

Double__Underscore__Casing (__)

Double Underscores are used to aggregate a new chain of tags.

Bottom-up naming

If the typical use case is top-down naming (global_context_mid_context_local), to achieve bottom-up naming, one could use __ to join each tag (local__mid_context__global_context).

Event Handler Names - __click as shorthand for onclick

A name that begins with __ can be though of as an unassigned local tag followed by contextual tags. This technique can be used to name event handlers.

Context Object Names - __user as shorthand for ctx__user

At times, it may be useful to have a ctx object representing a group of abstractions related to a certain tag.

const __user =
        { user_name: 'Joe',
          user_id: 44,
          user: {user_id: 44, user_name: 'Joe'},
          user_orders_transactions:
            [ { order_transaction_id: 99,
                order_id: 54}]}

Alternate names - user__

If a name is already used within a scope, it may be useful to define an alternate name. This is useful when a function takes an abstraction, clones it, & returns a new version of the abstraction.

async function refresh_user(user) {
  const {user_id} = user
      , response = await fetch_user(user_id)
      , user__ = await response.json()
  return user__
}

Factory Functions $sales_report

Factory functions are prefixed with a $, with the name of the created abstraction following.

const sales_report = $sales_report()

This technique may be useful in breaking down a function into component parts using scoping. In the following example, these queries are run in parallel using async/await & Promise.all.

Note that in this example, bottom-up naming is used to highlight that results is the type of the abstraction, with the rest of the name being context named top-down.

async function $sales_report() {
  const [ results__sales_aggregate_query
        , results__sales_regions_query
        , results__sales_forecast_query
        ] = await Promise.all([
          $results__sales_aggregate_query(),
          $results__sales_regions_query(),
          $results__sales_forecast_query()
        ])
  return {
    results__sales_aggregate_query,
    results__sales_regions_query,
    results__sales_forecast_query
  }
  async function $results__sales_aggregate_query() {
    // ...
  }
  async function $results__sales_regions_query() {
    // ...
  }
  async function $results__sales_forecast_query() {
    // ...
  }
}
Full post…

July 22, 2017

Svelte JS from Pug

Now it's time to implement server side rendering (SSR) using SvelteJS.

On my current project, I will be migrating from pug to sveltejs. The key concepts are Server Side Rendering, Hydration, & client/server architectural options.

Full post…

July 03, 2017

Svelte JS from Riot JS

Creating Web Components/Web Apps has never been more pleasurable. It's out with the old & in with the new. I converted my client's project to use Svelte JS from Riot JS. This post highlights some considerations why I chose Svelte & a a sample web component using Svelte.

Full post…

June 11, 2017

When We become a Muse to Our Tools

What happens when we become a muse to our tools?

When YouTube suggests videos that cater to your proclivities, what you see in your feed will be a reflection on your conscious attention domain.

Would the nature of modern conscious enlightenment be a sort of leveling-up administered by machine learning algorithms?

Would we be better off if we consciously create & choose our tools? When would it make sense to take what is easily given with all of the consequences? When would it make sense to create a tool that purely fulfills a need without unwanted attachments?

Some "it depends" questions to consider…

Full post…

June 10, 2017

Trump: United States Sovereignty & the United Nations

There are many in the UN & global corporate/finance that seek a carbon tax. It's not going to happen but that's not due to a lack of effort. This is why Trump pulled the US out of the multi-lateral Paris accord. The US was under energy sanctions & the US gave away money to "developing" economies such as China & India. This was a form of sovereign wealth transfer guided by global governance. Fortunately it was voluntary & Trump acted correctly in pulling out of the accord, though the UN is suing to keep the US locked in. Effectively, this is using international trade law to impose governance upon the US.

Full post…

June 07, 2017

Monorepo Static Sites using Svelte JS, Rollup, ctx-core, & Bash

BrianTakita.com is now built using a technology chain consisting of SvelteJS, RollupJS, ctx-core, & good ol' Bash.

You can see the source in the btakita.github.io repo.

Full post…

February 25, 2016

Monorepo Musings with ctx-core

It's been about 2 years since my previous post here. I've been busy working on a few client projects. As a consultant, I'm naturally inclined to accumulate a toolkit of tech (technology & techniques). In the domain of technology, where all levels of the solution stack are subject to change, keeping a toolkit while moving from project to project is a challenge.

Full post…

January 17, 2015

Feeling Abstraction

From http://haiphonghoaphuongdo.blogspot.com/2011/07/colorful-vector-abstraction.html - http://2.bp.blogspot.com/-_t6mHvuNOTs/Th23RDI-RgI/AAAAAAAAAL0/T_VMdr6wIcY/s1600/abstract-vector-free-art.jpg - Licensed under Creative Commons

Reductionist mechanisms in Physical Existence are Energy & Energy Transfer. We are all physically made of Energy.

Feeling an abstract notion such as Energy Transfer may seem tricky; however, it's simply connection.

A trick to feeling abstract terms is connect to something more familiar, such as a physical sensation.

Full post…

January 03, 2015

Do Not Worry, Everything Exists

From Wikipedia http://en.wikipedia.org/wiki/File:Creaci%C3%B3n_de_Ad%C3%A1m.jpg - Licensed under Creative Commons

Does God exist? Surely, Santa Claus & Unicorns do not exist. Yet we are talking about them. If they don't exist, why & how am I talking about them?

Santa Claus & Unicorns do exist, as fictional characters; more on God later. Everything Exists. The concept conceptually exists. It may also physically exist; like the men who name themselves Santa Claus.

Full post…

December 19, 2014

Why Say History When You Can Say Story?

From http://www.flickr.com/photos/bostontx/4461314652/ - Licensed under Creative Commons

In culture, we are taught to distinguish history & story as two separate concepts. Some (falsely) think of history being a masculine version of story (his story). However, history & story can be used interchangeably. Here's why.

Story

Story, a recounting of a sequence of events

Our culture distinguishes a story as being used for entertainment and fiction. Our culture also uses story for an informal narrative for people, animals, etc.

History

History (from Greek ἱστορία, historia, meaning "inquiry, knowledge acquired by investigation") is the study of the past, particularly how it relates to humans. It is an umbrella term that relates to past events as well as the memory, discovery, collection, organization, presentation, and interpretation of information about these events. Scholars who write about history are called historians. Events occurring prior to written record are considered prehistory.

History can also refer to the academic discipline which uses a narrative to examine and analyse a sequence of past events, and objectively determine the patterns of cause and effect that determine them.

Our culture says History is the recorded narrative of the sequence of Human events. However, we've heard the usages: The history of human civilization; The history of Mars; The history of the Universe; The history of Middle Earth. The vernacular has expanded the definition of history to include all of time and fiction worlds.

Biographies & Autobiographies are also considered history.

Story & History can be used Interchangeably

We already can use story in place of history since both are a recounting of a "sequence of events".

History can also be used in place of story since the vernacular usage of history includes fiction worlds, geological events, & physical events.

The defining line is blurred. Story & History can be used Interchangeably. The usages of Story & History are connected. Enjoy the connection.

Full post…

December 09, 2014

Magic Connections with the Philosophy of Language

From http://casiestewart.com/unicornrainbow/ - https://lh4.googleusercontent.com/-ylo97AfxI9c/SuW-sv-oDII/AAAAAAAAGxc/tVIc_fh1A9A/s2048/unicorn.jpg - Licensed under Creative Commons

Magic exists! Well, if you have listened to me lately, you will hear that everything exists (including fiction). When everything exists, we can recapture the entirety of language from those who impose restrictions on Existence. We have all heard "that does not exist". We can now say, "that" does exist & "that" is a useful concept.

I'm happy to see my own homespun approach have a strong connection to an established Philosophical branch. The Philosophy of Language (Wikipedia) brings concepts together into a system of logic to yield magical & insightful connections in Existence.

Full post…

September 14, 2013

Fast and Thorough Testing with Jasmine Flow

Automated testing helps to ensure that your software does not have regressions as you make changes. These changes include refactorings, new features, bug fixes, etc. A Software product has an intricate set of behavior which includes a large number of edge cases.

I'm a fan of black box testing, because it is decoupled from the implementation. The implication is the what is verified, rather than the how.

Full post…

September 14, 2013

Automated Black Box Testing

Automated testing encourages your software to behave a certain way going forward into the future.

When you write tests against your user facing requirements (black box and acceptance tests), you locking down how your app acts.

When you use automated tests for white box testing (unit tests), you lock down how your software is designed.

Full post…

September 08, 2013

"Re: Doing Good in the Addiction Economy"

From my wordpress blog

Doing Good in the Addiction Economy

Interesting but long winded post, IMO. But then, maybe my impatience toward long posts is telling in the short term rewards culture we live in. Of course time is valuable, and trying to get to the core concept of some the writing is often the goal. We don’t seem to savor the journey as much, or the journey has changed to be our lives toward success…

Full post…

September 07, 2013

There is no privacy! Control your internet face

Brian Takita - Peeping Tom - Created by tuchodi under the Creative Commons License - http://www.flickr.com/photos/tuchodi/4959060

With all of the revelations over how the NSA is snooping over your personal communications, companies storing and controlling your data, encryption backdoors and the fact that it's always crackable, one thing is becoming clear.

Full post…

September 07, 2013

Fractal Therapy

Existence (Universe & nature) evolves as fractals over time and space. If you aren't familiar, here's a 55 minute documentary. It's worth watching.

Full post…

September 07, 2013

backbone-signal - Practical Reactive Programming in Javascript

From Parthiv Haldipur http://www.flickr.com/photos/hmmmmm/3903176411/ - Licensed under Creative Commons

I have recently released backbone-signal (github.com), which is a reactive programming (Wikipedia) library with a practical & javascripty model api.

Full post…

September 04, 2013

Github Pages Custom DNS Gotcha

I set up briantakita.com using Github Pages & metalsmith. Overall, it took some effort to setup & learn, but it turned out to be fairly painless. In this aritcle, I talk about setting up the DNS to point briantakita.com to btakita.github.io.

Full post…

September 04, 2013

DIY SEO with BrandYourself.com

The wonderful web makes it very easy for someone to publish their thoughts and opinions, good and bad, true and false. If you find yourself at the wrong end of a post that shows up in your Google results, the implications can be very damaging. It ceases to be a matter of truth, but a matter of marketing.

Fortunately, you can take control over your name on the web, without having to spend thousands of dollars that online reputation repair firms charge.

Full post…