Understanding MVC Views in PHP

Note: the MVC and MVC-inspired patterns are advanced constructs. They are meant to be used in codebases where ordinary object-oriented (that follows SOLID and other guidelines) code starts to become unmanageable. By introducing this pattern you would impose additional constraints, which then lets you to contain very complex applications. MVC is not meant for “hello … Read more

What’s the best way to convert a number to a string in JavaScript?

like this: var foo = 45; var bar=”” + foo; Actually, even though I typically do it like this for simple convenience, over 1,000s of iterations it appears for raw speed there is an advantage for .toString() See Performance tests here (not by me, but found when I went to write my own): http://jsben.ch/#/ghQYR Fastest … Read more

Prefixing property names with an underscore in Objective C [duplicate]

I always use underscores. It creates a clear distinction between local variables and instance variables. It also avoids compiler warnings in the following situation: @interface MyClass { NSString *name } @property (nonatomic, copy) NSString *name; – (id) initWithName:(NSString *) name; @end @implementation MyClass @synthesize name; // The following method will result in a compiler warning … Read more

What kinds of patterns could I enforce on the code to make it easier to translate to another programming language? [closed]

I’ve been building tools (DMS Software Reengineering Toolkit) to do general purpose program manipulation (with language translation being a special case) since 1995, supported by a strong team of computer scientists. DMS provides generic parsing, AST building, symbol tables, control and data flow analysis, application of translation rules, regeneration of source text with comments, etc., … Read more

What is the purpose of wrapping whole Javascript files in anonymous functions like “(function(){ … })()”?

It’s usually to namespace (see later) and control the visibility of member functions and/or variables. Think of it like an object definition. The technical name for it is an Immediately Invoked Function Expression (IIFE). jQuery plugins are usually written like this. In Javascript, you can nest functions. So, the following is legal: function outerFunction() { … Read more