问:
Do programmers need a good memory?
It seems that it's necessary to remember all sorts of syntax to be able to program. If a person doesn't have a good memory for remembering names, will it be more difficult to learn to program?</p>

答:
I say an emphatic YES!

At present I am learning JAVA & C#.  All the tests are closed book, so for JAVA its all 100% from memory coding all applications in exams.

What's more, it is getting harder & harder.  I'm at the point now where I need to start using memory tricks like mnemonics, etc.

I would say High IQ, good general knowledge, good vocabulary, polymathism, higher mathematics knowledge, touch typing & good memory are all assets for a programmer.

I know very clever programmers that can't touch type or do higher math, etc.  It they did, they could be much better.

Title: Do programmers need a good memory?


问:
Differences between TypeScript and Dart
Microsoft recently unveiled Typescript, a new JavaScript-like programming language.
Some time ago, I heard about Dart, a new programming language created by Google to solve problems related to Javascript like performance, scalability, etc..

The purpose of both new languages seem the same to me.. What do you think?

Are the purposes of the languages the same?

What are the real differences about them?

答:
Quoting Bob Nystrom:

TypeScript seems nice if you like JS semantics or have a large JS
  codebase that you're invested in but you're having maintenance
  problems at scale. It's path for success is much smoother since it's
  (mostly?) backwards compatible with JS.

Dart is taking a riskier bet. It's farther from JS in a lot of ways
  which is, I think, mostly good as a day-to-day Dart programmer, but it
  makes the barrier of entry higher. But in return for that higher
  barrier of entry, you get:

Tree shaking

Getters and setters (though I presume TypeScript will get those eventually)

Operator overloading

Real block scope, no hoisting, no IIFEs

A native VM

Sane equality semantics

No weird implicit conversion craziness

Lexically bound this everywhere

Mixins

Annotations

An import system

User-defined subscript operators

Generics, with reification

Mirrors

Better collection classes

A cleaner DOM API

Also, he writes in http://www.reddit.com/r/programming/comments/10rkd9/welcome_to_typescript/c6g37xd :

I'm on Google's Dart team, so I'm naturally looking at it from that
  angle/bias. Here's some random stuff that caught my eye, mostly
  comparing it to Dart. I've only spent a few minutes skimming, so don't
  take any of this too seriously...

No generics

I guess some types are better than no types at all, but
  it's really rough to lose those. TypeScript does have built-in array
  types and object types cover some of the "map" type use cases. But not
  being able to define your own generic types is a drag. The docs say
  when added, generics will work using type erasure, which is what I'd
  expect given it's "compile to lightweight JS" style, but that can be a
  pain too. It's nice to be able to do stuff with your type arguments at
  runtime sometimes.

All types are nullable

Dart is the same way. Makes me sad in both
  cases.

The type annotation syntax is nice

Almost every language with
  optional type annotations (ML, Scala, F#, Kotlin, etc.) goes with
  "postfix after a :. Dart tries to use C-style type annotations which
  causes some nasty corner cases. I like what TypeScript has here,
  especially the syntax for function types:

```<code>function takeCallback(callback : (n : number) => number)
{ ... }
</code>```

Interfaces are structurally typed, classes are nominally typed

Makes sense given that
  it's JavaScript, but it seems pretty neat. Being able to implicitly
  implement an interface is nice. But TypeScript doesn't seem to let you
  go the other way: given a class, you can't make a new type that's
  compatible with it without concretely extending it because of the
  brand stuff. In Dart, thanks to implicit interfaces, you can.

Best common type can fail

That means this is a type error:

```<code>[1, true]
</code>```

You can overload in interfaces by parameter signature

This is really cool
  because it gives you a way have more precise type inference flow
  through a function call that does some dynamic type switching. For
  example:

```<code>interface Doubler {
  double(s : string) : string;
  double(n : number) : number;
}
</code>```

With this, when the compiler sees a call to
  double, it can correctly give you a precise return type based on the
  inferred argument type. What I'm not sure is how to actually implement
  a class that implements that interface and makes the type checker
  happy. You can't actually overload concrete methods, and my five
  minute attempt to make it happy by dynamic type checking didn't seem
  to work.

There's a dedicated syntax for array types

Makes sense since
  there's no generics. It's also nice and terse, which is good, but I
  personally prefer general-purpose generics over one-off special case
  collections.

There's no implicit downcasting

One of Dart's more
  unusual type system features is that assignment compatibility is
  bidirectional: you can downcast without a warning. Aside from the
  typical special case of assigning to/from any (dynamic in other
  languages), TypeScript doesn't allow that. You have to type assert.
  Personally, I like TypeScript's approach here.

Arrow functions and lexical this

This is just motherhood and apple pie. I like it. (Dart
  has this too, and this is always lexically bound.)

Overall, it looks
  pretty neat. If you want exactly the same JS semantics (good and bad)
  but also want a smattering of types, TypeScript seems decent. It's
  like Closure Compiler but with a better syntax.

If you want something
  that's a more aggressive step away from JS's syntax and semantics,
  then it seems like TypeScript isn't that.

ContentLicense: CC BY-SA 3.0

Title: Differences between TypeScript and Dart

Body:
Quoting Bob Nystrom:

TypeScript seems nice if you like JS semantics or have a large JS
  codebase that you're invested in but you're having maintenance
  problems at scale. It's path for success is much smoother since it's
  (mostly?) backwards compatible with JS.

Dart is taking a riskier bet. It's farther from JS in a lot of ways
  which is, I think, mostly good as a day-to-day Dart programmer, but it
  makes the barrier of entry higher. But in return for that higher
  barrier of entry, you get:

Tree shaking

Getters and setters (though I presume TypeScript will get those eventually)

Operator overloading

Real block scope, no hoisting, no IIFEs

A native VM

Sane equality semantics

No weird implicit conversion craziness

Lexically bound this everywhere

Mixins

Annotations

An import system

User-defined subscript operators

Generics, with reification

Mirrors

Better collection classes

A cleaner DOM API

Also, he writes in http://www.reddit.com/r/programming/comments/10rkd9/welcome_to_typescript/c6g37xd :

I'm on Google's Dart team, so I'm naturally looking at it from that
  angle/bias. Here's some random stuff that caught my eye, mostly
  comparing it to Dart. I've only spent a few minutes skimming, so don't
  take any of this too seriously...

No generics

I guess some types are better than no types at all, but
  it's really rough to lose those. TypeScript does have built-in array
  types and object types cover some of the "map" type use cases. But not
  being able to define your own generic types is a drag. The docs say
  when added, generics will work using type erasure, which is what I'd
  expect given it's "compile to lightweight JS" style, but that can be a
  pain too. It's nice to be able to do stuff with your type arguments at
  runtime sometimes.

All types are nullable

Dart is the same way. Makes me sad in both
  cases.

The type annotation syntax is nice

Almost every language with
  optional type annotations (ML, Scala, F#, Kotlin, etc.) goes with
  "postfix after a :. Dart tries to use C-style type annotations which
  causes some nasty corner cases. I like what TypeScript has here,
  especially the syntax for function types:

function takeCallback(callback : (n : number) => number)
{ ... }

Interfaces are structurally typed, classes are nominally typed

Makes sense given that
  it's JavaScript, but it seems pretty neat. Being able to implicitly
  implement an interface is nice. But TypeScript doesn't seem to let you
  go the other way: given a class, you can't make a new type that's
  compatible with it without concretely extending it because of the
  brand stuff. In Dart, thanks to implicit interfaces, you can.

Best common type can fail

That means this is a type error:

[1, true]

You can overload in interfaces by parameter signature

This is really cool
  because it gives you a way have more precise type inference flow
  through a function call that does some dynamic type switching. For
  example:

interface Doubler {
  double(s : string) : string;
  double(n : number) : number;
}

With this, when the compiler sees a call to
  double, it can correctly give you a precise return type based on the
  inferred argument type. What I'm not sure is how to actually implement
  a class that implements that interface and makes the type checker
  happy. You can't actually overload concrete methods, and my five
  minute attempt to make it happy by dynamic type checking didn't seem
  to work.

There's a dedicated syntax for array types

Makes sense since
  there's no generics. It's also nice and terse, which is good, but I
  personally prefer general-purpose generics over one-off special case
  collections.

There's no implicit downcasting

One of Dart's more
  unusual type system features is that assignment compatibility is
  bidirectional: you can downcast without a warning. Aside from the
  typical special case of assigning to/from any (dynamic in other
  languages), TypeScript doesn't allow that. You have to type assert.
  Personally, I like TypeScript's approach here.

Arrow functions and lexical this

This is just motherhood and apple pie. I like it. (Dart
  has this too, and this is always lexically bound.)

Overall, it looks
  pretty neat. If you want exactly the same JS semantics (good and bad)
  but also want a smattering of types, TypeScript seems decent. It's
  like Closure Compiler but with a better syntax.

If you want something
  that's a more aggressive step away from JS's syntax and semantics,
  then it seems like TypeScript isn't that.


问:
The 10 minutes technical interview
I must do a quick assessment of dozens of fresh students very quickly. I have 30 minutes meeting with each of them (in two or three days). I want to use most of the time to discuss non technical aspects. So I plan to use 10 minutes for technical questions. The same questions for all of them.

They are all hired already (they are students), what I need to know is the average level in order to prepare a training.

Ideally, the difficulty must be progressive in order to set a level for each. Level I will average, and I'll do an average on each question too.

If you had only 10 minutes and 10 questions to ask to a candidate, what would be your top 10 ?

答:
If these are students and you are looking to be able gauge where they are in their studies then there really shouldn't be any trick questions or questions that will make them think to hard. My advice would be to just focus on the basics - there is no much point in asking them to explain how reflection works if they still aren't fully up to speed on objects and inheritance.

Here are some sample questions that could be used and you could maybe start with something from the core knowledge category and then move around on the basis of how they answer the questions, kind of like how adaptive testing works.

Fundamentals

What are some basic program flow control commands?

What are some basic logical operations?

What is the difference between while and for loops?

Core

Briefly explain object oriented programming.

Briefly explain the concept of inheritance.

Briefly explain how databases operate.

What is the enum keyword used for and when would you use it?

Advanced

What can you tell me about C# generics or C++ templates?

What can you tell me about operator overloading?

What's the difference between a class and a struct?

What can you tell me about reflection in .NET?

ContentLicense: CC BY-SA 2.5

Title: The 10 minutes technical interview


问:
Best practices for logging user actions in production
I was planning on logging a lot of different stuff in my production environment, things like when a user:

Logs In, Logs Off

Change Profile

Edit Account settings

Change password
...
etc

Is this a good practice to do on a production enviornment?  Also what is a good way to log all this.  I am currently using the following code block to log to:

```<code>public void LogMessageToFile(string msg)
        {

            System.IO.StreamWriter sw = System.IO.File.AppendText(
                GetTempPath() + @"MyLogFile.txt");
            try
            {
                string logLine = System.String.Format(
                    "{0:G}: {1}.", System.DateTime.Now, msg);
                sw.WriteLine(logLine);
            }
            finally
            {
                sw.Close();
            }
        }
</code>```

Will this be ok for production?  My application is very new so im not expecting millions of users right away or anything, looking for the best practices to keeping track of actions on a website or if its even best practice to.

答:
If I was you and I was sticking with writing to a text file I'd use log4net and log into a specific "UserActions.log" file.  This way it doesn't muddle up your normal logging. By using log4net (or any other logging framework) you can avoid re-inventing the wheel and leverage rolling file appenders, warn/error/debug/info codes, batch file writing, etc.  It's always a good idea to build in good logging into any production level application.

In reality though, it's  probably better to store all this information in a database.  Using a database will let you  sort it, aggregate it, and do statistics on it easier

OwnerDisplayName: anthonypliu

OwnerDisplayName: devshorts


问:
2D grid with multiple types of objects
This is my first post here in programmers.stackexchange (I'm a regular on SO).  I hope this isn't too general.

I'm trying a simple project to learn Java from something I've seen done in the past. Basically, it's an AI simulation where there are herbivorous and carnivorous creatures and both must try to survive.  The part I am trying to come up with is that of the board itself.

Let's assume very simple rules.  The board must be of size X by Y and only one element can be in one place at one time.  For example, a critter cannot be in the same tile as a food block. There can be obstacles (rocks, trees..), there can be food, there can be critters of any type.  Assuming these rules, what would be one good way to represent this situation ?

This is what I came up with and want suggestions if possible:

Use multiple levels of inheritance to represent all the different possible objects (AbstractObject -> (NonMovingObject -> (Food, Obstacle) , MovingObject -> Critter -> (Carnivorous, Herbivorous))) and use polymorphism in a 2D array to store the instances and still have access to lower level methods.

Many thanks.

Edit: Here is the graphic representation of the structure I have in mind.

答:
Your proposal sounds reasonable, but:

beware of creating unnecessary levels of hierarchy

consider using a set of interfaces instead of a class hierarchy

if any of your operations require sorting out generic objects based on their dynamic subclass (e.g., by object casting or by using instanceof), you're almost certainly doing the wrong thing.

Specifically, I'd guess that resolving what happens when one object moves into a currently occupied space could be a conceptual problem, because it depends on the types of both objects.  But (per the third point), don't try to solve it by dynamically determining the type of each and looking them up case by case using switch, if, or some kind of table!  That "solution" is fragile, tedious, and doesn't scale well.

Instead, try basing your system on the interfaces needed to resolve your objects' behavior.  For the above example, try providing your generic simulation object a set of "response" handling methods, such as handleIntrusion(intruder).  If this handler needs more information about another object, it can call appropriate methods on that object, such as isVegetable() and perhaps handleBeingEaten(eater).  (I suppose there's a fine line between using and abusing predicates like isVegetable(), but they are still preferable to dynamic casting operations...)

You should be able to find a reasonably small set of operations that will allow your simulation objects to interact with each other.  A well-designed set of interfaces will allow you to modify and extend your simulation without reworking everything in it each time.

Title: 2D grid with multiple types of objects


问:
What are graphs in laymen's terms
What are graphs, in computer science, and what are they used for? In laymen's terms preferably.

I have read the definition on Wikipedia:

In computer science, a graph is an abstract data type that is meant to implement the graph and hypergraph concepts from mathematics.

A graph data structure consists of a finite (and possibly mutable) set of ordered pairs, called edges or arcs, of certain entities called nodes or vertices. As in mathematics, an edge (x,y) is said to point or go from x to y. The nodes may be part of the graph structure, or may be external entities represented by integer indices or references.

but I'm looking for a less formal, easier to understand definition.

答:
A better question would be "What aren't graphs used for?". Computer Science is, in many respects, the study of Graphs.

A graph, in laymen's terms, is a collection of arbitrary abstract objects called "nodes" or "vertices" that represent points of connection. They are then connected via "paths" or "edges". The abstract data type "Graph" is an implementation of the mathematical "Graph". So basically you have nodes and edges as your fields and various operations you can perform on them. You can, for instance, add a new node to the graph's collection (this could be a list or an array or some other structure depending on the language). You could then link that node to existing nodes. Operations would also be include traversing the graph, checking whether two nodes share an edge (are connected), retrieving values from nodes or edges, and the deletion of nodes or edges from the graph.

As far as utilization goes, Graphs are used all over the place. Networking makes particularly heavy use of them but they are found in Artificial Intelligence, Data Mining, Game Development, Geoinformatics, and a host of other disciplines. In formal Computer Science, they see even more use, namely as a way of representing state.

Effectively anything that you can represent as a set of connections can be represented as a graph and implemented via that ADT in some form.

Here's an example graphic I made:

Title: What are graphs in laymen's terms


答:
A graph is just a collection of objects connected together by lines called vertices.

The term "graph" is an abstraction and generalization of many data structures used in software development.  Linked lists, binary trees and AST's are all graphs.

Basically, any collection of objects that has pointers that associate the objects with each other is a graph.  Once you have a graph, you can apply the principles of graph theory to it, to solve certain problems.

Title: What are graphs in laymen's terms

Body:
What are graphs, in computer science, and what are they used for? In laymen's terms preferably.

I have read the definition on Wikipedia:

In computer science, a graph is an abstract data type that is meant to implement the graph and hypergraph concepts from mathematics.

A graph data structure consists of a finite (and possibly mutable) set of ordered pairs, called edges or arcs, of certain entities called nodes or vertices. As in mathematics, an edge (x,y) is said to point or go from x to y. The nodes may be part of the graph structure, or may be external entities represented by integer indices or references.

but I'm looking for a less formal, easier to understand definition.


答:
Graphs are one of the most important mathematical concepts used in computer science.

You've seen graphs many times over. Imagine that you are taking a plane flight from one city to another. You'll inevitably find a nice glossy magazine from the airline in the seat pocket in front of you. Near the back of that magazine you can almost always find a map that depicts the cities serviced by that airline represented as circles, with the flights that connect those cities represented as curved lines. That's a graph! The cities, represented as circles, are the nodes of this graph and the flights, represented as curved lines, are the edges. Graphs are just things with nodes and edges that connect nodes.

You can embellish those simple graphs in various ways. You don't want to see just a bunch of circles and lines when you're looking at that map. Those cities have names. Labeling those cities results in labeled graph. (You can also label the edges, e.g., flight 1234.) Computer science often associates data with the nodes, sometimes with the edges, but that's just an extension of the label. It's still a labeled graph. Another embellishment results if you can fly directly from city A to city B, but not from city B to city A. An obvious way to portray this is to put an arrow on the line that connects the cities to depict this one-way relationship. Now you have a directed graph.

Linked lists, trees, state transition diagrams, and lots of other computer science data structures are all examples of graphs. It is a very powerful concept.

Title: What are graphs in laymen's terms


答:
You don't specify whether you are using a database but if you are and that database is SQL Server, then you could add something called AutoAudit and automatically log all interactions with your data. Just make sure to specify only those objects you want audited.

But anyway, I wouldn't be trying to manually code my tracking as it'll end up a maintenance nightmare.

Also, for logging, don't roll your own, use Enterprise Library Logging or Log4Net or similar.

Title: Best practices for logging user actions in production

Body:
I was planning on logging a lot of different stuff in my production environment, things like when a user:

Logs In, Logs Off

Change Profile

Edit Account settings

Change password
...
etc

Is this a good practice to do on a production enviornment?  Also what is a good way to log all this.  I am currently using the following code block to log to:

```<code>public void LogMessageToFile(string msg)
        {

            System.IO.StreamWriter sw = System.IO.File.AppendText(
                GetTempPath() + @"MyLogFile.txt");
            try
            {
                string logLine = System.String.Format(
                    "{0:G}: {1}.", System.DateTime.Now, msg);
                sw.WriteLine(logLine);
            }
            finally
            {
                sw.Close();
            }
        }
</code>```

Will this be ok for production?  My application is very new so im not expecting millions of users right away or anything, looking for the best practices to keeping track of actions on a website or if its even best practice to.


答:
From a quick read through, I didn't see anyone talking about memory in the general sense of programming rather than a singular task of writing a program.

Memory is useful for two things:

Remembering the basic semantics / libraries:

This is easily supplanted by repetition and Google. IOW, the amount of memory you are born with has to be ridiculously low to be not able to surmount this problem.

Remembering context in big programs:

Here is where the trick is. As programs get bigger (and you get senior), the decisions you make totally relate to the amount of your knowledge of the system and ability to retrieve it in a matter of milliseconds if it is to be of any use in project discussions, debugging, reacting to operational emergencies etc. When the push comes to shove, no amount of documentation / wiki entries are going to help you - your team "wizard" is going to be your only option. This is one of the reasons why principal engineers are valued/paid so much. Most of them might not spend all their time actually coding at this point, they spend more time keeping current with the full picture and applying it for any problems / improvements. The good ones just keep in touch by doing a ton of CRs and a coding change here and there / prototyping newer revisions.

IOW, You can be a reasonable programmer with #1 alone, but if you are ever going to be the next Linus, You better have a lot of memory, at least enough to encompass the problem you are solving.

From my observations, I could even say that working memory is almost directly proportional to the worth of the person.

A little disclaimer to wrap up: If you have Eidetic memory but zero/low intellectual power in applying that logic, you will be no good to a project than a camera.

ContentLicense: CC BY-SA 4.0

Title: Do programmers need a good memory?

Body: It seems that it's necessary to remember all sorts of syntax to be able to program. If a person doesn't have a good memory for remembering names, will it be more difficult to learn to program?</p>


答:
A perfect layman's example might be Facebook. The network of you, your friends, and their friends etc, are collectively refered to as the social graph.

In this "graph" the people are considered nodes of the graph and the edges are friendship links.

In Facebook friend is a bidirectional relationship (A is B's Friend => B is A's friend) so the graph is an Undirected Graph. A network like Google+ or Twitter would be considered a Directed Graph since the direction of the relationship has meaning here.

All of these graphs are refered to as cyclic graphs, as the relationships between nodes can form cycles. A Family Tree, on the other hand, is a special kind of graph which, among other things, is Acyclic since there cannot be cycles in family tree relatioship. (It is technically called a Directed Acyclic Graph (DAG) since its both directed and acyclic)

This should cover all of the basic jargon involving graphs, so now you should be able to follow the rest of the material in the field.

Title: What are graphs in laymen's terms


问:
Achieving decoupling in Model classes
I am trying to test-drive (or at least write unit tests) my Model classes but I noticed that my classes end up being too coupled. Since I can't break this coupling, writing unit tests is becoming harder and harder.

To be more specific:

Model Classes: These are the classes that hold the data in my application. They resemble pretty much the POJO (plain old Java objects), but they also have some methods. The application is not too big so I have around 15 model classes.

Coupling: Just to give an example, think of a simple case of Order Header -> Order Item. The header knows the item and the item knows the header (needs some information from the header for performing certain operations). Then, let's say there is the relationship between Order Item -> Item Report. The item report needs the item as well. At this point, imagine writing tests for Item Report; you need have a Order Header to carry out the tests. This is a simple case with 3 classes; things get more complicated with more classes.

I can come up with decoupled classes when I design algorithms, persistence layers, UI interactions, etc... but with model classes, I can't think of a way to separate them. They currently sit as one big chunk of classes that depend on each other.

Here are some workarounds that I can think of:

Data Generators: I have a package that generates sample data for my model classes. For example, the OrderHeaderGenerator class creates OrderHeaders with some basic data in it. I use the OrderHeaderGenerator from my ItemReport unit-tests so that I get an instance to OrderHeader class. The problem is these generators get complicated pretty fast and then I also need to test these generators; defeating the purpose a little bit.

Interfaces instead of dependencies: I can come up with interfaces to get rid of the hard dependencies. For example, the OrderItem class would depend on the IOrderHeader interface. So, in my unit tests, I can easily mock the behaviour of an OrderHeader with a FakeOrderHeader class that implements the IOrderHeader interface. The problem with this approach is the complexity that the Model classes would end up having.

Would you have other ideas on how to break this coupling in the model classes? Or, how to make it easier to unit-test the model classes?

Update after going through the answers:

I have done a little more thinking on this problem and noticed that some of these dependencies were not really necessary (as most answers pointed out). The reason why they existed is because my UI layer needed it. Basically, I have inserted these dependencies so that UI layer can easily navigate from child to the header and display some header fields at the child level views. Looking at it now, it looks so simple; however it took some time for me to figure out why these dependencies existed in the first place. Now, the UI will basically keep the header in its context when navigating to the child level views.

On the other hand, I have removed some of the dependencies via interfaces. These dependencies were mostly one-to-one; for example between Header and HeaderReport. Previously, HeaderReport depended on Header for retrieving information (items, date, etc...) and this made HeaderReport very hard to test. Now, the HeaderReport depends on the HeaderDataProvider interface and I am able to achieve complete isolation. HeaderReport is very easy to test with stub classes for the HeaderDataProvider interface.

It looks easy to create these abstractions (UI Layer - Model Layer - Backend Layer), however in reality, it really takes a lot of practice!

答:
One way to do it is, as you said, to create interfaces between the classes. Each class would take its dependencies as interface references that can be mocked or stubbed in a unit test context. This might make you think a bit more about the essential parts of the design that are needed by each class. For example, you might find that the order item does not need the full order header. This process might lead you to discover latent concepts in the design, which will increase the chances of reuse and create elements more inline with their intent, or raison d'être.

On the other hand, maybe creating interfaces does seem odd for such synergistic and coupled concepts. If that's the case, you can use fluent test data builders to create a domain specific and direct way to easily create dependent objects. You don't need to test these builders directly, as they'll be used by test code to create the dependent objects.

Title: Achieving decoupling in Model classes


问:
Project Resource Organization and Structure at Cocos2d-X Development
Cocos2d-X is a game engine framework based on Cocos2d-iPhone, which consists of expanding supported platforms, with multiple choice of programming languages thats shares the same API structure.

What is be better Project Resource Organization and Structure at Cocos2d-X Development?

答:
In my opinion, to organize the resource depend on the type of your game, and the animation editor & UI editor and other tools you use.

I'm doing my first cocos2d-x project.  Here is how I deal with the resources.

I'm using the texturepacker to generate the plists.

I'm using the lua script to transform my old UI description file to new ones, and define new data structures and writing new Readers which cocos2d-x can support (something like cocos builder).

Each UI has its own directory, including .plist, .layout (my own ui description file).

I put all the animations together into one directory, in which the same sprites may share the same animation.


答:
This is not a direct answer to the question, more of an expansion on it.

When you launch a new app I recommend logging everything the user does: log in, log out, scratches their a**, everything. If it's web-based, consider using heat maps so you know what their mouse was doing.

When I was on the BravoX project at Xerox in the late 70's we recorded pixel-by-pixel mouse movements to figure out how users might use this weird thing called a WYSIWYG editor. We would watch playbacks of user sessions during lunch. It was extremely instructive. We discovered a use pattern we called Charlie Browning—the user would select some text and make it italic ... then they would undo ... then they would redo ... back and forth, back and forth. It turns out they were trying to understand this stuff at an emotional level. So we (Greg Kusnik did the code, if memory serves) put in some specific optimizations to support exactly this behavior.

Without the recording we would have never thought to do this.


问:
Should I implement slugs with my already fairly long URLs?
I'm considering implementing slugs in my blog. My blog uses MongoDB. One of the side-effects of using MongoDB is that it uses relatively long hex string IDs.

Example

before: http://lastyearswishes.com/blog/view/5070f025d1f1a5760fdfafac

after: http://lastyearswishes.com/blog/view/5070f025d1f1a5760fdfafac/improvements-on-barelymvc

Of course, that's a relatively short title.. I have some longer ones, but intend to limit the maximum character limit for slugs to something reasonable.

At what point does a URL become so long that it hurts SEO instead of improves it? In this case, should I leave my URLs alone, or add slugs?

答:
Matt Cutts, who fights spam at Google1, has commented on the number of words used in slugs:

Next question: what is excessive in the length of a keyword-rich URL? We have seen clients use keyword URLs that have 10 to 15 words strung together with hyphens; or blogs – we have seen them even longer there. A typical WordPress blog will use the title of the post as the post slug, unless you defined something different and you can just go on and on and on. Can you give any guidelines or recommendations in that regard?

Matt Cutts: Certainly. If you can make your title four- or five-words long – and it is pretty natural. If you have got a three, four or five words in your URL, that can be perfectly normal. As it gets a little longer, then it starts to look a little worse. Now, our algorithms typically will just weight those words less and just not give you as much credit.

The thing to be aware of is, ask yourself: “How does this look to a regular user?” – because if, at any time, somebody comes to your page or, maybe, a competitor does a search and finds 15 words all strung together like variants of the same word, then that does look like spam, and they often will send a spam report. Then somebody will go and check that out.

So, I would not make it a big habit of having tons and tons of words stuffed in there, because there are plenty of places on a page, where you can have relevant words and have them be helpful to users – and not have it come across as keyword stuffing.

Stephan Spencer: So, would something like 10 words be a bit much then?

Matt Cutts: It is a little abnormal. I know that when I hit something like that – even a blog post – with 10 words, I raise my eyebrows a little bit and, maybe, read with a little more skepticism. So, if just a regular savvy user has that sort of reaction, then you can imagine how that might look to some competitors and others.

URLs, and by extension slugs, are important for indexing, using a few actual words in them that also appear in the page will help with indexing, but overdoing it might prove counter productive. Keep in mind that you can, to a point, teach Google how to treat your URLs, through their Webmaster Tools.

Anecdotally I've noticed that the Google bot seems to really appreciate Sitemaps, a solid sitemap is perhaps a better investment of your time than worrying (too much) about the slugs.

Some further reading:

Slugs: are human-friendly or SEO-friendly URLs better?

Does SEO really affect user experience in a positive way?

How important is it to consider the URL when developing the UI for a web application?

SEO - which URL's are the best?

1 ...awesome job title: Head of webspam!


问:
How to use TFS as a query tracking system?
We already use tfs for managing defects in code etc, etc. We additionally need a way to "understand the domain & requirements of the products". Normally, without tfs we exchange emails with the consultants and have the questions/queries answered. If it is a feature implementation we sometimes "find" conflicts in the implementation itself. And when that happens the userstory is modified and the enhancement/bug as per that is raised in TFS.

Sometimes it is critical we come back to decisions we made or questions we wanted answers to. Hence we need to be able to track how that "requirement idea" or that "query in concern" evolved.

Hence how is it that we can use TFS to track all of this? Do we raise an "issue" item for this? Or do we raise a "bug" item?

The main things we'd ideally look in a query tracking system are as follows:

Area: Can be a module, submodule, domain. Sometimes this may be "General" - to address domain related stuff, or, event more granular to address modules, sub-modules. Take the case for the latter, if we were tracking this in excel sheets, we'd just write module1,submodule2; i.e. in a comma separated fashion. The things I would like here is to be able search for all queries relating to submodule2 sometime in the future.

Responses: This is a record of conversations between the consultant and any other stakeholder. For a simple case, it would just be paragraphs. Each para would start with a name and date enclosed in brackets and the response following that...each para would be like a thread - much like a forum thread

Action taken: We'd want to know how the query was closed, what was the input given, what were the changes that took place because of that, etc etc.

These are fields I think I would need in such a system apart from some obvious ones like status, address to, resovled by, etc. I am open for any other fields which are sort of important. To summarise my question: how can we manage "queries" in the system? Where should we ideally store data pertaining to those three fields I have mentioned above (for e.g. is it wise to store responses in the history tag assuming we are opening a bug for the query)?

答:
I have almost been there, implementing the solution that I am about to describe. The reason I am not currently using that is... well, besides my personal preference for other version control systems rather than TFS, is that the company using it found a more suited software for this.

In TFS, this is easy to implement. Whether you want to use "bug", "task" or any other element is really irrelevant. I would suggest Task on TFS OOB, but you can redefine and create more work item types as you want. (Which is actually useful to set up predefined fields.)

Areas:
As for the areas, you can defined them in TFS and each of these. The problem with TFS is that you may not have an item mapped to several areas. If you wish to defined areas as modules, submodules, funcionalities, etc. Anything that works for you.

As for searches, you can use TFS queries to define custom searches that will return tables or trees of work items. These are very customizable, useful and even exportable to different formats (Outlook, Excel with linked tables, Project, etc.) I've done so plenty of times, and event programmed burn down charts in Excel with linked queries from TFS.

Responses:
If you wish to define a custom work item type, you may create a text field for this, and force it to be completed before it can be assigned a finished state. The problem here is that you cannot anticipate what number of responses you may have. In here you may defined your set as a one-question and then one-response. Or comments/discussion and one response.

If you wish to have multiple responses (i.e., a discussion) I do not know how to accommodate TFS for that. What I have done so far is to have everyone log their responses in the very same way you described: date, name and text. If someone would mess up with the previous responses, you still have the history of the work item. Sometimes, rewriting the whole text is even desirable, to sum things up.

Action taken:
For this specific case I would recommend the addition of a custom field, in case every single of these items need it. Also, you could make it the last response, which makes sense when the action later needs to be verified by someone else or may even spawn further comments and corrections.

Personal view:

I know this sounds quite hacky, and yes, it is. TFS can be widely customized, but sometimes the workflow you've got does not correctly fit the way that the system works. I think this is one of these cases. As I have described, we had made it work, but as I said in the beginning of my response, another system which fits your needs better is always a better option.


答:
Log files are used 1. to get information for debugging system errors.  2. to research user activity for mischief, or 3. to understand how people use the system when you can't go watch them.  With that in mind:

Log environment (e.g. environment vars, other settings, etc.) on application startup.  This is helpful for debugging issues.

Log the user and the action (the distinct part of the URL) for each request.

Log all parameters for each request EXCEPT for passwords.  I like to put delimiters around each parameter in the logs e.g. phone{(999)999-9999} email{aaa@aaa.com}.  Passwords should never be written anywhere except to the database in a one way, cryptographically secure hash function with unique salt for each user and multiple rounds of hashing (see footnote)

When logging in, you should log the user's ip address, user ID, name, count of failed logins, maybe the browser, maybe the cookie session id, but never the password.

Remember to not log the password on the login page AND the change-password page, nor should you log the secret question or answer if you have that functionality.  Any other passwords or encryption keys must not be logged.  It's a good practice to write something like six stars to the log for these parameters so you can see that you remembered to suppress this data.

I like to log the total time it takes to serve each request: Done: 49ms

I like to log changes to session state.  These should be rare.

As others said, there are great logging libraries out there for logging to files, not sure about for logging to databases.

Store logs securely.  Even without passwords, there are state, federal, and international laws about Personally Identifiable Information (see Safe Harbor) making log data confidential.

Take backups.  If you let them flow into a full-drive backup every night, make sure to remember to back them up somewhere else before upgrading to a new server (don't ask me how I learned this).

Other tips

Footnote: To log someone in, hash the supplied password with the same hashing algorithm and the salt from the original hash for that user.  If the hash of the supplied password matches the password hash stored in the database, then they are logged in.  For this to work, you must define the character set for your password, disallow the Unicode substitution character and any other characters outside your set.


问:
Should I be looking for developers with specific skill sets or generalists that need to learn?
Thanks to the great help of this site and SO, I've been able to make a prototype of a software I want to sell but unfortunately although the prototype works I think my code quality is very low. I didn't use much OOP or design patterns so although my code is understandable to me, I think a normal developer would faint if they had to read it.

So I wanted to hire a developer to make it a bit more better quality and improve some of my implementations of API's that I may have not done correctly.   I'm having problems hiring a developer though.

I have met 2 developers and had them read my software specs.The problem is, they lacked my business's domain knowledge(which is completely understandable and no biggie) but they also lacked knowledge of the underlying tech systems I used such as Hadoop, Hbase, Cuda, etc..I spent alot of time explaining map/reduce, bigtables and other technologies I used. I thought it was common knowledge because of my interactions with people on this site but the people I met with mentioned they never had to deal with these things so they didn't know it.

My question is, for software projects that are hiring contractor developers is it a danger if the developer does not have experience with the underlying technologies? or can a general developer who is accomplished in another area realistically pick up new technologies?  I did a very very quick back of envelope calculation and I think the upfront costs would be similar if I hire a student or developer with no experience in my technologies who will work many hours versus hiring a highly experienced developer who charges double but finishes in half the time but what other risks should I be considering or worried about?  Also, should if I do hire a generalist, should I be paying for the time it takes them to learn hadoop or cuda if they are contractors(seems to make business sense but not sure how fair it is to them if they do not use the skill again).

I'm a bit confused so any suggestions would be great.

答:
is it a danger if the developer does not have experience with the underlying technologies?

Yes. (Learning takes time, and making mistakes is often part of the process.)

or can a general developer who is accomplished in another area realistically pick up new technologies?

Yes. (Picking up new technologies is something that generalists do all the time. You don't last very long as a programmer if you can't learn new things.)

I think the upfront costs would be similar if I hire a student or
  developer with no experience in my technologies who will work many
  hours versus hiring a highly experienced developer who charges double
  but finishes in half the time

Note that there's a big difference between 'no experience with technology X' and 'no experience, period'. It's one thing to have to learn some new framework or language, and quite another thing to start your first job as a developer and not have someone with some experience to point you in the right direction.

what other risks should I be considering or worried about?

Decisions that get made during the design and development process can be difficult and/or expensive to change later. A smart, experienced developer may save you a lot more than just development hours. On the other hand, someone who's really good at what they do will be able to charge accordingly.

I'm a bit confused so any suggestions would be great.

Perhaps Joel Spolsky's article will help: The Guerrilla Guide to Interviewing. In a nutshell, Joel says he looks for two things: 1) smart, 2) gets things done. Beyond that, I'd suggest looking for someone who you can work with, and who will understand what you're trying to accomplish and work toward that with you.


问:
Functions returning pointers
C++ noob here. I have a very basic question about a construct I found in the C++ book I am reading.

```<code>// class declaration
class CStr {
  char sData[256];
 public:
  char* get(void);
};

// implementation of the function
char* CStr::get(void) {
  return sData;
}
</code>```

So the Cstr::get function is obviously meant to return a character pointer, but the function is passing what looks like the value (return sData). Does C++ know to return the address of the returned object? My guess would have been that the function definition would be return &sData.

答:
For C and C++, array's degrade to pointers. An array cannot be returned as the value of a function, only a pointer can be returned. Returning the array is equivalent to returning the address of the first element of the array:</p>

```<code>return &sData[0];
</code>```

Title: Functions returning pointers

Body:
For C and C++, array's degrade to pointers. An array cannot be returned as the value of a function, only a pointer can be returned. Returning the array is equivalent to returning the address of the first element of the array:

return &sData[0];


问:
Why SQL is not so widespread in large desktop applications?
As a software developer, I've worked on projects ranging from tiny home-made apps to medium-size enterprise applications. In nearly every project I used a database or regretted choosing not to use it from the beginning.

Now, I am wondering a few things about the databases and their usage in general applications:

Why Windows itself doesn't use any "central" SQL database? For example:

Errors Reporting data is stored in a bunch of files,

Windows Update stores everything in flat files,

Icons cache is stored in a very strange single file which doesn't seem to be accessed through SQL, etc.

Why so many large applications avoid using databases? For example, wouldn't Microsoft Outlook gain by using a real database instead of reinventing the wheel by having its own format for .pst files and storing some data in registry?

If database adds an additional layer of an overall complexity and a tiny performance loss, it is a price of a huge advantage of making the code simpler in most circumstances, especially when it comes to the storage of small organized chunks of data instead of large binary streams. So why so few products are actually using databases? Probably the only application I know which actually uses Sqlite database is Firefox, and maybe Microsoft Exchange (but the last one is not a desktop application)?

Also, wouldn't a set of applications, like Microsoft Office or Microsoft Expression, benefit from having an unified SQL database, making it easier to deploy the applications, to update/upgrade the data, to share data between those applications, to make backups, etc.?

答:
Many applications embed SQLite. Quoting from their website:

SQLite is a software library that implements a self-contained, serverless,  zero-configuration, transactional SQL database engine. SQLite is the most widely deployed SQL database engine in the world. The source code for SQLite is in the public domain.".

You just use one of the available APIs, create a database, tables, etc and the SQL engine will store everything in a binary file that you can put anywhere within the user's file system. Best of all, it's FLOSS.


问:
Is a 64-bit Laptop going to be a problem for "Metro" apps?
I'm looking at a sample Windows 8 C# "Metro" style app (bingPushpin). When I 2-click MainPage.xaml, it gives me, "Design view is unavailable for x64 and ARM target platforms."

My Acer Aspire laptop is, indeed, 64-bit.

Is this going to continue to be a problem for me, or is there a workaround?

If the former, can anybody recommend a Windows 8 dev machine (laptop)?

答: Okay, I see: once I select "x86" from the "Solution Platforms" combobox (so that I've got, from left to right, "Local Machine | Debug | x86" it works fine.</p>


问:
Is Haskell's type system formally equivalent to Java's?
I realize some things are easier/harder in one language than the other, but I'm only interested in type-related features that are possible in one and impossible/irrelevant in the other.  To make it more specific, let's ignore Haskell type extensions since there's so many out there that do all kinds of crazy/cool stuff.</p>

答:
("Java", as used here, is defined as standard Java SE 7; "Haskell", as used here, is defined as standard Haskell 2010.)

Things that Java's type system has but that Haskell's doesn't:

nominal subtype polymorphism

partial runtime type information

Things that Haskell's type system has but that Java's doesn't:

bounded ad-hoc polymorphism

gives rise to "constraint-based" subtype polymorphism

higher-kinded parametric polymorphism

principal typing

EDIT:

Examples of each of the points listed above:

Unique to Java (as compared to Haskell)

Nominal subtype polymorphism

/* declare explicit subtypes (limited multiple inheritance is allowed) */
abstract class MyList extends AbstractList<String> implements RandomAccess {

    /* specify a type's additional initialization requirements */
    public MyList(elem1: String) {
        super() /* explicit call to a supertype's implementation */
        this.add(elem1) /* might be overridden in a subtype of this type */
    }

}

/* use a type as one of its supertypes (implicit upcasting) */
List<String> l = new ArrayList<>() /* some inference is available for generics */
```

<h2>Partial runtime type information</h2>

<pre class="lang-java prettyprint-override"><code>/* find the outermost actual type of a value at runtime */
Class<?> c = l.getClass // will be 'java.util.ArrayList'

/* query the relationship between runtime and compile-time types */
Boolean b = l instanceOf MyList // will be 'false'
</code>```

Unique to Haskell (as compared to Java)

Bounded ad-hoc polymorphism

```<code>-- declare a parametrized bound
class A t where
  -- provide a function via this bound
  tInt :: t Int
  -- require other bounds within the functions provided by this bound
  mtInt :: Monad m => m (t Int)
  mtInt = return tInt -- define bound-provided functions via other bound-provided functions

-- fullfill a bound
instance A Maybe where
  tInt = Just 5
  mtInt = return Nothing -- override defaults

-- require exactly the bounds you need (ideally)
tString :: (Functor t, A t) => t String
tString = fmap show tInt -- use bounds that are implied by a concrete type (e.g., "Show Int")
</code>```

"Constraint-based" subtype polymorphism (based on bounded ad-hoc polymorphism)

```<code>-- declare that a bound implies other bounds (introduce a subbound)
class (A t, Applicative t) => B t where -- bounds don't have to provide functions

-- use multiple bounds (intersection types in the context, union types in the full type)
mtString :: (Monad m, B t) => m (t String)
mtString = return mtInt -- use a bound that is implied by another bound (implicit upcasting)

optString :: Maybe String
optString = join mtString -- full types are contravariant in their contexts
</code>```

Higher-kinded parametric polymorphism

```<code>-- parametrize types over type variables that are themselves parametrized
data OneOrTwoTs t x = OneVariableT (t x) | TwoFixedTs (t Int) (t String)

-- bounds can be higher-kinded, too
class MonadStrip s where
  -- use arbitrarily nested higher-kinded type variables
  strip :: (Monad m, MonadTrans t) => s t m a -> t m a -> m a
</code>```

Principal typing

This one is difficult to give a direct example of, but it means that every expression has exactly one maximally general type (called its principal type), which is considered the canonical type of that expression.  In terms of "constraint-based" subtype polymorphism (see above), the principal type of an expression is the unique subtype of every possible type that that expression can be used as.  The presence of principal typing in (unextended) Haskell is what allows complete type inference (that is, successful type inference for every expression, without any type annotations needed).  Extensions that break principal typing (of which there are many) also break the completeness of type inference.

Body:
("Java", as used here, is defined as standard Java SE 7; "Haskell", as used here, is defined as standard Haskell 2010.)

Things that Java's type system has but that Haskell's doesn't:

nominal subtype polymorphism

partial runtime type information

Things that Haskell's type system has but that Java's doesn't:

bounded ad-hoc polymorphism

gives rise to "constraint-based" subtype polymorphism

higher-kinded parametric polymorphism

principal typing

EDIT:

Examples of each of the points listed above:

Unique to Java (as compared to Haskell)

Nominal subtype polymorphism

/* declare explicit subtypes (limited multiple inheritance is allowed) */
abstract class MyList extends AbstractList<String> implements RandomAccess {

    /* specify a type's additional initialization requirements */
    public MyList(elem1: String) {
        super() /* explicit call to a supertype's implementation */
        this.add(elem1) /* might be overridden in a subtype of this type */
    }

}

/* use a type as one of its supertypes (implicit upcasting) */
List<String> l = new ArrayList<>() /* some inference is available for generics */

Partial runtime type information

/* find the outermost actual type of a value at runtime */
Class<?> c = l.getClass // will be 'java.util.ArrayList'

/* query the relationship between runtime and compile-time types */
Boolean b = l instanceOf MyList // will be 'false'

Unique to Haskell (as compared to Java)

Bounded ad-hoc polymorphism

-- declare a parametrized bound
class A t where
  -- provide a function via this bound
  tInt :: t Int
  -- require other bounds within the functions provided by this bound
  mtInt :: Monad m => m (t Int)
  mtInt = return tInt -- define bound-provided functions via other bound-provided functions

-- fullfill a bound
instance A Maybe where
  tInt = Just 5
  mtInt = return Nothing -- override defaults

-- require exactly the bounds you need (ideally)
tString :: (Functor t, A t) => t String
tString = fmap show tInt -- use bounds that are implied by a concrete type (e.g., "Show Int")

"Constraint-based" subtype polymorphism (based on bounded ad-hoc polymorphism)

-- declare that a bound implies other bounds (introduce a subbound)
class (A t, Applicative t) => B t where -- bounds don't have to provide functions

-- use multiple bounds (intersection types in the context, union types in the full type)
mtString :: (Monad m, B t) => m (t String)
mtString = return mtInt -- use a bound that is implied by another bound (implicit upcasting)

optString :: Maybe String
optString = join mtString -- full types are contravariant in their contexts

Higher-kinded parametric polymorphism

-- parametrize types over type variables that are themselves parametrized
data OneOrTwoTs t x = OneVariableT (t x) | TwoFixedTs (t Int) (t String)

-- bounds can be higher-kinded, too
class MonadStrip s where
  -- use arbitrarily nested higher-kinded type variables
  strip :: (Monad m, MonadTrans t) => s t m a -> t m a -> m a

Principal typing

This one is difficult to give a direct example of, but it means that every expression has exactly one maximally general type (called its principal type), which is considered the canonical type of that expression.  In terms of "constraint-based" subtype polymorphism (see above), the principal type of an expression is the unique subtype of every possible type that that expression can be used as.  The presence of principal typing in (unextended) Haskell is what allows complete type inference (that is, successful type inference for every expression, without any type annotations needed).  Extensions that break principal typing (of which there are many) also break the completeness of type inference.


答:
Does C++ know to return the address of the returned object?

In this case, yes. An array's name is a constant pointer to the first element in the array. So, when

```<code>char* CStr::get(void) {
    return sData;
}
</code>```

is executed, pointer to the first element of the array is returned. So, the caller can reference the array and do a traversal. Run the following code. You'll see the output "hello, world".

```<code>#include <iostream>
#include <string>

class CStr {
    char sData[256];
public:
    CStr(std::string str);
    char* get(void);
};

CStr::CStr(std::string str) {
    if (str.length() >= 256) {
        sData[0] = '\n';
        return;
    }

    str.append("\n");
    str.copy(sData, str.length());
}

char* CStr::get(void) {
    return sData;
}

int main() {
    CStr msg("hello, world");
    char* str = msg.get();

    while (*str != '\n')
        std::cout << *str++;

    return 0;
}
</code>```

Title: Functions returning pointers

Body:
C++ noob here. I have a very basic question about a construct I found in the C++ book I am reading.

```<code>// class declaration
class CStr {
  char sData[256];
 public:
  char* get(void);
};

// implementation of the function
char* CStr::get(void) {
  return sData;
}
</code>```

So the Cstr::get function is obviously meant to return a character pointer, but the function is passing what looks like the value (return sData). Does C++ know to return the address of the returned object? My guess would have been that the function definition would be return &sData.

Body:
Does C++ know to return the address of the returned object?

In this case, yes. An array's name is a constant pointer to the first element in the array. So, when

char* CStr::get(void) {
    return sData;
}

is executed, pointer to the first element of the array is returned. So, the caller can reference the array and do a traversal. Run the following code. You'll see the output "hello, world".

#include <iostream>
#include <string>

class CStr {
    char sData[256];
public:
    CStr(std::string str);
    char* get(void);
};

CStr::CStr(std::string str) {
    if (str.length() >= 256) {
        sData[0] = '\n';
        return;
    }

    str.append("\n");
    str.copy(sData, str.length());
}

char* CStr::get(void) {
    return sData;
}

int main() {
    CStr msg("hello, world");
    char* str = msg.get();

    while (*str != '\n')
        std::cout << *str++;

    return 0;
}


答:
Using a log file presents a couple of issues. Firstly you may get errors when multiple processes attempt to access the file. You can also get problems when trying to cycle or clear the file while your system is running. The way around that is to use a database.

So, step 1 is to create a database table. I suggest the following fields:

 * userID

 * action (eg logon, delete foo)

 * Some descriptive text (allow nulls here)

 * timestamp

Step 2, Create a stored procedure with input for userID, action and descriptive text. Just use the current time to create the time stamp.

Step 3, Write a logging method in a convenient shared library so it is easy to included everywhere and get into the practice of calling that method as required. You may like to have a logging level flag logic as well to change what is logged.

Step 4, Create a maintenance routine to clear out old messages from the logging table from time to time. Perhaps delete when older than X, run each week or so as part of regular DB maintenance (index rebuilding, etc).

Once you have built this once, you should be able to use the code involved in other projects.


答:
Just a general advice. May not be directly related to your question.

It depends on what are you going to use logs for? Mostly logs are used in the production to detect the operations which cause the errors. If you are keeping them for tracking the user actions, then that's not part of the log. That must be the server side feature of the product. These things then definitely needs to go into database for later study. But the server side logs like, "Error occurred as some text is empty", is not part of the feature. These things needs to go in the file system. They must have following contents with them :-
user_id, error_number, error_text, file_name,function_name, thread_id,system_date_time, and any other context.

Now I am only talking about the logs in the files.

1) Keep them asynchronous. I/O operation is costly.

2) Design them as class than function. Future changes will be easy.

3) Keep them singleton, if possible. Singleton is difficult in multi-threaded, so design properly.

4) Also better to keep the interaction between logger and loggee simple. Most of the time send the message_number than actual message_text, and let the logger get the message from the number. This will help if later we want to make changes in the generic log formats.

Normally logger and also the things which we needs to log should be part of the design. I have seen cases where there were changes in design just to make sure that all relevant information is logged properly.


问:
Why has extreme programming (XP) gone out of date in favor of Agile, Kanban etc?
I like XP (extreme programming), especially the part where there are 2 programmers at the same screen, since a problem's solution is often found more quickly if only you explain what you're doing and pair programming forces you to explain what you're doing.

Over the last 10 years or so, the XP style of working seems to have gone out of date in favor of the working methodologies: Agile and/or Kanban. Why? Since XP seems to me to be a very good way to work and is a lot about the programming whereas Agile and Kanban are more about processes.

答:
In my view XP is a programming practices, Scrum and kanban are project management practices. They have a relation but do not replace each other.

In our kanban project we use pair programming (mostly for complex sections and debugging), TDD, CI. So it is still used but management is pushing the project management side harder.


答:
Try Log4Net.It allows you to log in files or database. Here's Tutorial!

We use Log4Net in all of our projects .


答:
There's a lot of different styles, methods and mindsets related to the whole field development, and everything has it's own, shiny name.

Agile is just a mindset that moves away from the usual, static programming models (like waterfalls) - it's primary goal is to achieve more flexible development and (at the very end) better software and happy customers. Below agile, there are a lot of different models like Scrum, Kanban, XP.

Especially Kanban doesn't come from software development originally, it originates in building cars (i remind Toyota introduced it for building cars and some software developers adopted and expanded it)

Pair programming, code reviews and such stuff are just tools - you can (and should) always do it during a project, regardless which method you use. It's just that this stuff is more native to agile than to static.

XP more or less introduced these things (or at least gave them a shiny name) and all the following stuff adopted them because it simply worked out good.

Title: Why has extreme programming (XP) gone out of date in favor of Agile, Kanban etc?

Body:
I like XP (extreme programming), especially the part where there are 2 programmers at the same screen, since a problem's solution is often found more quickly if only you explain what you're doing and pair programming forces you to explain what you're doing.

Over the last 10 years or so, the XP style of working seems to have gone out of date in favor of the working methodologies: Agile and/or Kanban. Why? Since XP seems to me to be a very good way to work and is a lot about the programming whereas Agile and Kanban are more about processes.


问:
Is it a bug or a task when something doesn't work, yet, in development process
We usually have this dilemma in our team.  Sometimes, in order to implement a task or a story we find out that the system must be in a specific state.  For example, a specific system configuration has to be made beforehand.

The task / story can be completed and it is working as specified on it with the proper configuration in place.  Note that the configuration is not directly related with the task.

Next, we have to create a new ... ??? ... something for the process of generating that configuration file.  This is where the problems appear.  Some say that it is a bug others say it is a task or an extra feature.

So, where is the limit between bugs and tasks in the development phase?  Should we even consider something a bug if all the tasks are working as stated in their definitions?  Can a thing be considered a bug because one compares it to the current (unstable) state of the system?

Short example:

A feature requires configuring a communication service for a specific
operation.

In the process of the implementation the team discovers that the service requires the hostnames of the pears to be resolvable to an IP address.

The team adds the hostnames to the DNS server (or hosts files) and continues implementing the required feature.

After the initial feature is working, a question is risen. Should the sysadmin configure the DNS or hosts file or should our application do it automatically?

An automatic solution is possible. So a decision is made to implement it.

... here start the discussions ... is this a bug or an extra feature / task?

PS: I know that I mixed feature / task / story in the question.  It is intentional.  I am interested in separating bugs from the rest.  Doesn't matter what the rest means in a particular case.

答:
I would say that from the moment something doesn't work to spec, or is simply broken, it is a bug.  Anything else is a task/feature/story, in other words: something extra you add to the program.

You could also introduce the concept of a 'change': not really fixing something that is broken, not something new you add, but changing how something works (usually as the result of a change in requirements).  But that's three types of 'todos', so a change would also be a task.


问:
What are the warning signs of impending doom to watch out for on a project?
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

These projects can be great learning experiences, soul-crushing disasters (or both!), and can occur for a multitude of reasons:

upper management change of heart

under-skilled / under-resourced team

emergence of superior competitor during dev cycle

over/under management

Once you've worked on a couple of such projects, is it possible to recognise at an early stage exactly when a project is doomed to fail?

For me, a big sign is having a hard & fast external deadline combined with feature creep. I've seen projects which were well planned out and proceeding right on schedule go horribly off the rails once the late feature requests started to roll in and get added to the final "deliverable". The proposers of these requests earned the nickname of Columbo, due to rarely leaving the room without asking for "just one more thing".

What are the warning signs you look out for that set off the alarm bells of impending doom in your head?

答:
Having worked on a failed project is one of the few things that most programmers have in common, regardless of language used, industry or experience.

Good, that's a relief!

I think not having daily, helpful management oversight is key to spotting creep. I believe that if you have the right information, if you get your devs to input the right information, then you can spot slippage quite quickly. What you do with it after that - well that's more politics and less dev...


答:
I would call this a task. If I understand you correctly, it is meant to enable a new feature, so it is not a bug fix - otherwise everything should be called a bug.

If the change made by this makes a meaningful difference to end users (independent of the main feature it is meant to support / enable), you may consider calling it a (sub)feature.

All in all, no need to agonize too much on terminology, the main point is to get it done :-)

Title: Is it a bug or a task when something doesn't work, yet, in development process

Body:
We usually have this dilemma in our team.  Sometimes, in order to implement a task or a story we find out that the system must be in a specific state.  For example, a specific system configuration has to be made beforehand.

The task / story can be completed and it is working as specified on it with the proper configuration in place.  Note that the configuration is not directly related with the task.

Next, we have to create a new ... ??? ... something for the process of generating that configuration file.  This is where the problems appear.  Some say that it is a bug others say it is a task or an extra feature.

So, where is the limit between bugs and tasks in the development phase?  Should we even consider something a bug if all the tasks are working as stated in their definitions?  Can a thing be considered a bug because one compares it to the current (unstable) state of the system?

Short example:

A feature requires configuring a communication service for a specific
operation.

In the process of the implementation the team discovers that the service requires the hostnames of the pears to be resolvable to an IP address.

The team adds the hostnames to the DNS server (or hosts files) and continues implementing the required feature.

After the initial feature is working, a question is risen. Should the sysadmin configure the DNS or hosts file or should our application do it automatically?

An automatic solution is possible. So a decision is made to implement it.

... here start the discussions ... is this a bug or an extra feature / task?

PS: I know that I mixed feature / task / story in the question.  It is intentional.  I am interested in separating bugs from the rest.  Doesn't matter what the rest means in a particular case.


答:
I'm actually with @pleinolijf and @Péter Török on this: it's only a bug if the software isn't working according to the spec. A specification error that wasn't caught in the design or initial development phase may warrant a spec change and subsequent code changes, but generally speaking, is not a bug.

Generally speaking, a "task" is actually the most generic type of issue in most trackers, and is useful when there is no other fitting type of issue. Anything else (change request, bug, requirement, feature request, gizmo banana, ...) is actually a specialization of the "task" issue type. This means that if there is a more appropriate type of issue available, you should think twice about using "task". Bugs should also be reasonably limited in scope, but of course sometimes it's hard to tell what the scope of a particular issue will be before having dived into it.

Hence, generalizing, the question really becomes "does the lack of a feature constitute a bug?". The feature in this case is the ability to set up, in an automated or user-friendly manner, the prerequisites for specific functionality which in turn is laid out in the spec. Since the base functionality is already there and works properly (according to the requirements laid out in the spec) without the change that is being discussed and without requiring workarounds during use, assuming the spec didn't call for an easy set-up process specifically, I would argue that everything that is currently in the software works the way it is supposed to. Hence, not a "bug".

What you are talking about is the addition of new functionality (automated set-up of prerequisites), which in general terms has a pretty high bar for being considered a bug in my book.

About the only way I could consider something like this to be a bug is if the specification states that there must be no manual set-up required. Otherwise, it's a specification omission, which calls for the spec to be updated with the newly discovered desired functionality and for it to be developed along the same lines that the original functionality was (the lack of which probably wasn't considered a bug).


答:
During the development process, something is only a bug if the programmer has ticked it off the TODO list and thinks that it works. Not if the program doesn't match the spec yet.

When the specs change (i.e. a new rule "Program should do X"), that doesn't mean the program suddenly has a new bug ("doesn't do X yet").


问:
Are CK Metrics still considered useful?  Is there an open source tool to help?
Chidamber & Kemerer proposed several metrics for object oriented code.  Among them, depth of inheritance tree, weighted number of methods, number of member functions, number of children, and coupling between objects.  Using a base of code, they tried to correlated these metrics to the defect density and maintenance effort using covariant analysis.

Are these metrics actionable in projects?  Perhaps they can guide refactoring.  For example weighted number of methods might show which God classes needed to be broken into more cohesive classes that address a single concern.

Is there approach superseded by a better method, and is there a tool that can identify problem code, particularly in moderately large project being handed off to a new developer or team?

答:
This is a tough question, and there is probably no "good" answer for it. The excellent comments posted by Daniel B. and Yannis Rizos are sound, and I'd argue further that the best metrics are those that you understand, along with their causes and consequences.

A recommended lecture for this would be the Goal-Question-Metric paradigm, by V. Basili [1], further described by L. Westfall [2]. Once you define your own need, then questions, then metrics, and if the CK metrics give you insights on this reduced set, then go for it.

To get back to the initial question (sic;), yes they are still used, even under the wood, as pointed out by Yannis. And for their meaning (complexity, maintainability) I find them relevant — this is clearly an opinion of mine.

As a side note, the CK metrics are first defined in [3] before being challenged by Subramanyam in [4].

[1] V. R. Basili, G. Caldiera, and H. D. Rombach, "The goal question metric approach," Encyclopedia of Software Engineering, vol. 2. Wiley, pp. 528–532, 1994.

[2] L. Westfall and C. Road, "12 Steps to Useful Software Metrics[1]," Proceedings of the Seventeenth Annual Pacific Northwest Software Quality Conference, vol. 57 Suppl 1, no. May 2006, pp. S40–3, 2005.

[3] Shyam R. Chidamber and Chris F. Kemerer, "A Metrics Suite for Object Oriented Design[2]," vol. 315, no. December. 1993.

[4] R. Subramanyam and M. S. Krishnan, "Empirical Analysis of CK Metrics for Object-Oriented Design Complexity: Implications for Software Defects[3]," vol. 29, no. 4, pp. 297–310, 2003.


问:
Questions about linking libraries in C
I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the math.h header, need to be linked in manually when included. I have been linking in the libraries using various flags of the form -l[library-name], such as -lm for the above-mentioned math library.

However, after switching from the command line and/or Geany to Code::Blocks, I noticed that Code::Blocks uses g++ to compile the programs instead of the gcc that I am used to (even though the project is definitely specified as C). Also, Code::Blocks does not require the libraries to be manually linked in when compiling - libraries such as the math library just work.

I have two questions:

Firstly, is it "bad" to compile C programs with the g++ compiler? So far it seems to work, but after all, C++ is not C and I am quite sure that the g++ compiler is meant for C++.

Secondly, is it the g++ compiler that is doing the automatic linking of the libraries in Code::Blocks?

答:
Both gcc and g++ are frontends to the GNU compiler collection. You should use the former for compiling and linking C code, and the latter for performing the same actions on C++ code. One of the strongest arguments for maintaining the distinction is that C is not a subset of C++.

If you link using g++ it will automatically link in the C++ standard library. Since the C standard library is part of the C++ standard library, the math library is included as well. This is why you do not need to link in the math library manually.

Title: Questions about linking libraries in C


问:
Text Classification Implementation
I've been trying to implement a text classification system. It needs to read a text file, and extract the words and the word frequency. So far, I've been planning to parse the words, put them in a dictionary and save it to an XML file. I am using C++/CLI.

Is this a good implementation or is there a simpler or better implementation?

May be related question (some code implementation): https://stackoverflow.com/questions/10631309/save-dictionary-to-xml-file

答:
Yes, there may be better solutions but given your "beginner" status what is the target of better; you can optimize for speed, or for portability.

A binary data structure that could be randomly accessed would be faster, as XML is but a data exchange format; this of course makes it great for portability.

You will need a binary data structure anyway, while you are parsing out the words, until you are ready the write out the XML.

Title: Text Classification Implementation


答:
Your question hits a lot of people very squarely where they live, in a place that can be pretty painful.  Bug is not a very precise technical term, but it certainly has a lot of emotional baggage.

Where you work, do people consider features to be planned improvements, and bug fixes to be unplanned improvements?  When a developer created code with bugs under the crunch of an all too short schedule, is he or she called back to be accountable for work that might not have been as thorough as needed?  As the expert on the code, do people give kudos for a rapid and responsive solution?  Do habitual under estimators have consequences after taking credit for features and for being fast, even though finding and fixing their bugs was very frustrating for testers and customers, and very time consuming for developers working on maintenance?

Of course they don't.  The more bugs we have, the less pride of workmanship we have, the less accomplished our team.  If you are working on features, you must be trusted and skilled.  If on bugs, not so much.  Features get a thank you and a party when they are done.  Bugs get the silent treatment or a retrospective that discusses how late the release was because we had so many bugs.  Maybe where you work the retrospective talks about how the features unfolded into additional unanticipated functional and systems requirements that were not part of the estimate but were resolved with overtime and heroic efforts from team members?

Making a feature is a task.  Fixing a bug is a task.  What we call bugs are often defects that relate to features we said were done, or missing parts that are due to incomplete understanding of functional or system requirements (or in Agile, user stories or use cases that are incomplete or missing alternative flows).

If our customer visible code is constantly constructed in advance of the underlying support, this is a design or project management problem.  We have TDD and unit testing, so ideally, we can be pretty thorough in our testing and pretty selective about exactly when we expose features through the UI to testers, customers, or product management.

Projects often use rapid UI prototyping to show a user interface that has no code behind it.  It does not do development any favors if product management believes that 80% of the work is done when that demo is shown, but the project continues to run for a long time.  Weigh carefully how far you let your prototypes run ahead of your field ready product.

Agile aims to break the contract mentality and makes collaboration using prototypes more palatable.  The relationship and communication between developers and stakeholders needs a high degree of give and take.  It helps to methodically manage requirements using a burn down list or other way to limit scope and shorten the time line that is subject to estimation.

Part of our problem is how we track progress.  If we have features described by percentage complete, we essentially take credit for something before it is accomplished.  Estimates percentage complete are extremely unreliable.  If we need to show progress, we should break things down to the level where we can say something that is considered important in our project that stands alone as a cohesive object that provides functionality is completely done.  Instead of partially complete milestones, only use fully complete inch-pebbles.

For the work that you describe, if it brings more pride and motivation into the team, I definitely vote for calling it a task and not a bug.


答:
There are quite a lot of static analysis tools that extract code metrics, and pretty much all of them will include some or all of the CK metrics. Most of the tools are language-specific; sonar is the only one I know that is not.

As for the usefulness: I'd say that guiding refactoring and identifying potentially problematic code is exactly what they are good for. But they should most definitely not be misused as a goal unto themselves.

Title: Are CK Metrics still considered useful?  Is there an open source tool to help?

Body:
Chidamber & Kemerer proposed several metrics for object oriented code.  Among them, depth of inheritance tree, weighted number of methods, number of member functions, number of children, and coupling between objects.  Using a base of code, they tried to correlated these metrics to the defect density and maintenance effort using covariant analysis.

Are these metrics actionable in projects?  Perhaps they can guide refactoring.  For example weighted number of methods might show which God classes needed to be broken into more cohesive classes that address a single concern.

Is there approach superseded by a better method, and is there a tool that can identify problem code, particularly in moderately large project being handed off to a new developer or team?


答: Don't get hung up on what to call it -- does it really matter? It's something that needs to be done, so write a story so that the work gets done. If you are an agile team you have the power to call it whatever you want. Come to a consensus as a team then start worrying about more important things. </p>


答:
Yes.  Both.

Ideally, you could find someone in the middle who would need a leg up, but not for someone to carry them on either technical or domain knowledge.  However, many forces affect the staffing problem you are trying to solve.

Why is there a Domain Skill Shortage

Developers are an itinerant group, moving from application domain to application domain as the market demands.  If something is hot, ten or maybe a hundred or even a thousand companies will chase it until competition drives all but a handful of players out of the market.  Consequently, incentives for developers to go deep into your business domain knowledge pre-hire is zip.  If you are doing something fairly novel, you won't find others with domain knowledge.  If you have competitors, or particularly ex-competitors, you should not have to give up your quest for domain experience.

If you hire a hot shot developer, they may be most interested in developing portable skills, so you may still be forced to carry a lot of weight for domain knowledge.  Perhaps you should consider either getting a system engineer to document feature related domain knowledge for use by the developer.  Perhaps between smart and gets things done, you will pick someone strong in the gets things done.  If you can find a developer who is interested in being with you for a while, learning both your business and your technology, who places needs of your company about equal with their own, that may be better long term than the smart guy whose plans involve climbing up and, pretty frequently, out.

High Demand Skills

If you are doing something that is in high demand, you must do much more to attract candidates.  If your visibility is low and what you have to offer in return is less stellar than the competition, you may either need to pay a lot more or grow the talent you need from a pool of candidates with other skills.

Domain Skills or Technology Skills?

In the question you mention several skills your candidates lack including Hadoop, Hbase, Cuda, map/reduce, and bigtables.  I am not sure I would call these domain skills because they are based in technology rather than the specifics of making a product that is industry specific to your customers.  I suspect that each of these skills is portable and will still be valuable after your particular industry has automated and you have dominated, found a niche, or moved on to something else.

Technical Skill Growth Attracts Good Candidates

The advantage of hiring and training for technology skills is that the smart, gets things done, aggressive, career oriented developer who trains themselves will jump at the chance to learn something with a long and rewarding future.  If you maintain challenges and a manageable new technology mix, many of the developers you want will embrace being one your team for both short term and long term mutual benefit.

Title: Should I be looking for developers with specific skill sets or generalists that need to learn?

Body:
Thanks to the great help of this site and SO, I've been able to make a prototype of a software I want to sell but unfortunately although the prototype works I think my code quality is very low. I didn't use much OOP or design patterns so although my code is understandable to me, I think a normal developer would faint if they had to read it.

So I wanted to hire a developer to make it a bit more better quality and improve some of my implementations of API's that I may have not done correctly.   I'm having problems hiring a developer though.

I have met 2 developers and had them read my software specs.The problem is, they lacked my business's domain knowledge(which is completely understandable and no biggie) but they also lacked knowledge of the underlying tech systems I used such as Hadoop, Hbase, Cuda, etc..I spent alot of time explaining map/reduce, bigtables and other technologies I used. I thought it was common knowledge because of my interactions with people on this site but the people I met with mentioned they never had to deal with these things so they didn't know it.

My question is, for software projects that are hiring contractor developers is it a danger if the developer does not have experience with the underlying technologies? or can a general developer who is accomplished in another area realistically pick up new technologies?  I did a very very quick back of envelope calculation and I think the upfront costs would be similar if I hire a student or developer with no experience in my technologies who will work many hours versus hiring a highly experienced developer who charges double but finishes in half the time but what other risks should I be considering or worried about?  Also, should if I do hire a generalist, should I be paying for the time it takes them to learn hadoop or cuda if they are contractors(seems to make business sense but not sure how fair it is to them if they do not use the skill again).

I'm a bit confused so any suggestions would be great.


问:
what is the purpose of arrows?
I am learning functionnal programming with Haskell, and I try to grab concepts by first understanding why do I need them.

I would like to know the goal of arrows in functional programming languages. What problem do they solve? I checked http://en.wikibooks.org/wiki/Haskell/Understanding_arrows and http://www.cse.chalmers.se/~rjmh/afp-arrows.pdf. All I understand is that they are used to describe graphs for computations, and that they allow easier point free style coding.

The article assume that point free style is generally easier to understand and to write. This seems quite subjective to me. In another article (http://en.wikibooks.org/wiki/Haskell/StephensArrowTutorial#Hangman:_Main_program), a hangman game is implemented, but I cannot see how arrows makes this implementation natural.

I could find a lot of papers describing the concept, but nothing about the motivation.

What I am missing?

答:
I like to think of Arrows, like Monads and Functors, as allowing the programmer to do exotic compositions of functions.

Without Monads or Arrows (and Functors), composition of functions in a functional language is limited to applying one function to the result of another function. With monads and functors, you can define two functions, and then write separate reusable code which specify how those functions, in the context of the particular monad, interact with each other and with the data which is passed into them. This code is placed within the bind code of the Monad. So a monad is one one view, just a container for reusuable bind code. Functions compose differently within the context of one monad from another monad.

A simple example is the Maybe monad, where there is code in the bind function such that if a function A is composed with a function B within a Maybe monad, and B produces a Nothing, then the bind code will ensure that the composition of the two functions outputs a Nothing, without bothering to apply A to the Nothing value coming out from B. If there were no monad, the programmer would have to write code into A to test for a Nothing input.

Monads also mean that the programmer does not need to explicitly type the parameters which each function requires into the source code - the bind function handles parameter passing. So using monads, the source code can begin to look more like a static chain of function names, rather than looking as though function A "calls" function B with parameters C and D - the code starts to feel more like an electronic circuit than a moving machine - more functional than imperative.

Arrows also connect functions together with a bind function, providing reusable functionality and hiding parameters. But Arrows can themselves be connected together and composed, and can optionally route data to other Arrows at runtime. Now you can apply data to two paths of Arrows, which "do different things" to the data, and reassemble the result. Or you can select which branch of Arrows to pass the data to, depending on some value in the data. The resulting code is even more like an electronic circuit, with switches, delays, integration etc. The program looks very static, and you should not be able to see much manipulation of data going on. There are fewer and fewer parameters to think about, and less need to think about what values parameters may or may not take.

Writing an Arrowized program mostly involves selecting off the shelf Arrows such as splitters, switches, delays and integrators, lifting functions into those Arrows, and connecting the Arrows together to form bigger Arrows. In Arrowized Functional Reactive Programming, the Arrows form a loop, with input from the world being combined with output from the last iteration of the program, so that the output reacts to real world input.

One of the real world values is time. In Yampa, the Signal Function Arrow invisibly threads the time parameter through the computer program - you never access the time value, but if you connect an integrator arrow into the program, it will output values integrated over time which you can then use to pass to other arrows.

Title: what is the purpose of arrows?


答:
Firstly, is it "bad" to compile C programs with the g++ compiler?

Define "bad".

There are a few things which may cause a valid C program to compile in C++ with a different semantic, if my experience is pertinent, you have more chances to find UB handled differently when changing the version of your C compiler than to meet them.

A C++ compiler will not compile some valid C programs, so compiling C with a C++ compiler will restrict you to their common subset, which is a stricter version of C. Restricting yourself to that C dialect is not not idiomatic (the major difference is the need to cast void* when another pointer type is needed) do so but quite a few projects started to use C++ in that way. They where using a C++ compiler to get a more type-safe version of C and then decided to allow the use of the additional features, one by one, as they deemed them pertinent. (The latest and more public example is gcc itself. GCC started to be written in K&R C, then mandated an ANSI C compiler, then was restricted to the common subset of ANSI C and C++, and now they are starting to use C++, another quite public example is that the examples in the second edition of K&R C were compiled with a C++ compiler -- but I think C++ was tightened since as it seems to me that some examples won't compile with a current C++ compiler).

Note that if you only use C++ compilers, you'll quickly introduce C++ dependencies in it.

Note also that of the new things in C99 and C11 are more subject to be different in C++.

Secondly, is it the g++ compiler that is doing the automatic linking of the libraries in Code::Blocks?

When used to link, a compiler always link a default set of libraries. That set for gcc doesn't included libm, it is included in the default set for g++.  G++ will not auto-detect additional libraries if they are needed (AFAIK neither will Code::Blocks), libm is a very particular case (some will argue that the fact that gcc doesn't link it by default is a bug in gcc).

Title: Questions about linking libraries in C

Body:
I am learning C (still very much a beginner) on Linux using the GCC compiler. I have noticed that some libraries, such as the library used with the math.h header, need to be linked in manually when included. I have been linking in the libraries using various flags of the form -l[library-name], such as -lm for the above-mentioned math library.

However, after switching from the command line and/or Geany to Code::Blocks, I noticed that Code::Blocks uses g++ to compile the programs instead of the gcc that I am used to (even though the project is definitely specified as C). Also, Code::Blocks does not require the libraries to be manually linked in when compiling - libraries such as the math library just work.

I have two questions:

Firstly, is it "bad" to compile C programs with the g++ compiler? So far it seems to work, but after all, C++ is not C and I am quite sure that the g++ compiler is meant for C++.

Secondly, is it the g++ compiler that is doing the automatic linking of the libraries in Code::Blocks?