Public Fields versus Automatic Properties

In a related question I had some time ago, there was a link to a posting on Jeff’s blog, explaining some differences. Properties vs. Public Variables Reflection works differently on variables vs. properties, so if you rely on reflection, it’s easier to use all properties. You can’t databind against a variable. Changing a variable to … Read more

What are data classes and how are they different from common classes?

Data classes are just regular classes that are geared towards storing state, rather than containing a lot of logic. Every time you create a class that mostly consists of attributes, you make a data class. What the dataclasses module does is to make it easier to create data classes. It takes care of a lot … Read more

Java Generics With a Class & an Interface – Together

Actually, you can do what you want. If you want to provide multiple interfaces or a class plus interfaces, you have to have your wildcard look something like this: <T extends ClassA & InterfaceB> See the Generics Tutorial at sun.com, specifically the Bounded Type Parameters section, at the bottom of the page. You can actually … Read more

Is it possible to make abstract classes in Python?

Use the abc module to create abstract classes. Use the abstractmethod decorator to declare a method abstract, and declare a class abstract using one of three ways, depending upon your Python version. In Python 3.4 and above, you can inherit from ABC. In earlier versions of Python, you need to specify your class’s metaclass as … Read more

Difference between a class and a module

╔═══════════════╦═══════════════════════════╦═════════════════════════════════╗ ║ ║ class ║ module ║ ╠═══════════════╬═══════════════════════════╬═════════════════════════════════╣ ║ instantiation ║ can be instantiated ║ can *not* be instantiated ║ ╟───────────────╫───────────────────────────╫─────────────────────────────────╢ ║ usage ║ object creation ║ mixin facility. provide ║ ║ ║ ║ a namespace. ║ ╟───────────────╫───────────────────────────╫─────────────────────────────────╢ ║ superclass ║ module ║ object ║ ╟───────────────╫───────────────────────────╫─────────────────────────────────╢ ║ methods ║ class methods and ║ module methods … Read more

Use of .apply() with ‘new’ operator. Is this possible?

With ECMAScript5’s Function.prototype.bind things get pretty clean: function newCall(Cls) { return new (Function.prototype.bind.apply(Cls, arguments)); // or even // return new (Cls.bind.apply(Cls, arguments)); // if you know that Cls.bind has not been overwritten } It can be used as follows: var s = newCall(Something, a, b, c); or even directly: var s = new (Function.prototype.bind.call(Something, null, … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)