Thursday, December 3, 2020

A Recipe for Refactoring a Legacy Spring Application Codebase

 We’ve all faced the problem of an ever-growing code base that slowly loses structure. Classes that were once small start to inflate, lines of code grow from hundreds to thousands, components become tightly coupled, and the single responsibility principle erodes. For a fast growing R&D department, this technical debt becomes ever more important to address in order to scale.

A bit of background: Datorama is a marketing intelligence platform that transforms the way marketers optimize their marketing performance, business impact, and customer loyalty. Founded back in 2012, we started off with 3 engineers, and have doubled our engineering head count year over year ever since. This exponential growth has, of course, come with some scaling challenges, and one evident challenge is how to keep an ever-growing code base organized and easy to use. In terms of our tech stack, being a data company, big parts of our platform are written in Java, some of those are written in Spring and most of our engineers use IntelliJ as their IDE.

We have two main efforts. Splitting the code into modules and micro-services. Modules and then micro-service is a great track to do it. So recently I made some refactoring in our code base splitting a part of a service to its own maven module. This service I was working on is built in Spring.

The specific problem we were facing lately is that parts of our codebase became too tightly coupled in a single, monolithic Maven module. It was not uncommon to stumble upon really long files (+2000 lines of code), there was no separation of concerns, and no single responsibility. Such a tightly coupled codebase also creates a ripple of side effects:

  • Build time takes longer, since your entire code gets compiled even when changes in other classes are made, all because they’re in the same module. Don’t underestimate this, build time can take several minutes! (multiply by 10 it gets to ~1h per day!).
  • When tests break it’s harder to understand why because everything is in the same module.
  • Engineers become inefficient and unhappy because most of the time they get lost in those tough lines of code.
  • The code becomes increasingly harder to modify and test.

In this post, I’d like to present a technique we’ve started using in order to tackle the ever-increasing code complexity by applying massive refactoring in a structured process:

Step 1: Define the Problem In Detail

We start by selecting a product module that can be split out, e.g. that is not strongly linked to other modules and can “live” independently.
This is not an easy task and the key to success is the ability to visualize your code’s structure and identify independent clusters. For this, we start out by using the excellent IntelliJ plugin — Java Method Reference Diagram. This plugin allows you to visualize a single class, showing you relationships between methods, fields and other classes in a usage graph. Put in their words, it provides you with:

“visual information about orphaned groups, meaning independent clusters of methods and fields that are candidates for refactoring to separate classes”

More often then not, once you choose a candidate class you’ll notice that when you first use this plugin the diagram looks like hell.

Image for post
Class diagram with initializers, fields, methods, statics, interfaces, etc.

In order to simplify things and get better visibility, I’d suggest hiding all statics, members, interfaces and keep only methods. The reasoning for this is that statics can always be extracted to a shared classes and made public, while fields are usually dependency-injected with Spring’s @Autowired annotation, meaning they could also be injected elsewhere after we refactor.

Image for post
Class diagram with only methods.

Notice how the filtered diagram is cleaner than the original one, albeit still crowded. Now start looking for clusters which are candidates for extraction. This is the toughest step. Don’t underestimate it, be patient, the devil is in the details. Try stretching imaginary rectangles around blocks of interconnected methods with shared functionality:

Image for post
Examples of possible clusters.

Step 2: Structural Decomposition

Now that you have identified separated clusters, move them to their own services, that’s how we’ll solve all those issues stated in the beginning. We’ll achieve single responsibility and it will be much easier to modify and test this “new” code. A simple step-by-step here is:

  1. Create a new class, managed by Spring (annotated with @Service, @Component etc.)
  2. Move a cluster of methods as is from the original class to the new one.
  3. In the new class, resolve all dependencies of class members and static fields. You will most likely need to auto-wire services that were available in the original class.
  4. In the original class, auto-wire the new service class. Delegate all of the moved method calls to those methods in the new class, while changing methods in the new class to be public / protected.
  5. Find all usages in the code that were calling public methods in the original class and change them to call the same methods in the new class.
  6. Rinse and repeat.

If you really want to leverage your refactoring, after you’ve extracted your code, go over these steps again in your “new” code and see if there is room for more extractions. Your classes will become super neat and tidy.

Step 3: Identify Anti-Patterns:

I believe anti-patterns exist in every application codebase, some are hard to identify.

Explore your “new” code and take the effort to identify those anti-patterns.
For example in the code I extracted, I found some very long if/else blocks where each case in the block referenced to a specific type of action needed to be done. Here’s a simplified example:

Step 4: Replace with Design Patterns:

This code could be replaced with a very nice and clean design pattern called Command pattern.

From the link:

Command declares an interface for all commands, providing a simple execute() method which asks the Receiver of the command to carry out an operation. The Receiver has the knowledge of what to do to carry out the request. The Invoker holds a command and can get the Command to execute a request by calling the execute method. The Client creates ConcreteCommands and sets a Receiver for the command. The ConcreteCommand defines a binding between the action and the receiver. When the Invoker calls execute the ConcreteCommand will run one or more actions on the Receiver.

In our implementation of the command pattern, note how each concrete command implementation is defined as a Spring @Service. This will serve us later for auto-wiring these commands and build an enum map of them.

Action command implementation
Initialization of command classes using Spring
Image for post
Structure before refactoring
Image for post
Structure after refactoring

In conclusion, Identify your code candidate, extract it and improve its design. You’ll make your code more readable, maintainable, extendable and testable. On top of all of this, think that all this refactoring has relatively low risk since we’re just moving things around and keeping business logic untouched, it’s just the structure that changes.

Datorama Engineering

Building things the Datorama way

Thanks to Ilai Gilenberg and Raanan Raz. 

Tuesday, December 1, 2020

From Legacy to Dependency Injection

We’ve all encountered tightly-bound code, and our first instinct is to correct it. However, there are only so many hours in a sprint, and it’s not always convenient to go on a large refactoring spree when the backlog is filling up. With JustMock, you can still ensure the code works, and it will set you up for the cleaning that will take place at a later time.

The code I am about to show is rather simplistic, and it may not be much of a burden to refactor when encountered. The principles are the same in testing the code then refactoring to achieve higher quality.

Here is a simple action on an ASP.NET MVC controller:

public ActionResult Index()
{
    var repository = new BookRepository();
    var books = repository.GetAll();
    return View(books);
}

These three lines of code retrieves all books from a BookRepository and passes them to the view. Testing this controller action doesn’t appear to be very difficult:

[Fact]
public void Index_Should_Return_All_Books_To_View()
{
    BookController controller = new BookController();
    var result = (ViewResult)controller.Index();
    var books = (IEnumerable<BookModel>)result.Model;
    Assert.Equal(5, books.Count());
}

This test has a major problem: it must call all the way to the backing data storage. I have been in many organizations that attempt to get around this by creating a “test” database. This approach leads to even more issues. First, the lack of code isolation means it can be more time consuming to track down the cause of a bug. If this test doesn’t work, I will need to figure out if this code is broken, if the repository is broken, or if there’s bad code in another layer that isn’t immediately noticeable. Next, it takes more work to make sure side effects in the database do not affect unrelated. It can also be troublesome to maintain the data. Finally, testing through every layer of the application is slow. When the application grows large and the tests become more numerous, it becomes a chore to run them… and you might as well forget automating it on check-in.

Here’s how to use JustMock to isolate this unit of code without refactoring.

[Fact]
public void Index_Should_Return_All_Books_To_View()
{
    var repository = Mock.Create<BookRepository>();
     
    repository.Arrange(r => r.GetAll())
              .Returns(Enumerable.Repeat<BookModel>(new BookModel(), 5))
              .IgnoreInstance();
 
    BookController controller = new BookController();
    var result = (ViewResult)controller.Index();
    var books = (IEnumerable<BookModel>)result.Model;
    Assert.Equal(5, books.Count());
}

 The first step was to create a mock object of the BookRepository used in the controller action. There isn’t an interface for this class, so it’s a good thing that JustMock will mock a concrete class. Next, I arranged for the repository to return a sequence of books when the GetAll() method is called on it. I then used IgnoreInstance() so that every instance of BookRepository encountered in this test would be replaced with the mock object.

It was that easy, and you’re now in a position to refactor the code to support dependency injection with minimal changes to your test.

First, we should give the BookRepository an interface (you can cheat and use the Extract Interface refactoring).

public interface IBookRepository
{
    IEnumerable<BookModel> GetAll();
}

 Next, promote the repository variable to a field (Introduce Field refactoring) and change its type to IBookRepository. Create two constructors: one with no parameters and one with an IBookRepository parameter. Chain the default constructor to the one with a parameter, passing in new BookRepository. In the constructor with a parameter, set the field to the passed in value.

public class BookController : Controller
{
    private readonly IBookRepository repository;
 
    public BookController()
        this(new BookRepository())
    {
    }
 
    public BookController(IBookRepository repository)
    {
        this.repository = repository;
    }
 
    public ActionResult Index()
    {
        var books = repository.GetAll();
        return View(books);
    }
}

In the unit test, remove the call to IgnoreInstance() and pass the mocked repository into the BookController’s constructor.

[Fact]
public void Index_Should_Return_All_Books_To_View()
{
    var repository = Mock.Create<BookRepository>();
 
    repository.Arrange(r => r.GetAll())
              .Returns(Enumerable.Repeat<BookModel>(new BookModel(), 5));
 
    BookController controller = new BookController(repository);
    var result = (ViewResult)controller.Index();
    var books = (IEnumerable<BookModel>)result.Model;
    Assert.Equal(5, books.Count());
}

Conclusion

In this article, you learned how to mock objects without changing the code base. You also learned one of the easiest techniques for introducing dependency injection in your project while causing minimal changes to your existing tests. There’s a wide world of best practices for creating loosely coupled architectures that are conductive to unit testing. I hope this helps you get started… happy coding!

Friday, July 24, 2020

start with smile

A Priest, a Politician, and an Engineer are set to be executed by guillotine during the French Revolution.

The Executioner brings the Priest up first. He ask him if he'd like to lie facing down or facing up for his death. He responds that he would like to be facing up, so he can see the heavens while he's going to God. So the Executioner lays the Priest down in the guillotine facing up. He then releases ... 
 UPVOTE  DOWNVOTE  REPORT

My boyfriend keeps talking about overthrowing capitalism in a violent revolution

Could this be a red flag?
 UPVOTE  DOWNVOTE  REPORT

What did the bird planning revolution say?

Coup, coup!
 UPVOTE  DOWNVOTE  REPORT
ADVERTISING

This joke may contain profanity. 🤔

An American spy is in Soviet Russia, digging up information on a powerful Russian politician. He finds him in a bar, walks in dressed in Russian attire, pretending to be Russian. Everybody in the bar looks at him, but he keeps his cool. He orders a drink and walks to the politician...

"Greetings, comrade." says the spy, but before he could finish his sentence, the Russian says, "I think you are American spy."

The spy is alarmed, but being a skilled, trained, spy, he says, "That is not true! I am the proudest Soviet there is! I can sing the anthem more beautifully than any ... 

The three most arguably important historical revolutions:

The Russian, the French, and dance dance
 UPVOTE  DOWNVOTE  REPORT

What happened in the Industrial Revolution?

Minor miners.
 UPVOTE  DOWNVOTE  REPORT

I started a revolution once.

But I got dizzy, so i stopped.
 UPVOTE  DOWNVOTE  REPORT

Three inmates are on the train to the gulag.

One of them decides to start a conversation.
“So what did you guys do to end up here? I came to the factory late and they accused me of slowing down the revolution.”

The second man says:
“I arrived at the factory too early and they accused me of trying to rush the revolution.”

T... 
 UPVOTE  DOWNVOTE  REPORT
ADVERTISING

What made the American Revolution the most dramatic war of all time?

It started over someone spilling the tea.
 UPVOTE  DOWNVOTE  REPORT

Hey girl, are you the French Revolution?

Because I keep imagining you sans-culottes
 UPVOTE  DOWNVOTE  REPORT

How scared were the french royalty during the French Revolution?

Very, they completely lost their heads..
 UPVOTE  DOWNVOTE  REPORT

During the French Revolution, the commoners were busy executing the elite and bourgeoisie by beheading them.

They dragged a lawyer up on the guillotine, but as the blade dropped toward his neck, it inexplicably stopped. That was taken as a sign from God to spare his life and he was freed.

Then they brought a wealthy merchant up for execution, but again the blade stopped just short and he, too, was ... 
 UPVOTE  DOWNVOTE  REPORT

During the French Revolution the Guillotine was a revolutionary piece of technology

Truly a piece of cutting-edge technology
 UPVOTE  DOWNVOTE  REPORT

What's the catchphrase of the Typing Revolution?

Viva la fonts.
 UPVOTE  DOWNVOTE  REPORT

Whoever thought of the idea of the french revolution was very thorough

while the concept was mostly raw, the execution was flawless
 UPVOTE  DOWNVOTE  REPORT

Standing on the beach after the great proletariat revolution of 1907, what did one Russian say to the other?

serfs up!
 UPVOTE  DOWNVOTE  REPORT

Why do French people only drive in 1st gear?

They love a lot of revolutions.
 UPVOTE  DOWNVOTE  REPORT

I was sat on a merry-go-round thinking...

I need to start a revolution
 UPVOTE  DOWNVOTE  REPORT

I'm still upset they marked me wrong on my 7th grade history test on the question "what did they set up during the French Revolution?"

I maintain that "lots and lots of guillotines" is technically correct...
 UPVOTE  DOWNVOTE  REPORT

The Soviet Union, 1927

A village is celebrating the anniversary of the revolution. The mayor gives s speech.

"We have accompliced so much during the last ten years! Look at Mikhail Pavlovich, before the revolution he was starving and illiterate. Today he is the best tractor driver in the village!"

People che... 
 UPVOTE  DOWNVOTE  REPORT

Why was King Louis happy when he was guillotined during the French Revolution

They lifted a weight off of his shoulders
 UPVOTE  DOWNVOTE  REPORT

It was the Best of Times, It was the Worst of Times...

Yes, it was the middle of the French Revolution, and Robespierre and his revolutionaries had gathered up a priest, a member of the aristocracy and an engineer, packed them into a tumbrel and dragged them off to the square to the waiting guillotine.

First they dragged the priest up onto the pl... 
 UPVOTE  DOWNVOTE  REPORT

What is France's favorite video game?

Homefront: The Revolution
 UPVOTE  DOWNVOTE  REPORT

My New Year revolution is

to never use autocorrect again.
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

It's the time of the French Revolution and they're doing their usual daily beheadings..

Today they're leading a priest, a prostitute and an engineer up to the guillotine.

They ask the priest if he wants to be face up or face down when he meets his fate. The priest says that he would like to be face up so he will be looking toward heaven when he dies. They raise the blade of the ... 

This joke may contain profanity. 🤔

It's been 125,000 generations since the emergence of human species, 7,500 generations since human physiology reached what is essentially its modern state, 500 generations since the agricultural revolution, 20 generations since the scientific revolution...

And 1 generation since I fucked your mom.

Just like you, progress is slow.

I have a New Year's Revolution

And it's to spell-check everything before posting!
 UPVOTE  DOWNVOTE  REPORT

The French Revolution was pretty rough. Did you hear about what happened to Louis XVI's head?

[Removed]
 UPVOTE  DOWNVOTE  REPORT

Why don't revolutions work?

Because after one revolution you're back where you started.
 UPVOTE  DOWNVOTE  REPORT

Vladimir Lenin found a magic lap. Upon rubbing it, a genie pop'ed out and offered him three wishes:

Vlad: I want to return to my country!

Genie: So Be It, replied the Genie.

Vlad: I want my message to be heard by me people!

Genie: So Be It, replied the Genie.

Vlad: I want to lead my people to revolution!

Genie: Soviet! Replied the Genie.
 UPVOTE  DOWNVOTE  REPORT

How do you start a Revolution on a budget?

Using a Coup-on.
 UPVOTE  DOWNVOTE  REPORT

In Soviet Russia......

Revolution Industrializes you!
 UPVOTE  DOWNVOTE  REPORT

I'm going to start a revolution, who's with me?

Ok, now just roll this wheel with me.
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

My 4 year old cousin told me this and I cracked up

Cousin: Knock knock

Me: Whose there?

Cousin: Weeneeda maka change butt

Me: Weeneeda make change butt who?

Cousin: Yes Michael, we need to make a change, but who? Who will be the first to stand up? We have burned through our resources leaving the planet cracked and bruised... 

During the French Revolution a doctor, a lawyer, and an engineer were facing execution on the guillotine.

The doctor was first, but the blade jammed and the doctor was set free due to Divine Intervention.

The lawyer was next, again the blade jammed, and was also set free.

As the engineer was being led to his doom, he glanced up at the blade and said “Wait a minute! I think I see the proble... 
 UPVOTE  DOWNVOTE  REPORT

What do you call a communist revolution that failed due to poor word choice?

A miss-commune-ication
 UPVOTE  DOWNVOTE  REPORT

Why did the Russian Revolution go so well?

They aimed for the tsars!
 UPVOTE  DOWNVOTE  REPORT

During the French Revolution, what was the executioner’s catch phrase?

“First come, first severed!”
 UPVOTE  DOWNVOTE  REPORT

Three Russian men are talking in the Gulag.

One of them asks the two others: "So what did you do?"

The first one answers: "Well, I arrived late at the factory, and so they accused me of slowing down the Revolution and the victory of the Proletariat."

The second one answers: "Well, I arrived early at the factory, and so they accu... 
 UPVOTE  DOWNVOTE  REPORT

Why did Louis XVI flee the revolution?

He felt a bit guillotine
 UPVOTE  DOWNVOTE  REPORT

What do you say to your friend who's just birthed a revolution?

Molotov!
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

What do you call a cat that participated in the Chinese Cultural Revolution?

a Meowist

I thought I could never be a good dancer until I discovered Dance Dance Revolution. Though I've only really mastered one move,

it's a step in the right direction.
 UPVOTE  DOWNVOTE  REPORT

"It's a revolution!" I yelled at the top of my lungs.

Scared the rest of the people on the Ferris wheel.
 UPVOTE  DOWNVOTE  REPORT

Three Russian men are in the gulag talking with each other.

They get to talking about why there were sent to the gulag.

“I was sent here for coming early to work in the factory. I was accused of trying to put myself ahead of my fellow worker.” The first one said.

“Aye comrad I was sent for being late to work at the factory. I was accused of d... 
 UPVOTE  DOWNVOTE  REPORT

Some Communists took over a wheel factory today

They declared a revolution.
 UPVOTE  DOWNVOTE  REPORT

A priest, a politician and an engineer were scheduled to be executed late in the French revolution.

It has to be "public", and people are tired of all the bloodshed, so a crowd of spectators is forcibly rounded up.

The priest is brought up to the guillotine and lays down on the table. The executioner pulls the cord and the heavy steel blade descends ... then shudders to a stop in the middl... 
 UPVOTE  DOWNVOTE  REPORT

Cold War Era Joke: This Russian dude had a talking parrot. A very special parrot who loved cursing the regime, and the Communist party leaders. One day, hard knocks on the door, "KGB, open up!". The guy hides the parrot in the freezer. The KGB searches the apartment and cannot find the parrot.

The KGB agents give the guy a warning. Once they leave, he runs to the freezer takes out the shivering bird and hugs it and tells the parrot to curse the revolution. The parrot is mum. "Com'on curse Brezhniev , curse the KGB. The parrot looks at the guy and says "I've just been to Siberia! I'm not t... 
 UPVOTE  DOWNVOTE  REPORT

How to start a revolution with change?

Just take a coin and give it a spin.
 UPVOTE  DOWNVOTE  REPORT

Why did workers in the industrial revolution have better sense of smell?

It's because of all that time they spent in the ol-factory.
 UPVOTE  DOWNVOTE  REPORT

They say revolution breeds revolution.

Resistance is fertile.
 UPVOTE  DOWNVOTE  REPORT

I was telling a great joke about the importance of the guillotine in the French Revolution...

But it didn't really land.
I guess execution really is key
 UPVOTE  DOWNVOTE  REPORT

My wife told me she wanted me to treat her like a queen.

So I had her executed with the guillotine for betraying the revolution and promoting undemocratic, outdated ideas.

Long live the republic!
 UPVOTE  DOWNVOTE  REPORT

How many Marxists does it take to screw in a light bulb?

None. The bulb contains the seed of its own revolution.
 UPVOTE  DOWNVOTE  REPORT

A physics teacher writes a question on a board

"A 40 kg child that 100 cm tall is holding a parent's arms swinging them 0.5 revolutions a second. If the parent let go of the child after 2 seconds, where will the child end up?"



A few moments later, the teacher then comes over and reads a student's answer:



"In a foste... 
 UPVOTE  DOWNVOTE  REPORT

What do you call an epic space opera set during the Russian Revolution?

Tsar Wars
 UPVOTE  DOWNVOTE  REPORT

Why did the dyslexic, Russian astronomer hate the revolution?

He was following the Tsar.
 UPVOTE  DOWNVOTE  REPORT

3 aristocrats in the French Revolution

So during the reign of terror in the French Revolution, there was a line of aristocrats waiting to be executed by guillotine. Near the middle of the line, there was a clergyman, an artist, and an engineer.

The clergyman got up to the chopping block and said a short prayer, and miraculously w... 
 UPVOTE  DOWNVOTE  REPORT

Did you know George III never even bothered to leave his couch during the American Revolution?

He was sofa king comfortable.
 UPVOTE  DOWNVOTE  REPORT

I'm still treating my burn

Older Englishman and I like to trade insults at work, and this happened...

Him: Oh dear, was having a good day and you show up.

Me: Don't make me start another Revolution to kick the rest of the English out.

Him (instantly): Well, you've been revolting for years.
 UPVOTE  DOWNVOTE  REPORT

Why is the French Revolution just like Prohibition?

They both got rid of Bourbon!
 UPVOTE  DOWNVOTE  REPORT

What's the fastest spinning country?

France, because it has the most revolutions per minute.
 UPVOTE  DOWNVOTE  REPORT

Hey, dictators! Moving the Earth further from the sun will keep you in power. Why?

Because it will take longer to make one full revolution.
 UPVOTE  DOWNVOTE  REPORT

I just changed my car engine to France.

Gonna have tons of revolutions now!
 UPVOTE  DOWNVOTE  REPORT

Whoever invented wheel,...

... started a revolution.
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

A priest decides to do some community work.

After considering where he should travel to do this work, he decides to travel to the Nigerian desert and assist the farmers working there.

After several weeks providing physical labour to the farmers he asks if there is a more effective way to help them. The farmer replied to him "Father, it... 

I was going to go on TV and show everyone my motor that spins at exactly 1,800 rpm. Unfortunately, the station uses a 30fps camera, so while you can still see the motor itself...

The revolution will NOT be televised
 UPVOTE  DOWNVOTE  REPORT

A soapbox orator addresses a crowd on the glories of communism

“Come the revolution, everyone will eat strawberries and cream!” A man at the front whimpers, “But I don’t like strawberries and cream.” The speaker thunders, “Come the revolution, you will like strawberries and cream!”
 UPVOTE  DOWNVOTE  REPORT

Did I tell you about my new Soviet bike?

For some reason it can only do one revolution and then it stops working.
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

What do you call an orgy on a rond-a-bout?

A sexual revolution

When it gets to January, I’m going to overthrow the Government!

It’ll be my new year’s Revolution
 UPVOTE  DOWNVOTE  REPORT

A priest, a drunk, and a engineer are about to be executed...

A priest, a drunk, and a engineer are about to be executed in France during the French Revolution. The priest is first in line and the executor asks him if he wants to be looking up or down as the guillotine blade falls on him. The priest replies "I want to look up at the heavens before I die." As a... 
 UPVOTE  DOWNVOTE  REPORT

A blonde takes part in a game show

[Disclaimer: I don't know whether this counts as a joke, if not please tell me which subreddit would be suitable, 'cause it's actually a pretty fun "story"]

First question: how long did the Hundred Years War last?

a) 99 years

b) 116 years

c) 100 years

d) 150 years<... 
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

A blonde participates in the television show Who wants to be a millionaire...

The TV host asks her the following questions:

1st
How long did the 100-year war last?

a) 116 years
b) 99 years
c) 100 years
d) 150 years

The blonde chooses to use the opportunity not to respond.

2nd
In which country did you find the Panama Cabin?

a) ... 

In the year 2030,

In the year 2030, space travel was expanding more than ever, and life science was seeing new revolutions every few weeks. Inventions in robotics and engineering were being created almost daily. But this new world came with a downside, the amount of harsh chemicals in the air were causing cancer to d... 
 UPVOTE  DOWNVOTE  REPORT

The country of Ohms is run by a brutal dictator.

Due to the suppression of their rights, the citizens of Ohms frequently rise up and attempt to storm the gates of the capital city. However, the dictator always has just the right number of mercenaries to repel the rebels and cause the survivors to disperse for a few months or so.

The dictat... 
 UPVOTE  DOWNVOTE  REPORT

Paul Revere’s Chicken (OC)

Paul Revere has a chicken named Gallo. When the American Revolution was well underway, he spent several nights training the chicken secretly in his barn. When he finally felt Gallo was ready, he brought it with him to the Sons of Liberty. At first, they laughed.

“Well, now, laugh if you want,... 
 UPVOTE  DOWNVOTE  REPORT

So I just put a baguette in my microwave

Guess you could say that I witnessed a French Revolution.
 UPVOTE  DOWNVOTE  REPORT

Hotel in Moscow

As a young man, Nickolai joined in the Bolshevik Revolution and was decorated for his role, and was invited to Moscow for the celebration, and put up in a big hotel there.
He had grown up in a remote village where there was no plumbing and knew nothing of toilets, so when he felt the call of natu... 
 UPVOTE  DOWNVOTE  REPORT

Different ethnic groups in the USSR have a meeting.

Each group has a representative, who must talk about what it is like living in the soviet union (and praise lenin and communism along the way if they don't want to get killed).

The Chukchi people live in Siberia, and haven't had it so great under soviet rule. Their representative begins to sp... 
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

Joe, Dave, Tommy, and Rodney start a folk rock band. Joe plays cymbals, Dave is on the 6-string, Tommy has the drums, and Rodney adds his unique twang to the vocals.

Their very first rehearsal, they come up with a great idea for an original composition. It takes heavy liberties with the cymbal part. Joe is ecstatic; cymbal players rarely ever get the recognition they deserve. This could be a revolution in the music industry!

They begin tuning and setting ... 

This joke may contain profanity. 🤔

A man walks into a bar

and the bartender asks "so what'll it be?"

The man sighs, and takes a seat. After a long pause he says "I'll take a pint of ale, but after I tell you this story, you may end up buying it for me."

"Well, I guess it'd have to be one hell of a story."

"Well, you see, you know that... 

This joke may contain profanity. 🤔

Stalin is dead and things have begun to lighten up a bit relatively speaking

An old couple live in an apartment in Moscow and she sends him down to buy some meat for supper. After queueing for the obligatory three hours he gets to the counter and the woman says 'No more meat, meat finished'. He cracks and starts raving 'I fought in the Revolution, I fought for Lenin in the F... 

Karl Marx dies and stands trial before St. Peter.

St. Peter: "The ideas you preach have brought misery to billions. I send you to the deepest pits of Hell!"

After a few months Satan calls God:

Satan: "God, please remove Marx from my realm as soon as possible."

God: "Why would I do that? He is a sinner, his fate is to burn in H... 
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

Lenin headed directly to Heaven after he died.

He thought he had done much good for the oppressed and deserved retirement in Heaven. He arrived at the gates.

"Who's there?"

"Vladimir Ilyich Lenin."

"Okay, okay! Last one in be sure to close the door. It's kind of cold in here..."

God checked Lenin's dossier and decided... 

This joke may contain profanity. 🤔

Highschool in a nutshell

Art: *draws dicks everywhere*

Biology: "mighty mitochondria... The powerhouse of the cell"

Chemistry: feelslikeamethlabman.jpg

English: "conjunction junction what's your function?"

Health: "here's STD-infected genitalia, now everybody take condoms"

History: *insert... 

After his death, Steve Jobs wakes up in Hell and asks Satan, "Why am I here?"... (It's not in bad taste.)

After his death, Steve Jobs wakes up in Hell and asks Satan, "Why am I here? Certainly I've changed the world for the better through an innovative technological revolution."

"That's quite true," says Satan. "You belong 'upstairs' and I'm only borrowing you for a few days. But see, whenever ne... 
 UPVOTE  DOWNVOTE  REPORT

How many communists does it take to screw in a light bulb?

None, we just sit in the dark complaining about capitalism.

But come the light-bulb revolution everything will be brighter.
 UPVOTE  DOWNVOTE  REPORT

I've been feeling really dizzy since yesterday

I think I need to stop these New Year revolutions.
 UPVOTE  DOWNVOTE  REPORT

What do South American governments and internal combustion engines have in common?

Both are measured in revolutions per minute.
 UPVOTE  DOWNVOTE  REPORT

Enrique Peña Nieto, Malala Yousafzai, and Donald Trump are walking along a beach

It's a bit of an oldie, and I think the last time I heard it, it came off as pretty racist. But I think the current political climate allows me to rehash it better.

Enrique Peña Nieto, who is the Mexican President, is walking along the beach one day with the US President, Donald Trump, and p... 
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

A man was working very hard in his lab one day...

and after countless hours of working, he had finally invented what he thought was the revolution of the century; the time machine.

Being so tired from his work, he decided to take a break and watch some of the latest news. He flipped through a few channels to find the news channel. The repo... 

In the Soviet Union a listener calls Radio Yerevan with a pressing question.

"Is it true" the listener asks "that in Moscow, at the Red Square, Moskvich cars are being given for free?"

"It is absolutely true" the host replies "just not in Moscow but in Leningrad, not at the Red Square but at the Revolution Square, not cars but bikes, and not given for free but... 
 UPVOTE  DOWNVOTE  REPORT

iPhone 7 is revolutionary!

•no headphones jack
•no wireless charging
•no curved screen
•no 4K resolution (or even full HD) screen
•no VR headset support
•no 360 camera support
•no expansion storage slot

It is true revolution in scamming people to upgrade from old iPhones!
 UPVOTE  DOWNVOTE  REPORT

What is the favorite scientific unit of the French?

RPM ( Revolutions Per Minute )
 UPVOTE  DOWNVOTE  REPORT

This joke may contain profanity. 🤔

What do you call the act of turning over in bed to switch from the missionary position to doggy style?

A sexual revolution.

Screwing in a lightbulb

How many Zombies does it take to screw in a lightbulb?

None, because they wouldn't fit and zombies don't screw.

&nbsp;

How many Irishmen does it take to screw in a lightbulb?

Thirty-one. One to hold the bulb and 30 to drink until the room spins!

&nbsp;
<... 

React Profiler: A Step by step guide to measuring app performance

  As react applications are becoming more and more complex, measuring application performance becomes a necessary task for developers. React...