问:
schedule compliance and keeping technical supports and resolving issues
I am an entrepreneur of a small software developer company. The flagship product is developed by myself and my company grew up to 14 people. One of pride is that we've never have to be invested or loaned.

The core development team is 5 people. 3 are seniors and 2 are juniors.

After the first release, we've received many issues from our customers. Most of them are bug issues, customization needs, usage questions and upgrade requests.

The issues from customers are incoming many times everyday, so it takes little time or much time of our developers. Because of our product is a software development kit(SDK) so most of questions can be answered only from our developers. And, for resolving bug issues, developers must be involved. Estimating time to resolve bug is hard. I fully understand it. However, our developers insist they cannot set the any due date of each project because they are busy doing technical supports and bug fixes by issues from customers everyday. Of course, they never do overwork.

I suggested them an idea to divide the team into two parts: one for focusing on development by milestones, other for doing technical supports and bug fixes without setting due days. Then we could announce release plan officially. After the finish of release, two parts exchange the role for next milestone.

However, they say they "NO, because it is impossible to share knowledge and design document fully." They still say they cannot set the release date and they request me to alter the due date flexibly. They does not fix the due date of each milestone. Fortunately, our company is not loaned and invested so we are not chocked. But I think it is bad idea to keep this situation. I know the story of ant and grasshopper.

Our customers are tired of waiting forever of our release date. Companies consume limited time and money. If flexible due date without limit could be acceptable, could they accept flexible salary day?

What is the root cause of our problem? All that I want is to fix and achieve precisely due date of each milestone without losing frequent technical supports.

I think there must be solution for this situation. Please answer me.

Thanks in advance.

PS. Our tools and ways of project management are Trello, Mantis-like issue tracker, shared calendar software and scrum(collected cards into series of 'small and high completeness' projects).

答:
The scenario is:

Your team is fourteen people, with five developers.

You are privately help and debt free.

Your customer likes your product enough to engage with you instead of going to someone else.

You have a technical business, and a non-technical person can't support the product.

Your developers need their focus for features and bug fixes.

Your developers don't want to alternate between feature development and bug fixes.

You are busy developing, but have not had recent releases to customers.

You have been favoring the creation of features to the correction of defects, maybe for a while now.

The answer is simple, but depending on whether your team has a mature attitude, unpleasant.

You need to pay the technical debt to fix the bugs.

You need to support customers using members of the team.

Your original instinct was probably correct.  Some team members need to work features and some bugs, alternating periodically.  If you went through the bug database and traced the defect to its author, that would be a way to assign the bugs and perhaps determine the duration of each person's rotation.  However, sometimes, the bug exists because the person writing the particular code didn't have the skill to write it.  This may be where your distinction between junior and senior team members can be of benefit.

WRT customer support, I recommend that you rotate that function as well.  If a small number of people work customer support, they will hear the same questions and provide the same answers, potentially building a database of FAQs.  Once you have written collateral for support, you can use less technical people to share it with customers.  There are many systems for automated customer support including Right Now Web which might be too expensive, but perhaps it can help you find leads to an open source alternative.  Not everyone on your team will have the talents needed for working with customers, so you may find you need to bite the bullet and if you have the skill, do it yourself.  At least for a while.


问:
Project Management Software / 1 maybe 2 developers
I am looking for software that I can use to "manage" multiple projects (5 - 10). Here are the features I would like but any recommendation is welcome.

Bug/Feature tracking on a per project basis.

Some way to keep all documents, diagrams, specs, requirements, in one place with the project. Better yet a tool where all these things or most of them could be authored.

Task management during the development phase with milestones and estimates/actuals.

Git integration

I have been doing contract work and i have been doing really well for myself as far as getting projects but its becoming VERY hard to manage everything in an efficient manner. I am trying to learn about best practices when it comes to software programming methodologies and the more I read the more i realize that I am just managing these projects poorly. I am getting things done but the more I take on the less "solid" everything is. I am afraid if I don't get some good solid tools/practices in place I am going to do my customers and myself a disservice. The problem is that there are SO many options that its hard to weed through them all. I was at a point today where I had decided that I would just code my own (there is some irony here)!

Obviously everyone has their likes dislikes I would love to hear from some of you lone programmers and how you manage everything since our needs aren't exactly the same thing that a large team might need. I also want a solution that can scale to 2 maybe 3 developers if I end up hiring some people to help with my work load.

Thanks again for your usual insights!

答: I have used Trac, Bugzilla, Redmine, and a few others, and we have settled on Redmine.  It fits our needs, is customizable enough to not back us into a corner with workflow, and easy to use (easy enough the boss gets it).  It can handle multiple projects as well as subprojects of a project.  I recommend Redmine to others.</p>

ContentLicense: CC BY-SA 3.0


问:
What is the standard for describing functions and objects?
What is the standard for describing functions/methods (function name, number of arguments, argument type, return type, etc...) in a manner that is language independent?

EDIT: More specifically, how does one describe a function without the use of diagrams? I thought there was a pure text standard.

答:
Types are pretty language dependant. If you have a "language-independant" description of functions/methods that includes types that go beyond ints, floats and strings, then it's really a language of its own, an interface description language.

There are many of these to choose from; WSDL is probably the most widely known nowadays.


答:
What you are asking is a formal language for describing functions, independent of formal language. This clearly cannot exist due to the contradiction in its definition. You will have to relax one side or other.

Keeping independent of all languages, the you get pseudo code which, by definition, does not have a standard.

If you relax the other constraint there are various formal languages (e.g. UML or any PL) you can use to describe your solution, however you are then effectively implementing your solution in this formal language.

Title: What is the standard for describing functions and objects?

Body:
What is the standard for describing functions/methods (function name, number of arguments, argument type, return type, etc...) in a manner that is language independent?

EDIT: More specifically, how does one describe a function without the use of diagrams? I thought there was a pure text standard.


问:
How to retain student/intern programmers?
We have a small team in our department and typically employ 1-3 students/interns.  The problem we have is retention.  We like to hire a student that will stick around as part of the team for more than just a summer quarter.  The problem is though the last 4 students we hired, up front we discussed this with them and they all ended up leaving earlier than we would have liked.

The relationships all ended in a good fashion, the students either obtained teaching assistant or research positions within the university, or went on to bigger and better things.  This is all understandable and we do not hold it against them for doing what is best for them.

But my perspective is different as I worked within our department for 2 years during undergraduate at which point I was brought on full time upon graduation.

How can we retain students?  We give them hardware they need/want, we provide them with problems to solve in anyway they see fit (within reason).  All in all to me this type of job for a student programmer is so flexible and awesome I cannot see how anyone would want to leave.

Thoughts ?

答:
I interned at a smallish company in school and ended up staying for two years.  One of the things that kept me there, I think, was when I started they had a small (about a month long) project for me to work through that let me learn about the company and let my manager learn my strengths.  I was then able to take on a couple of more substantial project that were more rewarding and interesting to me, and more helpful to the company.

Overall, I think the most important thing with interns is to have one off projects lined up that would be helpful.  If you don't really feel like you made a difference with your time, there are plenty of better ways to spend it.

You'll always get some amount of turnover with interns however.  There's a pretty big incentive to see what different companies are like so you can have an idea of what to look for when you graduate.

ContentLicense: CC BY-SA 2.5


问:
Is it possible for a good programmer to have never used version control?
I am looking for an expert programmer to help solve a difficult situation.

The interviews so far have been surprisingly disappointing. The best candidate so far is a very experienced programmer who has never used version control software.

The problem in itself might not be too serious because it is something which can be learned in a short time.

But there is a deeper aspect, which worries me:

How is it possible to actively develop software for 10-15 years without ever needing version control?

Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?

答:
I would find it strange, but not impossible for an experienced program to have never used dedicated source control.  At one company I worked with, they used source control extensively for their traditional C# and VB code.  But the pure database code (stored procedures and scripts as well as table definitions) were not in source control despite having two professional SQL Developers whose main job was to write, maintain, and execute pure database code.  I championed source control for the database entities there and was only partially successful.

At another company, the development team was small (one man shop for a long time, then two).  The previous developer's source control was have multiple copies of the source files with a date added at the end.  Aside from lacking a better source control system, my predecessor there was definitely competent and a smart man.

Before I became I professional, I was a hobbyist and didn't use any source control at all, I vaguely knew what it was but didn't bother.

In short, I think it odd that a professional wouldn't be very familiar with it, but especially if he is used to very-small teams it is certainly possible to be competent without it.  In hiring, I would not hold that against him.  I would absolutely hold a reluctance to learn and begin using it on the job against him though...


答:
Just as possible as it is for a poor programmer to be an expert on version control.
My point is, I don't know what version control does for your programming skills or problem solving abilities. It is a question of experience. Many smaller shops either don't use it or leave it to the indaviduals (who are often working solo) to figure it out for themselves.</p>

Title: Is it possible for a good programmer to have never used version control?

Body:
I am looking for an expert programmer to help solve a difficult situation.

The interviews so far have been surprisingly disappointing. The best candidate so far is a very experienced programmer who has never used version control software.

The problem in itself might not be too serious because it is something which can be learned in a short time.

But there is a deeper aspect, which worries me:

How is it possible to actively develop software for 10-15 years without ever needing version control?

Is the fact itself of not looking for a solution to the problem of tracking changes a sign of a wrong attitude to programming?


问:
FP for simulation and modelling
I'm about to start a simulation/modelling project. I already know that OOP is used for this kind of projects. However, studying Haskell made me consider using the FP paradigm for modelling a system of components. Let me elaborate:

Let's say I have a component of type A, characterised by a set of data (a parameter like temperature or pressure,a PDE and some boundary conditions,etc.) and a component of type B, characterised by a different set of data(different or same parameter, different PDE and boundary conditions). Let's also assume that the functions/methods that are going to be applied on each component are the same (a Galerkin method for example). The object's mutable state would be used for non-constant parameters.

If I were to use an OOP approach, I would create two objects that would encapsulate each type's data, the methods for solving the PDE(inheritance would be used here for code reuse) and the solution to the PDE.

On the other hand, if I were to use an FP approach, each component would be broken down to data parts and the functions that would act upon the data in order to get the solution for the PDE. Non-constant parameters would be passed as functions of something else (time for example) or expressed by some kind of mutability(emulation of mutability,etc.) This approach seems simpler to me assuming that linear operations on data would be trivial.

To conclude, would implementing the FP approach be actually simpler and easier to manage (add a different type of component or new method to solve the pde) compared to the OOP one?

I come from a C++/Fortran background, plus I'm not a professional programmer, so correct me on anything that I've got wrong.

答:
Good question, I've been thinking along similar lines.  Historically, the OO paradigm arose from the need for computer simulation - see the history of Simula - and despite early OO languages like Smalltalk being made by people who knew what they were doing (i.e. Alan Kay), OO is now arguably over-used and brings in far too much accidental complexity.

Generally, FP style programs will be shorter, easier to test, and easier to modify than OO programs.  As Rob Harrop put it in his talk, Is the Future Functional?, you can never get simpler than functions and data; the two compose infinitely, to build up whatever abstractions are needed.  So one way to answer your question (or am I just restating it? :) is to ask, What's the highest level function, and the highest-level input-data --> output-data look like?  Then you can start breaking down those "alpha" functions and data types into the next layer of abstractions, and repeat as necessary.

Another perspective (not quite answers) on your question is to look at this thread (disclaimer, I started it) on StackOverflow, some of the answers are very interesting: https://stackoverflow.com/questions/3431654/how-does-functional-programming-apply-to-simulations

My own opinion at this point is, unless you're modeling a situation where there really are discrete objects that only interact in definite ways (e.g. a model of a computer network) - and thus map directly to the capabilities of a clean, message-passing-paradigm OO language - it's simpler to go FP.  Note that even in the games-programming community - where simulations are very prevalent and performance requirements are paramount - experienced developers are moving away from the OO-paradigm and/or using more FP, e.g. see this HN discussion or John Carmack's comments on FP

Title: FP for simulation and modelling


问:
What is the motivation behind TypeScript?
We had JavaScript, then we had Flash, then we had Silverlight and then HTML5 ownd them all.

So what is the motivation behind TypeScript? What problems are going to be tackled and what improvements do we get with TypeScript?

http://www.typescriptlang.org/

答:
There are a few good reasons to use TypeScript, as far as I can see. First and foremost, as Mason Wheeler said, a compiler. Or rather all the checking a compiler does. JSLint and other tools are useful, but misses some problems and are sometimes plain wrong. I certainly welcome this "innovation".

Then there is a real type system, improving readability and enforce correct types. After all, this increases development speed.

For me, one of the great things is tooling support. That's probably a side effect of the type system, but nevertheless great. And really necessary, as current JavaScript tooling-support is beyond useful.

TypeScript tries to extend JavaScript. The compiler generates really nice JavaScript. And in addition to this, it follows the ECMAScript 6 proposals. (For example arrow function syntax, parameter default values, modules and so on.

It makes working with modules and classes easier. It is actually possible and quite common to work with classes and modules in JavaScript, but it requires some amount of boilerplate code. And it is not really easy to be read. TypeScript allows to write class-, interface-, and module-statements just like in Java or C#, which is by far easier if you ask me.

But after all, it is still just JavaScript. There is no need to learn a new language, or syntax. The only thing it adds, is the optional type system (which is great and overdue).

Then there is the "definitions library", which means I can use all my JavaScript libs without rewriting, or even patching them. However, I have the additional type system now.

I will definitely give it a try!

One last things, there is no competition between HTML5 and TypeScript. But that's another story.

OwnerDisplayName: Gero


问:
What is the best way to go about testing that we handle failures appropriately?
we're working on error handling in an application. We try to have fairly good automated test coverage. One big problem though is that we don't really know of a way to test some of our error handling.

For instance, we need to test that whenever there is an uncaught exception, a message is sent to our server with exception information. The big problem with this is that we strive to never have an uncaught exception(and instead have descriptive error messages).

So, how do we test something what we never want to actually happen?

答:
So, how do we test something what we never want to actually happen?

Sometimes, you can't, sometimes you don't want to. Boeing doesn't intentionally send a prototype jet into a nose dive 100 feet above the ground to test various "can't happen" type events. A nuclear power plant isn't going to intentionally drive the power plant past the point of no return to see if the tertiary backups work.

This one seems testable. Throw an exception you know isn't caught. Except via a catch-all (e.g., catch (...)), you almost certainly are not catching an exception of type BogusExceptionForTestPurposesOnly. So throw it in some test code. Just make sure this test code never makes it's way into the deliverable.


答: Add a special "break the rules" request to debug builds and invoke it.  For example add a "uncaught throw" request and make it throw a unique condition you think should be uncaught.</p>

Title: What is the best way to go about testing that we handle failures appropriately?

Body:
we're working on error handling in an application. We try to have fairly good automated test coverage. One big problem though is that we don't really know of a way to test some of our error handling.

For instance, we need to test that whenever there is an uncaught exception, a message is sent to our server with exception information. The big problem with this is that we strive to never have an uncaught exception(and instead have descriptive error messages).

So, how do we test something what we never want to actually happen?


答:
My own 2c is that it depends on how he reacted to being asked about VC. The possible reactions might be:

Huh? What's that

No we did  instead

No embarrassed shuffle, management wouldn't allow us

No embarrassed shuffle, but I investigated a little myself and thought it looked like something we should be doing.

In the case of 4, the guy would get a pass from me, he has the right attitude and will probably pick it up fine. In the case of 3, he gets credit for understanding that it's something that should be done but not as much credit as 4. If he was able to name a couple of factoids about VC (list some of the VC packages out there) I'd take that as evidence of some curiosity and might pass him.

If he answered 1 or 2, that is, if he did know and didn't care to know about VC, I would seriously question the judgement of the candidate. There will be other tools (bug tracking, quality metrics, build automation etc. etc.) that he'll need to work with and you'll probably find you have an uphill battle on all of these issues if he's not open to trying new approaches.

Like most people here, I think it would be unfair to disadvantage the candidate just because their employer wasn't up to speed; for me, it all depends on how they reacted to it.


问:
How do you stay motivated for hobby projects?
I started seriously programming as a hobbiest, student and then intern about 4 years ago and I've always done small projects on the side as a learning exercise.  Schools over now though, and I spend my days at work as a software developer. I would still love to do projects on the side to learn about areas in computer science that I'm not exposed to at work, but I've noticed that after 8 hours of starring at an IDE it's far to tempting to veg out.  Any time I do get up the gumption to work on something for a few hours lately it's gotten left by the wayside.

Anyone have any advice for sticking with side projects when you spend most of your day coding?

答:
Yep.  I burn out on coding too.  I love coding and making software, but after a long day (or week, or year) of programming at work ... firing up the ol' IDE at home gets harder and harder.

Lately there have been only two types of side-project that I can stay active with:

1) Contributions to a few open source projects where there is lots of interaction with other developers and users.  It can be hard to find a project that you're interested in, that has developers that you get along with, that needs developers, and that you're skilled enough to contribute to ... but once you've found a comfortable fit, it can be rewarding.

2) Getting permission to work on a few pet projects at work.  For many people this is a non-starter, but if you can swing an arrangement (even one-time only, or occassional), it can be satisfying.  It's a lot easier to get coding when the alternative is the usual grindstone chores at work.

Example on #2: for many years my company used a version control system that, while decent in most regards, was absolutely horrible about showing you your unversioned subfolders on disk.  Everyone had their own little ways of dealing with this nuissance.  I got fed up with it, and asked for time to write a little utility to make dealing with this problem much less painful.  It wasn't the most entertaining code I'd ever written (although there were a few challenging/interesting bits), but the real reward was seeing my coworkers using and enjoying the software, and being thanked for it.


问:
Breaking up a large PHP object used to abstract the database. Best practices?
Two years ago it was thought a single object with functions such as $database->get_user_from_id($ID) would be a good idea. The functions return objects (not arrays), and the front-end code never worries about the database.

This was great, until we started growing the database. There's now 30+ tables, and around 150 functions in the database object. It's getting impractical and unmanageable and I'm going to be breaking it up.

What is a good solution to this problem? The project is large, so there's a limit to the extent I can change things.

My current plan is to extend the current object for each table, then have the database object contain these. So, the above example would turn into (assume "user" is a table) $database->user->get_user_from_id($ID). Instead of one large file, we would have a file for every table.

答:
What i would recommend to you is to make a database class that knows how to run commands aganst the database and return things in a way you like make it expandable and easy to work with so you can do easy things like the following.

```<code>$table('user')->select('*')->where('user_id', 1234, '=')->exec();
</code>```

that will make it easy to expand that is not the best example but look into active record like suggested, also the one in code igniter is pretty good.

Then extend that class will all the tables that you need to work with. or group them byh the type of call that should make it easy for you to be able to keep everything nice and up to date and have smaller classes.

Body:
What i would recommend to you is to make a database class that knows how to run commands aganst the database and return things in a way you like make it expandable and easy to work with so you can do easy things like the following.

$table('user')->select('*')->where('user_id', 1234, '=')->exec();

that will make it easy to expand that is not the best example but look into active record like suggested, also the one in code igniter is pretty good.

Then extend that class will all the tables that you need to work with. or group them byh the type of call that should make it easy for you to be able to keep everything nice and up to date and have smaller classes.


问:
What is logical cohesion, and why is it bad or undesirable?
From the c2wiki page on coupling & cohesion:

Cohesion (interdependency within module) strength/level names : (from
  worse to better, high cohesion is good)

Coincidental Cohesion : (Worst) Module elements are unrelated

Logical Cohesion : Elements perform similar activities as selected from outside module, i.e. by a
  flag that selects operation to perform (see also CommandObject). i.e.
  body of function is one huge if-else/switch on operation flag

Temporal Cohesion : operations related only by general time performed (i.e.
  initialization() or FatalErrorShutdown?())

Procedural Cohesion :
  Elements involved in different but sequential activities, each on
  different data (usually could be trivially split into multiple modules
  along linear sequence boundaries)

Communicational Cohesion : unrelated operations except need same data or input

Sequential Cohesion :
  operations on same data in significant order; output from one function
  is input to next (pipeline)

Informational Cohesion: a module performs
  a number of actions, each with its own entry point, with independent
  code for each action, all performed on the same data structure.
  Essentially an implementation of an abstract data type. i.e. define
  structure of sales_region_table and its operators: init_table(),
  update_table(), print_table()

Functional Cohesion : all elements
  contribute to a single, well-defined task, i.e. a function that
  performs exactly one operation get_engine_temperature(),
  add_sales_tax()

(emphasis mine).

I don't fully understand the definition of logical cohesion.  My questions are:

what is logical cohesion?

Why does it get such a bad rap (2nd worst kind of cohesion)?

答: Logical cohesion can be bad because you end up grouping functionality by technical characteristics rather than functional characteristics. For example, consider an application consisting of multiple modules. Each module represents some business domain and has corresponding data access code. If you group all data access code across all modules then you have logical cohesion. After all, it is all data access and it in some cases it is beneficial to be able to evaluate the data access patterns of an application. This however is problematic because the business domain provides the module boundaries, not the technical domain. By achieving logical cohesion you end up losing on functional cohesion. Typically, the business domain defines a well-defined unit of deployment and technical aspects are there to support the business domain.</p>


答:
The best advice I can give is don't feel guilty when your hobby projects don't receive attention for a considerable amount of time. It is supposed to be fun, and working on something when you don't feel like working on it is hardly entertaining. I have a few such projects and a couple of them have quite a few users. People are used to me making a new release once a year and being receptive to bug reports / patches.

I actually get more of a kick out of seeing other people work on my code than I do working on it myself, in most cases.

The other thing I recommend is use ample discretion when coming back to something you have not seen in a while, just as you would in your day job. The urge to re-build, re-design, re-factor and such can get overwhelming. That is fine, as long as you understand that you'll keep ending up with basically the same thing each time. I find it much more rewarding to work on new features, especially as a hobby project.

Still, anything is much more fun and motivating when you have some partners to play with. Get your project out on sites like freshmeat, surely someone else will think what you came up with is useful and help you to improve it. That's where you really start having some fun :)

Title: How do you stay motivated for hobby projects?

Body:
I started seriously programming as a hobbiest, student and then intern about 4 years ago and I've always done small projects on the side as a learning exercise.  Schools over now though, and I spend my days at work as a software developer. I would still love to do projects on the side to learn about areas in computer science that I'm not exposed to at work, but I've noticed that after 8 hours of starring at an IDE it's far to tempting to veg out.  Any time I do get up the gumption to work on something for a few hours lately it's gotten left by the wayside.

Anyone have any advice for sticking with side projects when you spend most of your day coding?


问:
How can I figure out if programming is right for me?
I have an IT background and was pretty confident until an opportunity came up at work to go into programming(C#). I have never programmed before this, and the software I am programming for is a program I have never used before (a 3D modeling software).

It has been 6 months since then and I feel like giving up. I didn't get much training... about 3 weeks of training spread out over the last 6 months.

I think I would be good at programming but this experience is making me rethink my decision. I'm not sure if it's just me, or if this frustration is normal.

How can I figure out if programming is right for me?

答:
Programming is about problem solving first. The language is secondary.
As soon as you are tasked with writing your first program (by the way, you won't write the code yourself the first time - because it has all been written) and figure out the puzzle... make the connection, you will know right then and there if you want to be a programmer.</p>


答:
First off, forget about tables.  Tables are storage.  Think about your classes instead.  Often classes can be saved in a single table, but not always.  So dont think of them as interchangable.  They are very different things.

What you want to do is move the database queries into your classes.  Keep the database abstraction layer - just use it to execute queries that are passed into it.

So, instead of this:

```<code>$u = $database->user->get_user_from_id($ID);
</code>```

do this:

```<code>$u = new User( $ID);
</code>```

The constructor of the User class would handle loading the user from the db.

```<code>class User
{
   __construct( $id)
   {
      global $database;

      $database->Query( "select name, etc... from users where id = ?", $id);
      //load the object from query result
   }
}
</code>```

You then extend it so that it can do other tasks:

```<code>$u = new User( $ID);
$u->Email = "newemail@some.com";
$u->Save();
</code>```

Where Save() might be

```<code>function Save()
{
   global $database;  //there are other ways to do this, but you get the idea

   $database->query("update users set ......");

}
</code>```

Now you actually have classes doing what they should be doing - the User class worries about users.  The Database class worries about the database connection.

Title: Breaking up a large PHP object used to abstract the database. Best practices?

Body:
Two years ago it was thought a single object with functions such as $database->get_user_from_id($ID) would be a good idea. The functions return objects (not arrays), and the front-end code never worries about the database.

This was great, until we started growing the database. There's now 30+ tables, and around 150 functions in the database object. It's getting impractical and unmanageable and I'm going to be breaking it up.

What is a good solution to this problem? The project is large, so there's a limit to the extent I can change things.

My current plan is to extend the current object for each table, then have the database object contain these. So, the above example would turn into (assume "user" is a table) $database->user->get_user_from_id($ID). Instead of one large file, we would have a file for every table.

Body:
First off, forget about tables.  Tables are storage.  Think about your classes instead.  Often classes can be saved in a single table, but not always.  So dont think of them as interchangable.  They are very different things.

What you want to do is move the database queries into your classes.  Keep the database abstraction layer - just use it to execute queries that are passed into it.

So, instead of this:

$u = $database->user->get_user_from_id($ID);

do this:

$u = new User( $ID);

The constructor of the User class would handle loading the user from the db.

class User
{
   __construct( $id)
   {
      global $database;

      $database->Query( "select name, etc... from users where id = ?", $id);
      //load the object from query result
   }
}

You then extend it so that it can do other tasks:

$u = new User( $ID);
$u->Email = "newemail@some.com";
$u->Save();

Where Save() might be

function Save()
{
   global $database;  //there are other ways to do this, but you get the idea

   $database->query("update users set ......");

}

Now you actually have classes doing what they should be doing - the User class worries about users.  The Database class worries about the database connection.


问:
How do most sync programs monitor file changes?
Do sync programs like Dropbox typically track file changes by doing byte by byte comparisons, or using hashes, or using diff / keeping local commit logs like version control, or what?

答:
Ultimately to compare files you need to compare every byte - how else would you notice a single byte change?

In reality you read blocks of bytes and compute a hash value, you then check against a list of hashes. A good example is "rsync"

As far as I know dropbox only dedupes entire files, so will compute a hash of the entire file to check fro the same file


答:
Speaking from my experience as a programmer on IBM MVS systems: for the first ten years of my working career, the operating system I worked with had exactly one versionable filetype available to the programmer: the generation data set. This was essentially a file with a fixed number of versions, and you had to remember what version was what - pretty much useless for modern version control. Coupled with a filesystem that had no real directories, just more or fewer (8-character) qualifiers, the concept of a source-code management system was completely foreign to anyone working in that environment.

I didn't actually see a source-code control system until I moved to SunOS 3 and got to use RCS. At that point I was an extremely facile IBM systems programmer, highly productive, and very good at my job. All versioning was handled by copying backups to tape, and recording what was where.

If I were still working on mainframes at this point, it's entirely possible that I might still have never have been exposed to a formal version control system; the alternatives that are specifically supported are ClearCase and Rational, neither of which is free (and in point of fact are both quite expensive).

So saying that someone is by definition incompetent because he or she has never used version control is a specious argument. It is necessary to dig in and look at the details. If they claim to be a Linux/Unix/Mac OS developer but have never ever used version control, it speaks less well for them, and you may have to weigh whether their overall experience is such a good fit that you'd be willing to train them in modern software engineering. If they're and old-school mainframe programmer - and that's what you need - then concentrate on whether they have precisely the needed programming skills you want, and resign yourself to the fact that you'll need to teach this to them. As others have said, their response to the concept will be the deciding factor in that case.


答:
On Windows there's a mechanism to have the OS alert you when there's a change to a 'watched' directory structure - FindFirstChangeNotification().  When that indicates a file has changed, an application can then go about comparing files in the changed directory to find the actual files that have changed by looking at size, modified date, hash, etc.

This (as Michael points out below) is something that each platform would provide in some manner.  I wasnt saying this sort of thing was unique to Windows.

Title: How do most sync programs monitor file changes?

Body: Do sync programs like Dropbox typically track file changes by doing byte by byte comparisons, or using hashes, or using diff / keeping local commit logs like version control, or what?


答: .NET for instance has a FileSystemWatcher class.  I'm sure other low-level languages and runtimes can provide similar capabilities.  </p>


答: The only way to stay motivated is to have goals. If you have no goal you will get nowhere. Personally I find merely academic projects not very motivating but if I have a goal of creating a product, ie shareware, it is much easier to keep the motivation up.</p>


问:
What makes for a good JIRA workflow with a software development team?
I am migrating my team from a snarl of poorly managed excel documents, individual checklists, and personal emails to manage our application issues and development tasks to a new JIRA project. My team and I are new to JIRA (and issue tracking software in general). My team is skeptical of the transition at best, so I am also trying not to scare them off by introducing something overly complex at the start.

I understand one of JIRA's strengths to be the customized workflows that can be created for a project. I've looked over the JIRA documentation and a number of tutorials, and am comfortable with the how in creating workflows, but I need some contextual What to go along with it.

What makes a particular workflow work well?

What does a poorly designed workflow look like?

What are the benefits/drawbacks of a strict workflow with very specific states and transitions to a looser workflow, with fewer, broader defined states and transitions

答:
I'd start with three steps. To do, in progress, in production. Let the other states and transitions evolve as needed.

This technique is known as "paving the cow path" Rather than determining up front the most optimal approach to a new process...let the process evolve naturally.

To give an example of some steps you might fold into your process down the road, In Progress to In Production are very broad strokes. You might want to identify steps between the two such as: In QA, In UAT, and Ready for Deployment.

Essentially, I'm nudging you toward Kanban, David Anderson's book is a great resource for learning and leveraging it in your organization.


答:
From how it is described, I would say it is about coupling code together that has some cohesion, but breaks object orientation.

Example: calculation of a polygon's area.
When you put the calculation for the square together with the calculation for the triangle, and only choose by the input-param, then you have grouped two things logically by their outcome, not taking into account their real nature.

Title: What is logical cohesion, and why is it bad or undesirable?

Body:
From the c2wiki page on coupling & cohesion:

Cohesion (interdependency within module) strength/level names : (from
  worse to better, high cohesion is good)

Coincidental Cohesion : (Worst) Module elements are unrelated

Logical Cohesion : Elements perform similar activities as selected from outside module, i.e. by a
  flag that selects operation to perform (see also CommandObject). i.e.
  body of function is one huge if-else/switch on operation flag

Temporal Cohesion : operations related only by general time performed (i.e.
  initialization() or FatalErrorShutdown?())

Procedural Cohesion :
  Elements involved in different but sequential activities, each on
  different data (usually could be trivially split into multiple modules
  along linear sequence boundaries)

Communicational Cohesion : unrelated operations except need same data or input

Sequential Cohesion :
  operations on same data in significant order; output from one function
  is input to next (pipeline)

Informational Cohesion: a module performs
  a number of actions, each with its own entry point, with independent
  code for each action, all performed on the same data structure.
  Essentially an implementation of an abstract data type. i.e. define
  structure of sales_region_table and its operators: init_table(),
  update_table(), print_table()

Functional Cohesion : all elements
  contribute to a single, well-defined task, i.e. a function that
  performs exactly one operation get_engine_temperature(),
  add_sales_tax()

(emphasis mine).

I don't fully understand the definition of logical cohesion.  My questions are:

what is logical cohesion?

Why does it get such a bad rap (2nd worst kind of cohesion)?


答:
There are few possible reasons to not use version control:

Working in companies which are not doing software development as their main line of business.

Or if the developer has decided to use some other system - only valid for experienced ones.

Or if the developer has not yet learned how each system works

Or it's attitude problem against the tools which they're unfamiliar

But you should be careful when you meet people who assume:

That there is only one way to do something

Or that every programmer must do it the same way they're doing

Or that the practices people are using are easy to change


答:
Experience matters and you are correct that the mechanics of using source control tools can be learned pretty quickly.  But you are right to see a red flag.

Is your candidate isolated from the profession and its trends?

Will the many other aspects of working in a team also need to be learned?

For me, the issue about version control is more of a symptom than the disease.  The cause may vary, and be pretty benign.  A lot of ad-hoc programmers just started doing what they thought made sense, starting with a few books about programming, and did not make a systematic study of software development.  Sometimes, more so in the old days, computer science majors would graduate without ever having used a source control system because all their projects were individual projects and they went to companies with highly immature software process.

However he got there, if he has been a lone wolf for a decade or more, it may make living with people hard to do.

It might be worth asking if your candidate a few more probing questions.

Tell me about a time you worked as part of a team?

Tell me about a time when a team you worked on had a conflict between team members?

Tell me about a time when you received code from another developer and carried his project forward?

Tell me how you and other members of your team kept out of each others way when creating code together?

Tell me about a customer reported problem related to a feature that used to work, but didn't work in a later version?  How did you solve it?

What do you like about working in a team?

He may also be accustomed to having nearly complete control over his methods, processes, and being in a role where he is the sole software expert.  You will want someone who will be open to a new way of doing things.  More questions:

Tell me about a time you used or helped create a coding standard?

What kinds of things do you want to see in a coding standard?

How do you feel about rewriting someone else's code?

Tell me about a time you were involved in peer reviews of software or documentation?

Can you tell me about a proposal or contract for software development that you were involved in writing?

Tell me about your favorite software manager or supervisor?

Tell me about your favorite coworker or subordinate?


答:
I think it's not so much a question of "How is it possible to actively develop software for 10-15 years without ever needing version control?", but "How is it possible to actively develop software for the last 10-15 years without ever needing version control?".

Sure programming is possible without version control, but a professional ought to be familiar with the current state of the art, and be able to select the right tools to do the job. Failing to use the appropriate version management software makes your work risky and unreliable, and one of the reasons you want to hire a professional developer is that they ought to be able to manage risk.

A code-base that is properly annotated in a VCS is worth far more than one which is not. The reason for every change can be tracked and understood, making it possible for maintainers to get a deeper grasp of what they need to know. Failing to do this is unprofessional, and the only excuse for it would be if he/she had been constrained by poor managers at his/her previous job. Even then, shouldn't they have used versioning for their private projects?


答:
Pretty please! The entirety of our community doesn't live in highly-developed social communities where geeky hangouts and hacky events are overly abundant, neither do we all work in software development companies and some of us cannot even find relevant or up-to-date published resources in our native languages, printed or online, let ever encounter a fellow programmer in the flesh.

For all I can understand, if he's an experienced software developer as you say, then he's likely been a lone wolf working as a freelancer for small businesses.


问:
Why don't computers store decimal numbers as a second whole number?
Computers have trouble storing fractional numbers where the denominator is something other than a solution to 2^x.  This is because the first digit after the decimal is worth 1/2, the second 1/4 (or 1/(2^1) and 1/(2^2)) etc.

Why deal with all sorts of rounding errors when the computer could have just stored the decimal part of the number as another whole number (which is therefore accurate?)

The only thing I can think of is dealing with repeating decimals (in base 10), but there could have been an edge solution to that (like we currently have with infinity).

答:
It sounds like you're describing fixed-point numbers.

Bear in mind that storing the fractional part of a number in a separate location is precisely identical to creating a single space, twice as long, and storing the whole and fractional part in the two separate halves. In other words, it's identical to storing the number as an integer but simply assuming a fixed number of decimal spaces.

Normally floating-point numbers are stored using a binary variation on scientific notation because what usually matters is significant digits. Many other methods exist though. Fixed-point decimal numbers are commonly used for example for storing currency values, where accuracy is critical up to a certain whole number of decimal places but the number of required decimal digits never changes.


答:
Pick a project that you're genuinely interested in.

Spend a little time up front defining your goals for the project.

Break the project up into small phases so that it doesn't take hours and hours of work to feel a sense of accomplishment.


答:
Floating point numbers represent a vast range of values, which is very useful when your don't know ahead of time what the values might be, but it's a compromise.  Representing 1/10^100 with a second integer wouldn't work.

Some languages (and some libraries) have other characteristics.  Lisp traditionally has infinite precision integers. Cobol has calculations with fixed point decimal numbers.

You have to select your number representation appropriate to the problem domain.

Title: Why don't computers store decimal numbers as a second whole number?

Body:
Computers have trouble storing fractional numbers where the denominator is something other than a solution to 2^x.  This is because the first digit after the decimal is worth 1/2, the second 1/4 (or 1/(2^1) and 1/(2^2)) etc.

Why deal with all sorts of rounding errors when the computer could have just stored the decimal part of the number as another whole number (which is therefore accurate?)

The only thing I can think of is dealing with repeating decimals (in base 10), but there could have been an edge solution to that (like we currently have with infinity).


答:
There are actually modes of numbers that do that.

Binary-coded decimal (BCD) arithmetic has the computer work in base 10.  The reason you run into this rarely is that it wastes space: each individual digit of a number takes a minimum of four bits, whereas a computer could otherwise store up to 16 values in that space.  (It can also be slower, but it's possible to have hardware-accelerated BCD math that works just fine.). This is, in fact, exactly what most calculators do, which is why there are certain classes of rounding problems you'll never hit on a $5 Casio that will eat your lunch on a desktop computer.

The other route you can take is to use rational numbers--that is, a numerator and a denominator, stored as integers.  This is actually available in nearly all languages, is exact, and allows you to store everything in native binary formats.  The problem is that, at the end of the day, users probably do not want to see fractions like 463/13, nor even 35 and 8/13.  They want to see 35.615..., and the moment you get there, you face all the typical problems.  Add in that this format takes even more space, and can be significantly slower than floating point arithmetic, and you'll find no computers use this format by default.

So: computers can do what you want, but it's slow and it wastes space, so they only do it when they really have to.  The rest of the time, the speed and space savings of floating point are a better trade-off.


答: Fossil is the way to go.  It provides DVCS, bug tracking and wiki in a single tool.  It has really been a productivity booster for us.</p>

Title: Project Management Software / 1 maybe 2 developers

Body:
I am looking for software that I can use to "manage" multiple projects (5 - 10). Here are the features I would like but any recommendation is welcome.

Bug/Feature tracking on a per project basis.

Some way to keep all documents, diagrams, specs, requirements, in one place with the project. Better yet a tool where all these things or most of them could be authored.

Task management during the development phase with milestones and estimates/actuals.

Git integration

I have been doing contract work and i have been doing really well for myself as far as getting projects but its becoming VERY hard to manage everything in an efficient manner. I am trying to learn about best practices when it comes to software programming methodologies and the more I read the more i realize that I am just managing these projects poorly. I am getting things done but the more I take on the less "solid" everything is. I am afraid if I don't get some good solid tools/practices in place I am going to do my customers and myself a disservice. The problem is that there are SO many options that its hard to weed through them all. I was at a point today where I had decided that I would just code my own (there is some irony here)!

Obviously everyone has their likes dislikes I would love to hear from some of you lone programmers and how you manage everything since our needs aren't exactly the same thing that a large team might need. I also want a solution that can scale to 2 maybe 3 developers if I end up hiring some people to help with my work load.

Thanks again for your usual insights!


问:
How do I implement the bg, &, and fg commands functionaliity in my custom unix shell program written in C
I am extending the functionality of a custom unix shell which I wrote as part of my lab assignment. It currently supports all commands through execvp calls, in-built commands like pwd, cd, history, echo and export, and also redirection and pipes. Now I wanted to add support for running a command in background e.g. $ls -la&  I also want to implement bg and fg job control commands.

I know this can be achieved if I execute the command by forking a new child process and not waiting for it in the parent process. But how do I again bring this command to foreground using fg? I have the idea of entering each background command in a list assigning each of them a serial number. But I don't know how do I make the processes execute in the background, then bring them back to foreground. I guess wait() and waitpid() system calls would come handy but I am not that comfortable with them. I tried reading the man pages but still am in the dark. Can someone please explain in a layman's language how to achieve this in UNIX system programming? And does it have something to do with SIGCONT and SIGSTP signals?

答:
Suspending a command (CTRL-Z) works by sending a SIGTSTP to the child process. The shell is then free to interact with the user via stdin/stdout.

Resuming is accomplished by sending SIGCONT to the child process and then continuing to wait for it to finish.

Backgrounding a process is accomplished by sending SIGCONT but not waiting for it to finish. In this case, both the shell and the child process can interact with stdout/stderr, but stdin is typically intercepted by the shell.

Starting a process in the background is accomplished by doing a fork/exec, but not blocking until the child process exists.

Typically (as in always) a shell will also handle SIGCHLD, which is the way the OS notifies the parent process that a child processes has finished so that the parent can collect the exit code. Otherwise you end up with "zombie" processes; ones which aren't running but which haven't yet been collected by a parent.


答:
In the year 2012, for someone with 15 years of industry experience never to have used version control is a red flag. It might not be such a red flag if the year was 1982, or even 1992. But today, there had better be an excellent explanation for this puzzling gap in that developer's background.

Extraordinary situations require extraordinary explanations.

This is somewhat like a car mechanic who claims he's been fixing cars for 15 years, but never got so much as a spot of grease on himself.

Of course, smearing yourself with grease will not fix a transmission, and none of the steps in the repair manual call for such a thing, but that is not the point. The point is that being squeaky clean is gapingly inconsistent with what car mechanics actually look like when they are working. In that work, you get grease on yourself.

If you're interviewing someone experienced who admits he has no version control experience, he's probably exaggerating or fabricating some of his experience (and doesn't even know that version control is something widely used and important, and something he should also lie about!)

It's possible to see all kinds of jokers in interviews. I've seen people who cannot draw a diagram of a linked list, or write a function which inserts a node at the head of a linked list. Yet they claimed 20 years of work experience.

Even new grads from computer science can be expectd to have passive familiarity with version control, even if they haven't yet made extensive use of it.


答:
Writing what's changed is good when looking back. It has saved me a lot of times when figuring what's wrong and loads of problems were fixed quickly because I had it written down. In my opinion, it's good to keep an log. Especially if you are programming with more people than yourself.

If you are writing a web app, you can keep adding feautures with no version control because you are constantly just adding new things to it. But maybe you will write a log or a news post with the things that's new.

It's all about what you are programming on.


答:
I don't always stay motivated, but I find that when I tell other folks what I'm working on, I frequently end up spending so much energy discussing (aka arguing why I'm doing it X-way and not Y-way like the arguer thinks it should be done) that I lose interest in working on the project. So my "secret" is to not talk about stuff until after I've done enough to call it done.

My goals are frequently of the scale of "learn how to use M" or "how can you do N?" so the done-ness of the goal is usually distinct from the done-ness of the project.

My current employer takes the position (in the employment agreement) that I can't work on open source stuff, nor am I supposed to work on the side without written permission from above. Consequently, I don't work towards complete projects.


答:
We use Jira with an overly complex/customized work-flow thats supposed to be good for a small one man iOS game through to the next space shuttle deployment. Even as a team leader I cannot do things without getting an administrator involved. I cannot for instance, roll a defect marked as "fixed" back one step to "in action", so if I (or a team member) "fixes" a defect and then sees its not really fixed, it's off to an admin to get Jira fixed. Don't do this - your team will be justified in there skepticism.

.....Thats not Jira's fault.....

Things to keep in mind.
Jira is a tool to enable people to get their work done. As soon as it stops that happening, it's not doing what it is supposed to.

Jira has powerful reporting features - use them rather than work-flow that hinders getting the job done.

People normally want to do the right thing - make that easy. People sometimes have to do the wrong thing - make that possible. Use reporting and audit rather than command and control. e.g. "You should not be able to close a defect without it being verified by the test department, but the customer and CEO have decided the fix must go out today." - Developer closes defect and puts in comments "By Order of CEO"

Above all - KISS, It's not rocket science. Not every edge case need a custom way to deal with it - don't - edge cases are better deal with though comments and flexible work-flow.

Title: What makes for a good JIRA workflow with a software development team?

Body:
I am migrating my team from a snarl of poorly managed excel documents, individual checklists, and personal emails to manage our application issues and development tasks to a new JIRA project. My team and I are new to JIRA (and issue tracking software in general). My team is skeptical of the transition at best, so I am also trying not to scare them off by introducing something overly complex at the start.

I understand one of JIRA's strengths to be the customized workflows that can be created for a project. I've looked over the JIRA documentation and a number of tutorials, and am comfortable with the how in creating workflows, but I need some contextual What to go along with it.

What makes a particular workflow work well?

What does a poorly designed workflow look like?

What are the benefits/drawbacks of a strict workflow with very specific states and transitions to a looser workflow, with fewer, broader defined states and transitions


答:
There are numerous ways of storing fractional numbers, and each of them has advantages and disadvantages.

Floating-point is, by far, the most popular format. It works by encoding a sign, a mantissa, and a signed base-2 exponent into integers, and packing them into a bunch of bits. For example, you could have a 32-bit mantissa of 0.5 (encoded as 0x88888888) and a 32-bit signed exponent of +3 (0x00000003), which would decode to 4.0 (0.5 * 2 ^ 3). Floating-point numbers are fast, because they are implemented in hardware, and their precision scales with absolute size, that is, the smaller the number, the better your absolute precision, so the relative rounding error stays constant with absolute size. Floats are excellent for values sampled from a continuous domain, such as lengths, sound pressure levels, light levels, etc., and because of that, they are commonly used in audio and image processing, as well as statistical analysis and physics simulations. Their biggest downside is that they are not exact, that is, they are prone to rounding errors, and they cannot accurately represent all decimal fractions. All the mainstream programming languages have a float point of some sort.

Fixed-point works by using sufficiently large integers and implicitly reserving a part of their bits for the fractional part. For example, a 24.8 bit fixed-point number reserves 24 bits for the integer part (including sign), and 8 bits for the fractional part. Right-shifting that number by 8 bits gives us the integer part. Fixed-point numbers used to be popular when hardware floating-point units were uncommon or at least much slower than their integer counterparts. While fixed-point numbers are somewhat easier to handle in terms of exactness (if only because they are easier to reason about), they are inferior to floats in pretty much every other regard - they have less precision, a smaller range, and because extra operations are needed to correct calculations for the implicit shift, fixed-point math today is often slower than floating-point math.

Decimal types work much like floats or fixed-point numbers, but they assume a decimal system, that is, their exponent (implicit or explicit) encodes power-of-10, not power-of-2. A decimal number could, for example, encode a mantissa of 23456 and an exponent of -2, and this would expand to 234.56. Decimals, because the arithmetic isn't hard-wired into the CPU, are slower than floats, but they are ideal for anything that involves decimal numbers and needs those numbers to be exact, with rounding occurring in well-defined spots - financial calculations, scoreboards, etc. Some programming languages have decimal types built into them (e.g. C#), others require libraries to implement them. Note that while decimals can accurately represent non-repeating decimal fractions, their precision isn't any better than that of floating-point numbers; choosing decimals merely means you get exact representations of numbers that can be represented exactly in a decimal system (just like floats can exactly represent binary fractions).

Rational numbers store a numerator and a denumerator, typically using some sort of bignum integer type (a numeric type that can grow as large as the computer's memory constraints allow). This is the only data type out of the bunch that can accurately model numbers like 1/3 or 3/17, as well as operations on them - rationals, unlike the other data types, will produce correct results for things like 3 * 1/3. The math is pretty straightforward, although coming up with an efficient factoring algorithm is rather challenging. Some programming languages have rational types built into them (e.g. Common Lisp). Downsides of rationals include that they are slow (many operations require reducing fractions and factoring their components), and that many common operations are hard or impossible to implement, and most implementations will degrade the rational to a float when this happens (e.g. when you call sin() on a rational).

BCD (Binary Coded Decimal) uses "nibbles" (groups of 4 bits) to encode individual digits; since a nibble can hold 16 different values, but decimal numbers require only 10, there are 6 "illegal" values per nibble. Like decimals, BCD numbers are decimal-exact, that is, calculations performed on decimal numbers work out just like they would if you did them using pen and paper. Arithmetic rules for BCD are somewhat clumsy, but the upside is that converting them to strings is easier than with some of the other formats, which is especially interesting for low-resource environments like embedded systems.

Strings, yes, plain old strings, can also be used to represent fractional numbers. Technically, this is very similar to BCD, only that there's an explicit decimal dot, and you use one full byte per decimal digit. As such, the format is wasteful (only 11 out of 256 possible values are used), but it is easier to parse and generate than BCD. Additionally, because all the used values are "unsuspicious", harmless, and platform-neutral, string-encoded numbers can travel over networks without problems. It is uncommon to find arithmetic being done on strings directly, but it is possible, and when you do it, they are just as decimal-exact as the other decimal formats (decimals and BCD).


答:
I never considered myself a "programmer" until I started making money doing it professionally.

I've made quite a bit of money creating systems which made clients even more money. Whether or not I am a "good" developer is subjective.

I can GSD (Get Something Done) rapidly, which for web development has usually pleased my clients. They may not see some ugly code behind the scenes, lack of comments, etc.

I hadn't used Git and didn't have a Github profile until this year, which I feel is way "behind the times" in terms of modern programmer standards. I've also just started doing Rails and Django projects after only having done PHP, Flash and iOS in the past. I've since landed contracts developing sites in both for clients and for me, it's not been too painful to learn something new at all at 30 years of age and a few years out of programming.

Too much in modern day society focuses on keeping up with the Jones' and caring what other people think. If you can break off those shackles and consider what you need for your software development (speed/time to market, optimized resource management, well documented code, scalability, etc), then that may matter a lot more than whether someone knows Mercurial, SVN, Git or any other version control systems.

I prefer to ask developer candidates what they are passionate about, what is the coolest system they have ever made in their own opinion and what they spend their free time developing their skills in. If people don't advance their skills in their own time, that scares me more than other things, but doesn't mean it has to scare you.

I think you have some great answers to this question already from the people here and that should help you make your own informed decision based on your requirements.


问:
"Do you have any questions for us?" In an interview
You know the prospective company fairly well but are asked "Do you have any questions for us?".  To show interest, what are some of your favorite questions to reply?</p>

答:
I always ask what the company policies around training and personal development are.

do the have a budget for software or software related seminars? (e.g. Spring Core Training)

if a new technology or framework is being implemented, will you offer a group seminar?

do you reimburse staff for job related books, or have a company library?

do you allow employees to dedicate any percentage of their time other projects? (e.g. investigating and prototyping with new technologies)

How the answer, or react, to these questions gives you a decent indication of how interested they are in your growth as a developer.


问:
Does JAXP natively parse HTML?
So, I whip up a quick test case in Java 7 to grab a couple of elements from random URIs, and see if the built-in parsing stuff will do what I need.

Here's the basic setup (with exception handling etc omitted):

```<code>DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
DocumentBuilder dbuild = dbfac.newDocumentBuilder();
Document doc = dbuild.parse("uri-goes-here");
</code>```

With no error handler installed, the parse method throws exceptions on fatal parse errors.

When getting the standard Apache 2.2 directory index page from a local server: a SAXParseException with the message White spaces are required between publicId and systemId. The doctype looks ok to me, whitespace and all.

When getting a page off a Drupal 7 generated site, it never finishes. The parse method seems to hang. No exceptions thrown, never returns.

When getting http://www.oracle.com, a SAXParseException with the message The element type "meta" must be terminated by the matching end-tag "</meta>".

So it would appear that the default setup I've used here doesn't handle HTML, only strictly written XML.

My question is: can JAXP be used out-of-the-box from openJDK 7 to parse HTML from the wild (without insane gesticulations), or am I better off looking for an HTML 5 parser?

PS this is for something I may not open-source, so licensing is also an issue :(

答: This Stack Overflow answer has a couple of solutions. JAXP apparently only works on well formed XML. You'd need to convert the HTML to XHTML before subjecting it to the JAXP's standard parser.</p>

Title: Does JAXP natively parse HTML?


问:
Ruby: how to step through ruby code
I'm trying to learn how to step through Ruby code (written by more experienced programmers) in order to improve my knowledge of Ruby. Problem is that I don't really know how to do it well. Googling the topic brought me to an about.com page on Ruby; I thought a higher quality more comprehensive answer should belong on StackOverflow, so if anyone can write an answer (with an example) for it, showing how a beginner can step through code to learn as much as possible about it, it'd be much appreciated. </p>

答:
What you're looking for is a debugger.  With ruby 1.8, the ruby-debug gem provides the canonical one, and in ruby 1.9, the debugger gem provides a version of its successor that is well-maintained.

Start your program with the gem loaded, for example ruby -rdebugger yourfile.rb, and you'll have access to the debugger.

The debugger kicks in at a breakpoint, which is a signal to suspend execution, and give you a chance to poke around.  Typically, the easiest way to set a breakpoint is to add a source line at the point in execution you're interested in. Inserting a call to debugger, does this.  Lets debug this function that asks for a user name, but restricts it to doctors.  It's not letting "Dr. Bob" log in:

```<code>def get_user
  debugger  # This is where we break.
  name = ""
  begin
    print "What is your name?: "
    name = gets
  end until name.match /\ADr /
  puts "Welcome, #{name}."
  name
end

user = get_user
</code>```

Lets launch it:

```<code>ruby -rdebugger login.rb
</code>```

The program starts executing, then the debugger breaks us at line four. It shows us the next statement which is to be executed next.  We can get a more complete listing of our surroundings by typing l.

```<code>(rdb:1) l
[-1, 8] in login.rb
   1
   2  def get_user
   3    debugger
=> 4    name = ""
   5    begin
   6      print "What is your name?: "
   7      name = gets
   8    end until name.match /\ADr /
</code>```

You can examine the result of expressions by using the p command. p name will show us that the name variable is an empty string at this point of execution.

n steps, which executes the next line, and returns control to the debugger.  s will allow you to step into a method call.  c continues execution until the program terminates, or hits another breakpoint.  In this case, we'd probably want to use the n command to trace the execution of this method.  Just these handful of commands describes the vast majority of my debugging sessions.

The debugger has has interactive help which can be accessed with help.  A more conversational tutorial on the web is: Debugging with ruby-debug

Title: Ruby: how to step through ruby code

Body:
What you're looking for is a debugger.  With ruby 1.8, the ruby-debug gem provides the canonical one, and in ruby 1.9, the debugger gem provides a version of its successor that is well-maintained.

Start your program with the gem loaded, for example ruby -rdebugger yourfile.rb, and you'll have access to the debugger.

The debugger kicks in at a breakpoint, which is a signal to suspend execution, and give you a chance to poke around.  Typically, the easiest way to set a breakpoint is to add a source line at the point in execution you're interested in. Inserting a call to debugger, does this.  Lets debug this function that asks for a user name, but restricts it to doctors.  It's not letting "Dr. Bob" log in:

def get_user
  debugger  # This is where we break.
  name = ""
  begin
    print "What is your name?: "
    name = gets
  end until name.match /\ADr /
  puts "Welcome, #{name}."
  name
end

user = get_user

Lets launch it:

ruby -rdebugger login.rb

The program starts executing, then the debugger breaks us at line four. It shows us the next statement which is to be executed next.  We can get a more complete listing of our surroundings by typing l.

(rdb:1) l
[-1, 8] in login.rb
   1
   2  def get_user
   3    debugger
=> 4    name = ""
   5    begin
   6      print "What is your name?: "
   7      name = gets
   8    end until name.match /\ADr /

You can examine the result of expressions by using the p command. p name will show us that the name variable is an empty string at this point of execution.

n steps, which executes the next line, and returns control to the debugger.  s will allow you to step into a method call.  c continues execution until the program terminates, or hits another breakpoint.  In this case, we'd probably want to use the n command to trace the execution of this method.  Just these handful of commands describes the vast majority of my debugging sessions.

The debugger has has interactive help which can be accessed with help.  A more conversational tutorial on the web is: Debugging with ruby-debug


问:
How are operators organized in memory
How are operators organized/saved in the memory in context of a programming language.  Are they procedures/functions saved somewhere and compilers just manipulate things to call these procs whenever the operators are used in the program? </p>

答:
In a language like C or C++, simple native types like int, char, float, double in full features architectures with floating point hardware may typically become sequential machine instructions like the other statements in the code block.

In an architecture that does not have native floating point hardware (or even 32 bit ints), simple expressions may generate subroutine calls to run time libraries that supplement the device's basic capabilities.  I did an experiment with some eight bit micros vs. an X86 compiler a few years back and found big differences in the size of code generated.  x86 was 1/3 as big, and unlike the 8 bit architectures that had many run time calls for simple things like adding 32-bit and 64-bit integers, it was all generated by instructions sequences.

Often constants are inserted with the instructions as immediate operands.  In some architectures, the immediate data will be pushed on the stack or written relative to a stack pointer or a base pointer.  In an executable, the inserted instructions and the immediate operands will typically be in the code segment.  For complex data like arrays, strings, and user defined variables, if they are constant, they too may be emitted to a code segment, but what is more common is that during run time they are copied to a data segment that is initialized by the loader or the run time system.

Compilers have many methods of optimizing expressions, so if you single step and see what seems like very few instructions relative to an expression, it may mean that the constants in the expression were simplified.  There is also a technique in which common subexpressions are evaluated once before the first usage, then when needed again, the partial result is just used from a temporary variable or a register.

This group, or Stack Exchange Code Review would perhaps be a great venue to explain what is happening if you have additional questions about a block of source code and the machine instructions that it generates, particularly as relates to compiler optimizations.

When operators or expressions are used with complex data types like arrays, strings, structs, or classes, there may be some cases where things are performed sequentially, but generally, more complex types required functions calls.  A worthwhile exception to this is when a compiler provides OpenMP extensions that perform fine grain parallelism on small blocks of code that is dispatched across multiple cores.  But as interesting as it might be, the details are probably out of scope for this question.

Title: How are operators organized in memory


问:
How to take a step back and look at code with fresh eyes?
I've spent the last year as a one-man team developing a rich-client application (35,000+ LoC, for what it's worth). It's currently stable and in production. However, I know that my skills were rusty at the beginning of the project, so without a doubt there are major issues in the code. At this point, most of the issues are in architecture, structure, and interactions -- the easy problems, even architecture/design problems, have already been weeded out.

Unfortunately, I've spent so much time with this project that I'm having a hard time thinking outside of it -- approaching it from a new perspective to see the flaws deeply buried or inherent in the design.

How do I step outside my head and outside my code so I can get a fresh look and make it better?

答:
Have you considered leaving and finding a company where you can be in a team?  I feel very strongly that isolated or in a stagnant team, developers miss out on a lot the profession has to offer.

Peer reviews let someone who is already outside your head give your advice.  Stack Exchange Code Review might be a good place to put some code that isn't particularly proprietary to your company out for review.  It probably can't handle huge blocks, but many programs are made of a lot of simple code and some other code that is not simple and creates a lot of the problems.  If you have an example of some code that is typical, but gets repeated and altered many places, it might also be a good review candidate.  For example, if you format messages, don't ask to have all the message passing reviewed, just one fairly complex example message.

If you want to be more objective about your own code, I guess you could compare it to a coding standard, run static or dynamic code checkers on it, or if you are sparsely documented, adding comments might help.

There is a psychology of testing that makes it hard to test your own code but we certainly try our best to do so during unit test.  Reading your own code can be a similar, or worse problem.  Many fields use mentors, competitive judging, coaches, etc.  Our does too if you count architects, system engineers, and testers.  Customers with access to a bug reporting tool or customer support department will give you feedback from outside your head once the product is fielded.  This is another great reason for Agile's approach of releasing early and often.  You may be the sole developer in your company, but there are people affected by your code who can give you feedback about it from some angle.


问:
Why does Scala require functions to have explicit return type?
I recently began learning to program in Scala, and it's been fun so far. I really like the ability to declare functions within another function which just seems to intuitive thing to do.

One pet peeve I have about Scala is the fact that Scala requires explicit return type in its functions. And I feel like this hinders on expressiveness of the language. Also it's just difficult to program with that requirement. Maybe it's because I come from Javascript and Ruby comfort zone. But for a language like Scala which will have tons of connected functions in an application, I cannot conceive how I brainstorm in my head exactly what type the particular function I am writing should return with recursions after recursions.

This requirement of explicit return type declaration on functions, do not bother me for languages like Java and C++. Recursions in Java and C++, when they did happen, often were dealt with 2 to 3 functions max. Never several functions chained up together like Scala.

So I guess I'm wondering if there is a good reason why Scala should have the requirement of functions having explicit return type?

答:
Scala doesn't require an explicit return type on all functions, just recursive ones.  The reason for that is that Scala's type inference algorithm is (something close to) a simple scan from beginning to end that is incapable of lookahead.

This means that a function like this:

```<code>def fortuneCookieJoke(message: String) = message + " in bed."
</code>```

doesn't need a return type, since the Scala compiler can clearly see, without using logic variables or looking at anything other than the method's parameters, that the return type must be String.

On the other hand, a function like this:

```<code>def mapInts(f: (Int) => Int, l: List[Int]) = l match {
  case Nil => Nil
  case x :: xs => f(x) :: mapInts(f, xs)
}
</code>```

will cause a compile-time error, because the Scala compiler cannot see, without using either lookahead or logic variables, exactly what the type of mapInts is.  The most it could say, if it were smart enough, is that the return type is a supertype of List[Nothing], since Nil is of that type.  That doesn't give it anywhere near enough information to accurately determine the return type of mapInts.

Please note that this is specific to Scala, and that there are other statically typed languages (most of the Miranda/Haskell/Clean family, most of the ML family, and a few scattered others) that use much more comprehensive and capable type inference algorithms than Scala uses.  Also, be aware that this is not entirely Scala's fault; nominal subtyping and whole-module type inference are fundamentally at odds with each other, and the designers of Scala chose to favor the former over the latter for the sake of Java compatibility, while the "purer" statically typed functional languages were mostly designed with the opposite choice in mind.

Body:
Scala doesn't require an explicit return type on all functions, just recursive ones.  The reason for that is that Scala's type inference algorithm is (something close to) a simple scan from beginning to end that is incapable of lookahead.

This means that a function like this:

def fortuneCookieJoke(message: String) = message + " in bed."

doesn't need a return type, since the Scala compiler can clearly see, without using logic variables or looking at anything other than the method's parameters, that the return type must be String.

On the other hand, a function like this:

def mapInts(f: (Int) => Int, l: List[Int]) = l match {
  case Nil => Nil
  case x :: xs => f(x) :: mapInts(f, xs)
}

will cause a compile-time error, because the Scala compiler cannot see, without using either lookahead or logic variables, exactly what the type of mapInts is.  The most it could say, if it were smart enough, is that the return type is a supertype of List[Nothing], since Nil is of that type.  That doesn't give it anywhere near enough information to accurately determine the return type of mapInts.

Please note that this is specific to Scala, and that there are other statically typed languages (most of the Miranda/Haskell/Clean family, most of the ML family, and a few scattered others) that use much more comprehensive and capable type inference algorithms than Scala uses.  Also, be aware that this is not entirely Scala's fault; nominal subtyping and whole-module type inference are fundamentally at odds with each other, and the designers of Scala chose to favor the former over the latter for the sake of Java compatibility, while the "purer" statically typed functional languages were mostly designed with the opposite choice in mind.


问:
Should UML be used before or after a basic Program Design
UML Diagrams take time and even though they provide knowledge about program design, the design changes and so do requirements, and hence it becomes a chore to keep UML Diagrams in Sync  with code. I am trying to figure out how should we use UML in an optimum way.  </p>

答:
It depends.

In his book, UML Distilled, Martin Fowler discusses UML as having three usages: An implementation language facilitated by code generators and round-trip software engineering tools, a blue print for manual creation of the code, or a method of sketching ideas to be used in a design.

When we talk about UML, I think of a system put together by many people (the three amigos, Rumbaugh, Booch, and Jacobson being the most visible) that includes around 13 different diagram types.  Perhaps it follows a development life cycle described through the Rational Unified Process (RUP), but given the number of diagrams available, what are we talking about when we refer to basic program design?

I think we start with requirements elicitation using use case diagrams and use cases.  A lot of Agile developers swear by story cards, which is also great.  When we have the use case diagram, and use cases, we have something of a partitioning of the system, and maybe it is not too early for a deployment diagram or package diagram to identify the parts.  Activity, sequence, and class diagrams give a lot of detail, and may be too low level to show the design in a basic way?

My interpretation of UML is that its advocates expect it to provide all the diagrams needed.  If you want to use a block diagram or data flow diagram, they would probably point you back at one of their diagrams with the rational that those diagrams are remnants of structured design and have dissonance with the object oriented decomposition we are trying to make.  Personally, I think that any diagram or written plan that tells you how to begin and proceed effectively toward your goals has merit.


问:
Drop in service for account management, authentication, identity?
I'm building an Android app and associated set of web services for uploading/downloading data. I need a basic (no frills) solution for account management (register, login, logout, verify credentials/token).

What open source / third party solutions exist for this scenario?

I need:

create a new account db based on a salt

simple web service to create a new account

simple web service to authenticate supplied credentials and return some sort of token

That's it, I can get by without 'fancy' email activation or  password reset for the time being.

And then moving beyond simple account management, I will need some sort of 'token' based authentication for a web service.

Are there off-the-shelf components for this? Should I just use a 'blank' django or rails app to get this done? Seems crazy for everyone to be doing CREATE TABLE user_accounts ...

Thoughts?

Thank you.

答:
Here is where I've landed after two days of hacking. I welcome any feedback or criticism. If you identify a fundamental functional or security flaw with this approach, I'll paypal you enough cash for a pound of coffee or six-pack of beer.

I have selected Django as my 'modern web stack' for a foundational platform. I'll be leveraging it for security, account, session, and password management. I eagerly defer security-sensitive functionality to Django (i.e. following convention wherever possible). I do not shirk responsibility for security, but I believe informed consumption of an industry-vetted framework is inherently more secure than rolling your own. I selected Django primarily based on familiarity with and preference for Python, plus the framework's maturity.

Out of the box, Django has great support for account management and authentication. Of particular value is the great Django admin interface which lets a superuser reset passwords, disable accounts, etc. This is a huge value imho.

To support registration and account lifecycle management (password reset, etc), I went with the django-registration module:

https://bitbucket.org/ubernostrum/django-registration

This appears to be a very mature and vetted library with great documentation. It does not include basic form templates but I found a good set here which I customized:

https://github.com/yourcelf/django-registration-defaults

This got me up and running with a full account management solution for web-usage, but (as mentioned above) I need an API-based solution for a mobile app. I don't want to persist the user password locally on the phone and I'd prefer to avoid managing session cookies in my API calls (a token approach is superior imho). I discovered this module:

https://github.com/jpulgarin/django-tokenapi

Which works great. The only thing missing at this point was an API for programmatically registering new accounts from the native mobile application. I coded this myself.

So long story short, I have the following working (as vanilla-Django as possible):

full account auth and lifecycle management from Django Auth

full account web registration from django-registration

some primitive, but functional, account UI templates from django-registration-defaults

token-based security for mobile API calls via django-tokenapi

a special one-off API for registering new accounts inside the mobile app

Seems to be working...


问:
What reasons are there for not using a third party version control service?
I've recently noticed a bit of a trend for my projects as of late. I use to run my own SVN server on my VPS, but recently the nail went in the coffin for that when I got my last project migrated from my server to a Mercurial repo on Bitbucket.

What are some of the ramifications to this? (disregarding the change in version control systems)

It seems like there has been a huge explosion in version control hosting, and companies like Bitbucket even offer private repos for free, and Github and other such services are extremely cheap now. Also, by using them you get the benefit of their infrastructure's speed and stability.

What reasons are there these days to host your own version control? The only real reason I can think of is if your source code is super top secret.

答:
External services aren't always stable, sometimes they go down. Github has had a lot of bad luck with downtime in the past few months, out for sometimes hours at a time.

Code may be private. If you're under an NDA or something to not share code with anyone, that includes employees of external services, that can access code in repositories even after they've been deleted.

If you have a large number of repositories (for Github) or a large number of collaborators (for Bitbucket) it can get quite expensive to host them in the cloud. Most agencies who do client work would probably run into this limitation. Much, much cheaper to keep an PC under someone's desk with git or svn installed on it.

That's just what I can think of, off the top of my head.


问:
Is taking frequent breaks really that beneficial when programming?
I keep reading that it is recommended for a programmer to take frequent breaks while programming, and the usual recommendation I see is 5 minutes every half hour or 10 minutes every hour.

I gave it a try, but quite often I find something interesting during those 5 minutes, and it takes me away from what I was working on for longer than I planned. Either that, or my mind gets focused on something else and I find it hard to get back into my work and don't focus very well.

Is it really that beneficial to take frequent breaks while programming? Am I doing something wrong for it to be decreasing my productivity instead of increasing it?

答:
Not only is it beneficial to your productivity to take frequent breaks it is also beneficial to your health.  10 years ago I had a Pulmonary Embolism (blood clots in my lungs) from working too long without breaks.  I fortunately recovered from that and thought I was doing really good. Last April I got into a coding sprint for a couple of days.  The kind where time flies by and before you know it you've been sitting way too long.  I found myself extremely short of breath and when I went to the hospital I had a new batch of blood clots.

I'm back to setting alarms and walking around every hour.


问:
SQL Triggers and when or when not to use them.
When I was originally learning about SQL I was always told, only use triggers if you really need to and opt to use stored procedures instead if possible.

Now unfortunately at the time (a good few years ago) I wasn't as curious and caring about fundamentals as I am now so never did ask to the reason why.

What's the communities opinion in this? Is it just someone's personal preference, or should triggers be avoided (just like cursors) unless there is a good reason for them.

答: Triggers can be used to enforce constraints on database which can't be enforced during database schema creation and any DML statements.</p>


答:
Avoid using a third-party hosted version control system when:

The code is under NDA or otherwise has contractual or legal obligations that the hosting provider cannot or will not enforce. For example, code hosted externally may have issues with Common Criteria certification (this may or may not be an issue but source control was discussed in projects I have been involved in).

The code contains unfiled patents, trade secrets or other intellectual property that the hosting provider cannot or will not protect.

Other things to consider when using a third-party hosting provider:

Does the hosting provider support the version control system you are using? Conversion is possible but often complex and difficult. (This was mentioned in the question but it is included here for completeness)

How are you billed for the service? Are there limits or thresholds such as repository size limits, bandwidth caps or throttling, user caps? Most providers are relatively cheap but be sure to work out how much it will actually cost before using the service.

Does the hosting provider update to newer versions frequently? If not, are there features in newer versions you require? If they do, are there incompatibilities between the newer version and the version you are using now?

Does the hosting provider meet your uptime or bandwidth requirements? If the source code is inaccessible when you need it, what legal options are there to recoup costs? Most systems provide few guarantees.

Does the hosting provider store the source code in a country or jurisdiction where laws may allow others access? Many hosting providers will outsource their storage and servers to a IaaS cloud provider like Amazon but it is still worth asking the question.

Does the hosting provider provide audit logs of accesses, not just modifications?

How do you create and manage users who have access to the source code? Can you delegate this to other people in the organization? Can you access audit logs of user management?

Does the hosting provider provide or enforce strong or multi-factor authentication?

Does the provider enforce encrypted communication, e.g. SSL or SSH? Can you get access to any customer-specific side certificates or keys if required?

How do you "onboard" any existing source code? Can you upload or import history?

When you cease to be a customer of the hosting provider, can you get access to your source code history? If so how and for how long? What happens if the hosting provider goes out of business or merges with your competitor?

How will your needs change over time? Are you likely to need more or less space, users or repositories than you have now? Can the provider handle these changes?

Will your organization need more bandwidth to cope with the increased influx and outflux of data?

Does the existing, on-premise source control system integrate with an authentication service, such as Active Directory? Using a third party hosting provider usually means developers need to remember another set of credentials.

Remember, too, that third party hosting providers are not the "silver bullet" for redundancy. They can be great as an additional, readily accessible backup but few hosting providers will guarantee the backups, at least not without paying more.

That said, third party hosting providers can be great, particularly for a distributed workforce, since they can work on source code without needing VPN access, and it is one less server that needs to be administered.

Title: What reasons are there for not using a third party version control service?

Body:
I've recently noticed a bit of a trend for my projects as of late. I use to run my own SVN server on my VPS, but recently the nail went in the coffin for that when I got my last project migrated from my server to a Mercurial repo on Bitbucket.

What are some of the ramifications to this? (disregarding the change in version control systems)

It seems like there has been a huge explosion in version control hosting, and companies like Bitbucket even offer private repos for free, and Github and other such services are extremely cheap now. Also, by using them you get the benefit of their infrastructure's speed and stability.

What reasons are there these days to host your own version control? The only real reason I can think of is if your source code is super top secret.