答:
Almost all open source projects use some sort of gatekeeper workflow, where a person or group of people must sign off on all changes in order to go into the official build.  Some larger projects, such as the Linux kernel, have layers of gatekeepers.  You send a change to someone who manages an area of a subsystem, they send their changes to someone who manages an entire subsystem, and they send their changes to Linus Torvalds, who sometimes reviews the code himself or sometimes trusts his lieutenants.  These reviews usually don't have a formal structure.  It's just someone looking the code over before it gets merged.

As far as tools, look at the pull request mechanism on github for a good example.  You make a pull request, and on a web page dedicated to that pull request people make comments and the author makes revisions until it is good enough to accept.  Other gatekeepers just use plain git to apply patches from mailing lists or merge pull requests from public repositories, which is one of the main reasons DVCSes like git were invented.

Title: Are there code reviews in opensource projects? If so, what tools are used to do this?

Body:
I know there is a big push for code reviews in commercial development. However, are code reviews used in open source software or is based on trust? If so, then how are they performed? [Is it a delayed commit, "a pre commit environment", is there a tool that allows for the patch to be sent to another dev]?

Are there any projects that use code reviews?

From my understanding the Linux kernel is mostly based around trust of the committer. MySQL was based on the main author's approval and the performance impact.


问:
How does one become a big contributor to an opensource project?
I know that the default advice for open source projects, and getting started, is to start fixing bugs. But I have a feeling that its the path that one would want to take if they wanted to be a tester/fixer of bugs in the project. How does one become an active contributor of an opensource project? [I.e. on the level of architecture]</p>

答:
There are no shortcuts.  Open source projects are extremely merit based.  When you have shown you are capable of handling smaller tasks, you will eventually be trusted with larger and larger tasks.  Open source projects also have a lot of drive by contributors who contribute one or two patches then move on, and even more people who "contribute" one or two grand but unimplemented ideas then move on.  If you want to make larger contributions you'll have to show you're in it for the long haul.

That being said, incremental architectural improvements are often welcome, especially if they solve a major bug or performance problem.  For example, several years ago one of a handful of patches I contributed to the Cinelerra project was an architectural change to the undo stack that significantly reduced memory consumption and latency for undoable operations.

You're going to find the most success if you're solving a problem you are personally facing, rather than just setting out to "become a contributor to an open source project."  When I submitted that patch to Cinelerra, I wasn't trying to contribute an architectural change to a randomly chosen open source project, I was trying to figure out why it took so freaking long to move an in/out point when editing my videos.

ContentLicense: CC BY-SA 3.0


问:
Are there code reviews in opensource projects? If so, what tools are used to do this?
I know there is a big push for code reviews in commercial development. However, are code reviews used in open source software or is based on trust? If so, then how are they performed? [Is it a delayed commit, "a pre commit environment", is there a tool that allows for the patch to be sent to another dev]?

Are there any projects that use code reviews?

From my understanding the Linux kernel is mostly based around trust of the committer. MySQL was based on the main author's approval and the performance impact.

答:
Open source projects often have (and should, if they don't) a clearly published set of "community guidelines", which often includes a description of the project workflow and how contributions are accepted (and thus how they are tested), as well as the process for becoming a core committer.

As far as code review, again it depends on the community but the guidelines are often made clear.  Some example guidelines for contributions by non-committers range from "working code wins" to "contributions must have full test coverage and documentation, with tests committed at the same time as the code" and everything in between; regardless of these guidelines, the one guideline that is implied is that the core committers will review any and all contributions from non-committers before accepting them.

Open source projects with groups of core committers also often have virtual meetings or dedicated time to discuss any contributions that may need extra sets of eyes -- much like the SE process of multiple close votes by users of a certain reputation before a question is closed, and the discussion of questionable things via meta or chat.

Here are a few quick links to some example community documents for projects I know best, where you can find answers to your question specific to these projects (you'll soon notice a theme):

Project Blacklight community principles

DSpace code contribution guidelines

Apache contributors tech guide


问:
Does code generation increase the code quality?
Arguing for code generation, I am looking for some examples of ways in which it increases code quality. To clarify what I mean by code generation, I can talk only about a project of mine:

We use XML files to describe entity relationships in our database schema, so they help us generate our ORM framework and HTML forms which can be used to add, delete, and modify entities.

To my mind, it increases code quality because human error is reduced. If something is implemented incorrectly, it is broken in the model, which is good because the error might appear sooner since more generated code is broken too.

Since I was asked for the definition of code quality, let me clarify this, what I meant is software quality.

Software Quality:
It is not one attribute but many, e.g. efficiency, modifiability, readability, correctness, robustness, comprehensibility, usability, portability etc. which impact on each other.

答:
In addition to Martin's answer, I would add that SQL code generation is very good when you work in a record-by-record basis (select * from tab1 where tab1.pkcolumn = :parameter, update tab1 set [any number of columns] where tab1.pkcolumn = :parameter, etc). And your ORM will shine in that scenario, because of the SQL that needs to be generated is indeed repetitive.

My main worries is metaqueries - queries on object's properties that the ORM translate to SQL using whatever algorithm. Very similar metaqueries can generate SQL that's completely different - and have no guarantee that this generated SQL is performatic.

A metaquery language that translates to another language (SQL) that translate to a query plan to effectively execute the data gathering. And the generated result must be objects, so the ORM must instantiate the affected objects - so it can trigger another rain of queries to fill the attributes of the objects not brought by the metaquery itself...


问:
Is there any good reason why lines with only whitespace should be truncated?
Typically, when you hit Enter in a smart editor, it copies the indentation of the last line by inserting the same amount of spaces, so if you don't delete them, the code looks like this:

```
sub sum {
    my @numbers = @_;
   &nbsp
    my $sum = 0;
    foreach (@_) {
         $sum += $_;
    }
   &nbsp
    return $sum;
}
```

(Yes, the example is silly; that sub could be written in two or three lines. :))

To be honest, these lines make my cursor feel dizzy, so I tend to clear them out. (I admit, that this behavior generates commit noise + inconsistency.)  Plus, the whitespace are unnecessary bytes.  Well, probably none of these does matter, at least in most obvious ways.  So I wonder if there is any better (i.e. less subjective and less over-pedantic) reason why the lines should be blanked (by s/^\s+$//).

Note: And please try not to point me to the style guide. Imagine I'm the one writing the style guide: should I inherit rule "delete the extra spaces" or just bravely fight my intuition and leave those peaceful \t's and 's alone?.  Or I just want to improve my "own" guide, which I can use where "official" guide is silent or missing.

答:
Because empty heredoc terminators make multi-line quotes pretty (I blame Schwern for this):</p>

```<code>\t  my $value = $dbh->selectrow_array( << '', {}, $index );
\t  \t  SELECT value
\t  \t  FROM table
\t  \t  WHERE key = ?

\t  print $value;
</code>```

Body:
Because empty heredoc terminators make multi-line quotes pretty (I blame Schwern for this):

\t  my $value = $dbh->selectrow_array( << '', {}, $index );
\t  \t  SELECT value
\t  \t  FROM table
\t  \t  WHERE key = ?

\t  print $value;


问:
What's your favourite quote about programming?
What's your favourite quote about programming?

One quote per answer, and please check for duplicates before posting!

答:
By Mike Williams, one of the creators of Erlang:

Find the right methods—Design by Prototyping.

It is not good enough to have ideas, you must also be able to implement them and know they work.

Make mistakes on a small scale, not in a production project.

LastEditorDisplayName: Roger Pate

ContentLicense: CC BY-SA 2.5


问:
Any valid reason to Nest Master Pages in ASP.Net rather than Inherit?
Currently in a debate at work and I cannot fathom why someone would intentionally avoid Inheritance with Master Pages.

For reference here is the project setup:

BaseProject

MainMasterPage

SomeEvent

SiteProject

SiteMasterPage

nested MainMasterPage

OtherSiteProject

MainMasterPage (from BaseProject)

The debate came up because some code in BaseProject needs to know about "SomeEvent".  With the setup above, the code in BaseProject needs to call this.Master.Master.  That same code in BaseProject also applies to OtherSiteProject which is just accessed as this.Master.

SiteMasterPage has no code differences, only HTML differences.

If SiteMasterPage Inherits MainMasterPage rather than Nests it, then all code is valid as this.Master.

Can anyone think of a reason why to use a Nested Master Page here instead of an Inherited one?

答:
No.

First, I'd recommend using the MVP design pattern for webforms.  Separate the logic that manipulates the view from the logic that manipulates the data model (View Logic, Business Logic).  Put all your logic in classes instead of in the code-behind. Also, decide which works best for you: Passive View or Supervising Controller.

SiteMasterPage has no code differences, only HTML differences.

Extract all the logic into a separate class: [Description]MasterPage such as class DefaultMasterPage. Each MasterPage would inherit this class.  This way you're not duplicating code.  The only differences will be with the html in the MasterPages.

If the logic begins to diverge you now have the option to Inherit and Override functionality (still in separate classes, not in the code-behind).


问:
JavaScript Phone Screen
For a simple phone screen question we generally always ask about scoping rules. It's clearly one of the biggest gotchas of JavaScript. Out of everyone we ask almost everyone insists that in an if or for loop a variable is scoped to that block as opposed to the function.

Is this an unreasonable question?

答: If its purpose is to test important JavaScript knowledge that you want good candidates to possess, then no. Seems reasonable to me.</p>

Title: JavaScript Phone Screen


答: Actually, as "trivia" (fact that you either know or don't) interview questions go this one has the uncommon virtue that it's something it's hard to imagine an experienced programmer not having encountered, as well as something hard for someone who has encountered it to forget.</p>

Title: JavaScript Phone Screen

Body:
For a simple phone screen question we generally always ask about scoping rules. It's clearly one of the biggest gotchas of JavaScript. Out of everyone we ask almost everyone insists that in an if or for loop a variable is scoped to that block as opposed to the function.

Is this an unreasonable question?


问:
Is it better to spend resources on a skilled team or good process practice?
Which one of these is of more importance? Skilled team or good process practice?

When I say skilled, I mean logical, creative members with good coding and testing skills.  Good process would be the development methodology, like agile, scrum, etc

答:
There are a lot of good answers here already, and so I won't try to comprehensively answer the question in all its possible aspects.  My own judgment on this issue would depend quite a bit on how hard the problems are that you're trying to solve.   That's obvious I suppose; if your problem is sufficiently cutting edge, you need creative, able, insightful programmers.   Process is no substitute.   But if your project diet is humdrum, you can certainly build an environment where the senior developers you do have can coach the inexperienced, and you can use some software development processes to provide a support framework for this to happen.  As long as you have perhaps >50% skilled developers, you should be able to get the project to move forward and develop your team's skills at the same time.   This assumes that "skilled" includes having some coaching abilities, and of course that isn't always true.

Certainly given a choice I would establish a relatively modest skills floor; take on only developers who have already worked on maintaining an existing code base successfully.    Grinding out crap software is easy.   Maintaining an existing code base for a period yields vital insights about how to design good software.


问:
Support multiple frameworks in a JavaScript library
I have a small JavaScript library that I've written that depends on prototype.js.

I'm considering creating a new version that would use jQuery instead.

The goal is to make it easier for users to install (choose which framework you use!) while not making it harder for me to maintain.

The main issue I see is that I would need to support two separate versions with overlapping functionality. If there is a bug, then I would need to fix it in two separate places.

How can I support multiple different frameworks in a JavaScript library without having a maintenance nightmare?

答:
You don't. You do not build libraries on top of frameworks. You just support standards, like the DOM and ES5.1

Those standards work in modern browsers, if the users of libraries want to support legacy browsers tell them to use any of the standard polyfills.


问:
Request / Reply , how should one initiate the actual sending of the transmission?
I'm working on Language level interfaces to web API's. These libraries are of course built around existing HTTP Request/Reply interfaces. I see myself as having a few options

submit method on the request object e.g

```<code>my $req = Request->new( ... );

my $response = $req->submit; # returns response

my $res2     = $req->submit; # sends the same request again
</code>```

lazy request accessor

```<code>my $req = Request->new( ... );

my $response = $req->response; # returns a reference to the response

my $res2     = $req->response; # doesn't send again, just returns the reference

$req->clear_response;          # clears the response value

my $res3     = $req->response; # sends again because no response exists
</code>```

These are the 2 options I'm thinking of. I have seen more examples of the former but I'm not sure if there's a reason why. Do you have any preferences on which style interface? or are there other ways I'm not thinking of? Overall I'm trying to discern what the best API is to retrieve the response.

答:
Most people who want to keep a reference to the same response around will just save $response somewhere.  Your second option violates the single responsibility principle for the method and makes it unpredictable.  Sometimes response returns an old reference and sometimes it sends a new request.  It also adds additional steps if you want to send another request.  It's obvious in a small function, but if a lot of code intervenes between requests, you won't know for sure if you need or want to do a clear first in order to generate a new response.

If you are set on caching the response in the Request object, I would at least make it a separate name from the one that submits it.  For example, $response = $req->submit for actually submitting it, and $req->response if you just want to retrieve the last cached response.


问:
Duck checker in Python: does one exist?
Python uses duck-typing, rather than static type checking.  But many of the same concerns ultimately apply: does an object have the desired methods and attributes?  Do those attributes have valid, in-range values?

Whether you're writing constraints in code, or writing test cases, or validating user input, or just debugging, inevitably somewhere you'll need to verify that an object is still in a proper state--that it still "looks like a duck" and "quacks like a duck."

In statically typed languages you can simply declare "int x", and anytime you create or mutate x, it will always be a valid int.  It seems feasible to decorate a Python object to ensure that it is valid under certain constraints, and that every time that object is mutated it is still valid under those constraints.  Ideally there would be a simple declarative syntax to express "hasattr length and length is non-negative" (not in those words.  Not unlike Rails validators, but less human-language and more programming-language). You could think of this as ad-hoc interface/type system, or you could think of it as an ever-present object-level unit test.

Does such a library exist to declare and validate constraint/duck-checking on Python-objects?  Is this an unreasonable tool to want? :)

(Thanks!)

Contrived example:

```<code>rectangle = {'length': 5, 'width': 10}

# We live in a fictional universe where multiplication is super expensive.
# Therefore any time we multiply, we need to cache the results.

def area(rect):
    if 'area' in rect:
        return rect['area']
    rect['area'] = rect['length'] * rect['width']
    return rect['area']

print area(rectangle)
rectangle['length'] = 15
print area(rectangle) # compare expected vs. actual output!

# imagine the same thing with object attributes rather than dictionary keys.
</code>```

答:
Remember that duck typing is really just an (implicit) promise to implement certain methods, with the agreement that the call will fail at run time rather than at compile time. Because of that, a ducktyper would really just be an explicit promise - which isn't really that different from an interface.

I know that zope has an implementation of interfaces - http://wiki.zope.org/zope3/WhatAreInterfaces

Although I haven't used it personally

Title: Duck checker in Python: does one exist?


答: While not necessarily unreasonable, it is a fairly useless question - if you think that the variable belongs to the function, you got the right answer. If you think it belongs to the block you will write good code anyway - how often does a variable declared inside a loop have any meaning outside that loop? Scoping confusion tends to go away if you use appropriate variable names.</p>

Title: JavaScript Phone Screen


问:
What did they call Object-Oriented Programming before Alan Kay invented the term?
Alan Kay claims that "I made up the term "object-oriented", and I can tell you I did not have C++ in mind."  What he had in mind, of course, was Smalltalk.  But he did not make up object-oriented programming itself; he got the basic ideas from Simula.  So if the term hadn't been invented yet, what did they originally call object-oriented programming in Simula?</p>

答:
Actually Alan Kay didn't have Smalltalk in mind when he came up with the term "object oriented programming":

At Utah sometime after Nov 66 when, influenced by Sketchpad, Simula, the design for the ARPAnet, the Burroughs B5000, and my background in Biology and Mathematics, I thought of an architecture for programming. It was probably in 1967 when someone asked me what I was doing, and I said: "It's object-oriented programming".

The original conception of it had the following parts.

I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).

I wanted to get rid of data. The B5000 almost did this via its almost unbelievable HW architecture. I realized that the cell/whole-computer metaphor would get rid of data, and that "<-" would be just another message token (it took me quite a while to think this out because I really thought of all these symbols as names for functions and procedures.

My math background made me realize that each object could have several algebras associated with it, and there could be families of these, and that these would be very very useful. The term "polymorphism" was imposed much later (I think by Peter Wegner) and it isn't quite valid, since it really comes from the nomenclature of functions, and I wanted quite a bit more than functions. I made up a term "genericity" for dealing with generic behaviors in a quasi-algebraic form.

I didn't like the way Simula I or Simula 67 did inheritance (though I thought Nygaard and Dahl were just tremendous thinkers and designers). So I decided to leave out inheritance as a built-in feature until I understood it better.

Smalltalk was the result of this conception, borrowing and extending the concepts of "object" and "class" from Simula, which Simula in turn inherited from ALGOL, as described on "The development of the Simula languages" by Kristen Nygaard and Ole-Johan Dahl (1978, page 253):

In ALGOL, blocks (including procedures) are seen externally as generalized operations. By introducing mechanisms for quasi-parallel sequencing, ~essentially the same construct could play the role of processes in parallel, and through mechanisms for naming block instances and accessing their contents they could function as generalized data objects. The essential benefits of combining data and operations in a single construct were already there to be explored.

One result of this exploration was the discovery that "procedure attributes" might be useful. The following example of a class of "abstract" car objects is quoted from the Language Definition document (Dahl and Nygaard 1965), sect. 5.3.

Further inspiration, especially for sub-classing, was C.A.R. Hoare's record class (page 258):

The subclass idea of Hoare (68) was a natural starting point, but there were two difficulties:

We needed subclasses of processes with own actions and local data stacks, not only of pure data records.

We also needed to group together common process properties in such a way that they could be applied later, in a variety of different situations not necessarily known in advance.

Much time was spent during the autumn of 1966 in trying to adapt Hoare's record class construct to meet our requirements, without success. The solution came suddenly, with the idea of "prefixing", in December 1966. We were thinking in terms of atoll booth on a bridge, with a queue of cars which were either trucks or buses. (This example reappears in (Dahl and Nygaard 1968)).

The terms "class" and "object" also appear on SIMULA 67 COMMON BASE LANGUAGE by Ole-Johan Dahl, Bjorm Myhrhaug, and Kristen Nygaard (pages 4-5):

The block concept corresponds to the intuitive notion of "sub-problem" or "sub-algorithm" which is a useful unit of decomposition in orthodox application areas.

A block is a formal description, or "pattern" of an aggregated data structure and and associated algorithms and actions.

...

An extended block concept is introduced through a "class" declaration and associated interaction mechanism such as "object references" (pointers), remote accessing", "quasi-parallel" operation, and block "concatenation".

Classes are discussed in more detail in chapter 1.3.3 (page 5):

A central new concept in Simula 67 is the "object". An object is a self-contained program (block instance), having its own local data and actions defined by a "class declaration". The class declaration defines a program (data and action) pattern, and objects conforming to that pattern are said to "belong to the same class".

...

So, although the term "object oriented" wasn't invented yet, both "class" and "object" were used similarly to their modern use before Alan Kay began developing Smalltalk in 1969.

Ivan Sutherland goes as far as identifying Simula as the first object oriented programming language, on Sketchpad: A man-machine graphical communication system (page 4), also recognizing C.A.R. Hoare's, Douglas T. Ross', ALGOL's and Sketchpad's influences:

Nevertheless, Sutherland's attempt to remove the division between users and programmers was not the only system that, in failing to do so, provided the imaginative leap to a new programming paradigm. Nygaard and Dahl's Simula [7] was the first conventional programming language incorporating the principles of object orientation, but Sketchpad's implementation of class and instance-based inheritance (though not called objects) predated Simula by several years.

There appears to have been a common influence through the work of Douglas T. Ross, who is mentioned in the acknowledgements of this dissertation and also cited in the MIT Lincoln Laboratory technical report based on it. Ross sat on the Algol 68 committee with C. A. R. Hoare in the mid-1960s, where his previous work on a record-like data structure (called a plex) influenced Hoare's own ideas on abstract data types [3], later credited by Nygaard and Dahl as the origin of the class definition mechanisms in Simula [7].

Alan Kay's seminal Dynabook project, which led both to the Xerox Star and to the explosion of interest in object oriented programming through his language Smalltalk, was directly influenced by Sketchpad. Kay has written of the fact that the genesis of Smalltalk lay in the coincidental appearance on his desk of both a distribution tape of Simula and a copy of Sutherland's Sketchpad thesis [5]. Kay recognized that the two systems were based on the same underlying type concepts (apparently derived via two different routes from Ross's plex), and that these could form the basis of a more widely usable programming system. In comparing these two routes of influence, Simula was a far larger project than Sketchpad, rightly recognized as the first object-oriented programming language, but we hope that the special emphasis of Sketchpad on supporting abstraction in the user interface itself may yet become viable as a result of ongoing research efforts [2,6].

However Alan Kay, obviously, considers Smalltalk to be the first object oriented language:

Though it has noble ancestors indeed, Smalltalk’s contribution is a new design paradigm–which I called object-oriented–for attacking large problems of the professional programmer, and making small ones possible for the novice user. Object-oriented design is a successful attempt to qualitatively improve the efficiency of modeling the ever more complex dynamic systems and user relationships made possible by the silicon explosion.

and having coined the term, I think there isn't much of a debate there.

To finally answer your question: Some of the core concepts of object orientation did exist on Simula, and on earlier languages like Algol and LISP, but the paradigm itself didn't, hence there wasn't really a need for a name.

Smalltalk was designed with object orientation in mind, at least what Alan Kay thought of as object orientation:

OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things. It can be done in Smalltalk and in LISP. There are possibly other systems in which this is possible, but I'm not aware of them.

The architecture may seem like an amalgamation of earlier concepts, but its central concepts were introduced by Smalltalk, thus marking the first implementation of the paradigm.


问:
What kinds of low level knowledge matter?
I realize that this question is similar to Low level programming - what's in it for me, but the answers didn't really address my question well.  Part from just an understanding, how exactly does your low level knowledge translate into faster and better programs?

There's the obvious lack of stop-the-world from garbage collection, but what else is an advantage?  Do you really outperform your optimizing compiler?  Do you pack your data structures in as tight as possible and be concerned about alignment?  There's extra freedom naturally, but does that really translate into a faster program?

答:
It's not just about faster.  Extra CPU cycles from various CPU pipeline stall penalties and extra memory accesses due to cache misses and such, in sufficiently repetitive performance critical code, can add up to take measurable extra energy.  A big cost in data centers these days is energy and cooling costs, and a big cost in mobile devices is the battery weight.  The transistors have become nearly free, but the nanoWatts have not.

An optimizing compiler can help, but it might not know all the possible algorithmic transformations that still can produce a useful result. (e.g. humans sometimes know how to cheat and get away with it.)  The short vector/SIMD math units in many CPUs these days (even on mobile device processors) can often only be fully utilized with some low-level knowledge about them.

Embedded and signal processing programmers use this low-level knowledge all the time, sometimes just to meet spec.  If you can pack your code to run in a 10 cent cheaper processor, and end up shipping millions per annum embedded in some toy, you more than paid for a software engineer's salary or three.


答:
You're right that some low-level knowledge doesn't matter. For example, I think you'd be nuts to routinely re-jigger arithmetic to replace multiplication and division with equivalent bit-shift operations to save a cycle or two. The speed-up is likely to be microscopic, the compiler might do it anyway, and I suspect doing things like triangle_area = (base >> 1) * height is just asking for trouble when someone looks at your code in six months. Similarly, a lot older code jumps through incredible hoops to reduce the number of floating point operations; that's also not worth the hassle, mental overhead, and potential for bugs these days.

On the other hand, there are other low-level concepts that can give you relatively large gains for minimal work. For example, consider caching. For example, you could iterate over an NxN matrix like this:

```<code>for(i=0; i<N; ++i)
   for(j=0; j<N; ++j)
       do_something(matrix[i][j]);
</code>```

or like this:

```<code>for(j=0; j<N; ++j)
  for(i=0; i<N; ++i)
     do_something(matrix[i][j]);
</code>```

If the matrix is suitably large, one of these (depending on how the language lays out the array) will cause a cache-miss for every single array access, while the other will be optimal. Assuming you've got to iterate over the matrix somehow, why not prefer the potentially faster one? They're equally readable, equally writable, etc.

In general, I think appreciating the things going on "under the hood" can help inform your decisions when programming in higher-level languages (e.g., Can I code this in a way that doesn't trash the cache over and over again?). If you're unfamiliar with the relationship between an array index and a memory address, you might not appreciate how important it is to check array indices and buffer sizes. I think you could glean a lot of this information from the higher-level language's documentation, but it'll definitely be more in-your-face in C.

Obviously, the trick is not to go overboard. There is a theoretical speed difference between i++ and ++i, but if copying a single four-byte variable makes or breaks your web-app, the app is already in pretty dire straights.

Title: What kinds of low level knowledge matter?

Body:
I realize that this question is similar to Low level programming - what's in it for me, but the answers didn't really address my question well.  Part from just an understanding, how exactly does your low level knowledge translate into faster and better programs?

There's the obvious lack of stop-the-world from garbage collection, but what else is an advantage?  Do you really outperform your optimizing compiler?  Do you pack your data structures in as tight as possible and be concerned about alignment?  There's extra freedom naturally, but does that really translate into a faster program?

Body:
You're right that some low-level knowledge doesn't matter. For example, I think you'd be nuts to routinely re-jigger arithmetic to replace multiplication and division with equivalent bit-shift operations to save a cycle or two. The speed-up is likely to be microscopic, the compiler might do it anyway, and I suspect doing things like triangle_area = (base >> 1) * height is just asking for trouble when someone looks at your code in six months. Similarly, a lot older code jumps through incredible hoops to reduce the number of floating point operations; that's also not worth the hassle, mental overhead, and potential for bugs these days.

On the other hand, there are other low-level concepts that can give you relatively large gains for minimal work. For example, consider caching. For example, you could iterate over an NxN matrix like this:

for(i=0; i<N; ++i)
   for(j=0; j<N; ++j)
       do_something(matrix[i][j]);

or like this:

for(j=0; j<N; ++j)
  for(i=0; i<N; ++i)
     do_something(matrix[i][j]);

If the matrix is suitably large, one of these (depending on how the language lays out the array) will cause a cache-miss for every single array access, while the other will be optimal. Assuming you've got to iterate over the matrix somehow, why not prefer the potentially faster one? They're equally readable, equally writable, etc.

In general, I think appreciating the things going on "under the hood" can help inform your decisions when programming in higher-level languages (e.g., Can I code this in a way that doesn't trash the cache over and over again?). If you're unfamiliar with the relationship between an array index and a memory address, you might not appreciate how important it is to check array indices and buffer sizes. I think you could glean a lot of this information from the higher-level language's documentation, but it'll definitely be more in-your-face in C.

Obviously, the trick is not to go overboard. There is a theoretical speed difference between i++ and ++i, but if copying a single four-byte variable makes or breaks your web-app, the app is already in pretty dire straights.


问:
Using functions as statements on Python
A great feature of Javascript is function statements. You can do this:

```<code>(function myFunc(){
    doSomething();
    doSomethingElse();
})();
</code>```

Which is a way to declare a function and call it without having to refer to it twice. Can that be mimified on Python?

答:
Python does not have this syntax for functions.  It does, however, support the lambda syntax which can be used in this way.  However, a lambda is an expression and not a statement, so it is limited.

```<code>(lambda x: x*x)(10)
</code>```

would return 100

When this feature is needed, just use the def statement to define a function

```<code>...
def tmp(x,y):
   foo(x);
   foo(y);

tmp(12,24)
...
</code>```

Title: Using functions as statements on Python

Body:
Python does not have this syntax for functions.  It does, however, support the lambda syntax which can be used in this way.  However, a lambda is an expression and not a statement, so it is limited.

(lambda x: x*x)(10)

would return 100

When this feature is needed, just use the def statement to define a function

...
def tmp(x,y):
   foo(x);
   foo(y);

tmp(12,24)
...


答:
Understanding how memory behaves is IMO among the most fruitful things. Particularly:

What CPU cache is and why it matters.

Why primitives, and particularly arrays of primitives, are faster than equivalent (arrays of) objects.

Why in multidimensional arrays rows and columns aren't equivalent at all (alignment).

Memory barriers, locking vs. CAS operations.

Also  you can help the optimizing compiler: for example, by making simple for loop through an array with explicit start and end indices may allow the compiler to optimize away bound checking (which is about the only thing that makes Java arrays slower than native arrays).

As with all optimization, it only matters where it does :)


问:
myeclipse: can I customize templates like sysout in jsp
Myeclipse's java code templates like sysout make coding easier, and they can also be customized. But seems it's jsp editor has no such capability.

Is it possible to create and customize some templates like sysout in myeclipse jsp editor, and if yes, how?

答:
Yes.

Go to:

MyEclipse->Preferences->MyEclipse->Files , and

Editors->JavaScript->Editor->Templates.

There you can see the existing templates that work in a similar manner to the Java templates. If the context is JavaScript then they'll be available when editing JavaScript. To get the code to automatically be inserted when you enter the template name then hit Ctrl+Space, ensure the name is unique and that no other template name starts with the same characters and ensure the Auto Insert flag is also set.


问:
Polymorphism and passing
I am writing a text based RPG, and I have three classes that inherit from a super class, they all have special attacks that they can perform, at the same time I have a class that holds the function which handles battles in my game.

Now how do I get the unique special abilities functions for whatever role the player chooses into the battle function?

Also I am using the vector.push_back method to handle how my sub classes are referenced.

答:
You just need a virtual member function in your superclass:

```<code>class Superclass
{
    virtual void specialAbility() = 0;
};
</code>```

And implementations in your subclasses:

```<code>class Subclass1 : public Superclass
{
    void specialAbility()
    {
        // Do something specific to this subclass...
    }
};

class Subclass2 : public Superclass
{
    void specialAbility()
    {
        // Do something specific to this subclass...
    }
};
</code>```

Now when you do your battles, you could do something like this (edited to put in class):

```<code>class BattleDoer
{
    void doBattle(std::vector<Superclass*> combatants)
    {
        for (unsigned int index = 0; index < combatants.size(); index++)
        {
            combatants.at(index)->specialAbility();
        }
    }
};
</code>```

This will cause the appropriate member function defined in the subclass to be called on each of the combatant objects.

Edit:

To populate your combatant list and call the doBattle() function, you can do something like this:

```<code>int main()
{
    Superclass* combatant1 = new Subclass1;
    Superclass* combatant2 = new Subclass2;

    std::vector<Superclass*> combatants;
    combatants.push_back(combatant1);
    combatants.push_back(combatant2);

    BattleDoer battleDoer;
    battleDoer.doBattle(combatants);

    delete combatant1;
    delete combatant2;
}
</code>```

It is important to use pointers here. Only pointers and references can be used to provide polymorphism. You cannot have variables of type Superclass because it cannot be instantiated, you can only have references and pointers of type Superclass. Smart pointers should probably be used but I thought I'd keep it simple.

Title: Polymorphism and passing

Body:
You just need a virtual member function in your superclass:

class Superclass
{
    virtual void specialAbility() = 0;
};

And implementations in your subclasses:

class Subclass1 : public Superclass
{
    void specialAbility()
    {
        // Do something specific to this subclass...
    }
};

class Subclass2 : public Superclass
{
    void specialAbility()
    {
        // Do something specific to this subclass...
    }
};

Now when you do your battles, you could do something like this (edited to put in class):

class BattleDoer
{
    void doBattle(std::vector<Superclass*> combatants)
    {
        for (unsigned int index = 0; index < combatants.size(); index++)
        {
            combatants.at(index)->specialAbility();
        }
    }
};

This will cause the appropriate member function defined in the subclass to be called on each of the combatant objects.

Edit:

To populate your combatant list and call the doBattle() function, you can do something like this:

int main()
{
    Superclass* combatant1 = new Subclass1;
    Superclass* combatant2 = new Subclass2;

    std::vector<Superclass*> combatants;
    combatants.push_back(combatant1);
    combatants.push_back(combatant2);

    BattleDoer battleDoer;
    battleDoer.doBattle(combatants);

    delete combatant1;
    delete combatant2;
}

It is important to use pointers here. Only pointers and references can be used to provide polymorphism. You cannot have variables of type Superclass because it cannot be instantiated, you can only have references and pointers of type Superclass. Smart pointers should probably be used but I thought I'd keep it simple.


问:
Are there any actual case studies on rewrites of software success/failure rates?
I've seen multiple posts about rewrites of applications being bad, people's experiences about it here on Programmers, and an article I've ready by Joel Spolsky on the subject, but no hard evidence or case studies.  Other than the two examples Joel gave and some other posts here, what do you do with a bad codebase and how do you decide what to do with it based on real studies?

For the case in point, there are two clients I know of that both have old legacy code.  They keep limping along with it because as one of them found out, a rewrite was a disaster, it was expensive and didn't really work to improve the code much.  That customer has some very complicated business logic as the rewriters quickly found out.

In both cases, these are mission critical applications that brings in a lot of revenue for the company.  The one that attempted the rewrite felt that they would hit a brick wall if the legacy software didn't get upgraded at some point in the future.  To me, that kind of risk warrants research and analysis to ensure a successful path.

Have there been actual case studies that have investigated this?  I wouldn't want to attempt a major rewrite without knowing some best practices, pitfalls, and successes based on actual studies.

Aftermath:  okay, after more searching, I did find three interesting articles on case studies:

Rewrite or Reuse.  They did a study on a Cobol app that was converted to Java.

The other was on Software Reuse: Developers Experiences and Perceptions.

Reuse or Rewrite Another study on costs of maintenance versus a rewrite.

I recently found another article on the subject: The Great Rewrite. There the author seems to hit on some of the major issues.  Along with this was the idea of prototyping by using the proposed new technology stack and measuring how quick the devs picked it up.  This was all as a prelude to a rewrite, which I thought was a great idea!

答:
Speaking from experience and living in a company that has poorly conceived enterprise architecture from the beginning I can honestly say the biggest issue is developing a comprehensive understanding.

This idea that a system can be broken down into pieces and understood individually is flawed.  At some point in time a single individual, or several individuals had to be able to conceive of the whole problem in its entirety.  If that problem is a series of business problems and the technologies that drive them; it may take a person in the company several years to understand all the systems to a level where replacing them without a disaster or a missed requirement is possible.  This was certainly the case at my company when I took over as Director of Technology.  If it wasn't for the fact that I am myself a coder I wouldn't have been able to slowly understand all the details of the poorly organized, tightly coupled, tightly bound architecture and integration of technology.  If small hidden, undocumented details like "We put the eBay order number in the "SYSOENT.PO_NUMBER" field in the ERP system because that's what Wendell the VB coder from Florida decided to do" are overlooked the results can be disastrous, and the only way to know this is to slowly discover it all.

If someone is asked to replace the engine on an aircraft while in flight, or face certain death - given the proper amount of tools and resources that individual would need to know how to override the sensors, hydraulic system, how to re-route fuel flow, manipulate systems that were never designed to be changed or manipulated externally or from the cockpit.  This is often what the prospect of rewriting a business-application is like.  The application is usually pounded into the business between many different other technologies.

I guess my primary point is, the system must be understood in nearly it's full complexity, and it must be at some point in time understood in it's completeness in order for the new system to be properly "engineered" and not just "made".

Cookies are made, software (should be) engineered.


问:
Store HighRes photos in Database or as File?
I run a site which has a couple of million photos and gets over 1000 photos uploaded each day. Up to now, we haven't kept the original file that was uploaded to conserve on space. However, we are getting to a point that we are starting to see a need to have high-res original versions. I was wondering if its better to store these in the filesystem as an actual file or if its better to store them in a database (ie: mysql). The highres images would be rarely referenced but may be used when someone decides to download it or we decide to use it for rare processes like making a new set of thumbnails sizes/etc.</p>

答:
Without knowing it the question you are asking is very closely related to content management.  Part of the domain of content management is managing attributes of that content - that is your problem here.

Store the images wherever you like that serves your purposes.  What you need to do is develop a model for defining an authority for meta-data and variants of the images you produce.

Let's say I have product images.  I have a data-development staff, a sales staff, a customer service staff, and an IT staff.

My sales staff may want to add images of products that they take
when they review the product and post it on forums.

My data    development staff needs to be able to find images from
our    suppliers, ftp, web and associate them with the products for
use in    our website.

My customer service staff needs to be able to mark images as
incorrect, and indicate when customers complain about images not
being correct or representative of an item.

My IT Staff needs to be able to know which image is the hi-res,
which image applies to which product, and needs to be able to
seamlessly create any resolution-version of the image at any point in
time. As requirements for image sizes on our website change over
time the process of generating new sizes should be as automated as possible.

The KEY to this problem is that there must be a database that contains information about all of the images in your organization and the standards you create to affect those images must be reflected in the database that describes all of your images.

When the time comes that you have too many images, (terabytes) and you want to archive images older than 6 years your database will let you know which images, and all variants of those images that need to be archived.  You can update the database to indicate those images that are archived (and where) so the image can be restored again if it's truly necessarily.


答:
Performance isn't the only benefit to understanding low-level details in your program. For example, if an application I write crashes, I often get one or more of these things:

a crash log containing a backtrace in the form of addresses on the call stack, and the value of the program counter and other registers

a core dump, containing the state of the process's virtual memory at the time of the crash.

In order to work out what's going on there, you need some knowledge of how the memory layout of the CPU architecture works, the calling conventions of the platform your code is running on and often the ability to read a disassembly of the platform code that appears in the stack trace.


问:
How do I showcase my work experience in programming?
I'm a student of web development languages like PHP, Ruby, and Python. Currently I'm working on some school projects but I'm trying to work on some weekend projects which I can use to showcase for potential employers, what's the best way to set this up? Specifically, are there any tips you have for a new programmer because I don't want opinions on how this or that should or shouldn't be set up. If possible please give real examples.

Edit: what about Git? Is this a good place to show my projects?

答:
Usually participating to an Open-source project gives you some coverage, and some credibility as a developer, either a ruby or a php open project, that have everyday application into a enterprise environment.
Your commit and contribution to the project is traceable.</p>


答:
I agree with Raynos here; don't build libraries on frameworks.

It's not clear to me why prototype.js is a "framework" and jQuery is a "library," though. They seem extremely similar in scope and purpose.

Either they are both frameworks, implying that they're meant for building applications rather than libraries, or they're both libraries... but, as libraries, they are both quite general-purpose; it's probably not the best idea to build other libraries on top of either one, as you've introduced a dependency to your user with a bunch of extra cruft not useful for accomplishing whatever your library is for.

In other words, most libraries (apart from "general purpose" libraries) are meant to provide some specific functionality, and I assume this includes your library. Let's say for the sake of discussion that your library is for drag-and-drop page editing, so you've made use of some of the mouse input handling abstraction code in one of the GP libraries... Okay, but because of the design of the GP libraries, that means you need to include the whole thing just for the mouse handling. This might be acceptable in an application, but for a library it is really not acceptable.

If I wrote a library in C++ and I had to include every single library in the boost framework as a dependency, it would be huge and nobody would use it. Thankfully boost is designed in a modular way, as separate libraries, so nobody does that.

In contrast, the popular GP JS libraries have been designed as one-piece deals. You need mouse input handling? Great, you also have to include keyboard handling, query selectors, XHR wrappers, DOM sugar, etc. Again, you can kind of ignore this in an application, but in a library made for other developers to use, this is nuts. It makes no sense to introduce dependencies where 95% of the code is irrelevant to your library and will never run.

Title: Support multiple frameworks in a JavaScript library

Body:
I have a small JavaScript library that I've written that depends on prototype.js.

I'm considering creating a new version that would use jQuery instead.

The goal is to make it easier for users to install (choose which framework you use!) while not making it harder for me to maintain.

The main issue I see is that I would need to support two separate versions with overlapping functionality. If there is a bug, then I would need to fix it in two separate places.

How can I support multiple different frameworks in a JavaScript library without having a maintenance nightmare?


问:
SQL DB design to support user feeds (in application like facebook)
I have a social network server with a MySql DB. I want to show the users feeds like done in Facebook. Example - UserX now Friend with userY, userX did like on postX etc.

Currently I have table: C1 : UserId C2 : LogType (now friend, did like etc) C3 : ObjectId (Can be userId or postId) - set depending on the LogType.

Currently to get all related logs to show to the user I do the following queries: 1. Get All user Friends userIds 2. Query all rows which C1 is in userIds (I query completed) 3. Scan the DB and see - if LogType equals DidLike, check if post's OwnerId is the userId - if yes add it to logs.

And so on.

Obvious this is not efficient at all.

I am looking for a better way. I thought I had in mind: Create a new table (in addition to the Log table) C1 : UserId C2 : LogId (from Log table) C3 : UserID of the one who did the action When querying logs - look in the table and get related Logs (by LogId) from LogTable.

Updating the table: Whenever user doing action that should be in the log: 1. Add the Log entry to LogTable. 2. Scan the DB and see which users are interested with the Log (Who my friends are, Who is the owner of the post) and add related entries to the new table. (must be done in BG). 3. If user UNFRIEND another user - then look in the logs for all rows where C3 == UNFRIENDED user id and delete them.

Any opinions? Other suggestions?

答:
This is largely within the realm of "things not ideal for rdbms"

Graph databases solve problems like...

User A is friends with User B

User A likes Product Z and user B also likes Product Z

User A is friends with User B who KNOWS User C

http://neo4j.org/


问:
How to improve designer and developer work flow?
I work in a small startup with two front end developers and one designer. Currently the process starts with the designer sending a png file with the whole page design and assets if needed. My task as front end developer is to convert it to a HTML/CSS page. My work flow currently looks like this:

Lay out the distinct parts using html elements.

Style each element very roughly (floats, minimal fonts and padding) so I can modify it using inspection.

Using Chrome Developer Tools (inspect) add/change css attributes while updating the css file.

Refresh the page after X amount of changes

Use Pixel Perfect to refine the design more.

Sit with the designer to make last adjustments.

Inferring the paddings, margins, font sizes using trial and error takes a lot of time and I feel the process could become more efficient but not sure how to improve it.

Using PSD files is not an option since buying Photoshop for each developer is currently not considered. Design guide is also not available since design is still evolving and new features are introduced.

Ideas for improving the process above and sharing how the process looks like in your company will be great.

答:
Sigh, we have very similar problems.  My developers sometimes spend 3x the time of the designer on simple things.

First off have the designers and the coders sit beside eachother for half a day or during the early stages of a new design/project.  I find this helped tremendously and they largely solved their problems together.  The designers once they realized how much work went into making everything 'perfect' were extremely willing to put in more upfront effort.  You have to make them aware of the hardship as a developer to get their PSD / PNG so close in html/css.

Second there are some good tools to allow designers (non-coders) to view/preview CSS styles in real time.  This is a great way for them to see how something is going to look in a browser and this is how you can get your designers to easily construct "style-guides" even when they aren't themselves css experts.

http://www.panic.com/coda/

http://www.panic.com/coda/img/screenshots/css-screenshot_02.jpg


答:
Your issue is the same as if you were asked to do an app which can use either .NET Framework or Java, or a website component which works either with Silverlight or with Flash, depending on what the user has.

It is possible technically, but it leads to duplicate code and maintenance difficulties. There is nothing to do with it.

That's why most JavaScript libraries use one and one only framework.

That's also why most frameworks are able to work side by side: it allows to use several libraries which use several frameworks on a same website¹, avoiding collisions in method names like $().

Note about the advice given in two other answers: “don't build libraries on frameworks”. It is, well, too idealistic. This advice may be applied to maybe 1% of the libraries, probably much less: the libraries which are written by teams of developers able to build a library which will work on any browser, which will still be maintenable, and which require, for some reason, no framework at all.

This may be the case for example if you're writing a library which will be used at the home page of Amazon website²: you have to minimize the size of JavaScript code at all costs for performance/bandwidth reasons, and you have enough competent developers to not use any framework.

Outside Amazon/Google/Apple scale websites, do never follow the “don't build libraries on frameworks” advice, unless your library is too basic to require a framework. Instead:

Reuse, instead of reinventing the wheel,

Spend time doing something useful and interesting, i.e. writing your library, instead of writing something already available in every framework,

Trust the frameworks: they are written by skilled people who know things you may not know or forget,

Rely on abstractions: when I use a JQuery animation, I know it will work in Chrome, Firefox, Safari, Opera and even Internet Explorer. When I'm creating my own, I have to test it in those five browsers (up to ten if you count their major versions), and I'm pretty sure I will fail the first time at least in one browser.

¹ This is the thing you don't want to do if you care about the quality of your website. Still, lots of websites don't, and it is not unusual to find two, sometimes even three JavaScript frameworks on a same website side by side.

² Note that according to jQuery website, Google, Dell, NBC etc. are using it, so it's not because you're working on a large scale website that you cannot use a framework. In practice, large companies will end up inventing their own, which fits better their needs. This is the case for example for Google and its Closure Library.


问:
To reorganize code, what to choose between library and service?
I want to reorganize a large application with lot of code duplication into multiple components. Plus, some code is also duplicated over other applications.

The common set of functionality that can be taken out of main application is clearly defined.

Now, do I write a library or do I write a service for this functionality;
so that all such applications continue to work and there is only one code-base (of common functionality) to maintain ?

答:
How do you use the parts of the code you want to put in libraries/services?

If you want to use them from several machines without having to deploy the libraries on all of them, than use services (either with REST calls, or as a default WCF service, depending on your precise requirements).

If you want the simplest form, with no client-server communication involved, use libraries.

Note that you can use both: a library which has an associated service which acts as an interface. This way, you can distribute the library when appropriate, and access it through the service in other cases.


问:
How and what should I be (unit) testing for in this method?
I am relatively new to unit testing and have a query about what/how I should be testing a certain method. For the following (psudo-c#) method I have created (not a real-life example) what would you test for?

Initially, my thoughts would be to test the output with variations on the dictionary of form fields, e.g. valid, invalid, missing values. However I also wonder how you would test to make sure the object values have been changed to the correct value and that the correct email message was attempted to be sent (obviously both services could/would be mocked).

I hope what I am asking makes sense, I appreciate this is a subjective question and the answers may be 'it depends' ;)

```<code>public bool ProcessInput(Dictionary<string, string> formFields, ObjService objService, EmailService emailService)
    {
        try
        {
                   // Get my object id
                   int objId;
                   if(!int.TryParse(formField["objId"], out objId)
                   {
                      return false;
                   }

                   // Update my object - would you validate the save against a DB or a mocked inmemory db?
                   var myObj = objService.Find(objId);
                   myObj.Name = formField["objName"];
                   objService.Save(myObj);

                   // Send an email - how would you test to make sure content, recipient, etc was correct?
                   emailService.SendEmail(formField("email"), "Hello World");

                   return true;
        }
        catch(Exception ex)
        {
        return false;
        }
    }
</code>```

答:
You are on the right track. You should be testing (at least) the following scenarios:

invalid (non-integer) object ID: the method should return false and no changes should be made (i.e. no services called)

unknown object ID: the method should probably behave similarly to case 1 (but currently it does not seem to handle that case)

valid object ID, valid name in the form field: object should be saved to the object service, email should be sent

valid object ID but missing name in the form field: similar to case 3???

Both ObjService and EmailService should be mocked in your tests, then you can verify that they are (not) called with the expected parameters.


答:
Well I am not really an expert in the subject but I have done some of "unit testing" stuff.

Ideally, for unit testing, your method parameters must comprise of abstract types, something like

```<code> public bool ProcessInput(IDictionary<string, string> formFields, IObjService objService, IEmailService emailService)
</code>```

And so what your really want to test is ProcessInput and mocking away the email service and ObjService by creating a mock object of IEmailService and IObjservice using some library like Moq.

To answer what you must test, you may consider some of the test cases below

Passing a null object in formFields and see how your method treat null objects

Passing non-parsable kind of keys in dictionary

Passing a objID in dictionary which cannot be found by objService.Find(objId)

Some functional flows checking happy case...

That is what comes to my mind. Hope this helps. Please feel free to discuss further if there is something I am missing.

Title: How and what should I be (unit) testing for in this method?

Body:
I am relatively new to unit testing and have a query about what/how I should be testing a certain method. For the following (psudo-c#) method I have created (not a real-life example) what would you test for?

Initially, my thoughts would be to test the output with variations on the dictionary of form fields, e.g. valid, invalid, missing values. However I also wonder how you would test to make sure the object values have been changed to the correct value and that the correct email message was attempted to be sent (obviously both services could/would be mocked).

I hope what I am asking makes sense, I appreciate this is a subjective question and the answers may be 'it depends' ;)

```<code>public bool ProcessInput(Dictionary<string, string> formFields, ObjService objService, EmailService emailService)
    {
        try
        {
                   // Get my object id
                   int objId;
                   if(!int.TryParse(formField["objId"], out objId)
                   {
                      return false;
                   }

                   // Update my object - would you validate the save against a DB or a mocked inmemory db?
                   var myObj = objService.Find(objId);
                   myObj.Name = formField["objName"];
                   objService.Save(myObj);

                   // Send an email - how would you test to make sure content, recipient, etc was correct?
                   emailService.SendEmail(formField("email"), "Hello World");

                   return true;
        }
        catch(Exception ex)
        {
        return false;
        }
    }
</code>```

Body:
Well I am not really an expert in the subject but I have done some of "unit testing" stuff.

Ideally, for unit testing, your method parameters must comprise of abstract types, something like

 public bool ProcessInput(IDictionary<string, string> formFields, IObjService objService, IEmailService emailService)

And so what your really want to test is ProcessInput and mocking away the email service and ObjService by creating a mock object of IEmailService and IObjservice using some library like Moq.

To answer what you must test, you may consider some of the test cases below

Passing a null object in formFields and see how your method treat null objects

Passing non-parsable kind of keys in dictionary

Passing a objID in dictionary which cannot be found by objService.Find(objId)

Some functional flows checking happy case...

That is what comes to my mind. Hope this helps. Please feel free to discuss further if there is something I am missing.


问:
Should I use non-standard tags in a HTML page for highlighting words?
I would like to know if it's a good practice or legal to use non-standard tags in an HTML page for certain custom purposes.

For example:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
  consequat, felis sit amet suscipit laoreet, nisi arcu accumsan arcu,
  vel pulvinar odio magna suscipit mi.

I want to highlight "consectetur adipiscing elit" as important and "nisi arcu accumsan arcu" as highlighted.

So in the HTML I would put:

Lorem ipsum dolor sit amet, <important>consectetur adipiscing
  elit</important>. Nullam consequat, felis sit amet suscipit laoreet,
  <highlighted>nisi arcu accumsan arcu</highlighted>, vel pulvinar odio
  magna suscipit mi.

and in the CSS:

```<code>important {
 background: red
 color: white;
}

highlighted {
 background: yellow;
 color: black;
}
</code>```

However, since these are not valid HTML tags, is this ok?

答:
http://www.w3.org/TR/html5/elements.html

This is revision 1.5612.

Authors must not use elements, attributes, or attribute values that are not permitted by this specification or other applicable specifications, as doing so makes it significantly harder for the language to be extended in the future.


问:
URL Encryption vs. Encoding
At the moment non/semi sensitive information is sent from one page to another via GET on our web application. Such as user ID or page number requested etc. Sometimes slightly more sensitive information is passed such as account type, user privileges etc.

[EDIT: I may have worded this wrong, I'm not passing sessionID or actual user privileges, just simple NON-sensitive data - I just don't want the user to see the words easily, does not matter if a more technical user can read it as they cannot do any damage and cause security concerns. read the chat with @delnan]

We currently use base64_encode() and base64_decode() just to de-humanise the information so the end user is not concerned.

Is it good practice or common place for a URL GET to be encrypted rather than simply PHP base64_encoded?

Perhaps using something like, this:

```<code>$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
</code>```

Is this too much or too power hungry for something as common as the URL GET.

答: If you pass just UserID something like  Page Number then just URL GET is fine. If you do not need any explicit security on them, it would be a overhead for you.</p>

Title: URL Encryption vs. Encoding


问:
Maximum project duration for Feature Driven Development Project
Is there a duration limit for FDD Project when those projects are likely to fail due external and internal factors?

For example XP projects should kept short due the openess of the concept and dependents on the individuals in the team and lack of documentation which is vulnerable to disturbances like losing team members and so forth.

答:
The possibility of project failure is something that you try to factor in early on.  If you see a project has a very high probability of failure, either it won't get off the ground, or in the early exploratory phase the risks identified will need to be managed. As per the OPs example, people getting sick or leaving the team are factors that can occur in any project, and a good project planner will try and build a little additional slack into the schedule to try and cater for the "unforseen" problems that may arise.

The issue of a lack of documentation should not arise on an FDD project, as it is very much an artifact-heavy method. Also, the lack of documentation on an XP or an agile process to extend the OPs example should not be an issue for an agile process if the code is written to be readable, and the requirements have been listed and collated appropriately.

So a "duration" limit really doesn't make much sense as per the OPs question, as the duration of an FDD project is usually something that is fixed by contract. Deliverables within the project duration would usually be defined as Feature Sets, and the duration of a feature set will be variable as it depends on the number and complexity of the features being implemented.

However, FDD is also what I like to think of as a wrapper methodology, in that within the scope of the Develop/Test stages, the feature sets can be treated as mini-projects in themselves, and could be implemented using an Agile methodology if it is deemed to offer value to the project and all of its stakeholders. What FDD really offers is a collection of artifacts - and in particular the reports - which can be used to measure project progress, and this is particularly important when it is seen as difficult to offer working code at the end of every iteration, as the customer wants to know that months of development where they don't see what they have been paying for has been spent fruitfully. Thus, where risks are high and working modules are contractually specified at only a handful of intervals over a long period of time, deliverables in the form of reports and other project artifacts can be used to mitigate some of the problems that can arise when a project looks like it could be going off the rails.  The earlier the reports/parking-lot charts/etc... can be delivered, the sooner measures can be taken to try and keep a project either on track, or limit the damage that running over time may cause.


问:
How useful is a project log or diary?
I want to know how difficult/useful it is to keep a project log or diary. I'm worried that keeping track of what I did will eat up too much time...</p>

答:
Off the top of my head, here a just a few reasons why it is important to keep a log.

If you wish to patent something you have invented, then a log book becomes a very vital piece of evidence.

If you work in an environment where there is a culture of blame, you will want to note what you did, when, what was said, etc, simply to cover your own backside.

If you wish to keep track of thoughts or ideas that you don't have time to immediately explore, then a log book is a good place to note things for later review.

If you work on multiple projects, and your time sheet requires a relatively detailed accounting of your work to track project costs, or bill customers, the log book becomes a place to track your time.

Team meeting notes, Agendas and so on.

Agreements, disagreements, decisions, and especially why and how these things occurred can be a real life saver when the information is really needed.

Whenever I finish writing in the last page of a log book, I'll find myself looking back over older books from years before, just to see how far my knowledge has come, how my thinking has changed, and it can be amazing what you learn from your own working past, particularly if you are thinking about changing jobs, and you want to fill your CV with lots of really interesting projects and achievements.

Title: How useful is a project log or diary?


答:
No, it's not good practice for all the reasons supplied by all other answers. Instead of reiterating those points, I'd like to present an option I haven't seen in those answers!

In the case that there are no existing tags whose semantic meaning matches your goals, you could use a combination of CSS and the new data-* attribute in the HTML 5 spec. Of course, this will work with most any tag you choose.

Example:

```<code>Lorem ipsum dolor sit amet,
<span class="important" data-type="important">consectetur adipiscing elit</span>.
Nullam consequat, felis sit amet suscipit laoreet,
<span class="highlighted" data-type="highlighted">nisi arcu accumsan arcu</span>,
vel pulvinar odio magna suscipit mi.
</code>```

Whilst this isn't a perfect solution, since there is no well defined semantic meaning for data-* attributes, this would at least allow you to provide additional information to those that known the meaning of your data-type attribute.

Title: Should I use non-standard tags in a HTML page for highlighting words?

Body:
I would like to know if it's a good practice or legal to use non-standard tags in an HTML page for certain custom purposes.

For example:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam
  consequat, felis sit amet suscipit laoreet, nisi arcu accumsan arcu,
  vel pulvinar odio magna suscipit mi.

I want to highlight "consectetur adipiscing elit" as important and "nisi arcu accumsan arcu" as highlighted.

So in the HTML I would put:

Lorem ipsum dolor sit amet, <important>consectetur adipiscing
  elit</important>. Nullam consequat, felis sit amet suscipit laoreet,
  <highlighted>nisi arcu accumsan arcu</highlighted>, vel pulvinar odio
  magna suscipit mi.

and in the CSS:

```<code>important {
 background: red
 color: white;
}

highlighted {
 background: yellow;
 color: black;
}
</code>```

However, since these are not valid HTML tags, is this ok?

Body:
No, it's not good practice for all the reasons supplied by all other answers. Instead of reiterating those points, I'd like to present an option I haven't seen in those answers!

In the case that there are no existing tags whose semantic meaning matches your goals, you could use a combination of CSS and the new data-* attribute in the HTML 5 spec. Of course, this will work with most any tag you choose.

Example:

Lorem ipsum dolor sit amet,
<span class="important" data-type="important">consectetur adipiscing elit</span>.
Nullam consequat, felis sit amet suscipit laoreet,
<span class="highlighted" data-type="highlighted">nisi arcu accumsan arcu</span>,
vel pulvinar odio magna suscipit mi.

Whilst this isn't a perfect solution, since there is no well defined semantic meaning for data-* attributes, this would at least allow you to provide additional information to those that known the meaning of your data-type attribute.


问:
What is the easiest way to migrate your current programming environment to a new laptop?
I have a WinXP based laptop with pretty basic hardware configuration by today's standards. I am planning to upgrade to a WinXP based laptop with a lot better hardware.

The problem: My current laptop has truck loads of software like cygwin, perl, ruby etc. Installing each software manually is going to be pretty cumbersome. Not to mention customizing the packages.

Is there any software (freeware or commercial, both okay) that can migrate my current programming environment with minimum fuss?

答:
I have found that the tedious part of setting up a new system is not installing and configuring everything, but finding all the software and documentation, and remembering how to set everything up.

Enter Evernote. I simply created a note and listed each step with everything I need to remember. This note is available from any computer or device.

Also I keep a copy of all the software installers (and secret codes) in one place (like an external drive). You can even copy installers from a CD and put them in the folder (although CD install software is disappearing...).

Then, setting up a new computer is a breeze, just a few hours that go smoothly, instead of an all-day searching and trying to remember annoyance.

Also, with an SSD, installers run about 5 times faster, so the actual waiting time is minimal.

Finally, you may need to set up a new computer more often than you think. If a hard drive fails, or your laptop gets lost/stolen, or the system gets corrupt, then you can go through this process.


答:
Why are you using GET in the first place? Just POST the sensitive data over HTTPS, and add suitable CSRF protection.

This is assuming that the information is sensitive in the sense that the authorized user and the server may see it, but others (other users and attackers) must not.

If the user isn't allowed to see the information either, then just don't send it in the first place. Keep it on the server; if you need to link it to the user, pass a session ID back and forth (with the usualy precautions and safeguards in place), and store the sensitive information in the session (that is, server-side).

Sending sensitive information to an unauthorized client is sloppy, because it gives the attacker an opportunity for off-line cracking methods.

Title: URL Encryption vs. Encoding

Body:
At the moment non/semi sensitive information is sent from one page to another via GET on our web application. Such as user ID or page number requested etc. Sometimes slightly more sensitive information is passed such as account type, user privileges etc.

[EDIT: I may have worded this wrong, I'm not passing sessionID or actual user privileges, just simple NON-sensitive data - I just don't want the user to see the words easily, does not matter if a more technical user can read it as they cannot do any damage and cause security concerns. read the chat with @delnan]

We currently use base64_encode() and base64_decode() just to de-humanise the information so the end user is not concerned.

Is it good practice or common place for a URL GET to be encrypted rather than simply PHP base64_encoded?

Perhaps using something like, this:

```<code>$encrypted = base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key))));

$decrypted = rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($encrypted), MCRYPT_MODE_CBC, md5(md5($key))), "\0");
</code>```

Is this too much or too power hungry for something as common as the URL GET.


问:
Real-time stock market application
I'm an amateur programmer. I'd like to develop a software application (like Tradestation), to analyse real-time market data. Please teach me if the following approach is correct, ie the procedures, knowledge or software needed etc:

Use a DB to read the real-time feed from data provider: what should be the right DB to use? I know it should be a time serious one. Can I use SQL, Mysql, or others? What database can receive real-time data feed? Do I need to configure the DB to do this?

If the real-time data is in ASCII form, how can it be converted to those that can be read by the DB and my application? Should I have to write codes or just use some add-ins? What kind of add-in are needed?

How should I code the program to retrieve the changing data from the DB so that the analysis software screen data can also change asynchronously? (like the RTD in excel)

Which aspects of programming do I need to learn to develop the above?

Are there web resources/ books I can refer to for more information?

答:
The database is the least important decision. MS SQL Server, PostgreSQL or MySQL will work fine.

Here's the important decisions:

Platform - Is this going to run on your computer or on a server and delivered through a web page?

Data provider. This is the hardest part to research and solve. I have had good experiences with MB Trading. You can find more answers on Quant SE or perhaps Stack Overflow. You will need to create a prototype to test the API.

Language - From my own experience doing something similar, I suggest C# if it will run on your computer. Not C++ or C, as they are a lot more work with little benefit for this application. Java might be a good choice. Rails might be good if it running on a server.

You may be able to query the data provider once every second, and update the screen. This will depend on how the API works.

Here's some advice. Working with a data provider API and drawing charts is not very easy for a beginner. You will probably need to learn quite a bit about the language you are working in during the process. You can find great resources on Amazon, and ask here or on Stack Overflow for the best.

Title: Real-time stock market application


问:
What are known approaches to graphing algebraic expressions?
I am planning to build an expression parser that will be used to graph algebraic functions ( think TI-83 ) with JavaScript.

Functions will take the form of f(x)=

Aside from typical operators such as: + - * / ^

I'd also like to add support for inline functions such as: sin(), cos(), log() and random().

I have looked at implementing the Shunting Yard algorithm for parsing expressions, but it does not look like an efficient approach to evaluating a function with a hundreds or thousands of inputs. What other known algorithms exist for this task?

答: Shunting Yard is O(n) on the length of the function.  You can't get any better asymptotic complexity than that, so you're left with potential linear speedup.  The only thing I can think of that might be faster is to translate the function into native javascript and use eval.  You definitely want to benchmark that, though.  Another thing to do would be to only generate the RPN version once, then just execute that for each value of x.


问:
Forking an open source project: should one create a new changelog file? Should restart version number?
I am going to fork an open source project. Would you recommend to create a new changelog file or to update the original one? Would it be reasonable to increment its version number or would it be better to reset it?</p>

答:
If by fork, you mean start an upstream incompatible project, then I'd recommend resetting the version number and simply referencing the old changelog on the first commit for your changes.

(Github and other dvcs services have added new meaning to "fork").


问:
I'm going to quit my job because of our platform: how can I leave a productive explanation of this?
I'm planning on leaving my current job because we're locked into using Blub, with an enterprise Blub framework and a Blub-level web server, on mediocre shared hosting. My coworkers are friendly and my boss is an average small business owner - I want to leave entirely because of the technical reasons. I feel like being soaked in Blub is bad for my brain and making me a worse programmer.

When I leave, how can I explain this to my boss and coworkers? How can I phrase my complaints about Blub productively? What kind of warning can I and should I leave for my successor in documentation?

(trying to make sure I meet the standards)

答:
Just say that you feel that working with Blub is not compatible with the way you want to develop career-wise. This keeps the reason for leaving your current job close to yourself, limiting the possibility of people to take you leaving personally. Just stay calm and say that it was not the working environment, but that you and the work have grown apart. If they are the nice people you say they are, they will understand.

In addition, warning them that you feel blub is not the tool for them is all you can do. Spamming the docs with "blub sucks" is probably not going to work.


答:
I don't know anything about Blub itself, but I've been in a similar situation where there was something about my job that I think should be fixed, but don't want to burn bridges. Here are a few ideas that may help.

Try to fix the issue. Explain to your boss that you think Blub is a bad decision for the health and growth of the company. Provide specific cases and instances where it's hurting the company (or where some other platform would help the company better). Suggest an alternative that you feel is superior and be ready to back it up with facts (remember - objective data). This will allow you to voice your concerns and gauge how your boss responds and how open he is to different technologies (or, how married he is to Blub). You may also gain some insight into why the company is using Blub and sticking with it. It will also give you a gauge of whether it's worth sticking out through it, if the company has decided to change technologies. (Note - this may depend on your boss. Obviously, this won't work if he's in love with it and thinks it's the future of technology.)

Hold out until you get a job offer. You've dealt with it until now, so find a new job and wait to leave until you get an offer. This gives you an easy out - "I've been offered a position that better suits my career goals" (or some other more neutral line). Granted, this doesn't necessarily help your current company, but it's also not entirely up to you to fix the matter.

Say you want to take your career in a different direction. Explain that you would prefer to work on a different platform and that Blub isn't your cup of tea. This allows you to say something along the lines of "I don't like it," without getting into the religious debate of code languages/platforms. As Paul said in his answer, it keeps the reasons for you leaving close to you and reduces the chance of people taking it personally.

Make it clear that it's not the office environment. Make sure your boss and coworkers know that you enjoyed working with them. Offer to connect with them on LinkedIn if you haven't already. Try to keep in touch with them as part of your professional network.

As for your successor and documentation, simply make sure all the issues/quirks that you know of are documented somewhere, either in the code or in a wiki or some other structured documentation platform. Explain in comments why you did something a certain way and be matter-of-fact about it - "doing it this way because our version of Blub doesn't support Alternative Method X." If your successor is familiar with Blub and doesn't mind it, then they're not going to heed any kind of "stay away!" messages. Someone not familiar with it is probably going to think you're just one of those platform elitists and ignore overt messages, and someone who is familiar with Blub and doesn't like it, or is on the fence, will either already sway to your side after more experience,  wouldn't have applied to the position, or would ignore your "stay away!" messages, anyway.

Title: I'm going to quit my job because of our platform: how can I leave a productive explanation of this?

Body:
I'm planning on leaving my current job because we're locked into using Blub, with an enterprise Blub framework and a Blub-level web server, on mediocre shared hosting. My coworkers are friendly and my boss is an average small business owner - I want to leave entirely because of the technical reasons. I feel like being soaked in Blub is bad for my brain and making me a worse programmer.

When I leave, how can I explain this to my boss and coworkers? How can I phrase my complaints about Blub productively? What kind of warning can I and should I leave for my successor in documentation?

(trying to make sure I meet the standards)


答:
Leave on as much of a positive note as possible.  Don't spin the story into a negative about Blub.  Spin your exit story about this exciting new opportunity to expand your skills beyond Blub.

Then leave a written list of tasks in progress and the "potential" danger spots for your technical replacement. It is now their job to convince management (if they agree with you), not yours.


答:
There is  nothing wrong with saying "I am leaving/left my last position because I wanted to work with newer/more interesting/less crufty technology."  You're a software developer!  You're supposed to have strong opinions.

But I would prefer to hear  you say you were running towards something than running away from something.  "I really got excited about Flubber on the Stack Exchange network; it sounded more modern and fully featured than Blub, so I want to take my career in that direction."


答:
The key question is who owes whom what.

You sound like a fairly low level guy in a medium to large organization, in the learning phase of your career; and in that position, you owe your employer precisely nothing except two weeks notice.   Be assured that they don't think they owe you any more either.

I'm not saying that if there is someone who actually will listen and cares about your reasons, you shouldn't talk at length - but don't kid yourself that you have any leverage to actually change things for the better as part of your exit activities.


答:
A lot of good comments above.  A few things to add or highlight:

Don't quit until you have the new job.  You lose all your leverage.

Document everything you do to ensure a smooth handover.  Go above and beyond in training your replacement.

Before and after the move, don't disparage anyone there or their decisions.

If asked why you are leaving you can honestly say "to learn new things" and leave it at that.

Handled correctly, you could still get a good reference a few years down the line.

Good luck with this!


问:
What kinds of low level knowledge matter?
I realize that this question is similar to Low level programming - what's in it for me, but the answers didn't really address my question well.  Part from just an understanding, how exactly does your low level knowledge translate into faster and better programs?

There's the obvious lack of stop-the-world from garbage collection, but what else is an advantage?  Do you really outperform your optimizing compiler?  Do you pack your data structures in as tight as possible and be concerned about alignment?  There's extra freedom naturally, but does that really translate into a faster program?

答:
IO (file or any other output device)

Networking (IO, but important enough that it deserves its own bullet)

Memory hierarchies (understand why it's bad to go from cacheA -> cacheB -> main mem -> disk)

Of course all of the low level stuff is valuable at some level, but these three will pay pretty good dividends to an application-level programmer to understand.  Edit: these also are places where low-level techniques are frequently applied.


答:
A lot depends on the size of the project and goals of the project.  In a small project you can put things in Excel.  Remember that rework takes longer than doing something right the first time so it's worth planning a little to save time later.

Things you should track in lists:

External commitments, especially dates.

Scope - At least at a high level.  Depending on the situation this gets more detailed.

Dependencies - what you need from others.

Issues, risks and To Dos

What your spending time on (the rigor is dependent on if this is for self knowledge or external billing)

Title: How useful is a project log or diary?

Body: I want to know how difficult/useful it is to keep a project log or diary. I'm worried that keeping track of what I did will eat up too much time...</p>


答:
If this is a small company, and you're the tech expert, you should seriously consider having an honest (private) discussion with your boss about how Blub is hurting his business.

I'm not sure from your description if you would characterise yourself as the company's tech expert, and I realise that you said the company is "locked" to Blub. Perhaps this is not the correct discussion to have if there are other happier employees, or if there really is no alternative for the business model.

But, this seems to me to be pretty serious. In one way, it is hurting his business simply because you are not enjoying it and finding it unproductive and have come to the point that you want to leave. Losing a good employee is a pretty horrendous situation for a small business (you are far more crucial to them, than you would be at a large corporation).

I wouldn't be inclined to leave any warning for a successor - but do make sure to comment and document your code as well as possible to make it relatively easy for them to take over.

I disagree partially with other answers that you shouldn't leave your job until you have an alternative. If this job is really getting you down, it can make you sound resentful in interviews for new jobs, which is very unattractive to employers. (If that's the case, it might be better just to get a clean break) The advice to put a positive spin on things by looking forwards is very good advice.


答:
Passing information this way is a hazard waiting to be exploited.  You need to think
about what someone who understood the traffic could do to the site that is accepting
the GET.

You should use POST

If any sensitive data is being passed, it should be encrypted.

You should checksum and sign the package of data so it can't be altered
and similar packages can't be constructed.

Title: URL Encryption vs. Encoding


问:
Is there a more efficient way to filter large arrays than preg_match()?
I have a log that our web application builds. Each month it contains around 16,000 entries of a string with about the average sentence worth of text.

To filter/search through these in our admin panel the script uses preg_match() but this seems to be taking ages and timing out on the 30sec limit. I have isolated that it is indeed the preg_match() that causes the time out.

Is there a more efficient way to search through values in a large array for a users input?

答: I would research in_array() and array_search() to see if they catch what you're looking for. Otherwise, use a for loop and use stripos() on each entry's text, which is my normal tool for searching in strings.


问:
Where does Objective-C fall in the language performance continuum?
There seems to be a lot of discussion of the various speed merits to C or C++ as compared to say Java or Python, but I rarely see Objective-C mentioned. Roughly where does it fall in terms of language performance?</p>

答:
Unlike C++, Objective-C is designed as a clean superset of C.  The few Objective-C compiler I've used are better known as C compilers, but also handle Objective-C.

So, it's safe to assume that in the code generation level, C and Objective-C are equivalent.

The first difference appears in the OOP ABI, also called "late method binding". Just like in C++, Objective-C relies in compiler-generated function pointer tables that are traversed at runtime.

Unlike C++, however, the binding method is more 'dynamic', and promotes the use of the id superclass everywhere, making it slightly slower than C++ in theory.  In practice, this difference is way below measurable.

Finally, the most important performance issue is the quality of the libraries used.  Since Objective-C is only really popular in the Apple systems, it's reasonable to assume you're using it with Cocoa; which is a fine set of high-level libraries.  In most cases, you can leave the heavy lifting to them, so your code either don't have to be so fast, or if you do heavy crunching, then it's likely to be a mostly-static code base, roughly similar to plain C.

TL;DR: it's right there with C and C++ languages where it matters most.  If you're not getting good performance, check your algorithms; just as in any serious language.


答:
Short answer:
It's compiled into a similar format as C/C++/D/Go/Rust. It doesn't use a virtual environment like Java/.Net. And it isn't interpreted like Python/Ruby/Lua/JavaScript.
So it is on the faster end of the spectrum.</p>

Title: Where does Objective-C fall in the language performance continuum?

Body: There seems to be a lot of discussion of the various speed merits to C or C++ as compared to say Java or Python, but I rarely see Objective-C mentioned. Roughly where does it fall in terms of language performance?</p>


问:
Is there a language between C and C++?
I really like the simple and transparent nature of C: when I write C code I feel unencumbered by "leaky abstractions" and can almost always make a shrewd guess as to the assembly I'm producing. I also like the simple, familiar syntax for C.

However, C doesn't have these simple, helpful doodads that C++ offers like classes, simplified non-cstring handling, etc. I know that it's all possible to implement in C using jump tables and the like, but that's a bit wordy at times, and not very type-safe for various reasons.

I'm not a fan of the over-emphasis on objects in C++, though, and I'm gun shy of the 'new' operator and the like. C++ seems to have just a few too many hiccups to, for instance, be used as a system programming language.

Does there exist a language that sits between C and C++ on the scale of widgets and doodads?

Disclaimer: I mean this as purely a factual question. I do not intend to anger you because I don't share your view that C{,++} is good enough to do whatever I'm planning.

答:
These might be the droids you're looking for...

Go - http://golang.org/

D - http://dlang.org/

Rust - http://rust-lang.org/

Title: Is there a language between C and C++?