“public” or “private” attribute in Python ? What is the best way?

Typically, Python code strives to adhere to the Uniform Access Principle. Specifically, the accepted approach is: Expose your instance variables directly, allowing, for instance, foo.x = 0, not foo.set_x(0) If you need to wrap the accesses inside methods, for whatever reason, use @property, which preserves the access semantics. That is, foo.x = 0 now invokes … Read more

What does ‘low in coupling and high in cohesion’ mean

What I believe is this: Cohesion refers to the degree to which the elements of a module/class belong together, it is suggested that the related code should be close to each other, so we should strive for high cohesion and bind all related code together as close as possible. It has to do with the … Read more

Explaining Python’s ‘__enter__’ and ‘__exit__’

Using these magic methods (__enter__, __exit__) allows you to implement objects which can be used easily with the with statement. The idea is that it makes it easy to build code which needs some ‘cleandown’ code executed (think of it as a try-finally block). Some more explanation here. A useful example could be a database connection object (which then automagically closes … Read more

jQuery creating objects [duplicate]

How would I create an object in jQuery, and then proceed to make a couple of different instances of this object I.e Create an object named box which holds a variable called color. And then make a couple of instances of this object with different stored colours.

When/why to make function private in class?

You should make a function private when you don’t need other objects or classes to access the function, when you’ll be invoking it from within the class. Stick to the principle of least privilege, only allow access to variables/functions that are absolutely necessary. Anything that doesn’t fit this criteria should be private.

Fields in interfaces

All fields in interface are public static final, i.e. they are constants. It is generally recommended to avoid such interfaces, but sometimes you can find an interface that has no methods and is used only to contain list of constant values.

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