The tag has no usage guidance.

learn more… | top users | synonyms

35
votes
6answers
17k views

What is the difference between a function and a lambda?

I'm a little bit confused about 'function' and 'lambda'. I've seen some examples showing that the scheme keyword lambda works very similarly to the JavaScript keyword function, but I really don't ...
6
votes
4answers
453 views

Which popular object-oriented languages support readonly methods?

I thought that many object-oriented languages have a reserved keyword for methods which do not modify the state of an object. These methods often have names that start with get. AFAIK a "getter" is ...
4
votes
1answer
5k views

What's the difference between static and dynamic binding? [closed]

We are learning about methods in class, and I am having trouble especially with the concept of static vs. dynamic. Wikipedia says this: Methods can be bound to a class at compile time (static ...
16
votes
6answers
5k views

Prefer class members or passing arguments between internal methods?

Suppose within the private portion of a class there is a value which is utilized by multiple private methods. Do people prefer having this defined as a member variable for the class or passing it as ...
5
votes
5answers
315 views

Is it good or bad form to name a function after the workaround it fixes? [closed]

Lets say you have to write some code to fix a bug that on first glance by another engineer would seem weird or unnecessary. Would it be good or bad form to put the code in a method named for example ...
3
votes
7answers
1k views

Pass in single settings object vs multiple setter methods?

Working with C++. Suppose I have a class BoxFilter. The class is used to filter boxes which have properties such as height, width, depth, weight, etc. The filter might have something like MaxWidth ...
45
votes
6answers
3k views

Refactoring into lots of methods - is this considered clean or not? [duplicate]

So, I watched as my colleague complained a bit about a project he has inherited from someone who is, shall we say, not very experienced as a programmer (intern left to his own devices on a project). ...
10
votes
4answers
468 views

Where does “method” as a special term in OOP originate?

"Method" is a special term in Object-Oriented Programming. Does anyone know when the word began to be used in this particular sense, and in connection with what programming language or other branch of ...
5
votes
5answers
349 views

Sending Whole Data Object As Argument Or Just Required Fields?

Let's say I have a class that just stores data: ClassData Field1 Field2 Field3 Now let's say I have a function that uses Field1 and Field2: public void DoStuff(string field1, string ...
4
votes
2answers
191 views

Does the single responsibility principal promote flexibility?

Does the single responsibility principal promote flexibility? If not what are the other methods to make your classes more flexible? By flexibility I mean, a class is able to function correctly at any ...
10
votes
2answers
822 views

Design: Object method vs separate class's method which takes Object as parameter?

For example, is it better to do: Pdf pdf = new Pdf(); pdf.Print(); or: Pdf pdf = new Pdf(); PdfPrinter printer = new PdfPrinter(); printer.Print(pdf); Another example: Country m = new ...
5
votes
4answers
2k views

What is a good pattern for combined caching and reinitialization?

I have a situation where I have three requirements: Lazy initialization - don't create the collection until asked for it Caching - keep the collection in memory on the object Reinitialization - be ...
9
votes
5answers
6k views

Differences between messages and methods?

In Objective C you have the concept of sending messages to other objects, and, well this is very similar to method calling in languages like C# and Java. But what exactly are the subtle ...