Have you ever worked with pipelines in Laravel?!

Probably you have heard it while having an interview?

It has lots of use cases and one of its usage is middleware implementation in its kernel.

I'm going to write about pipelines and its design pattern.

thread 🧵

1/8

First of all Pipelines in Laravel are implemented based on chain of responsibility design pattern.

In chain of responsibility which is a behavioral design pattern we pass data to receivers and this receivers implement a specific interface that has a handler method.
2/8

Handler methods may deal with the passed argument and pass it to the next handler.

read more about the design pattern here :

https://t.co/XrJKXecyTv

Let's go for the main part :
3/8

Imagine we want to implement a twitter bot that gets some tweets around the trends and filter the words that we don't wanna show finally send as a new tweet from our bot.

About the filtering part, if it was me, I would implement it with pipelines.

Why?!
4/8

Currently I know exactly what words should be filtered but what about the future?! What if I want to add more filters, I will have to modify the source code and add more switch, if else statements, etc.

I want my code to be robust and maintainable keeping SOLID principles.
5/8

So I'm gonna use pipeline like this (picture) :

First I will have my initial filters and also give the ability to myself or other developers to add more filters without even seeing the code.

See the picture and lets go deeper and check the main interface and pipelines 😎
6/8

I have defined a contract for all of my filters, every new filter and existing filters must implement this interface and implement the filter method

As you can see in the previous picture we gave our method name "filter" passed to via()

Nothing more let's go for filters
7/8

This is one of the filters we have implemented as you can see everything is clear filter method gets an argument called $content which is the text we wanna filter and when we modify the content and remove bad words it calls the next receiver from pipelines filters we defined
8/8

That's it all.
This is the pipeline design pattern we have in Laravel.

As you can see there are a lot of advantages using this design pattern having SOLID standards.

But sometimes it's better to keep things simple when our program is not that big and you are alone...

More from For later read

Today's Twitter threads (a Twitter thread).

Inside: Planet Money on HP's myriad ripoffs; Strength in numbers; and more!

Archived at: https://t.co/esjoT3u5Gr

#Pluralistic

1/


On Feb 22, I'm delivering a keynote address for the NISO Plus conference, "The day of the comet: what trustbusting means for digital manipulation."

https://t.co/Z84xicXhGg

2/


Planet Money on HP's myriad ripoffs: Ink-stained wretches of the world, unite!

https://t.co/k5ASdVUrC2

3/


Strength in numbers: The crisis in accounting.

https://t.co/DjfAfHWpNN

4/


#15yrsago Bad Samaritan family won’t return found expensive camera https://t.co/Rn9E5R1gtV

#10yrsago What does Libyan revolution mean for https://t.co/Jz28qHVhrV? https://t.co/dN1e4MxU4r

5/

You May Also Like

I just finished Eric Adler's The Battle of the Classics, and wanted to say something about Joel Christiansen's review linked below. I am not sure what motivates the review (I speculate a bit below), but it gives a very misleading impression of the book. 1/x


The meat of the criticism is that the history Adler gives is insufficiently critical. Adler describes a few figures who had a great influence on how the modern US university was formed. It's certainly critical: it focuses on the social Darwinism of these figures. 2/x

Other insinuations and suggestions in the review seem wildly off the mark, distorted, or inappropriate-- for example, that the book is clickbaity (it is scholarly) or conservative (hardly) or connected to the events at the Capitol (give me a break). 3/x

The core question: in what sense is classics inherently racist? Classics is old. On Adler's account, it begins in ancient Rome and is revived in the Renaissance. Slavery (Christiansen's primary concern) is also very old. Let's say classics is an education for slaveowners. 4/x

It's worth remembering that literacy itself is elite throughout most of this history. Literacy is, then, also the education of slaveowners. We can honor oral and musical traditions without denying that literacy is, generally, good. 5/x
A THREAD ON @SarangSood

Decoded his way of analysis/logics for everyone to easily understand.

Have covered:
1. Analysis of volatility, how to foresee/signs.
2. Workbook
3. When to sell options
4. Diff category of days
5. How movement of option prices tell us what will happen

1. Keeps following volatility super closely.

Makes 7-8 different strategies to give him a sense of what's going on.

Whichever gives highest profit he trades in.


2. Theta falls when market moves.
Falls where market is headed towards not on our original position.


3. If you're an options seller then sell only when volatility is dropping, there is a high probability of you making the right trade and getting profit as a result

He believes in a market operator, if market mover sells volatility Sarang Sir joins him.


4. Theta decay vs Fall in vega

Sell when Vega is falling rather than for theta decay. You won't be trapped and higher probability of making profit.
1/“What would need to be true for you to….X”

Why is this the most powerful question you can ask when attempting to reach an agreement with another human being or organization?

A thread, co-written by @deanmbrody:


2/ First, “X” could be lots of things. Examples: What would need to be true for you to

- “Feel it's in our best interest for me to be CMO"
- “Feel that we’re in a good place as a company”
- “Feel that we’re on the same page”
- “Feel that we both got what we wanted from this deal

3/ Normally, we aren’t that direct. Example from startup/VC land:

Founders leave VC meetings thinking that every VC will invest, but they rarely do.

Worse over, the founders don’t know what they need to do in order to be fundable.

4/ So why should you ask the magic Q?

To get clarity.

You want to know where you stand, and what it takes to get what you want in a way that also gets them what they want.

It also holds them (mentally) accountable once the thing they need becomes true.

5/ Staying in the context of soliciting investors, the question is “what would need to be true for you to want to invest (or partner with us on this journey, etc)?”

Multiple responses to this question are likely to deliver a positive result.