Overloading functions

In short : No, it is not possible. However, You can mimic this kind of behavior: Obviously, since Matlab is a dynamic language, you can pass arguments of any type and check them. function foo(x) if isnumeric(x) disp(‘ Numeric behavior’); elseif ischar(x) disp(‘ String behavior’); end end You can also use varargin, and check the … Read more

Is it possible to extend a default method implementation of a trait in a struct?

This isn’t possible directly now. However, RFC 1210: impl specialization contains various aspects that will make this sort of behaviour work, for example, something like this should work: trait Foo { fn method(&self) { println!(“default implementation”); } } trait Bar: Foo { … } partial impl<T: Bar> Foo for T { default fn method(&self) { … Read more

When to use a Class in VBA?

It depends on who’s going to develop and maintain the code. Typical “Power User” macro writers hacking small ad-hoc apps may well be confused by using classes. But for serious development, the reasons to use classes are the same as in other languages. You have the same restrictions as VB6 – no inheritance – but … Read more

Coupling, Cohesion and the Law of Demeter

Grady Booch in “Object Oriented Analysis and Design”: “The idea of cohesion also comes from structured design. Simply stated, cohesion measures the degree of connectivity among the elements of a single module (and for object-oriented design, a single class or object). The least desirable form of cohesion is coincidental cohesion, in which entirely unrelated abstractions … Read more

In SOLID, what is the distinction between SRP and ISP? (Single Responsibility Principle and Interface Segregation Principle)

SRP tells us that you should only have a single responsibility in a module. ISP tells us that you should not be forced to be confronted with more than you actually need. If you want to use a print() method from interface I, you shouldn’t have to instantiate a SwimmingPool or a DriveThru class for … Read more