Jul 03 2018

A short skepticism story

Category: MiscellaneousIuliana @ 13:15

I started learning programming at age of 14. I was in high-school and the programming language did not really matter to me. For me it was all about algorithms and data structures as means to solving problems. Whether I was using FoxPro, Turbo Pascal or C, what it mattered was solving the problem and getting the results.

Then I went to the university and because of a series of unforeseen circumstances I ended up writing most of my solutions in Java. And it was all classes, interfaces and objects, OOP for short.

Almost my whole career was centered around the OOP way of solving problems. Even when I was writing JavaScript code, I was still stuck on classes , objects, fields and methods. It did not really occur to me that there was other way of thinking and designing my solutions anymore. OOP seemed so natural, it modeled real life objects and processes after all. But real life is most of the time inefficient and less than optimal, and real life solutions are based on things designs created by at least two generations before and propagated by adults that function based on the “it is known” principle. Because, after all, there is a risk involved in doing things differently, that most people prefer not to take. It is the “If it works, don’t fix it!” engineering principle.

Enter “Gica-Contra”, a Romanian term that describes people that “swim against the current”, people that feel compelled to be against the other 99%. This term has always been used by my mother to describe me because since I was a child I was quite rebellious and stubborn, and always felt the need to ask that  damn question loathed by parents who thought parenting is easy: “Why?”. If you think this kind of attitude changes with age, you are mistaken. I have become the kind of adult that does the following:

  • asks “Are you sure?”
  • says “Let me double-check that!”
  • says “Neah, there must be a different/easier way to do this!”
  • asks “But, what if …?”
  • asks “But how do you really know?”
  • says “If too many people have the same view on this, there is something shady about it.”
  • and many more.

And all that my friends, translates to a single term: skeptic.

Being so stuck on OOP, I was quite skeptical about functional programming. And rightfully so, as the only programming language I could associate it to was Turbo Pascal, and suffice to say, I did not like Turbo Pascal very much. Also there is so much hype about functional programming nowadays, that it tingles my Gica-Contra sense a little bit too much. And that’s the thing that got me worried. I’ve always considered my skepticism as a superpower, as the fuel for my out-of-the box thinking engine. But when it came to functional programming, it kept me from even taking it into consideration, it kept me in the dark. And that’s when it hit me: I was behaving exactly like the traditionalists and conservative narrow minded humans that I’ve always claimed to despise.

This had to change. I needed to come into the light. Thankfully I now work for a company that pays for independent study, we have 10 training days per year, when you are payed just to study whatever you are curious about and the conclusion of those days must be shared with your colleagues via a blog post or presentation. So I took advantage of my first training day to start learning Kotlin. And it was mind-blowing. Especially since one day earlier I also participated to a Scala workshop that went very well. All of a sudden, there was all this new information coming from comparing the two languages. It’s like the fog was lifted from my eyes and I finally could see the power and the versatility of functional programming.

And most of all, I could see the practical side of it. Solutions that needed 20 lines of code to be implemented in Java, needed only 2 lines in Kotlin, and surprisingly, they were still readable. Almost the same in Scala. Come to think of it, I have been bothered for a while by all the boilerplate code required in Java to fit the OOP principles and some coding conventions  that nobody asked me about. All these getters and setters, all the bloody curly braces and all the NPEs… Kotlin and Scala reduce that. And funny enough Java is going in that direction as well, I mean with modules, you might as well just declare your fields public and avoid writing setters and getters, because if the class is not in an exported package you have nothing to worry about.

So yeah, interesting times are coming. No worries, I’ll keep you in the loop. ;)

Stay safe, stay happy!

 

Tags: , , ,


Dec 07 2017

Experience cloud

Category: MiscellaneousIuliana @ 11:12

I created this for a presentation about my experience and skills and I thought it belongs here.

The word cloud above covers all my 11 years of development so far and clearly reveals which topics I am best at. Although I always wished myself to become an agnostic developer, also known as a polyglot developer, after all these years I have to accept the fact that Java & Spring are clearly my strongest points.

Where should I go from now? Well… I have considered learning Kotlin for a while. ;)

Tags: , ,


Sep 18 2013

The repetitive programmer

Category: TechnicalIuliana @ 12:36

You know who you are. I know who you are. And I hate you. And I despise you. Every time I have to  work with your code my brain keeps screaming WHY? WHY?WHYYYYYYY?  and I begin to think you are retarded. Or maybe just not retarded, but maybe you learned to program on another planet, because no programmer from this Earth, not even a mediocre one would write code like you do and also be paid for it. I would not pay you for it, I would send you do dig holes or clean shit pipes or something that does not imply any brain power whatsoever. Because you have none!

Sample:

// [bla bla  bla - code that I won't put here]
final ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
	Document document = new Document(PageSize.A4);
	PdfWriter writer = PdfWriter.getInstance(document, bos);
        // [bla bla  bla - code that I won't put here]
	if (document != null) {
	    document.close();
	}
	if (writer != null) {
	    writer.close();
	}
        // [bla bla  bla - code that I won't put here]
        OutputStream outputStream = new FileOutputStream(attachmentURL);
	bos.writeTo(outputStream);
        // You might notice that the outputStream was not closed
} catch (MailException e) {
        if (log.isWarnEnabled()) {
                log.warn("Cannot send email for something " + something.getId(), e);
	}
	sendAdminMessage("Error sending email message to user", "Cannot send email for something nr "
			+ something.getId() + ". Message is = " + e.getMessage());
			return false;
} catch (MessagingException e) {
	if (log.isWarnEnabled()) {
		log.warn("Cannot send email of something " + something.getId(), e);
	}
	sendAdminMessage("Error sending email message to user", "Cannot send email for something nr "
			+ something.getId() + ". Message is = " + e.getMessage());
			return false;
} catch (IllegalArgumentException e) {
	if (log.isWarnEnabled()) {
		log.warn("Cannot send email ofsomething " + expressOrder.getId(), e);
	}
	sendAdminMessage("Error sending email message to user", "Cannot send email for something nr "
			+ something.getId() + ". Message is = " + e.getMessage());
			return false;
} catch (MalformedURLException e) {
	if (log.isWarnEnabled()) {
		log.warn("Cannot send email of express order " + something.getId(), e);
	}
	sendAdminMessage("Error sending email message to user", "Cannot send email for something nr "
			+ something.getId() + ". Message is = " + e.getMessage());
			return false;
} catch (IOException e) {
	if (log.isWarnEnabled()) {
		log.warn("Cannot send email of something " + something.getId(), e);
	}
	sendAdminMessage("Error sending email message to user", "Cannot send email for something nr "
			+ something.getId() + ". Message is = " + e.getMessage());
			return false;
} catch (DocumentException e) {
	if (log.isWarnEnabled()) {
		log.warn("Cannot send email of something " + something.getId(), e);
	}
	sendAdminMessage("Error sending email message to user", "Cannot send email for something nr "
			+ something.getId() + ". Message is = " + e.getMessage());
			return false;
}

So, 7 catch-es, for seven types of exceptions, we do the same thing for every type of exception, write the same code, because it looks good in the SVN if somebody looks, he will see that you wrote a lot of code. A lot of crap more like it. And why the hell do you not make sure all your streams are closed??
The person who wrote this code is payed a few thousand euros to write code like this. Yeah, I guess the recruitment department sucked ass when this person was hired.

So yeah, if you write code like this, quit programming now and look for another job. You clearly are not made for this and you are a despicable person.

Tags: ,


Oct 13 2012

Learning Spring, part III

Category: TechnicalIuliana @ 18:15

I have a new hot question for you:

We have two classes AccountServiceImpl and ClientServiceImpl. Any of these classes inherits from each other, meaning one is a subclass of the other. What will happen if we define a pointcut like this:

"execution( * *..AccountServiceImpl.update(..)) 
       && execution( * *..ClientServiceImpl.update(..)) "

And here are your options:

  1. The pointcut matches any public update methods of the two classes whatever the arguments.
  2. The pointcut matches any update methods of the 2 classes whatever the arguments and the method visibility.
  3. The pointcut matches any update methods of the two classes, with one ore more arguments and whatever the method visibility.
  4. No join point is defined.
  5. Something else will happen.

Continue reading “Learning Spring, part III”

Tags: ,


Sep 15 2012

Learning Spring

Category: English posts,TechnicalIuliana @ 23:47

A few months ago the company where I am currently employed sent me to Belgrad to train me in Spring Core. The training lasted 4 days and at the end I was supposed to take the Spring Core certification exam and pass it.

I delayed that for a while, but because now I have some spare time I decided it was time for me to do this thing. So I went over the slides and the spring code samples again. But after doing some mock tests I concluded I will most likely fail the certification, because the official materials were not enough so I started reading Spring in Action. Still I noticed that in the tests there was still stuff that I hadn’t covered. So I started reading Spring Reference. And because I have some problems in retaining information just by reading it, I stared to test the recommended examples. And this is where I hit some walls.

But before telling you what is not clear for me I shall tell you what technologies I’m using for development: Maven 3.0.0, Jdk 1.7, Intellij Idea 11.1.3 and Spring 3.1.2 (I know the certification is for 3.0, but as the Spring reference manual has 840 pages, I might as well read about the new and useful stuff added in 3.1)

The first problem I had was with the compound property names. I tried using them. Idea does not recognize them and my test fails.

Continue reading “Learning Spring”

Tags: ,


Jun 19 2012

when you have an itch…

Category: English posts,TechnicalIuliana @ 10:34

… you gotta scratch it. And I had a serious itch cause by my Windows. Even if Windows has evolved so much, even if Windows 7 is the peak of greatness among all the Windowses before it, it still does not know how to manage 4 core processors. So I was seriously pissed about the fact that Windows 7 froze from time to time, making my super-laptop look like my first computer, an AMD K6, 500 MHz and 256 MB SRAM. Which was definitely not cool, considering the fact that my laptop’s configuration looks like this: Intel Quad Core i5-450M and 6 GB DDR3. The only reason I kept windows so far on my laptop was that my processor has a capability known as turbo boost, meaning that can over-clock itself when needed. But this won’t be needed that much if the tasks were efficiently distributed between the 4 cores, which were not.

So two days ago, I just snapped, decided to give up the possibility of playing games for a while and went on a search for the perfect Linux for my laptop. I am fond of Gentoo as you know, but compiling a full OS was not an option because it is a time-consuming operation and also because all that compiling would set my laptop on fire and it’s already hot in Romania right now (32 Celsius degrees). So I was left to choose between Archlinux and Mint. I did not even consider Ubuntu, it’s a Linux that looks and acts like Windows, the thing I was trying to get rid of. I had Archlinux before and I know in order to get the final result some time must be wasted on its configuration, so I went for Mint.

In less than 30 minutes I had a fully functional and compact Linux, oh well … fully for a normal user, not for me, a curios developer. So after this I went on and started installing the development software. The first one I wanted to install was the jdk. Mint uses open-jdk which Idea and STS refuse to go along with, so I went on a quest for installing the Oracle version. If on other Linux systems this was a piece of cake on Mint, it was not so, because Mint has all these symlinks pointing to open-jdk binaries, and even if you do everything right, set the JAVA_Home variable and add it to the path, when you will execute “java -version” in the console, the binary that will be executed will still be the one of the in the open-jdk. The only way to change this is to go to /usr/bin, see where the specific symlinks point to and change that. After that I installed Idea and STS and everything was flawless.

Then I wanted to add a second monitor and this is where all blew up in my face. But not because there was something wrong with Mint, but because one of the cables was not plugged in correctly in my monitor and the system did not see it. I did not even consider that the problem might come from a cable and went on and tried to install nVidia drivers in order to convince the system to see my external monitor. After the first restart I was left without an interface, because the nVidia drivers were not stable, ofcourse. So I went old-school and installed lynx, a text based browser, and searched for a solution for my problem. I did so and tried different options for an hour, when finally it worked and I had my graphic interface back, but the external monitor still was invisible to Mint, so I considered the possibility of the monitor not actually being plugged in the laptop. I check the cables and … surprise. It detected it right away.

Conclusion: if you want to install a Linux on your laptop, I truly recommend Mint, it is small, smart, fast and it knows how to work the special buttons on your laptop, without any additional settings. And is also easy to install, if you are not an old-school developer who considers problems being caused by the software first :D , that is. :)

Tags: , , , ,


May 05 2012

What does a passionate developer do…

Category: English posts,TechnicalIuliana @ 22:35

… when is stuck in a hotel room because of the rain, bored out of his mind and with no mood to work? Well when that happens to me I start to reed my java feed reader and depending on what I find there I might write my own articles. So… yes, this article is today’s consequence of boredom.

1. What is the flaw with the Stack class?
Actually, there are two of them all being caused by the fact that java.util.Stack extends java.util.Vector:
I. Extending Vector methods insertElementAt and removeElementAt can be called and they actually work, so the stack definition is not respected (that part with only the last inserted element being accessible, the LIFO principle)
II. Extending Vector, Stack is also synchronized which makes it slow and when synchronization is not necessary this  is quite inefficient. This is not exactly a flaw, it’s more of a personal observation observation.

Then again in the api it is written that “It extends class Vector with five operations that allow a vector to be treated as a stack “, so I guess these are not flaws, the Stack class just works as intended. (Recommendation: use ArrayDeque)

2. Can an interface extend multiple interfaces?
There is no right answer to this question, because it depends of the point of view of the interviewer.
I. Yes, because you can define an interface like this:
public interface MultipleIntf extends List, Serializable {
}
II. No, extending means actually inheriting all functionality of the super-entity and  perhaps adding new functionality, in the case of interfaces there is nothing to inherit and no functionality to add. Except for the obligation to implement all abstract methods that will be enforced on the implementing class.

3. What is lazy loading?
Lazy loading is a name to describe the process of not loading something (object/class) until needing it. This question will surely take you to a ClassLoader discussion, so it is better to know and understand the Java Class Loading mechanism.
So:
– the java source files are compiled into executable code for the JVM, called bytecode, stored into *.class files.
– at start-up JVM has no loaded classes. When the first class is loaded, the classes on which its execution depends are searched and loaded too. So if I have a class which has imports statement for ArrayList and Serializable, the JVM will load my class, then it will search and load ArrayList.class and Serializable.class. Let’s imagine we have a big application with a lot of class files and one of them is missing. The application will run just fine, until we try to access a functionality implemented by that class, when the JVM will let us know that the class was not found by throwing a java.lang.ClassNotFoundException.
And this my darlings is lazy loading. A class is not loaded until used and there would be no point in doing that for efficiency reasons. Right? Anyway, if you want to have a deep understanding of the Java Class Loader, I recommend this article.

Tags: , , ,