My Dell Studio XPS 16 (1647) upgraded

November 25, 2012 Personal No comments

DellStudioXPSI’m not only reading books & blogging about them. Of course these two things require lots of computer resources :), but I also do some programming and simply sit in front of my laptop, which sometimes requires much more resources, especially if sitting is virtual.

In blog post “My new Dell Studio XPS 16 (1647) laptop” I wrote “So looking at the pictures above it is seen that bottleneck of my new laptop is hard disk and memory speed. This means that when something will require accessing hard disk (loading something into memory, working with svn, etc) I will not gain performance. Sadly, but I can do nothing about this.”

Well, I can!

Before:
Studio.XPS.1647.WindowsExperience

After:

image

I think it is pretty much obvious what happened to my laptop. It got two presents from Amazon:

Samsung MZ-7PC256B/WW 256GB SSD (2,5’’, 256MB Cache, SATA 6.0Gbps)

Corsair PC1333 8GB (1333MHz, 204-polig, 2x 4GB) DDR3-RAM Kit

While 8Gb of memory and SSD it is not something that can surprise someone these days I feel very happy about my purchase and confident that current performance is enough for me at least for 1 year.

I’ve been thinking if it worth posting my journey of migrating to new hard drive, which includes screwdrivers, aches of system image restoring, backups in clouds and on my external 2Tb drive, ending with bullet points, aka. recommendations for you. But you are not stupid, and internet is full of this crap. Sometimes I’m just getting sick when watching primitive “unpack” videos on youtube, so I hope you didn’t get sick because of my post. I just wanted to share my happiness with you!


No comments


Book Review: “The Art of Unit Testing: With Examples in .Net”

November 22, 2012 Book Reviews, UnitTesting No comments

I always wanted to read some comprehensive book on unit testing, therefore book “The Art of Unit Testing: With Examples in .Net” appeared in my list of books to read. It has been more than 1 year since I planned to read it, finally it took me only 2 days to read it – yesterday and the day before yesterday. Sometimes comprehensive things are not that comprehensive as you imagine them or… maybe with time topic is no longer that vast for you.

Nevertheless, I remember my first months of my first job as Software Developer. During one of my first team meetings question of failed Unit Tests was raised. Our clients were really concerned about quantity of tests and reasons behind tests failing during nightly builds. I clearly remember that passionate discussion and someone saying “… or are there guys who don’t know what Unit Test is?” and loud laugh after that. I made smile on my face. I maybe heard once or twice about such combination of words, resulting in abbreviation UT, but it didn’t ring a bell. I wasn’t brave enough to ask. Now I think I wasn’t one in that room who didn’t know, otherwise why would we had problems in the first place?

Because of coincidences and my eagerness, when I was about to leave many considered me as internal expert in Unit Testing. No surprises, I have many posts on UnitTesting.

Reading this book forced me to think twice about some of the testing techniques I use. Probably I changed my mind about some code I write, both in test and outside. I took some notes for myself.

Now bit of critics

Good indicator if book is for beginners is if it has something like “right click on…” – Yes, this book has few mouse clicks.

Roy introduces many definitions. Some of them are bit contradictional. For example, it might look like there are fakes, stubs and mocks while reading the book, but at some point of time you read this “A fake is a generic term that can be used to describe either a stub or a mock object (handwritten or otherwise), because they both look like the real object.” At least Martin Fowler thinks that fake is different from stub and mock. It is something I also don’t like about definitions in UnitTesting, they are blurred. Every faking mocking framework has its own interpretation and word “mock” is too much overloaded.

As per me, there are some things, which might look not completely professional for the book writer. I mean phrases like this one: “When all else fails and your code is hard to test, you have three choices: use a “super” framework like Typemock Isolator, change the design, or quit your job.” I hope you know why Typemock is highlighted as well. :)

Sometimes stuff is over explained. For example, “One test calling another breaks isolation and introduces a dependency” and then goes explanation why this is bad idea with lots of bullet points. Well, I wouldn’t even think about mentioning stupidity of doing such things.

Book “Working Effectively with Legacy Code” is referenced really often. It worth reading it. I even have hardcopy of it, but only read few pages.

Book is really easy to read. It is straight, well structured and formatted. I enjoyed reading it.

My personal list of things I can improve about my unit testing

Caution: this list is my personal, for you it might look completely different.

– I tend to write extremely testable code, which often results in overengineered design with low percentage of “private” code. Roy recommends to not test methods, which are better left private to code under test.

– Stop overspecifying unit tests.

– One mock per test. I would like to violate this rule less frequently.

– Ideally one assert per test.

– Think more about applying some global testing techniques, like separation of integration tests from unit tests, or fast from slow, etc.

– Utilize more syntaxes and capabilities of testing/mocking frameworks.

Do I recommend the book?

In short, YES. If you are just starting with Unit Tests this book is excellent for your learning and I highly recommend it. If you have developers in your team who need to learn Unit Testing give them this book. Finally, read it yourself, at least scroll parts 1 and 2, read part 3 and slowly scroll part 4.



No comments


Book Review: “Being Geek: The Software Developer’s Career Handbook”

November 21, 2012 Book Reviews, Career 3 comments

Never heard of such book? Don’t panic, I’m here to help you understand if it worth your time or not.

So, last week I read “Being Geek” in hope that it will energize me and give some additional inspiration, which I’m lacking it in my new job, but this is topic for separate post.

I’m not completely sure if I’m any kind of geek, but the book describes people who share many similar habits to those I have and very likely many other developers have as well.

Michael takes you though one reincarnation of your gig from the beginning, when you are just passing an interview until the end, when you are considering to leave. He provides you with lot of hints and tips for any stage of your career, whenever it is negotiating of your salary, creating quality code or leading others.

I’m lucky that I’ve never heard about author’s blog “Rands in Repose” before, because otherwise I would not reap anything new accordingly to reviews on Amazon. I read this book in quick pace, as I usually like short essays talking about our developer’s job. I think that book has increased by baggage of understanding how developers see their profession, how real management should look like, and what are interactions between different types of people in software organization.

Author definitely has much more management experience than average developer has therefore his story is shifted towards company’s core – employees and their interaction. He helps to understand how organizations operate on higher level. I think that this is exactly what I’ve grasped from the book, and what you can also take for yourself.

Do I recommend the book? – Well, if you don’t read Lopp’s blog and if you like career and software craftsmanship books and if you don’t have any other higher priority books in mind, then yes. :)


3 comments


Haskell programming language

October 29, 2012 Haskell, Languages 3 comments

“Haskell is an advanced purely-functional programming language. An open-source product of more than twenty years of cutting-edge research, it allows rapid development of robust, concise, correct software.” This official definition is only missing one point: Haskell is mind-blowing programming language.

First of all, let’s start with realizing that Haskell is all about purity as opposite to many other functional languages, which do a lot of compromises, like Scala. It could be due to the fact that this language was created by a group of highly educated people, or better to say researches. I think their intent was exactly to create language which would be some kind of definition of a pure functional language.

So what does “pure” mean in this context?

As per Joel Spolsky, when answering similar question on SO:

“In a pure functional language, you can’t do anything that has a side effect.

A side effect would mean that evaluating an expression changes some internal state that would later cause evaluating the same expression to have a different result. In a pure functional language you can evaluate the same expression as often as you want with the same arguments, and it would always return the same value, because there is no state to change.

For example, a pure functional language cannot have an assignment operator or do input/output, although for practical purposes, even pure functional languages often call impure libraries to do I/O.”

Personally I found Haskell to be the most exciting programming language among all I’ve ever touched. It has many interesting paradigms and features. Most of them are present in other languages, some are not. I would like to briefly go through some of them.

Currying

In Haskell there is no function that can accept more than one parameter. What?

Well, of course you can write function

add a b = a + b

But, under the hood it is always translated into 2 functions. One of them is responsible for taking parameter a and applying (+) to result of second function. Second function is there to take first function and apply it on b.

Partially applied functions

This allows for partially applied functions, which is completely cool stuff.

map ( * 2) [1,2,3]

In above code ( * 2) is actually partially applied function. We are only supplying one parameter instead of two, expected by the * function. So the result of what we get is a function like (x * 2), accepting parameter x.

This function is then applied to the list [1,2,3] one by one, thus we get: [2,4,6].

As another example, we can extract partially applied function from our add to create function, which always adds 1.

addOne x = add 1

So it can be used like addOne 5 to produce 6.

Lazy evaluation, zipping and few other things

Lazy evaluation isn’t anything new for C# developer. You can think about it as about differed execution in LINQ. Zipping is not something cool, but rather one of the common features of functional languages, but I just wanted to include it here. Below is function every8, which demonstrates mentioned things as well as ranges and recursion.

module Every8thStartingWithSumOfXandY where
  everyThird x = x:everyThird(x+3)
  everyFifth y = [y,(y+5) ..]
  every8 x y = zipWith (+) (everyThird (x)) (everyFifth (y))

You can later use this code to get [4,12,20,28], like below:

take 4 (every8 1 3)

List comprehensions

This code below allows you two have a list, which consists with items which are less than 3:

[x | x <- [1,2,3,4,5,6], x < 3]

Pattern matching and guars

For example we can match on head and tail of list to perform reverse of list:

rev (h:t) = rev t ++ [h]

Combining pattern matching and list comprehensions we can effectively write quick sort in one line:

qSort (m:r) = qSort [x | x <- r, x < m] ++ [m] ++ qSort [x | x <- r, x >= m]

When I wrote this, I was so much amazed if not shocked about how much Haskell is concise and powerful in expressing complex things. I used to write quick sort many times in C++ back in my university days during programming competitions and even it was easy it never took me one minute or one line to write. (Of course, there are performance considerations regarding two implementations, but we are not talking about them now.)

Monads

Don’t be mislead. A lot of other trivial things in Haskell are painful and difficult to implement. To somehow overcome such complexities concept of monads was introduced in functional languages. With them chain of operations can be executed allowing to bypass some data (or state if you will).  “Haskell is overly abstract and seems to complicate the simplest tasks, but once you see how monads unify some of the most difficult concepts in programming: backtracking, continuations, error propagation, state management, and parsing, among many others, you can begin to appreciate how elegant monads really are. But to people not familiar with those topics and their difficulty and who have never seen monadic code, monads are just weird math crap.” said Tac-TIcs. Well, for me they are still very difficult even I can read and understand code with their usage. I’ve prepared some other piece of code, which will probably not bring much light on monads, but it shows usage of build-in Nothing and Just. Defining own monads is hard, and worth separate blog post.

module Main where

look key [] = Nothing
look key ((k, val):rest)
  | key == k  = Just val
  | otherwise = look key rest

al = [(1, []), (2, [(22, "something deep inside")]), (3, [(33, "else")])]

Which can be used like this:

look 2 al >>= look 22

So you can basically work around Haskell’s restrictions and call methods one by one, using this smarty-looking operator “>>=”. Haskell made easy things hard and then introduced Monads to make those hard things easy again. Now you can write code with sugar do-syntaxes.

Conclusion

I’m too new to Haskell to talk about some advanced features and to write programs which are over 10 lines of code. But from what I’ve tried I definitely like the language. This is language for your weekend’s fun. Play with it!

I hope you liked this short Haskell journey.


3 comments


Book Review: “The Pragmatic Programmer”

October 22, 2012 Book Reviews 3 comments

It took me less than one week to reread “The Pragmatic Programmer”.

I like beginning of the book the most, because it introduces pragmatic programmer and I like to think about myself as about such type of programmer.

So who are pragmatic programmers?

Pragmatic programmers are guys with willing to outperform, to stand out of the crowd, always trying to see bigger picture in order to produce higher quality code and to bring more value to customers. They learn a lot, they read technical blogs. You are also pragmatic, as very likely you share similar opinions about doing our job.

We don’t stop on achieved, we continue improving. We don’t just do our tasks, we make sure we do the right thing. We have a vision on our career and on what we want from our professional lives. We don’t complain, we solve problems. Cats don’t eat our source code, and we don’t live with broken window. We keep an eye on what is happening so no one can silently boil us as stupid frogs.

As per book pragmatic programmer is early adopter, inquisitive, critical thinker, realistic and jack of all trades.

This book is critically outdated when it comes to technologies or tools, because it was written IT centuries ago, in 1999. But it is astonishing how up to date it is about all other things.

I strongly recommend reading this book.

I find ideas expressed in book close to my understanding of software craftsmanship and I have my things to remember to become successful developer. In book you will find 70 tips, not just 8 as I have in my post!

I think this book is great because it inspires, and thus I would like to read it once again.


3 comments


Code & Beer: Functional programming languages – Try 1

October 17, 2012 CodeAndBeer, DevMeeting No comments

Last week I’ve failed in organizing internal “Code & Beer” event.

So what I did was just short invite stating that I will be there after working day and whoever wants can come and join. I bought some beer and snacks and mentioned about this as well. At least it should have been a good reason for some to join.

Idea behind this was to learn some new concepts from functional programming, which day-to-day language doesn’t support or encourage explicitly.

As I try to introduce myself to some of the programming languages (including functional), I thought it would be wonderful idea to do this in circle of people who share same attitude to programming.
 
I didn’t have high expectation to number of attendees. I thought that maybe 5 will join, but even less came. A good dozen of people who promised that they will attend had good excuses. 2 people is not enough for effective code & beer session. Not enough laugh and not enough diversity. But no one of us wasted our time, not sure about those who didn’t join though.

I tried small and it went even smaller, maybe if I try bigger it will be at least small? Who knows. But I’m afraid that there is not enough interested developers in my company so it should be something behind company’s walls.


No comments


Professional .NET 2012 – Vienna, Austria

September 24, 2012 Conferences No comments

On September 14, 2012 I attended conference for .NET developers here in Vienna, called Professional .NET 2012.

image

I’m very glad that company has sent me to this conference. Well, it was not any kind of exclusive and expensive conference somewhere abroad, but rather excellent money for value event for employees, who like to improve their professional skills. When I just started I asked about going to Oslo for NDC, which is awesome conference. For new developer it was bit too over budget and I understand it – who knows, maybe in reality I’m crap-code writer, which shall be fired the next morning.

Conference took place in some hotel, and from what I understood, not cheap one. So accordingly it resulted in great tasty lunch. This is always a big plus for any conference. Despite it was called “Professional .NET” I have seen a lot of young people which didn’t seem to have years of experience at all. If I were student I wouldn’t take much out of that day.

Intro and 2 side talks were in German, so I cannot say anything about those, for me it was boring. All other sessions were in English.

Two special presenters were invited and they were core for the conference.

Ayende Rahien just turned all things upside-down. Whatever you learnt from any smart patterns books older than few years is just not acceptable. Everything could be written in very simple manner with depth averaging 4. True or false?

Personally I liked very much the way Ayende presented stuff and how he talked about things and also that he made people think. Even flow of his speech was like some continuing brainstorm. What I didn’t like completely is that he is very concentrated only on one side of the problem, talking like all software is just about reading data from database. Yes, I say something against known Ayende, because I’m sure he shows only one side of the coin. Besides, he likes to blame other people, so why not other people blame him a bit.

If you don’t know Ayende, for sure you have heard about his projects. Oren (his real name) has written Rhino Mocks, RavenDB, NhibernateProfier and contributed to tons of open source projects.

Sebastien Lambla was another special guest. To be honest, I’ve never heard about him before (but I realize now that I read his posts time-to-time). Apparently he has contributed a lot to open source and community, as people, who attended with me knew about him. You maybe heard about OpenWrap or OpenRasta. I just went though this interview with him, to understand more about what he does. Steve Ballmer, you should finally respond him with Microsoft’s vision on open-source!

It was interesting conference, but not a revolution.


No comments


Scala Language

September 3, 2012 Languages, Scala 3 comments

Back in university I had few classes dedicated to Scala programming language. Sometimes suddenly things come back to us.

If you never heard about Scala, here is my very short introduction.

Scala was created as bridge between object oriented and functional languages so that it can run on Java Virtual Machine (JVM) and be fully interoperable with Java classes. As Martin Odersky, creator of language, said “I wanted to show that the two paradigms can be unified and that something new and powerful could result from that combination.”

Scala doesn’t force to write in functional style, however it does have all standard features one would expect from functional programming language. The more you prefer OOP, the more likely that your Scala code will look like Java code. If someone starts with functional languages he or she might get impression that Scala isn’t functional language at all. Personally, if I wanted to learn functional programming I would rather go for Haskell which will “force you to eat the whole functional programming burrito”, as Bruce A. Tate, author of “7 languages in 7 weeks” says.

Scala allows for very laconic syntaxes. Sometimes it is way to much of different syntaxes, sometimes syntax is quaint, for example operator “::=” for adding elements to the list, but once you played enough with language you will be able to write shorter pieces of code than what it would take in most conventional languages.

Here is how you could calculate total sum of string lengths in a list:

val listOfStrings = List("a", "ab", "abc", "abcd")
val totLength = (0 /: listOfStrings) { (length, item) => length + item.length() }
println(totLength)

I also wrote generation of permutations in in lexicographic order:

object PermutationGenerator extends App {

  var perm = Array[Char]('a', 'b', 'c', 'd')
  printPerm(1, perm)

  for (i <- 2 to factorial(perm.length)) {
    perm = nextPermutation(perm)
    printPerm(i, perm)
  }

  def factorial(n: Int): Int = n match {
    case 0 => 1
    case x if x > 0 => n * factorial(n - 1)
  }

  def printPerm(i: Int, a: Array[Char]) {
    print(i + ": ")
    a.foreach(c => print(c))
    println()
  }

  def swap(a: Array[Char], i: Int, j: Int) {
    val tmp = a(i)
    a(i) = a(j)
    a(j) = tmp
  }

  def nextPermutation(a: Array[Char]): Array[Char] = {

    val k = (a zip a.tail) lastIndexWhere { case (x, y) => x < y }

    val l = a lastIndexWhere { c => a(k) < c }

    swap(a, l, k)

    return a.take(k + 1) ++ a.takeRight(a.length - k - 1).reverse
  }
}

Code above isn’t functional or imperative completely but rather some combination. Scala is different from other languages, because it allows for such flexibility. There are languages which make easy things hard and hard thing easy. In Scala it is up to you. For example, to avoid swap method (mutable operations) I could have wrote this “obvious” statement:

return (a.take(k) :+ a(l)) ++ ((a.takeRight(a.length - k - 1).take(l - k - 1) :+ a(k)) ++ a.takeRight(a.length - l - 1)).reverse

Few days ago I also wrote one application to continuously traverse web site and find there some specific links and then send e-mail with complete list of them. But to be honest I gave up debugging it and finding problems, even Scala has more or less accepted integration in eclipse IDE. App was rewritten in C#. My cheating was supposed to win T-shirt to my wife. Surprisingly the site went down next day. My guess is I was not the only one smart-ass to do traversing of the site.

I only took few baby steps, but from what I know now I feel deep sympathy to this language.

Links:

How and Why Twitter Uses Scala

Scala official introduction

Have you every programmed in Scala? How was it?

I imagine that it was fun, but would like to hear from you.


3 comments


My First Presentation in a New Company

August 5, 2012 DevMeeting, Presentation, Success 2 comments

A long time passed since I’ve delivered a technical presentation. Mainly because I now live in another country and establishing myself in a new company.

Well “establishing” is loudly said. I’m just software developer. Probably it worth to write separate post on my experiences in this company, since it is very much different from one I worked in Ukraine and I’m sure from most other companies there. I think I had much better perspectives as speaker before I moved (at least those short-term perspectives).

I talked about OData protocol, starting with introduction (read blog posts OData and OData service with WCF and data in memory) and finishing with its applicability to a project we do. Thanks to this presentation I crossed some imaginary mental barrier to more frequent presentations and sharing knowledge, something that I like, and something that I started to take solid steps back in Ukraine.

Now I’m starting it from the beginning.

Presentation I delivered was rather not official and only team wide. It was first I ever delivered in English, so I was limited in number of language tricks which I can use, and probably it impacted quality. Also I didn’t want to make it look like I’m smart-ass, thus I used pace and tone of a normal working meeting. Well, to be honest, I even didn’t know how to behave in this new environment. But from what I see guys liked my presentation, so this gives me a bright spark of enthusiasm to continue sharing interesting stuff.

There are few pitfalls with continuing, some of them pleasing. For example, developers here on average are more experienced and it would be more difficult to surprise them with something. It means that I would need to prepare more in depth topics, which of course requires more time to prepare. But, in the end, it is great that I work with more experienced programmers than me. On the other hand, I’m afraid that most of guys I know here are not willing to spend their spare time to form or join some community of software developers, and I can understand them.

Since I already mentioned about community, I have some ideas about organizing something cool here in Vienna/Austria, for foreigner developers, like me. Will blog about it soon.


2 comments


Book Review: Programming WCF Services

July 22, 2012 Book Reviews, WCF 2 comments

To be honest, for me this was the most exhausted reading since years. I started reading this book probably year or even more ago. Always coming back to it in hope that at some point of time it will grasp me into normal pace of reading, so I will be able to finish it. But it was not the case.

Though I finished the “Programming WCF Services”, I’m bit disappointed. I thought that the book will serve me with deep insight into advanced topics in easy to consume manner. Instead it jumped from extreme basics to intermediate and to advanced, but always with chunks of code, which were either boring or repeating or difficult to understand by simple reading. When I was about to try something out articles from internet were more helpful for me then code from book.

The book is good in what it does, but now I think about it more like about cookbook and not like about book you read from beginning to the end. It was my mistake to read it like that.

I feel myself comfortable with WCF. Reading this book was to strengthen my knowledge in WCF and to open tough things I didn’t know. I’m afraid that I did not met what I expected. Of course no one can remember all innumerous extension points or tricky security configuration or other wide range of stuff possible with WCF. Probably author of the book knows everything he wrote by heart. I wish I have super memory, but I often forget a lot of things I read about. Pity! If you know basics and understand core principles it should not be a problem to figure out what you need with couple of MSDN pages and some googling. I hope I will manage my further assignments even without knowing all possible combinations of configurations of WCF, even I look stupid not being able to shot people with immediate WCF solutions/answers/ideas.

One more lesson learned: It is better to play more with things you what to learn about than to obdurately read comprehensive book about those things.


2 comments