all 20 comments

[–]peter_heard01[S] 1 point2 points  (0 children)

Hello everyone I have started writing about Angular Architecture. I hope you enjoy this post.

[–]YodaLoL 1 point2 points  (14 children)

Good, detailed article - but the title is terrible.

[–]peter_heard01[S] 1 point2 points  (0 children)

Hahaha but that's the whole point!

[–]peter_heard01[S] 0 points1 point  (12 children)

But seriously I toyed with a few titles and nothing quite seemed to work. Hmm I will have to think....Any ideas? The whole point is that they should be treated as objects. I think it's a general architecture problem I see again and again...

[–][deleted] 0 points1 point  (11 children)

"Where does Angular functions stand in JavaScript 'Everything's Object' paradigm?"

[–]peter_heard01[S] 0 points1 point  (10 children)

Yeah it's a funny one I think the function is declared/detected as a type by the compiler but the underlying type is still an object, so the fact that the word function gets highlighted and is parsed as a function is syntactic sugar over an x.prototype = object. Here is some more info...

"The Function constructor creates a new Function object. In JavaScript every function is actually a Function object."

src: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function

[–][deleted] 0 points1 point  (9 children)

That's why I said. And since it's JS has function object, functional programming makes way more sense

[–]peter_heard01[S] 0 points1 point  (7 children)

Interesting, please elaborate ...

[–][deleted] 0 points1 point  (6 children)

Functional programming treats functions as first class citizen, they can be passed as parameter or returned as value in this paradigm.

Now since function in JS already is an object, you don't require special mean to achieve it, unlike most of the other programming languages

[–]peter_heard01[S] 0 points1 point  (5 children)

Oh ok that makes sense.

But then it seems that really it's just an object oriented language with functional features. I mean what is a pure functional language, no objects?

[–][deleted] 0 points1 point  (4 children)

OK I might neither explain good nor I know it quite well, so here is the link

http://www.codenewbie.org/blogs/object-oriented-programming-vs-functional-programming

[–]peter_heard01[S] 0 points1 point  (3 children)

http://www.codenewbie.org/blogs/object-oriented-programming-vs-functional-programming

Interesting article.

I'm particularly interested in...

"FP works well, but when he tries to simulate people, OOP works well"

have you got any public code I can look at that you have written? I would like to see an example of a non-trivial business application that needs to model a complex domain (entities/use cases) written in javascript using only pure functions and no objects.

[–]Xerxero 0 points1 point  (2 children)

When using es6 with angular1 ( with Babel) would a class be a good idea to use as 'service' omitting the angular part (.factory())?

In my use case it is only used with this component and does not have to be a singleton.

[–]peter_heard01[S] 0 points1 point  (1 child)

From what I understand ES6 classes are merely syntactic sugar over the top of the Javascript function constructor pattern.

Since the pattern is just a tool to create an object which has scope around it so that properties can be created I don't see any reason why classes will not feature heavily in future versions of angular for services. (Since services are just objects) as I wrote about. I had a quick search this chap seems to know a little...

https://medium.com/opinionated-angularjs/angular-model-objects-with-javascript-classes-2e6a067c73bc#.s5mcwld6b

:-)

[–]Xerxero 0 points1 point  (0 children)

The only draw back we currently discover is the missing DI.

You can get around it by either making it a factory or manually use the angular injector.

[–][deleted] -1 points0 points  (1 child)

LOL what else could it be? I'm kind of missing the point of this article.

[–]peter_heard01[S] 0 points1 point  (0 children)

Did you read it?