The tag has no wiki summary.

learn more… | top users | synonyms

3
votes
4answers
362 views

Using ref instead of out. Would that be considered a bug?

Given that out and ref parameters have slight different connotations would writing code like below be considered a bug (even though it doesn't cause an issue at present), or just a lack of ...
18
votes
8answers
953 views

How and why to decide between naming methods with “get” and “find” prefixes

I always have trouble figuring out if I should name a certain method starting with getSomething versus findSomething. The problem resides in creating helpers for poorly designed APIs. This usually ...
1
vote
1answer
240 views

Wrapping Primitives to Enable Returning null — Bad Practice?

I am frequently tempted to wrap integers, etc, solely for the purpose of writing methods that can return null. Negative 1 can work in many cases, but too often (especially in sound) it's a valid ...
0
votes
3answers
583 views

What is the reason behind methods with return values and methods with void?

I want to uderstand why there is a method in C# that could reurn a value, for example: public int Accelerate() { Speed++; return Speed; } and a method that does not reurn a value (void)? ...
9
votes
2answers
744 views

Refactoring several huge C++ classes / methods. How to start? [duplicate]

Possible Duplicate: I’ve inherited 200K lines of spaghetti code — what now? I'm dealing with legacy code. It contains some BIG classes (line count 8000+) and some BIG methods (line count ...
1
vote
2answers
3k views

Pass structure as an argument in c# method

I want to know if it is possible to pass a Structure as a parameter in c# method and if possible, is it a good practice to do so? I have a c# method which is taking six arguments, i really hate that. ...
1
vote
1answer
68 views

How to sell logistical procedures that require less time to perform but more finesse?

I am working with a group where part of the responsibilities is managing a certain set of configuration files which, of course, have the same skeleton/structure across different environments but ...
4
votes
2answers
1k views

Naming methods that do the same thing but return different types

Let's assume that I'm extending a graphical file chooser class (JFileChooser). This class has methods which display the file chooser dialog and return a status signature in the form of an int: ...
1
vote
2answers
263 views

Should HTTP Verbs Be Used Semantically?

If I'm making a web application which integrates with a server-side backend, would it be considered best practice to use HTTP methods semantically? That is, for example, if I'm fetching data (e.g., to ...
54
votes
18answers
4k views

Are long methods always bad?

So looking around earlier I noticed some comments about long methods being bad practice. I am not sure I always agree that long methods are bad (and would like opinions from others). For example I ...
9
votes
1answer
2k views

Is there a difference between arguments and parameters?

It might be like this: Parameter means from the callers POV and arguments mean inside the procedure, or other way round. Or is there no difference? Update In Swedish we say "anropsparametrar" i.e. ...
3
votes
2answers
519 views

Do we ethically have the right to use the MAC Address for verification purposes?

I am writing a program, or starting at the very beginning of it, and I am thinking of purchase verification systems as a final step. I will be catering to Macs, PCs, and possibly Linux if all is said ...
5
votes
6answers
808 views

Should I have a separate method for Update(), Insert(), etc., or have a generic Query() that would be able to handle all of these? [closed]

I'm currently trying to write a class library for a connection to a database. Looking over it, there are several different types of queries: Select From, Update, Insert, etc. My question is, what ...
7
votes
4answers
368 views

How to prevent duplicate data access methods that retrieve similar data?

In almost every project I work on with a team, the same problem seems to creep in. Someone writes UI code that needs data and writes a data access method: AssetDto GetAssetById(int assetId) A week ...
5
votes
4answers
640 views

Method flags as arguments or as member variables?

I think the title "Method flags as arguments or as member variables?" may be suboptimal, but as I'm missing any better terminology atm., here goes: I'm currently trying to get my head around the ...
4
votes
4answers
1k views

Best Method of function parameter validation

I've been dabbling with the idea of creating my own CMS for the experience and because it would be fun to run my website off my own code base. One of the decisions I keep coming back to is how best ...
15
votes
10answers
14k views

What is the opposite of initialize (or init)? [closed]

The term will be used as a method name. The method is called when a part of the user interface is hidden (or removed), and it is used to reset values to default and dispose objects that will not be ...
2
votes
3answers
111 views

Efficient Summary calculation method or approach?

I have an object hierarchy with a number of leaf nodes that will contribute to summary values for the parent object (specifically: project cost and square footage). What's the most efficient way to ...
2
votes
2answers
508 views

The best way to have a pointer to several methods - critique requested

I'm starting with a short introduction of what I know from the C language: a pointer is a type that stores an adress or a NULL the * operator reads the left value of the variable on its right and ...
3
votes
2answers
302 views

Better use on the name of variables

I have a method that looks like this: Public Function NormalizeStreetAddress(country As Namespace.Country, streetAddress As Namespace.StreetAddress) _ ...
4
votes
5answers
221 views

Group method parameter or individual parameter?

I would like to ask on method parameters design consideration. I am usually deciding between using individual variables as parameters versus grouping them to a class or dictionary as one parameter. ...
4
votes
3answers
137 views

Using “prevent execution of method” flags

First of all I want to point out my concern with some pseudocode (I think you'll understand better) Assume you have a global debug flag, or class variable named "debug", class a : var debug = ...
4
votes
3answers
1k views

Should a method do one thing and be good at it? [duplicate]

"Extract Till You Drop" is someting I've read in Uncle Bob's blog, meaning that a method should do one thing alone be good at it. What is that one thing? When should you stop extracting methods? ...
28
votes
5answers
7k 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
449 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
3k 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 ...
8
votes
6answers
2k 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
299 views

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

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
914 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
439 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 ...
4
votes
5answers
292 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
190 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
715 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 ...
1
vote
1answer
95 views

Contrary method subjects for identical method names

I've got method naming paralysis! Say I've got one class - "System", and another class "User". Now, if I want to notify user(s), I can call: // this method can notify individuals and collections of ...
5
votes
4answers
934 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 ...
6
votes
5answers
3k 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 ...