When should I use an interface and when should I use a base class?
Should it always be an interface if I don't want to actually define a base implementation of the methods?
If I have a Dog and Cat class. Why would I want to implement IPet instead of PetBase? I can understand having interfaces for ISheds or IBarks (IMakesNoise?), becau...
I've been a Ruby developer for several years, and a Perl developer before that, with some PHP somewhere in there. I want to expand my knowledge, and think the best way to do that will be by learning something very different from what I know. I know OO, and I know functional programming pretty well. What I don't know is a language that us...
Can I specify interfaces when I declare a member?
After thinking about this question for a while, it occurred to me that a static-duck-typed language might actually work. Why can't predefined classes be bound to an interface at compile time? Example:
public interface IMyInterface
{
public void MyMethod();
}
public class MyClass //D...
Can someone tell me what Strong typing and weak typing means and which one is better?
...
I was working with the generic class in vb.net.
And it seems extension method cannot be applied to generic class without specifying the type.
I have this generic class
Public Class MyGeneric(Of T)
'Methods and properties go here
'
'
End Class
This is Ok
<Extension()> _
Public Sub DoSomething(ByVal myGenericDoubleObj As ...
I was looking into scripting to be incorporated into my apps. Then I bumped into Script.Net and Nemerle. I do know that they have different syntax and Nemerle supports macro but not Script.Net. But I would like to know more about their differences in terms of functionality, usage and flexibility. And which one would you recommend, why?
...
I am learning functional programming style. From this link http://channel9.msdn.com/shows/Going+Deep/Brian-Beckman-Dont-fear-the-Monads/, Brian Beckman gave a brilliant introduction about Monad. He mentioned that Monad is about composition of functions so as to address complexity.
A Monad includes a unit function that transfers type...
I've started to look into the whole unit testing/test-driven development idea, and the more I think about it, the more it seems to fill a similar role to static type checking. Both techniques provide a compile-time, rapid-response check for certain kinds of errors in your program. However, correct me if I'm wrong, but it seems that a uni...
I'm trying to validate a few python arguments. Until we get the new static typing in Python 3.0, what is the best way of going about this.
Here is an example of what I am attempting:
class A(object):
@accepts(int, int, int)
def __init__(a, b, c):
pass
class B(A):
@accepts(int, int, int, int)
def __init__(a, b, ...
I'd like to understand the advantages of super-strong typing, a la SML or Scala, over conventionally strongly typed languages such as Java or c++. Could someone give a brief overview of the advantages of very strong typing, or better yet, post an example of an error which would be caught at compile time in very strongly typed language, ...
Are there any other ways of changing a variable's type in a statically typed language like Java and C++, except 'casting'?
I'm trying to figure out what the main difference is in practical terms between dynamic and static typing and keep finding very academic definitions. I'm wondering what it means in terms of what my code looks like.
...
I am a PHP web programmer who is trying to learn C#.
I would like to know why C# requires me to specify the data type when creating a variable.
Class classInstance = new Class();
Why do we need to know the data type before a class instance?
...
It seems to me that the most invaluable thing about a static/strongly-typed programming language is that it helps refactoring: if/when you change any API, then the compiler will tell you what that change has broken.
I can imagine writing code in a runtime/weakly-typed language ... but I can't imagine refactoring without the compiler's h...
sqlite uses something that the authors call "Manifest Typing", which basically means that sqlite is dynamically typed: You can store a varchar value in a "int" column if you want to.
This is an interesting design decision, but whenever I've used sqlite, I've used it like a standard RDMS and treated the types as if they were static. Inde...
Ok, so can someone explain to me why F# allows you to overload the > and ^ operators, but doesn't allow you to use them?
+ (op_Addition): Works just fine.
^ (op_Concatenate): Compiler error in F#. Apparently only strings can be concatenated.
> (op_GreaterThan): Runtime Error – Failure during generic comparison: the type Program+OppTest4...
I'm working in a C# web service with a generic static class that takes a type. I was wondering why this does not compile:
Type type1 = typeof(MySnazzyType);
Assert.AreEqual(0, ConnectionPool_Accessor<type1>._pool.Count);
It gives this error:
The type or namespace name 'type1' could not be found (are you missing a using directive ...
I didn't really pay as much attention to Python 3's development as I would have liked, and only just noticed some interesting new syntax changes. Specifically from this SO answer function parameter annotation:
def digits(x:'nonnegative number') -> "yields number's digits":
# ...
Not knowing anything about this, I thought it could ...
Simple question folks: I do a lot of programming (professionally and personally) in compiled languages like C++/Java and in interpreted languages like Python/Javascript. I personally find that my code is almost always more robust when I program in statically typed languages. However, almost every interpreted language I encounter uses dyn...
Hi,
I hear a lot that new programming languages are dynamically typed but what does it actually mean when we say a language is dynamically typed vs. statically typed?
Thanks
...
I was reading Paul Graham's "The Hundred-Year Language" article.
http://www.paulgraham.com/hundred.html
In there he makes a claim that static typing "preclude[s] true macros".
For example, types seem to be an
inexhaustible source of research
papers, despite the fact that static
typing seems to preclude true macros--
without...