0

Mostly I've worked with JavaScript, but am currently working with C#. It occurred to me that when programming and taking into account object hierarchies, that in both cases I don't really know how the code is being executed.

When writing 'class' hierarchies in JavaScript I found that Java programmers were scandalized about defining these hierarchies external to constructor definition. For example:

function SomeConstructor() {}
SomeConstructor.prototype.someMethod = function() {}
var someItem = new SomeConstructor()
someItem.someMethod()

This is quite different to the way a traditional OOP language is constructed (at least in my less than 2 years of experience), for example in C#:

public class SomeClass{
  public SomeClass() {}
  protected void SomeMethod() {}
}
SomeClass someItem = new SomeClass();
someItem.SomeMethod();

Question: Do language paradigms such as OOP focus on improving efficiency of code execution, developer output (i.e. ease of use), or both?

Zach Smith
  • 8,458
  • 13
  • 59
  • 133
  • I believe this question is better suited for [SE](http://softwareengineering.stackexchange.com/) website – yeputons Feb 03 '17 at 10:50
  • @yeputons when referring other sites, it is often helpful to point that [cross-posting is frowned upon](http://meta.stackexchange.com/tags/cross-posting/info) – gnat Feb 03 '17 at 11:12
  • I think it's possible to move questions? But I don't think I have that privilege – Zach Smith Feb 03 '17 at 11:30

1 Answers1

1

Question: Do language paradigms such as OOP focus on improving efficiency of code execution, developer output (i.e. ease of use), or both?

I would say that object-oriented programming (OOP), aspect-oriented programming (AOP) and other paradigms are on the highest level possible.

The higher is the layer, the more focus is put on productivity.

Therefore, I would conclude that OOP, AOP and other paradigms implemented on programming languages are focused on productivity and efficiency is a task for compilers, which do a lot of magic that otherwise would produce an extremely inefficient compiled code.

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
  • I was told about AOP by a senior dev where I used to work, and then asked not to try it at all. I kind of see how it would be frustrating when results of a program are not directly defined in the code that you are looking at. Saying that, would it be fair to say that the higher the level of abstraction, the more difficult it is to read someone else's code? Seems like there is a tradeoff between 'developer efficiency', 'maintenance efficiency' and 'compiled code efficiency' - or 'difficulty in making compiled code efficient'. Thank you for the answer – Zach Smith Feb 07 '17 at 09:32
  • @ZachSmith A procedural-only programmer would also say that you shouldn't go into OOP at all because you need to implement more code to do the same thing. AOP is suitable for specific cases while OOP is more generic. If the rule of the higher is the abstraction, the more difficult is to read the code, then it's simply because that higher concept isn't well implemented in the language, library or framework. Just take a look at frameworks like PostSharp and how you can do a lot of things behind the scenes leaving the code cleaner than one that wouldn't use AOP at all. – Matías Fidemraizer Feb 07 '17 at 09:47
  • @ZachSmith Also, take a look at some of my libs, https://github.com/mfidemraizer/trackerdog. Would change tracking be that easy if I wouldn't use AOP? :D See the tutorial [here](http://matiasfidemraizer.com/trackerdog/html/52e40f26-3dfe-47e0-adf1-09233e98f42e.htm) and I believe you'll build your own positive opinion about AOP. – Matías Fidemraizer Feb 07 '17 at 09:48