Naming "class" and "id" HTML attributes - dashes vs. underlines
<div id="example-value"> or <div id="example_value">? This site and Twitter use the first style. Facebook and Vimeo - the second. Which one do you use and why? ...
<div id="example-value"> or <div id="example_value">? This site and Twitter use the first style. Facebook and Vimeo - the second. Which one do you use and why? ...
c# 3.0 offers us getters and setters with compiler generated backing fields - this is really great, but there are plenty of times that you still need to use a backing field. In a perfect world (opinion), you would be able to do something like class MyClass { ... stuff ... public string MyProperty { private string _myBackingFi...
I have heard a lot about the importance of programming style. In my opinion, indention is easy to deal with. But other things frustrated me a lot. Considering a particular example to demonstrate the use of inet_makeaddr. /* demonstrate the use of host address functions */ #include <stdio.h> #include <arpa/inet.h> #include <netinet/in.h>...
Is this the most efficent way to forward the 'each' call to the Hash's native each method. Should I make @index visible to the outside? I'm a bit unsure as a block is invovled. class TimeSlice def initialize(list) # @index is a hash @index = list.do_some_magic() end def each(&block) @index.each(&block) end end ...
Hi all I have the following code. class person(object): def __init__(self, keys): for item in keys: setattr(self, item, None) def __str__(self): return str(self.__dict__) def __eq__(self, other) : return self.__dict__ == other.__dict__ Now I want to take this code and only do...
Consider the two code segments below. Which one is better and Why? If you have any other idea, please do mention. Where can I find answers to coding practices like these? If you are aware of any book / article, please do share. //Code 1 bool MyApplication::ReportGenerator::GenerateReport(){ bool retval = false; ...
I have a big object say MyApplicationContext which keeps information about MyApplication such as name, path, loginInformation, description, details and others.. //MyApplicationCtx class MyApplicationCtx{ // .... private: std::string name; std::string path; std::string desciption; struct loginI...
Hi everybody :) I often find myself using lambdas as some sort of "local functions" to make my life easier with repetetive operations like those: Func<string, string> GetText = (resource) => this.resourceManager.GetString(resource); Func<float, object, string> FormatF1 = (f, o) => String.Format("{0:F1} {1}", f, o); Func<float, object, ...
As far as I know, there are 3 types of comments recognized by PHP: /* A block comment */ // A single-line comment # Also a single-line comment However, many coding standards, for example, those of PEAR or Kohana, discourage the last type of comments with no explanation. The question is, why is it so? Is this syntax planned for deprec...
Related Questions: Benefits of using short-circuit evaluation, Why would a language NOT use Short-circuit evaluation?, Can someone explain this line of code please? (Logic & Assignment operators) There are questions about the benefits of a language using short-circuit code, but I'm wondering what are the benefits for a programmer? Is it...
What is the significance of declaring variables in VB/VBA like so: Private m_sName As String Private m_lAge As Long As opposed to; Private m_sName As String Private m_lAge As Long I am working on a project which up to now uses the latter, and has done since long before I joined the project. Two new developers have...
It seems like people who would never dare cut and paste code have no problem specifying the type of something over and over and over. Why isn't it emphasized as a good practice that type information should be declared once and only once so as to cause as little ripple effect as possible throughout the source code if the type of somethin...
I sometimes use temporary variables to shorten the identifiers: private function doSomething() { $db = $this->currentDatabase; $db->callMethod1(); $db->callMethod2(); $db->callMethod3(); $db->... } Although this is a PHP example, I'm asking in general: Is this bad practice? Are there any drawbacks? ...
Hi i have naming problems with two of my functions i've got a function is_void that returns true if the argument is "empty" (in some sense). How would you call an opposite function? isnt_void? is_set? is_not_void? i have a pair of functions, the first one installs a handler to catch errors in the subsequent code and the second removes...
Okay, so I've got a .NET console application with it's Main method, contained in a Program class. You know, the usual: class Program { static void Main(string[] args) { // Do something spectactular } } Since I've started using StyleCop and FxCop so rigorously, I've become kind of nit-picky about making sure everyth...
Being compelled by the advantages I'm looking for a way to integrate generic programming into my current programming style. I would like to use generics in C# but can't find any good introductory material with some everyday examples of use. If you have experience with generics: what resources did you find most useful learning them? (book...
Readed bog of Ulrich Drepper and come across 2 entries that looks like conficting. In the first one (string in global space) Ulrich states that the string should be defines as: const char _pcre_ucp_names[] = "blabla"; while already in second one (string in function) he argues it should be declared as: static const char _pcre_ucp_nam...
What would be faster? This: sprintf(&str[strlen(str)], "Something"); or strcat(str, "Something"); Is there any performance difference? ...
What's the convention for naming functions in C++? I come from the java environment so I usually name something like: myFunction(...){ } I've seen mixed code in C++, myFunction(....) MyFunction(....) Myfunction(....) what's the correct way? Also, is it the same for a class function and for a function that's not a class function?...
Source: http://blogs.msdn.com/brada/articles/361363.aspx Tab characters (\0x09) should not be used in code. All indentation should be done with 4 space characters. Can someone give me an argument as to why this would matter? Shouldn't compilers just ignore this tabs? I always use tabs, just because it's easier and indented code...