C# interface method ambiguity

Implement explicitly: public class AllYourBase : IBase1, IBase2 { int IBase1.Percentage { get{ return 12; } } int IBase2.Percentage { get{ return 34; } } } If you do this, you can of course treat your non-ambigous properties just like normal. IAllYourBase ab = new AllYourBase(); ab.SomeValue = 1234; However, if you want to access … Read more

Best practice for constant string for implementations to use

I don’t think there is a best practice. It is just a matter of preference. I store constants inside static classes. public static class Constants { public static class Messages { public const string Error = “Error accessing api…”; public const string Hello = “Hello …”; } } Usage var result = new TextResult(Constants.Messages.Error); FYI: … Read more

Private classes in Objective C

Objective-C has no notion of private classes or private instance variables in a formal declarative fashion. Instead, visibility in Objective-C is entirely controlled by where you declare something. If it is in a header file, it can be imported by something else. If it is declared in an implementation file, it cannot (reasonably) be imported … Read more

Stateless Object Oriented Programming vs. Functional Programming?

It’s a question of degree. The advantages to using a functional language for functional programming are the carrot and the stick. The carrot is that functional languages have functional syntax and semantics and come with functional libraries. The stick is that functional languages can force you to adhere to certain standards. If you do FP … Read more

Are functions objects in Python?

You are looking for the __call__ method. Function objects have that method: >>> def foo(): pass … >>> foo.__call__ <method-wrapper ‘__call__’ of function object at 0x106aafd70> Not that the Python interpreter loop actually makes use of that method when encountering a Python function object; optimisations in the implementation jump straight to the contained bytecode in … Read more

What is the purpose of checking self.__class__?

self.__class__ is a reference to the type of the current instance. For instances of abstract1, that’d be the abstract1 class itself, which is what you don’t want with an abstract class. Abstract classes are only meant to be subclassed, not to create instances directly: >>> abstract1() Traceback (most recent call last): File “<stdin>”, line 1, … Read more