Development on Various Platforms
12.8K views | +0 today
Follow
Development on Various Platforms
Your new post is loading...
Your new post is loading...
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Object Oriented Javascript

Object Oriented Javascript | Development on Various Platforms | Scoop.it

If you are reading this I’d like to assume you know what Javascript is and the fact that it’s object oriented, what not many people know though is how to do the most common object oriented “things” in Javascript, such as inheritance, private functions and such.

The fact that Javascript is prototype based and not class based is what makes it hard to get into for most programmers. If you come from Java, PHP, C#, C++, Python, Ruby or pretty much any language you’ll find objects in Javascript are a bit unique, and they certainly are but in a good way!

 

* Prototypes
* Constructor Functions
* Encapsulation
* Inheritance
* Static vs Instance
* Abstracting it up a bit
* Conclusion


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

jTypes - emulate classical inheritance where objects are defined by classes

jTypes - emulate classical inheritance where objects are defined by classes | Development on Various Platforms | Scoop.it
jTypes is the most comprehensive and robust JavaScript library for overcoming differential inheritance with prototype-based objects.

 

jTypes will provide you with the ability to develop robust, modular, and scalable application libraries in JavaScript using encapsulation, inheritance, and polymorphism. What exactly does that mean? You know all those keywords from languages such as C++ or C# that you started missing quite badly after you transitioned to JavaScript? You know what we're talking about; all those modifiers of classical inheritance such as virtual, abstract, and override or private, protected, and public that gave you so much more control and freedom with your libraries. Well jTypes lets you use those keywords in JavaScript, so you can develop extremely powerful and robust web applications using the principals of classical inheritance.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Javascript Modules, AMD, and the road ahead.

Javascript Modules, AMD, and the road ahead. | Development on Various Platforms | Scoop.it

There are many design patterns used in Javascript and I would recommend taking a look at Javascript Patterns by Stoyan Stefanov for a full introduction to the most widely used patterns. Of the design patterns available, the Module pattern has gotten the most recognition in the past few years thanks in part to the maturation of the module pattern via commonjs as well as the wild success of node.js.

 

The Module Pattern

In a nutshell the module pattern allows you to create code that can expose a public API while safe guarding private variables and methods behind a pseudo blackbox.

 

The future looks bright

We’ve looked at the basic Module pattern and seen how to use it to create some really powerful Javascript. We then took a look at how AMD works and how we could easily change our code to build our modules following the Commonjs specification for asynchronous modules, lastly we took a look at the bleeding edge harmony modules specification. I find that it is easy to see the beauty of where ECMAscript 6 is heading, with respect to modules, when you take a look back at where we’ve already been and how we’ve evolved up to this point.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Partial Application in JavaScript

Partial Application in JavaScript | Development on Various Platforms | Scoop.it

Unless you've used a functional programming language such as ML or Haskell, concepts such as partial application and currying may be foreign to you. Since JavaScript supports first-class functions, once you understand these concepts, you can put them to use in your code.

Whether writing code just for yourself or presenting an API to your users, it's often helpful to create a more specialized function as a "wrapper" to a more generalized function if you expect to be performing a task repetitively. One way to do this would be to just define the functions manually.


Via Jan Hesse
more...
Mickael Ruau's curator insight, October 9, 2013 5:28 AM

Concepts de programmation  fonctionnelle utilisables en javascript.

Jan Hesse's curator insight, October 12, 2013 4:39 AM

more current post at: http://benalman.com/news/2012/09/partial-application-in-javascript/

Oriol Lluch's curator insight, October 15, 2013 4:19 PM

Great Article to understand the concept behind functions in Javascript

Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Scaling Isomorphic Javascript Code

Scaling Isomorphic Javascript Code | Development on Various Platforms | Scoop.it

Design patterns are the bread and butter of application development. They encapsulate and outline the concerns of the application and the environment of the in which it exists. Between the browser and the server these concerns can vary widely:
* Is the view ephemeral (e.g. on the server) or long-lived (e.g. in the browser)?
* Is the view reusable across different use-cases or scenarios?
* Should the view be annotated with application-specific tags or markup?
* Where should the bulk of the business logic reside? (in the model? in the controller?)
* How is the application state persisted or accessed?
Lets explore some of the existing patterns and how they answer these questions:
* Model-View-Controller
* Model2
* Model-View Presenter and Model-View-ViewModel
* Modern Javascript Implementations
* Real-time Implications
* tl;dr? Introducing Resource-View-Presenter
* Conclusion


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Writing High Quality Code

Code must work, but
* fixing a bug introduces (many) new bugs
* a new developer cannot (easily) comprehend the code
* implementing changes/features is (extremely) difficult
* no, or not up-to-date documentation
* cross browser problems

 

Quality
* is degree of perfection of a product
* is the standard of something as measured against other things of a similar kind


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Dependency Injection in Node.JS

Dependency Injection in Node.JS | Development on Various Platforms | Scoop.it

Dependency injection frameworks are relatively uncommon in node. On the client, Angular uses dependency injection, but the learning curve of Angular is so steep that the core of dependency injection ends up being obscured by all the other concepts. Generally, javascripters think of dependency injection as "that thing Martin Fowler invented."

Despite its reputation as an obscure Design Pattern, dependency injection is a pretty good idea. In fact, i.TV wrote their own dependency injection framework, dependable, when they realized they were doing it manually throughout their application code. By using dependency injection, we've been able to clean up a bunch of boilerplate code, keep our codebase tidy, and solve Real Problems in application development.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Classless JavaScript

As JavaScript developers, or even web developers as a whole, we seem terrified by the thought of direct usage. No technique or idea seems to be considered “legit” until it has been abstracted by several layers of syntactic sugar and, potentially useless, fluff.

One of the common abstractions is the addition of “classes” to JavaScript; prototypical inheritance isn’t good enough for us lot by the looks of things. We seem to crave the features of other languages when our language of choice isn’t really built for them, it’s built in a different way and probably shouldn’t have classical inheritance principals forced down its VM / throat.

So what if we worked with JavaScript in a more natural way? First, what would be more natural? Personally I believe that, like the underlying language, everything should revolve around objects; we create and manipulate these malleable entities instead of trying to lock things down and restrict our data.

This idea lends its self exceptionally well to functional programming and the actual VM, which no longer needs to mess with prototype chains or any other form of inheritance for that matter. It’s as raw as JavaScript usage can get, it’s kind of like C structs (although nothing like them at the same time) and I think it’s pretty elegant.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

The "Magic" behind AngularJS Dependency Injection

If you’ve built anything with AngularJS you know there’s a lot of “magic” that you can usually ignore because it just works. One of the most magical parts for me is dependency injection. Just by adding a parameter to your controller function you suddenly get access to a powerful Angular service. It’s really pretty amazing but you sorta just have to trust it … until something goes wrong.

It turns out one easy way to break an AngularJS app is to minify your javascript. This happened to me when I deployed my app to production. The Angular app was being served from a Rails application and Rails automatically minifies javascript in prodution. It turns out there’s a simple and a well documented fix in their tutorial (search for “A Note on Minification”) that boils down to “use an array of parameter names” but it wasn’t clear to me why it worked.

In the rest of this article we’re going to
* Build a simple AngularJS application
* See how magical dependency injection is
* Investigate how dependency injection is implemented in AngularJS
* Break our app by minifying the javascript
* Understand how the fix works


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Surviving Big JavaScript Projects

Surviving Big JavaScript Projects | Development on Various Platforms | Scoop.it
Anton Kovalyov provides an inside look into a large JavaScript project, presenting techniques for maintaining code quality while allowing the team to push lots of changes every day.

Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Exploring JavaScript prototypes via TypeScript’s class pattern

Exploring JavaScript prototypes via TypeScript’s class pattern | Development on Various Platforms | Scoop.it

In this post, I’m going to take a close look at how JavaScript’s prototypal inheritance works by analysing how Microsoft’s TypeScript language uses it to provide a simple implementation of classes. Don’t worry if you’ve never used TypeScript, we’re not really concerned with the language itself here, just the JavaScript that is produced by its compiler, and how it achieves class-based inheritance in a language that doesn’t natively support it.

This is of particular importance because EcmaScript 6 will include classes that work a lot like TypeScript’s. The idea of adding classes to JavaScript is controversial, but I think some of the hostility stems from a mistaken belief that classes are some kind of competing inheritance mechanism to prototyping, or are an attempt to turn JavaScript into Java. In fact, modern proposals for classes in JavaScript are just a syntactic codification of prototypal inheritance patterns that are already in use.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Knockout.js tips and tricks

Knockout.js tips and tricks | Development on Various Platforms | Scoop.it

Knockout.js is a very powerful 2-way binding MVVM framework for JavaScript built by Steve Sanderson. The basic idea is rather than work directly with the DOM, a ViewModel ties a JavaScript object to the DOM and any updates to the ViewModel are automatically reflected in the DOM and any DOM changes are reflected in the ViewModel. It provides very little opinion on specifics about how to structure applications which makes it flexible.

Below are some tips and tricks I've learned in using Knockout in a few large scale applications.

* Context Issues
* Better ViewModels with a BaseViewModel
* Accidental Rendering Templates
* Using Extenders
* Working with fn
* Require.js
* Custom Bindings
* Conclusion


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Functional reactive programming in JavaScript

Functional reactive programming in JavaScript | Development on Various Platforms | Scoop.it

Mid May, I gave a talk at NodePDX on functional reactive programming in JavaScript. I discussed the general ideas behind the programming paradigm and various implementations that exist. The video is finally available online and the slides are also available.

 

* Flapjax

* Reactive Extensions (RxJS)

* Shafty

*Javelin

* Bacon.js

 


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

AngularJs Good Unit Test Structure For Controllers & How to test ajax code and Promises

AngularJs Good Unit Test Structure For Controllers & How to test ajax code and Promises | Development on Various Platforms | Scoop.it

The poorly the structure is made for unit testing the more and more complected it will take to write a unit test for a simple functioning piece of code , and it will feel that your fighting your way against testing, instead it should feel more fun! So i’ll be showing a structure that worked for me very well when working with angular controllers Before going deep with the structure, i’ll be using

* Jasmine (unit testing)

* Jasmine spies (mocking)

* karma (because its awesome)


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Applicative Programming In JavaScript With lodash.js

Applicative Programming In JavaScript With lodash.js | Development on Various Platforms | Scoop.it

n general, applicative programming is the pattern of defining a function that takes a function and then invokes that function for each element in a collection/list. To apply this definition of applicative programming to JavaScript, you will need to know a little something about first-class functions before we dive in. So, let's start there.

JavaScript has first class functions. This means that instances of the Function constructor can go and do anything any value in the language can do because functions in JavaScript are values.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Learning from Javascript Libraries

Learning from Javascript Libraries | Development on Various Platforms | Scoop.it
Learning from Javascript libraries by Trevor Landau is a talk on interesting patterns that popular libraries like jQuery, Backbone, Angular, and more use to solve problems.

jQuery runs on approximately 50% of all websites and is the de facto standard for DOM manipulation. Most front end developers use it, but how well do they understand what’s happening when they use the API? How does a library take on the problems it solves? What are the reasons behind some of the techniques it uses? Observing the code under the hood of a library/framework is a fantastic way to become a better developer and thereby user of that library/framework. Better understanding of design patterns in some of the most popular libraries can open opportunities to contribute and be a better open source citizen.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

JavaScript Testing Tactics

JavaScript Testing Tactics | Development on Various Platforms | Scoop.it

A different approach to JavaScript testing

This talk is the missing manual to writing great JavaScript tests. I'm very excited to share it with you, because I really believe it can change how you approach writing software; this journey certainly has for me.

This talk, as delivered at DevReach in Sofia, Bulgaria, is the culmination of years of practicing to write beautiful JavaScript tests that provide just the right feedback to prompt me to take actions which dramatically improve the design of my code. As a result of my singular focus, my approach is very different than what you'd find searching for a tutorial or a README about JavaScript testing, TDD, or unit testing in general.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Compose, don't inherit (not a lot anyway).

Compose, don't inherit (not a lot anyway). | Development on Various Platforms | Scoop.it

Lately I've seen a lot about JavaScript Inheritance and in particular different github projects that allow you to do inheritance in a certain way. Most of these solutions are about trying to use some form of classical inheritance and with good reason. If you're used to any other language then that is probably what you learned and so it makes sense. Also there can be performance gains as using a "class" means you won't be mutating an object's signature and as such a JavaScript runtime can make optimizations for that "type".

There are also some good articles about what JavaScript inheritance is really about and if you only read one, make sure to read Kyle Simpsons: JS Objects.

But do we really need long inheritance chains where we link up lots of objects and have lookups going up a chain? As JavaScript is so flexible can we learn things from Functional and Aspect Oriented styles of programming? I think we can.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

syringe - An ultra-lightweight dependency injection framework for JavaScript

syringe - An ultra-lightweight dependency injection framework for JavaScript | Development on Various Platforms | Scoop.it

Syringe is a teeny-tiny JavaScript dependency injection framework that allows you to dynamically assign data contracts to your functions and methods. No more worrying about passing information directly, indirectly, or relying on the lexical scope as Syringe can vaccinate your operations ahead of time!

Now, let's roll up our sleeves and begin shall we?


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

In praise of AngularJS

I can think of two main stumbling blocks: “Dependency Injection” and all that “service”, “factory”, and “controller” stuff (not to mention “directives”). And Model-View-Something.

It’s not hard. It wasn’t designed to be hard. The terminology is pretty clever. I’d say that it was invented to produce a mental model which can be used and extended. And like a beautiful clock, it doesn’t start ticking until all the little pieces are positioned just right. Then it will run (and evolve!) forever.

Dependency injection is nothing new, it’s essentially another name for “require” (Node.js), “import” (Python), or “#include” (C/C++). 

That’s dependency injection. And Angular uses it all over the place. It will often call functions through a special “injector” and get hold of all args expected by the function. One reason this works is because closures can be used to get local scope information into the function. Note how myCode had access to “value” via a normal JavaScript closure.

In short: dependency injection is a way for functions to import all the pieces they need. This makes them extremely modular (and it’s great for test suites, because you can inject special versions and mock objects to test each piece of code outside its normal context).

The other big hurdle I had to overcome when starting out with Angular, is all those services, providers, factories, controllers, and directives. As it turns out, that too is much simpler than it might seem...


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Hailing All Frequencies - Communicating in AngularJS with the Pub/Sub Design Pattern

Hailing All Frequencies - Communicating in AngularJS with the Pub/Sub Design Pattern | Development on Various Platforms | Scoop.it

In this article I show you how to use the Pub/Sub Design Pattern for inter-component communications in AngularJS.

 

AngularJS has several ways that you can use to communicate between components, but the most used methods require your components to know too much about those they are communicating with, which increases the coupling between components and decreases their modularity and cohesion. This makes it hard to reuse your components in other applications.

By using the Publish/Subscribe design pattern we can decrease the coupling between components and encapsulate the details used for component communications. This will help increase your component’s modularity, testability and reuse.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Testable JavaScript

Testable JavaScript | Development on Various Platforms | Scoop.it
Mark Ethan Trostler conducts a tutorial on getting started with JavaScript testing.

Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Ask Not What JavaScript Can Do For You

Exploring how hard it is to write well structured and error safe code in vanilla JavaScript.


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Modern JavaScript: Promise patterns

Modern JavaScript: Promise patterns | Development on Various Platforms | Scoop.it

Promises are great for giving us a way of writing asynchronous code without having to indent our code but if that's the only thing you're using them for then you're missing the point of promises. Promises are an abstraction that make doing several things easier. They have two properties that make them easier to work with:

* You can attach more than one callback to a single promise

* values and states (errors) get passed along

Because of these properties it makes common asynchronous patterns using callbacks easy. Here are some cases which may pop up from time to time: 

* Converting callback functions to return promises

* Sequential Calls

* Error Handling

* Pool

* Some fun


Via Jan Hesse
more...
No comment yet.
Rescooped by Ertunç Efeoğlu from JavaScript for Line of Business Applications
Scoop.it!

Better JavaScript with Strict Mode and JSHint

With great flexibility comes great responsibility… and JavaScript is very flexible.  Too flexible, some might argue.  There are many “features” of JavaScript that result in code that is hard to read, dangerous or buggy to execute, and in some cases creates performance issues.  In 2008, Douglas Crockford wrote a fantastic book called “JavaScript: The Good Parts” that described the features he found problematic: global variables, the assignment of ‘this’ to the global object, misuse of eval, etc.  If you write JavaScript, it’s a must read.

Several of the “bad” features Crockford identified have been mitigated with “Strict Mode.”  This was added to version 5 of ECMAScript (the JavaScript standard; supported by most popular web browsers).  Strict mode throws exceptions or prevent behavior when “bad” features or common coding errors are evaluated.  A couple of examples…


Via Jan Hesse
more...
No comment yet.