coding-style

Call back style

I am writing an iPhone application which in numerous places needs to perform non HTTP or FTP networking of a very simple request response type. I've wrapped all this up into a SimpleQuery class that integrates with the run loop. SimpleQuery *lookup = [[SimpleQuery alloc] init]; [lookup setDelegate:self]; [lookup doQueryToHost:querySer...

What is your attitude towards hard coding?

Mine is this: Hard coding is the way! All my problems go away. Just code it one by one. And problems come back kill your day. I absolutely hated it but the fact is "business people" tend to like it because it takes less time to get what they wanted. And as a software developer especially working in a corporate environment, most peo...

Industry spread code formatting tools

What are the tools that are most used in the industry for formatting source code, C++ in particular, so to obtain a style consistency of the whole code base? Possibly tools that would allow the user to select which style to apply (e.g. BSD, GNU, etc...)? I could not find many references on the web to solid, wide-spread tools for such a ...

Underscore prefix on member variables. intellisense

everyone said the "underscore, no underscore" debate is purely philosophical and user preference driven but with intelli-sense having the underscore allows you to differentiate your member variables from your local variable very easily and thus giving you a concrete benefit is there any counter argument to this benefit of having undersc...

Well written C++ examples

I'm currently learning C++ and would like to start reading others sourcecode to pick up tips. I was wondering if anyone has examples of well written C++ that I can take a look at (and not pick up bad habits from) ...

C# programming style question - Assignment of Null Before Real Assignment

Is there a good reason (advantage) for programming this style XmlDocument doc = null; doc = xmlDocuments[3]; vs XmlDocument doc = xmlDocuments[3]; I have seen it many times but to me it just seem overly verbose ...

Resharper: how to force introducing new private fields at the bottom of the class?

Resharper offers a very useful introduce and initialize field xxx action when you specify a new parameter in a constructor like: Constructor (int parameter) The only (minor) nuisance is that it puts the new field at the beginning of the class - and I'm a fan of putting private parts as far away as possible from the prying eyes of stra...

Using typedefs (or #defines) on built in types - any sensible reason?

Well I'm doing some Java - C integration, and throught C library werid type mappings are used (theres more of them;)): #define CHAR char /* 8 bit signed int */ #define SHORT short /* 16 bit signed int */ #define INT int /* "natural" len...

Naming convention for property

Which one is preferable or more clear? public int FrozenRegionWidth { get; set; } Or... public int WidthOfFrozenRegion { get; set; } ...

How and How often do you refactor your code?

My question vaguely relates to this one. However, it doesn't address the techniques or practices. I am reading The Pragmatic Programmer and it strongly advocates refactoring code as often as you can. However, it doesn't go into detail about how to do that and how often. How do you guys go about refactoring your code, and how often do y...

Is it poor coding practice to have a SQL table that contains a column with the same name?

Example: CREATE TABLE ErrorNumber ( ErrorNumber int, ErrorText varchar(255), ) This can result in queries that look like: SELECT ErrorNumber FROM ErrorNumber WHERE ErrorNumber=10 ...

What is the alternative to excessive use of the dot operator in Obj-C?

See what you think of this line of code: if ([pickerViewController.picker.bvc.currentResolve.name isEqualToString:message]) ... Would you consider this to be excessive use of the dot operator? If not, I can leave it as-is. But if so, what's the preferred alternative? ...

Importance of Code Formatting Specificly Spacing

How important is it for readability that code be in this form: public void DoStuff() { var v = new Object(); v.PropertyID = "abc"; v.Type = "abc"; v.Style = "abc"; v.SetMode(Mode.Abc); v.Draw(); } vs. public void DoStuff() { var v = new Object(); v.PropertyID = "abc"; v.Type = "abc"; ...

Enumerated data types and class APIs in C++

If you're supposed to encapsulate everything inside a class definition, how is it then possible to use enumerated data types with the class? For example I've just written the following code... enum PizzaType {DEEP_DISH, HAND_TOSSED, PAN}; enum PizzaSize {SMALL, MEDIUM, LARGE}; class Pizza { public: Pizza(); void set...

Java - Is This Good Programming Practice?

Hi folks, Just wondering if the following is considered to be good programming practice or not? I like to keep my individual source files as concise and uncluttered as possible, but I'm wondering what more experienced coders would think of it. I especially like the idea of the Settings.java class to keep all of my "Magic Numbers" in th...

Where to start programming?

Once you have your first set of requirements and design done where do you start programming? (Assume tests will be written in the same order, but before the code). The entry point Framework/Support classes Entity Classes Easiest thing first Hardest thing first What do you suggest? ...

Better Java method Syntax? Return early or late?

Duplicate: Should a function have only one return statement? and Single return or multiple return statements? Often times you might have a method that checks numerous conditions and returns a status (lets say boolean for now). Is it better to define a flag, set it during the method, and return it at the end : boolean validate(Doma...

C++: When is it acceptable to have code in the header file?

I've been taught to keep class definitions and code separate. However, I've seen situations where people would often include some bits of code in the header, e.g. simple access methods which returns a reference of a variable. Where do you draw the line? ...

Return concrete or abstract datatypes?

I'm in the middle of reading Code Complete, and towards the end of the book, in the chapter about refactoring, the author lists a bunch of things you should do to improve the quality of your code while refactoring. One of his points was to always return as specific types of data as possible, especially when returning collections, iterat...

How do you enforce coding standards in your team?

We are a .NET shop, mostly coding using C# in VS. We created coding standards for our organization, and now we need to enforce them. We can use tools like FxCop & StyleCop. What we want: On each developer's PC, have settings that will give them a warning or error when they compile their code. When they check in the code into version...