in my previous post http://sadekdrobi.com/?p=25 i listed some  Satisfaction Confusions that we are having in
popular imperative procedural object oriented statically typed C-like syntax programming languages, the question was where the goodness really comes from, and what are the drawbacks to such confusions.
One epression that is lately often used to stegmatise a piece of code is to tell “not object oriented”.  This expression is a good sign of something we always waited, which is the awareness of the majority of today’s developers of the importance of the Object Oriented programming principiles. But on the other hand, the expression itself highlights another satisfaction confusion. Even myself, i sometimes feel it an insult to be told that my code is not object oriented, so what?!! should it be? or… it is not meant to be !!!
 Yes it is not, consider microsoft’s dotNet’s delegates, they are methods holders, they are not object (forgetting about the implementation behind) , each time i talk about delegates (and spesifically about observer pattern implementation in dotNet) to a Java guru, i get an instant reaction “hey! thats not oop” or “you cant compare that to the royal anonymous class” , and my answer is SURE YOU CAN NOT, java anonymous classes are a lot of goodness, but delegates are quite handy, why to construct an interface when u need to pass really one method.
The goodness of delegates makes observer’s usage in dotnet is quite easy , as easy as to subscribe to an event Event;
u do event+= a delegate that carries your method that has the suitable signature, and if your really think about it, you’ll find out that passing functions arround is not a microsoft’s inventery, that all what Functional Programming about…
consider the following example:
this piece of code enumerates a list of integers and returns a new list of their squares
IList newList= new List();
foreach(int i in list){
 newList.Add(i*i);
}
what if i want to get a list of every element i*2 , or maybe something else, i have each time to rewrite the Enumeration , and do the think,
so if we consider this piece of code that returns the sum of the elements in the list
int sum=0;
foreach(int i in list){
 sum+=i; }
what if i want the sum of the squeres? it makes sense to pass a function huh?
In fact functional programming ( and others like logical Prolog ) features are quite missing in most of today’s industrial popular languages. Even if -in my opinion- there construction is more logical and meaning revealing than instruction based languages.
But using these features doesnt mean that we forget objects, nor modelling and other practices we ever learnt. The point is TO FREE OUR MINDS!
But what about performance? well today’s prformance problem is not anymore like yesterdays, now we are adding more several processors to the machine than adding a more powerfull one. But in imperative languages u tell the machine exactly how to do, whereas in other paradigms (like functional programming ) you tell it what to do, and you leave the machine the freedom of how to do it! delegating some of the tasks of optemization to the machine than the developer.
Adding to all of that the fact that this might be more Domain Driven Designs’s Ubiquitous Language friendly ( see Eric Evans DDD ).
Think freely, think in terms of what you need, and not what you like, use OOP when you need it, functional when it makes sense, predicates where it really fits.
What we really need is a level of maturity of developers when thay can decide how to do, not in terms of fashion, nor of feelings or habite, but in terms of need, then we can make a better choice i guess…
Doesnt all of that make sense?


For me , a more satisfacting programming language should be, object oriented , not absolutely imperative but has its important features, not absolutely functional but has its fun , C-driven familiar syntax, statically typed , reflecive for dynamic features…
i guess i am taking about C# 3.0 ? linq? or maybe F#? who cares!
Comment by sadek — February 18, 2007 @ 12:51 am
[...] part 2 : http://sadekdrobi.com/?p=26 [...]
Pingback by Sadek Drobi’s Blog » Obsev:: Satisfaction Confusion — February 18, 2007 @ 12:53 am
Absolutely correct. The only thing I disagree is that this kind of decision should come from the developers. I believe this type of choices should be in the hands of the Tech Architect, since it´s his job to know the choices and to decide which one fits best in the problem domain you got. Now, if you have a Tech Architect in the team and he keeps telling you that you should use OO no matter what and close your eyes to the whole wide world, I´d say he´s not a really good one.
In the company I work for I do this job, and we started doing some stuff in PowerShell (Oh MY GOD?! You using the damned CONSOLE??!?!) for the IT guys, since it enhances their productivity and makes deployment a lot easier. We are considering using IronPython for some scripting capabilities we need in our applications. Whatever nice thing we find that will make us more productive, enhance the quality of our software and make our jobs easier, by all means we are taking it!
That´s the point that I agree with you. People should stop being so close-minded and start looking around other people´s work. There are some smart people around you know? :) I do check CodePlex a lot to see if there are any projects that will help me and my teams, and if it does I try to get in contact with whoever is coordinating it to see if it´s a serious effort.
So I guess the message you are trying to send is quite correct: No solution fits all problems, and think about your problem before using that one good ol´ solution that you always use. The discredited solution might prove invaluable!
Comment by Bernardo Heynemann — February 21, 2007 @ 10:19 pm