I just hope the following doesn't seem to you like redundant jabber :)
Anyway, there is that:
for (p = fmt; *p; p++) {
if (*p != '%') {
putchar(*p);
continue;
}
switch (*++p) {
/* Some cases here */
...
}
}
And I wondered why the writer (Kernighan / Ritchie) used the continue in the if ...
Introducing some of the goodness of collection operations to our codebase without adding a new external library dependency, we are adding these methods to our utility package.
static public List<T> filter(List<T> source, Predicate<T> filter);
static <Y,T> public List<Y> transform(List<T> source, Mutator<Y,T> filter);
static public boole...
bool fn()
{
if(something bad happen)
return false;
..
}
void gn()
{
assert(something == true);
..
}
When I write a function in production code, which way should I
choose?
...
Anyone have a naming strategy that works well for service proxy classes?
For example, if I am given three web services within two projects as follows:
XWs
AService.asmx
YWs
BService.svc
CService.svc
What would use as the Service Reference Name & Namespace for AService, BService and CService ?
In general, I'd like something in ...
So I have some C++ code for back-tracking nodes in a BFS algorithm. It looks a little like this:
typedef std::map<int> MapType;
bool IsValuePresent(const MapType& myMap, int beginVal, int searchVal)
{
int current_val = beginVal;
while (true)
{
if (current_val == searchVal)
return true;
MapType::i...
Some would argue that Bazaar Model of development can lead to a tangled mess of cowboy code.
I'm wondering, which model does Django follow? At first glance it seems to be a highly organized bazaar model, with vetting and triage stages and such. However, the source is available at all times, but not every patch or suggestion gets rando...
After using the Django template language, I really miss being able to do things like this:
{% if condition %}
<!-- snip -->
{% else %}
<!-- snip -->
{% endif %}
When I am using JSP, I am stuck doing something like this:
<logic:equal name="something" value="example">
<!-- snip -->
</logic:equal>
<logic:notEqual name="somet...
Given this declaration:
using System;
using System.Collections;
using System.Collections.Generic;
namespace AProject.Helpers
{
public static class AClass
{
and this declaration
namespace AProject.Helpers
{
using System;
using System.Collections;
using System.Collections.Generic;
public static class AClass
...
My OCD makes me add "break" when writing case statements, even if they will not be executed. Consider the following code example:
switch(option) {
case 1:
a = 1;
b = 7;
break;
case 2:
a = 2;
b = 4;
return (-1);
break;
default:
a = -1;
break;
}
My two ...
Possible Duplicate:
Do you prefix your instance variable with 'this' in java ?
Coding standards question. Maybe should be Wiki, let me know. Should I qualify all my instance properties and methods with this. or should I leave it off. Do you think it makes statements more readable and traceable? Or is it just a few wasted key...
I'm creating a game in C++ (speaking of which, does the code I use matter?), which coudl be loosely described as a board game, and I'm wondering which of these two "check if character is out of bounds" functions is more efficient:
ONE:
int main()
{
//display board
//get player input
//move player
//if player is out of b...
What comes first? After the design has been outlined and approved, should a designer create pages in HTML and then hand them to a developer to add code? Or should a developer build simple pages that work and hand them over to the designer?
I've always done the latter, but recently worked with a designer who built an entire site in HTML ...
Consider this line:
if (object.getAttribute("someAttr").equals("true")) { // ....
Obviously this line is a potential bug, the attribute might be null and we will get a NullPointerException. So we need to refactor it to one of two choices:
First option:
if ("true".equals(object.getAttribute("someAttr"))) { // ....
Second option:
S...
Hello,
I would like to restyle a context menu, but I have a question about how to structure my Xaml.
In my application resources, I have something like this:
<ControlTemplate TargetType="MenuItem" x:Key="MenuItemTemplate">
...
</ControlTemplate>
<ControlTemplate TargetType="ContextMenu" x:Key="ContextMenuTemplate">
<ControlTe...
I find now that I work in a mostly solo environment that I actually type fully qualified methods calls more and more, instead of make use of the using directive. Previously, I just stayed consistent with the most prominent coding practice on the team.
Personally, I find it easier to read verbose code at a glance, I type fast especial...
I want the eclipse Java Compiler Warnings available as an ant task (ie without eclipse) - ideally as ant plugins - but I want the cruise control ant task to fail if an eclipse warning shows up. For the following warnings
Non-static access to static member
Method with a constructor name
Serializable class without serialVersionUID
Assign...
Is there any good reason to avoid unused import statements in Java? As I understand it, they are there for the compiler, so lots of unused imports won't have any impacts on the compiled code. Is it just to reduce clutter and to avoid naming conflicts down the line?
(I ask because Eclipse gives a warning about unused imports, which is ...
So, I often have trouble describing a function in a succinct name. It's usually not a problem in functions that are made for reuse, but often a large process needs to be broken into sub-functions. Often these get strange names, such as connectionsToAccessLines or handleWallVisionSplit or something like that. And while these functions onl...
A coding style presentation that I attended lately in office advocated that variables should NOT be assigned (to a default value) when they are defined. Instead, they should be assigned a default value just before their use.
So, something like
int a = 0;
should be frowned upon.
Obviously, an example of 'int' is simplistic but th...
This question is related to C#, but may be applicable to other languages as well. I have a reservation against using code such as the following:
using System.Windows.Forms;
class MyForm : Form
{
private Timer myTimer;
private Button myButton;
public MyForm()
{
// Initialize the components, etc.
myTimer...