The tag has no wiki summary.

learn more… | top users | synonyms

8
votes
5answers
825 views

Designing database related methods, which is better to return: true/false or row affected?

I have some methods that perform some data changing in a database (insert, update, and delete). The ORM I'm using return row-affected int values for those type of method. What should I return for "my ...
30
votes
9answers
3k views

How to name a method that both performs a task and returns a boolean as a status?

If there is a method bool DoStuff() { try { // doing stuff... return true; } catch (SomeSpecificException ex) { return false; } } should it rather be called ...
8
votes
1answer
392 views

Refactoring a 1500 LOC method that only builds the graphical UI [closed]

I'm currently scratching my head over how to refactor a method that basically only builds the UI. The method is more than 1500 lines of code (LOC) long - and counting. It has grown, there was no plan ...
2
votes
1answer
88 views

For instance methods, would always returning self or this, instead of using a void return type, be a clean coding style? [closed]

I just came across this article, and in particular, this answer. Essentially they're talking about returning self from instance methods to allow for method chaining. That being said, one of the ...
0
votes
2answers
213 views

Design Pattern: Algorithm varies according to the input arguments

I will give a simple example to help you understand my question. Suppose we have a rectangle and a Utility class with a method that creates a buffer arround a shape. The .createBuffer method has ...
-2
votes
3answers
62 views

Method naming advice required [closed]

My question will be about how do you think it would be fit to name some methods in a fluent interface. Let me try to demonstrate the problem. Consider this relation tree: A person can have dogs ...
25
votes
8answers
4k views

Why have private static methods?

I just wanted to clear up a question I have. What is the point of having a private static method as opposed to a normal method with private visibility? I would have thought an advantage to having a ...
4
votes
2answers
386 views

Should I expose a “computed” value as a property or a method?

I have a C# class that represents a content type in a web content management system. We have a field that allows a web content editor to enter an HTML template for how the object is displayed. It ...
1
vote
1answer
143 views

What do you call a method that might do something? [closed]

Is it okay to call it void maybeGenerateUIDsAndDownload() ? Because sometimes it will generate UIDs and download but sometimes it will not do it.
1
vote
1answer
87 views

When should I pass value as class variable and when as a method argument?

Is there a general rule of thumb, when we should pass a value as as class variable and when as a method argument? Or is it just a choice of the developer? For example -- are there any reasons, why ...
5
votes
3answers
395 views

Member functions vs. Non-member functions for math operators

I'm writing a linear algebra library (long story short, it's a school assignment) that involves matrices, vectors, etc. In the process of creating this library, I'm going to be creating functions ...
1
vote
1answer
117 views

Dynamic method creation in python

I have a class that will have a number of external methods that will all call the same smaller set of internal methods. So something like: obj.method_one(a, c) and obj.method_two(a, c) where ...
1
vote
1answer
113 views

Use of # in answers/documentation when referring to methods of a class

When looking through Java documentation or answers for Stack Overflow / programming forum questions, I often see people referring to methods like String#format, Object#clone etc, rather than ...
3
votes
4answers
644 views

Use null object as argument to method

Consider the following piece of code class Foo { public: //... bool valueFirstGet(int& value) const { if(this==nullptr) {return 0;} ...
4
votes
3answers
170 views

Python: How to decide which class' methods should provide behavior (functionality) affecting multiple classes

I have a question about object oriented design that is not specific to Python but since my code is in Python, I tagged it as such. How do I decide which of my classes should be responsible for ...
0
votes
2answers
923 views

When to use functions vs methods?

So I know that methods are more OOP than functions. I was wondering if someone could show me an example of a function and a method and explain the differences between methods and functions to me? ...
4
votes
4answers
302 views

Why is the following naming guideline different between OO and non-OO languages?

I am working with a non-OO language and I'm trying to name my routines consistently. I came acrross the following guideline from Steve McConnell's Code Complete: To name a procedure, use a strong ...
1
vote
1answer
450 views

What is the difference between method header and method signature?

I want to know what is exactly a method header and what is a method signature and is this the same among programming languages or just in C#? So, is it correct to say the following is a method ...
-1
votes
2answers
140 views

Naming methods that perform HTTP GET/POST calls? [closed]

In the application I am currently working on, there are generally 3 types of HTTP calls: pure GETs pure POSTs (updating the model with new data) "GET" POSTs (posting down an object to get some data ...
0
votes
2answers
666 views

Basic Objective-C Questions

I'm new to objective C, I'm following "Objective C 5th Edition Stephen Kochan and I don't have anyone to ask my doubts to. I'm confused with this question: Q. Is it necessary to use "-" or "+" before ...
3
votes
3answers
304 views

Making some methods mostly contain method calls, while others doing “the lowest level” work [duplicate]

So I thought about this, and I don't know if it's included or not in any methodology. I think the advantages of this coding style is that, at the lowest level, the code is extremely testable, and ...
3
votes
6answers
436 views

use areFoo or isFoo?

I have never seen the use of "are" for boolean methods, but the use of "is" is very common. When I want to use "are" is usually because I am passing multiple variables, or a list of objects. I ...
1
vote
4answers
202 views

Until what point should I refactor? [duplicate]

What do you think until what point should a programmer refactor the code? Basically having def method do_something end Pieces of code would be handy, but they increase spaghetti code until the ...
4
votes
6answers
308 views

Fields vs method arguments [closed]

I just started writing some new class and it occurred to me that I was adding a lot of method arguments that are not strictly needed. This is following a habit to avoid having state in classes that is ...
2
votes
2answers
354 views

Should I put utility methods inside a class?

I have been working on a library which contains a large set of functions. For the sake of simplicity, I am going to use just one set as an example. I am not sure which is the better way, in terms of ...
27
votes
4answers
1k views

How do programming languages define functions?

How do programming languages define and save functions/methods? I am creating an interpreted programming language in Ruby, and I am trying to figure out how to implement function declaration. My ...
2
votes
1answer
181 views

Methods as verbs: is the object the subject? [duplicate]

Is there some recommended practice regarding methods as verbs in OOP? Should the object work syntactically as subject or as object/complement? Should object.doSomething() be normally understood as ...
-3
votes
2answers
2k views

Java: The best way to learn it when MOOCs and books are not enough? [closed]

This topic was taken from Stack Overflow, but it was put on-hold due to Opinion-based question. So I moved it to here. I've had some great troubles with my homework exercises and I've used ...
0
votes
2answers
497 views

UML representation of type being passed as a parameter

I want to draw a UML diagram of my program. Class Barney has a method Yabadaba(Doo d) which takes a parameter of type Doo. How do I represent that class Doo is used in class Barney in my UML diagram? ...
9
votes
11answers
2k views

What is the reason for using lowercase for the first word in a local variable (eg, employeeCount, firstName)

I take a good deal of criticism from other programmers due to my use of full proper casing for all my variables. For example, your typical programmer will use employeeCount for a variable name, but I ...
1
vote
2answers
288 views

Which is architecturally correct for Data Access Layer method names - Fetch or Select? [closed]

I have seen the words Fetch and Select used seemingly interchangeably when naming data access layer methods (ex. Person.Select or Person.Fetch). Which one is correct? My instinct is that the ...
4
votes
5answers
315 views

How does the concept of a class change when passing data to the constructor instead of method parameters?

Let's say we're making a parser. One implementation could be: public sealed class Parser1 { public string Parse(string text) { ... } } Or we could pass the text to the ...
1
vote
5answers
215 views

Is it a good practice to write a method that gets something and checks the value? [duplicate]

Occassinally I have to write methods like this: string GetReportOutputDirectoryAndMakeSureExist() { string path = Path.Combine ( ... ) //whatever logic if(!Directory.Exists(path)) ...
1
vote
6answers
363 views

Naming functions that retrieve a value

I have this personal rule to start all function/method names with a verb. My verb of choice for functions or methods that get a value based on some data structure or object is get. I'm wondering if ...
0
votes
2answers
180 views

Overriding - Access to Members with Reference Reassignment

I have recently been moving through a couple of books in order to teach myself Java and have, fortunately, mostly due to luck, encountered very few difficulties. That has just changed. I read a ...
107
votes
13answers
22k views

Is it OK to split long functions and methods into smaller ones even though they won't be called by anything else? [duplicate]

Lately I've been trying to split long methods into several short ones. For example: I have a process_url() function which splits URLs into components and then assigns them to some objects via their ...
3
votes
3answers
1k views

What is a static method compared to instance/class/private/public methods?

I'm learning programming in Objective-C and I can't understand what a static method is. I know what class/instance/private/public methods are. Can someone explain what it is using an example and ...
2
votes
5answers
520 views

Why sequential cohesion for operations in a method is not a good idea?

I read from the seminal Code Complete book that method statements that require to be executed in order passing parameter from one to the next is a code smell and is an example of a sequential ...
2
votes
1answer
295 views

Understanding high cohesion principle for methods in object oriented design

I know the idea of strong cohesion applies to methods as much it applies to classes. Just to be clear when I say strong cohesion of a method I mean a method which does only one task and does it well. ...
5
votes
3answers
324 views

Should a method's parameter list contain objects or object identifiers?

Our teams is having the following discussion: Let's say we have the following two methods: public Response Withdraw(int clubId, int terminalId,int cardId, string invoice, decimal amount); public ...
8
votes
1answer
363 views

Math library methods in Google's Go Programming Language

I have been programming in google Golang and have been enjoying it due to its brevity but I find it surprising that almost all its Math standard library methods are for the floating point type. Is ...
0
votes
2answers
114 views

addIfNotExist alternative

Is there are any standards or conventions on naming methods which add something if it not exist into another something. For example: Store.instance().addItemIfNotExist(item) IfNotExist is really ...
4
votes
3answers
362 views

Renaming long named method in C# [closed]

I'm working on a project where exist one method with title string ValidateNewPasswordExpireCurrentPasswordAndCreateNewPassword(...) I'm sure the method name must be changed. But can't found good ...
3
votes
4answers
358 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 ...
14
votes
8answers
851 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
203 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
473 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)? ...
8
votes
2answers
598 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
2k 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 ...