Linked Questions

-2 votes
2 answers
343 views

My sample program like below; public class Animal { public virtual string MakeSound() { return "General Sound"; } } public class Dog : Animal {...
Akhil's user avatar
  • 2,050
3 votes
0 answers
176 views

i'm trying to understand the basics of polymorphism. I do understand why it could be useful to assign a superclass to a sub class or a sub to a super. what i don't understand quite well is the logic ...
Kenan's user avatar
  • 31
0 votes
1 answer
96 views

As I've read the substitution of objects of a concrete type by instances of a subclass of that concrete type must preserve a program's correctness, a program's invariants. I'd like to know what ...
beginpluses's user avatar
715 votes
14 answers
329k views

What does the expression "Turing Complete" mean? Can you give a simple explanation, without going into too many theoretical details?
dlinsin's user avatar
  • 19.6k
182 votes
21 answers
164k views

I have a class Animal, and its subclass Dog. I often find myself coding the following lines: if (animal is Dog) { Dog dog = animal as Dog; dog.Name; ... } For the variable Animal ...
michael's user avatar
  • 1,949
215 votes
13 answers
57k views

The word seems to get used in a number of contexts. The best I can figure is that they mean a variable that can't change. Isn't that what constants/finals (darn you Java!) are for?
Dustman's user avatar
  • 5,339
204 votes
10 answers
306k views

What is the difference between syntax and semantics in programming languages (like C, C++)?
haccks's user avatar
  • 107k
111 votes
12 answers
21k views

A lot of people seem to agree, that the Singleton pattern has a number of drawbacks and some even suggest avoiding the pattern entirely. There's an excellent discussion here. Please direct any ...
Brian Rasmussen's user avatar
80 votes
12 answers
31k views

I need some resources that talk about how to design your software to be extensible, i.e. so that other people can write add-ons/plug-ins that adds functionality to it. What do you recommend? Any ...
hasen's user avatar
  • 167k
72 votes
6 answers
12k views

My understanding of the Liskov substitution principle is that some property of the base class that is true or some implemented behaviour of the base class, should be true for the derived class as well....
Aishwar's user avatar
  • 9,754
51 votes
7 answers
24k views

I always thought functions and methods were the same, until I was learning Swift through the "Swift Programming Language" eBook. I found out that I cannot use greet("John", "Tuesday") to call a ...
Ricky's user avatar
  • 10.5k
56 votes
5 answers
90k views

For a unit test, I need to mock several dependencies. One of the dependencies is a class which implements an interface: public class DataAccessImpl implements DataAccess { ... } I need to set up ...
helpermethod's user avatar
  • 62.8k
43 votes
5 answers
24k views

The Liskov Substitution Principle states that a subtype should be substitutable for that type (without altering the correctness of the program). Can someone please provide an example of this principle ...
random512's user avatar
  • 1,093
33 votes
10 answers
21k views

When I design classes and have to choose between inheritance and composition, I usually use the rule of thumb: if the relationship is "is-a" - use inheritance, and if the relationship is "has-a" - use ...
Igor's user avatar
  • 27.4k
30 votes
8 answers
2k views

In the comments of this answer it is stated that "checking whether the object has implemented the interface , rampant as it may be, is a bad thing" Below is what I believe is an example of this ...
Gene C's user avatar
  • 2,030

15 30 50 per page
1
2 3 4 5
14