The Power of Micro-Philosophy in Software Development
Tags: softwareengineering, philosophy, programming, development
Published: 2023-07-26 12:26:43

I am convinced that the best way to develop a computer program is by applying the "micro-philosophy".

In this article, I'll briefly talk about:
- GNU
- TailwindCSS
- Refactoring
  - Trunk Based Development
- Clean Code and The Pragmatic Programmer

And I will demonstrate how this approach is present in each one of these _entities_.

The **micro-philosophy** is a method that breaks down big challenges into micro tasks, simplifying problem-solving.

> "Slowly, we get to where we want to get" - ExaltaSamba

## [GNU](https://en.wikipedia.org/wiki/GNU)
![GNU](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02bplfnlpns392ehiluk.png)
I am not an expert on the history of Unix, GNU, and Linux.

But, what I understand is that:

- Unix was an Operating System written in C
  - Launched in 1971
  - It worked on various processors and architectures
    - Something rare at the time
  - It was from a private company and sold commercially.
- GNU is a free code project/movement.
  - It was initiated in 1984
  - Its initial goal was to build an Operating System
    - Completely free
    - With open code. 
  - It had various mini-programs that performed various functions of an operating system
  - It was almost ready in 1992, only the _kernel_ (main module) was missing to combine them.
- Linux is actually an abbreviation for _GNU/Linux_.
  - In 1992, [Linus Torvalds](https://en.wikipedia.org/wiki/Linus_Torvalds) created a _kernel_ that used all the subprograms of GNU
  - With this, he created the first distribution of the _GNU/Linux_ operating system.

In a **very** abbreviated way, now you understand what GNU is.

Okay, what does this have to do with _micro_? Well... Let's go there.

GNU/Linux is the personification of the Free Software philosophy, which advocates for collaborative and open-source development. Its principles are:

- _Copyleft_
  - The opposite of _copyright_ (copyright)
  - It ensures that any and all changes made in the software are "free from copyright".
- Transparency
  - All code and documentation are open and available to everyone.
- Collaboration
  - It believes in the collaborative power of developers united by a common goal.
- **Simplicity**: The GNU packages are examples of _micro_-programs that solve a single problem.

GNU encourages and defends the **micro-philosophy**! 

The movement saw the operating system as a collection of _small_ programs that do only one thing but do it very well!

Some of the programs that are part of the GNU package are:
- [ls | cat | cp | mv | rm | wc](https://www.gnu.org/software/coreutils/manual/coreutils.html)
- Bash (The default Terminal of almost all GNU/Linux _distros_)
- Nano (Text editor present in all GNU/Linux _distros_)

One of the best things about using Linux, or some _unix-based_ operating system (Hi Mac OS) is being able to create combinations of programs to perform some task.

This is possible through the "pipe (|)" command, for example, if you want to generate a rank of most used words, you can use:

```
cat file.txt | tr ' ' '\n' | sort | uniq -c | sort -nr | head -10
```

There isn't a specific program that does this, but it is possible to carry out this task by combining the commands: [cat](https://www.gnu.org/software/coreutils/manual/coreutils.html#cat-invocation), [tr](https://www.gnu.org/software/coreutils/manual/coreutils.html#tr-invocation), [sort](https://www.gnu.org/software/coreutils/manual/coreutils.html#sort-invocation), [uniq](https://www.gnu.org/software/coreutils/manual/coreutils.html#uniq-invocation), and [head](https://www.gnu.org/software/coreutils/manual/coreutils.html#index-head).

## TailwindCSS
TailwindCSS has revolutionized the way I use CSS.

It is a CSS framework that calls itself [_utility first_](https://tailwindcss.com/docs/utility-first).

Unlike other CSS frameworks such as _Bootstrap_, _MaterialUI_, and _ChakraUI_, _TailwindCSS_ **has no complete components**.

It is nothing more than a set of **micro-classes** of CSS, where each class **applies only one style**.

Although it may seem contradictory, working with tiny classes provides a lot of flexibility, power, and stimulates creativity.

These classes are shortcuts to styles that have already been written countless times on millions of websites on the web, in addition to having dynamic classes (like p and m) and accepting fixed parameters, ex: h-[300px].

![Padding Section in the Tailwind documentation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8mxkbns96zup0wh09foz.png)

Just like GNU, Tailwind also believes in the **power** of the micro-philosophy for problem-solving.

## Refactoring

![Refactoring book by Martin Fowler](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6b0gwh15574knha8gjow.jpg)
Recently, I have been reading the book [Refactoring](https://www.amazon.com/Refactoring-Improving-Existing-Addison-Wesley-Signature/dp/0134757599) by Martin Fowler. In it, several strategies and techniques to improve code are addressed. 

According to the author, refactoring is a controlled technique to improve the design of an existing code.

> It's a disciplined way to clean up code that minimizes the chances of introducing bugs.

The refactoring process according to Martin Fowler involves:

- Making _small_ changes that do not alter the code's behavior.
- Taking small steps, to make fewer mistakes.
- Running builds and tests with each new change, only updating if it is working.

By doing this, you ensure that the code is always functional and, little by little, it gets better.

The book also comes with 70 code improvement techniques.

Big refactorings are done taking advantage of the **power** of the **micro-philosophy** applied to code improvement.

According to Martin, the quickest way to solve a problem or improve a project is to solve small sequential micro-problems that, combined, solve a giant problem.

### Trunk Based Development
It's a project versioning strategy, focused on maintaining short-lived _branches_ and:

- Always merge to main
- Merge frequently (ideally once a day)
- Use Feature Flags to hide features that are not ready

This helps to avoid:
- Complex merge conflicts
- Commit-racing

The explanations for these two assumptions can be found in this SENSATIONAL [article](https://martinfowler.com/articles/branching-patterns.html#Trunk-basedDevelopment) by Martin Fowler.

Here, the _micro_ concept appears in advocating that _micro_ changes should be merged into the main project as quickly and frequently as possible.

With this, it becomes easier to:
- Review PR
- Resolve merge conflict
- Keep all branches updated

If you are able to maintain a strategy with short-lived _branches_.

## [Clean Code](https://www.amazon.com.br/C%25C3%25B3digo-limpo-Robert-C-Martin/dp/8576082675/ref=sr_1_1_sspa?__mk_pt_BR=%25C3%2585M%25C3%2585%25C5%25BD%25C3%2595%25C3%2591&amp;keywords=clean+code&amp;sr=8-1-spons&amp;sp_csd=d2lkZ2V0TmFtZT1zcF9hdGY&amp;psc=1&_encoding=UTF8&tag=codista-20&linkCode=ur2&linkId=5a42cf85455594d2b57676b39695d2b3&camp=1789&creative=9325) and [Pragmatic Programmer](https://www.amazon.com.br/Programador-Pragm%25C3%25A1tico-Aprendiz-Mestre/dp/8577807002/ref=sr_1_5?keywords=programador+pragmatico&amp;sr=8-5&amp;ufe=app_do%253Aamzn1.fos.6121c6c4-c969-43ae-92f7-cc248fc6181d&_encoding=UTF8&tag=codista-20&linkCode=ur2&linkId=5ef9b9be4e551373d735af38c034e83d&camp=1789&creative=9325)
Two great books about system development coding and a career as a programmer.

Both defend:
- Small functions
  - With descriptive names
- Readable code 
  - Understandable
  - Self-explanatory
  - Without comments
- Good Neighbourhood Policy 
  - Leave the code better than you found it
- Continuous refactoring
  - Never be afraid to change the code for the better, never!
  - Refactor to improve reading, understanding, or maintenance
- Unit tests
  - Common point in the 3 books
  - Facilitates maintenance (more security to change)
  - Facilitates understanding of business rules
  - Forces the creation of small and decoupled functions

## Micro-Philosophy
It is present in each of these _entities_ of programming.

It consists of breaking down large problems, daunting tasks, or complex features, into **micro**-tasks.

All authors assert that the true **speed** in software development 
 is tied to the practice of small, iterative, testable, and maintainable steps.

In my experience, adopting this approach has simplified complex problems and amplified safety in software development practices. 

Believe me, integrating micro-philosophy into your workflow could be a game-changer.

Thank you for reading, I would love to hear some of your thoughts on the comments section, have a nice day!