Refactoring, braces, indentation, Hungarian notation, and other stylistic issues relating to code.

learn more… | top users | synonyms (8)

0
votes
0answers
57 views

Programming Style in Large Scale C++ Applications [closed]

Recently I've been browsing source code of large applications written in C++ to learn a bit but I couldn't help but notice that most if not all use a lot of IFDEFs and class-less functions (where they ...
2
votes
3answers
33 views

What is the best solution to deprecate include certain files

I have few ini files in project. Some of them is deprecated, how can i prevent their use? I dont want delete them or change access permissions, i just want some error for slow refactoring=) Any good ...
-2
votes
2answers
34 views

what is special to use class structure in python albeit it is possible to import functions from plain script? [closed]

I am a newbie programmer at python and I am thinking about the class usage of the python. Although it is possible to import all the functions inside a script, what might be the situation that faces to ...
-2
votes
1answer
35 views

Concise way to find max/min with potentially nil value [closed]

I have two arrays, max_of_row (which stores the maximum value in each row) and min_of_col (which stores the minimum value in each col). I initialize these as max_of_row = [] and min_of_col = []. ...
-2
votes
0answers
48 views

Why is if/else recommended [closed]

When coding i always see the following style ( for the most part i deal with Java ) if check_1 logic if check_2 logic if check_3 logic if check_4 ...
0
votes
5answers
42 views

How a programmers solve the dilemma of using old variables instead of new variables?

For example: ... some code int sizeOfSomeObject = someObject.length(); ... some code, sizeOfSomeObject is not need anymore now I need other int variable for other action(for example, for position ...
0
votes
1answer
33 views

Long function declaration line. What are the conventions for splitting it?

Here is the declaration dll_DoublyLinkedNode *dll_search(const dll_DoublyLinkedList list, void *key, int (*compare)(void *data, void *key)){ Should I split it? Should I just leave it as it is? ...
0
votes
0answers
8 views

Code formatting

Code looks like this in my editor: if(waiting_list_flag) { SwitchDialog('RFOWAITLIST'); } else { SwitchDialog('RFO'); } But looks like this in IE Developer Tools Debugger or Firebug or ...
1
vote
1answer
15 views

Declaring variable in class header VS. constantly declaring a variable in update cycle

Sorry if the title is a little vague, my terminology isn't that great yet. What I'm t?rying to say is: which one is better in terms of memory management and if there is any difference Or which one is ...
0
votes
0answers
37 views

How does defining function variables before { and after function declaration work? [duplicate]

I have been looking at some documentation for my C projects and came across a peculiar type of function declaration. Here is an example: function_name(arg1, arg2) int arg1; char *arg2 { ...
1
vote
3answers
45 views

Why addListener() typically returns void?

Am seeing that a typical addXXXListener() returns void ! I have seen this as a practice across the board whether it is UI frameworks (like Swing) or server-side frameworks. For ex: Class: ...
1
vote
4answers
80 views

Initialize all variables, always

I am reading the FreeBSD coding style and am quite liking it (as I like vertically compact code). There is however this: Initialize all Variables You shall always initialize variables. Always. ...
0
votes
1answer
22 views

implementing mostly repeating content in ASP.NET WebForms' controls

The original problem is how to make the most maintainable code given that I need to have a menu bar that is very similar but not identical in most WebForms. At first glance I thought I wanted to ...
0
votes
1answer
33 views

Code structure with Asynctask Android

I guess I am just producing "Spaghetti-Code". Perhabs some experts can help me write a better code for my solution. Following Pseudocodes will show my problem: I have some procedures that runs long. ...
3
votes
2answers
101 views

Which is more efficient in Erlang: match on two different lines, or match in tuple?

Which of these two is more efficient in Erlang? This: ValueA = MyRecord#my_record.value_a, ValueB = MyRecord#my_record.value_b. Or this: {ValueA, ValueB} = {MyRecord#my_record.value_a, ...
-1
votes
3answers
33 views

Best Coding Practice using if else [closed]

I am confused on which one of the following 2 practices to follow, I have mentioned two scenarios below, please assist me which style looks good. Scenario 1: style 1: function xyz(int param) { ...
1
vote
2answers
72 views

C++ NEW Object as parameter (Like Java)

I'm coding some stuff in C++, and as always we have some "thoughts" if something similar exists on the language... I'm now, with an doubt about objects passing as parameters. What I always do, is ...
0
votes
3answers
38 views

How to decide whether is-a or instanceof relationship is suitable in a given situation?

OK, this has happened to me many times now so I might as well ask the community. I often have a problem deciding whether declaring something as an instance or as an is-a inheritance (and declaring an ...
4
votes
2answers
60 views

good practices while using enums in java

I have a problem related with implementing something in Java and I guess Enums are a part of it (or maybe it's just me who made them a part of the problem. So the thing is I have a model class, lets ...
8
votes
6answers
341 views

Python, best way to write a sum of two for loops

Normally I know we can do sum([func(x,x) for x in i]), but I got an if check and two for loops, so what is the most pythonic way to write the code bellow. you can assume that similarity will return a ...
0
votes
1answer
6 views

PHP_CodeSniffer rules documentation

Where is it possible to find documentation on PHP_CodeSniffer rules available? Seems to me like the rules exist, but nobody knows the list of them and their properties. I faced the essential problem, ...
0
votes
4answers
35 views

Form cleanliness, use divs or elements with display:block?

Having the following example http://jsfiddle.net/Pg8UY/, whats more correct? Divs for line breaks or using display:block so the form uses less elements to display the desired style? <div ...
4
votes
2answers
42 views

Python exception chaining

Is there a standard way of using exception chains in Python? Like the Java exception 'caused by'? Here is some background. I have a module with one main exception class DSError: class ...
4
votes
3answers
56 views

In php, should curly brackets be used even in short conditional statements?

In PHP, I do know curly brackets are not required for one-statement conditionals. But this question is about good coding style. (Of course when talking about style, it's usually better to just use ...
0
votes
0answers
4 views

Returning information on a bad request, but knowing what the caller needs?

I have an API call that clients make to migrate user accounts. It's a very simple migration. I'm coding a small check to make sure the account has not been already migrated, and I am at a crossroads ...
2
votes
3answers
67 views

Does it still make sense to create a helper method when it will only be called once? [closed]

I frequently find myself creating methods to hold small (<50 lines) algorithms. However, when I first learned methods, we were constantly taught that they were a way to condense/clean up code by ...
2
votes
3answers
104 views

What should and should not be in an Erlang header (.hrl) file?

I'm a bit confused on what an .hrl file should be used for. It's my understanding that .hrl files can contain any valid Erlang code and that using the -include directive will essentially insert the ...
0
votes
1answer
39 views

Java Code beautifier/formatter library with PHP, JavaScript support

I'm searching a java library that formats/beautifies a given source code snippet. The library should support at least PHP and JavaScript source files. The reason why i'm searching this is because the ...
0
votes
6answers
61 views

Which is better of the two: if-elif-else or if-else

This is not a homework question, this question is a result of just another discussion with my friend. I searched a lot but could not find any reliable source which establishes the answer with proper ...
0
votes
1answer
55 views

Vim: Problems with indentation/alignment [duplicate]

So I've got a problem (obviously). I read an interesting article about "Smart Tabs", and I've tested this in Emacs and it works perfectly fine. So currently I'm using Emacs because I've tried this in ...
1
vote
1answer
22 views

Is it acceptable for a submit button to have a name attribute?

Usually, a submit button works fine without a name attribute. However, there are occasions where there's a need to have two submit buttons for the same form, hence making use of the name attribute to ...
0
votes
2answers
39 views

namespace inclusion in header and template classes

Well, this is not a real programming issue, but more about good/bad practice I'm working of my final project of CSP course which is a library with several solvers. Most classes are heavily ...
0
votes
3answers
49 views

What is the cleanest way to calculate instance variables in initialize?

Say I have a class that defines a collection of my days and how wacky they are. Is it better to initialize my @scores variable in the initialize function like so: class WackyDayScorer attr_reader ...
0
votes
2answers
33 views

Having more efficient code to return errors

I have created a main class where all my main member activation deactivation functions are and all the other things related to them are also done this main class(along with some main functions) is ...
0
votes
1answer
45 views

Does Microsoft have a collection of style guidelines for XML?

I am creating websites/application in C#, and in so doing I have to construct web.config's and app.config's in order to hook them up with providers. My development team seems to no be able to agree on ...
1
vote
3answers
60 views

How to properly structure functions?

let's say we have a class with some methods in it, of which at least one is of rather complex nature: class Example { public function Example() { } private function ...
0
votes
3answers
33 views

Dictionary: hard-coded vs. external file

I have a java application which is started and stopped multiple times per second over hundreds of millions of items (called from an external script). Input: String key Output: int value The purpose ...
0
votes
1answer
27 views

PHP “use” declarations repeated or with a comma?

I was curious to know, when declaring use statements with PHP at the start of a class, why the "use" keyword is generally repeated in each line even though it is possible to put a coma at the end off ...
5
votes
3answers
107 views

Is it bad practice to write a whole Flask application in one file?

I'm currently writing a web application in Python using the Flask web framework. I'm really getting used to just putting everything in the one file, unlike many other projects I see where they have ...
1
vote
3answers
85 views

Create a function with for loop syntax

Is it possible to create a function with a "for loop" style syntax? And if so, what would that style of function be called? For example a for loop follows this syntax: for(i = 0; i < 10; i++) { ...
3
votes
3answers
165 views

Is it good practice to bind shared pointers returned by functions to lvalue references to const?

Although it took me a while to get used to it, I now grew the habit of letting my functions take shared pointer parameters by lvalue-reference to const rather than by value (unless I need to modify ...
1
vote
1answer
33 views

Should I use Objects for Tiles?

I am making a small 2D game which has a character that can jump (side-scroller). Now the levels in the game are made from tiles (mario like?). Now my character can jump at the moment but he can't land ...
0
votes
1answer
27 views

Using an ObservableCollection in a service

I have a few projects. One of the projects will be deployed as a Windows Service. An other project is a WPF application. There are a few other applications managing some data (of external hardware or ...
-2
votes
0answers
37 views

Error in installing a numerical program Titan2D (titan-3.0.0) [closed]

I have this error when I try to install the last version of titan-3.0.0, you can see also the error that I had on the same code on the previous Stackoverflow message: ...
2
votes
1answer
38 views

Should Conditional Chain Success be Implicit or Explicit

Which is the better practice? To make the logic for your successful case implicit or explicit in a conditional chain? Please note that the logic is exhaustive in all of the following, so it is really ...
3
votes
3answers
59 views

Testing if an object is a string

I have a function that manipulates a string; however, sometimes my input isn't already a string. For example it could be a path object. I need to convert it to a string because I want to call methods ...
0
votes
2answers
35 views

How to read from a SQLite Database and pass the value to a textview in another Class

I'm fairly new to Android. I'm making an application that shows a whole lot amount of different stings on previous and forward button clicks. I also have a database stored in the assets folder.. now ...
0
votes
2answers
40 views

PHP Best Practice: Using Mixed return types

I understand that this topic was briefly approached here but I hope to understand the general do's and don'ts of using multiple return types in PHP. There seems to be varied opinions about this ...
0
votes
2answers
32 views

$_GET msg giving error when no msg travels in url

i m using this piece of code when my login page authenticate me that this username or password is incorrect, echo "<script languge='javascript'>location.href='index.php?msg=Incorrect UserName ...
2
votes
2answers
95 views

Is this a reasonable use of namespaces with C++ inheritance hierarchies?

Here is an example of something similar to code I recently wrote, that has proven to be a little contentious at work: namespace Shape { class Renderer { public: virtual void Draw ...

1 2 3 4 5 100