Skip to content

Monthly Archives: June 2016

What are the advantages and disadvantages of leaving your country to live or study abroad?

airplaneThese days many people go abroad to study or even to live. In this essay I’ll share some thoughts about living in a foreign country. Moving abroad is a life-changing decision and you have to think through all possible details. Of course it heavily depends on the country where you live and the country where you’re going to move, but here I’m talking about moving to a better place to live.

Of course, when you see pictures and videos of a country of your dream, you see many advantages. For instance, people are more polite and the life on the whole is much better. You see those vibrant cities and peaceful villages, surrounded by amazing green valleys. And when you eventually get there, you understand that it’s really right up your street… Until the “honeymoon” ends.

Read More →

Go vegetarian: bullshit or healthy lifestyle?

Yesterday I was given a homework to write an essay on a subject “Go vegetarian: bullshit or healthy lifestyle”. So, here are some thoughts:

Go vegetarian: bullshit or healthy lifestyle

There are many people in the world who don’t eat meat. Those are vegetarians. Vegetarianism is the practice of abstaining from the consumption of meat and meat by-products. They have different reasons to do it: while some people suppose that it’s healthier, others think that it’s unethically and violently to grow and then kill animals. As I know, all things can have its own prons and cons, and vegeterianism is not an exception. In this essay I’ll try to shortly describe the main advantages and disadvantages of this idea.

Read More →

How to create an ATG pipeline processor?

I’m currently studying Oracle ATG. Kinda big monstrous eCommerce platform. Today I had to create a commerce pipeline processor. So, I started googling and found this great tutorial by Oracle: Creating processors. Well, that’s not bad. But it’s a bit poor. For example, I’d like to know, what is the Object pParam? What is the PipelineResult pResult? Actually, there’s the third (unanswered) question: why all parameters starts with “p”?

Ok, I’ve found some answers to my questions. Let’s see.

Read More →

Observer pattern

Observer is a software design pattern, that is used when some objects create events and other objects should be notified when these events occur.

The main idea is that we have two types of instances: one that produces events and one that consumes them. Events producer must have three methods:

  1. addObserver(Observer observer)
  2. removeObserver(Observer observer)
  3. notifyObservers(…)

The first two methods are used to add and delete observers from a collection. The third method must iterate that collection and call notify(…) method of the Observer instance.

Java has its own Observer interface and Observable class, but sometimes we don’t want to extend from a class, or we want to adjust the API, you can create your own interfaces, as I’ve done in the following example:

Read More →

Strategy pattern

With this post I’m starting series of articles dedicated to GoF design patterns. GoF stands for Gang of Four – four authors that wrote a famous book about design patterns.

So the first pattern I want to describe is Strategy. It allows to choose the behaviour of instances at runtime by defining appropriate strategy.

Let’s see an example. Supposing we have a class Order, which has getTotal() method, that returns total cost of Items in this order:

 

public int getTotal() {
	int total = 0;
		
	for (Item item : items) {
		total += item.getPrice();
	}
		
	return total;
}

 

Very simple, isn’t it? But what if we want to change the price depending on some circumstances? That’s where we can use the Strategy pattern. Click read more to see full example.

Read More →