答:
There is another reason you would like to push to a repo (even if it's, in one way or another, local): workstations.

I don't know about you, but I work in 4 different computers (1 PC at home, 1 Laptop, 1 Office PC and 1 Office Laptop) and pushing changes to a properly set up Git server in my company's server makes syncing fast and painless. Since Git is a DVCS, that's putting that advantage to use: it's not only backups, but all different codebases I'm working on can be easily merged, checked and analyzed.

It can be local if, for example, your home PC is the "server" (or the origin) and you have a home laptop - that way you can easily keep in sync.

Sidenote: People often say "I'd rather use Dropbox (or any other sync service)". The massive amounts of objects that a Git repo has makes it ridiculous to use Dropbox like that. It's an option, but I wouldn't say a good one.


问:
What can be done to programming languages to avoid floating point pitfalls?
The misunderstanding of floating point arithmetic and its short-comings is a major cause of surprise and confusion in programming (consider the number of questions on Stack Overflow pertaining to "numbers not adding correctly"). Considering many programmers have yet to understand its implications, it has the potential to introduce many subtle bugs (especially into financial software). What can programming languages do to avoid its pitfalls for those that are unfamiliar with the concepts, while still offering its speed when accuracy is not critical for those that do understand the concepts?

答:
I find it strange that nobody has pointed out the Lisp family's rational number trick.

Seriously, open sbcl, and do this:
(+ 1 3) and you get 4.
If you do*( 3 2) you get 6.
Now try (/ 5 3) and you get 5/3, or 5 thirds.

That should help somewhat in some situations, shouldn't it?

ContentLicense: CC BY-SA 2.5

ContentLicense: CC BY-SA 3.0


问:
Are these steps enough to put my bash script under GPL 3?
I have written a bash script I would like to put under GPL v3. I've read the GNU documentation
on How to Apply These Terms to Your New Programs and How to use GNU licenses for your own software. Still, I'm not quite sure what to put there and which artifacts are needed.

So far, I did the following:

Put a file called COPYING (which contains the license) into the project folder

At the beginning of my script, I attached the following to my script:

up is a bash function to simplify vertical file system navigation.

Copyright (C) 2012 Oliver Weiler

This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.

This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

You should have received a copy of the GNU General Public License
  along with this program.  If not, see http://www.gnu.org/licenses/.

Is this all I have to do? Is putting the licence into a separate file actually needed, if the notice in the script file links to it?

答: Yeah, that's pretty much it. The separate file with the actual license isn't strictly needed, but then again, we're talking about copyright and legal matters dealing with the digital era. Nothing is strictly legal or illegal, and the whole field is an uncomfortable shade of gray where it depends on who you piss of, how good of a lawyer you both can afford, and what giants have tangential interests in the outcome. </p>


问:
Tips on persuading boss that code review is a good thing
Let's say one works in a hypothetical company that has several developers that rarely worked together on projects and the Boss didn't believe that code reviews are worth the time and cost.

What are various arguments that could be presented in this scenario that will portray the benefit of code review?  Furthermore, what are the potential arguments against code review here and how can these be countered?

答:
As well as the knowledge sharing mentioned by the others, find examples of bugs that would have been found during a code review and measure how long they took to fix - this includes the time spent researching the problem and releasing the patched version as well as the actual time fixing the bug.

Take this cost, which will probably be a least a couple of days effort, and contrast it to the time you would have spent on a code review and acting on the results.

This will show your boss that code reviews are worth the expense.


问:
Domain Objects with Interfaces
I'm in a situation where part of my system has a dependency on another module in the same system, but the modules themselves need to remain independently deployable, where the parts they depend on would be filled in with another implementation.

A module in this instance is the concept of a bunch of components that all contribute to servicing a business function. The system is also built in C#.

So, where I depend on another module, the source module defines an interface describing the functions it needs the dependent party module to implement. The contract types (domain model objects) are also interfaces for the dependent module.

Here is where it gets a bit hazy to me. The dependency inversion principle doesn't sit well in my head at this point. Both of those "modules" are of the same importance as each other. Which should define interfaces and force the other to reference it? I'm suspecting a 3rd project sitting between the modules that handles setting up the dependencies (probably a DI container). Should the entities in the modules be interfaced? They are simply bags of get/set (no DDD here).

Can anyone offer any guidance here?

Thanks in advance.

Edit 1:

The project structure:

```
Module1.Interfaces
   IModuleOneServices
Module1.Models
   ModuleOneDataObject
Module1
   Module1 implements IModuleOneServices

Module2.Interfaces
   IModuleTwoServices

Module2.Models
   ModuleTwoDataObject - has property of type ModuleOneDataObject

Module2
   Module2 implements IModuleTwoServices
       depends on IModuleOneServices
```

Module2 needs to be deployable by itself, and remains compilable, and sometimes, run without a Module1 present at all.

答:
Hmm, sounds like you need a glue module. How about an orchestrator which knows both the modules and can mediate between them? The modules themselves needn't know each other then.

Another option is to put the "shared" classes in a shared library that both the modules can depend on.

This is not exactly dependency inversion but why would you follow that approach dogmatically. I suspect that you are building an application with those two modules so a top down approach is fine here imho.

Title: Domain Objects with Interfaces


答:
The dependency inversion principle would very nicely apply to what you are trying to do.

Let me exemplify. If A uses B, than A depends on B. To brake the dependency you introduce an interface. The interface must belong to package A and can be implement by B or C or any other module. The important part here is the belonging to A. If you do that, you can deploy A without deploying or recompiling B. A depends on an interface, which is the most abstract thing you can have in OO. Depending on abstract things is also the best you can do.

Now, this solved the problem where A uses B. If I understand you correctly, your B module also uses A. So you have a reverse dependency also. This cyclic dependency should be avoided whenever possible. However, if it happens, just create an interface belonging to B and implemented by A. Do the reverse of my previous paragraph.

This way you can deploy each of your modules independently. The only reason to deploy both is when you change the interface in such a way that it is not backward compatible any more.

Title: Domain Objects with Interfaces

Body:
I'm in a situation where part of my system has a dependency on another module in the same system, but the modules themselves need to remain independently deployable, where the parts they depend on would be filled in with another implementation.

A module in this instance is the concept of a bunch of components that all contribute to servicing a business function. The system is also built in C#.

So, where I depend on another module, the source module defines an interface describing the functions it needs the dependent party module to implement. The contract types (domain model objects) are also interfaces for the dependent module.

Here is where it gets a bit hazy to me. The dependency inversion principle doesn't sit well in my head at this point. Both of those "modules" are of the same importance as each other. Which should define interfaces and force the other to reference it? I'm suspecting a 3rd project sitting between the modules that handles setting up the dependencies (probably a DI container). Should the entities in the modules be interfaced? They are simply bags of get/set (no DDD here).

Can anyone offer any guidance here?

Thanks in advance.

Edit 1:

The project structure:

```
Module1.Interfaces
   IModuleOneServices
Module1.Models
   ModuleOneDataObject
Module1
   Module1 implements IModuleOneServices

Module2.Interfaces
   IModuleTwoServices

Module2.Models
   ModuleTwoDataObject - has property of type ModuleOneDataObject

Module2
   Module2 implements IModuleTwoServices
       depends on IModuleOneServices
```

Module2 needs to be deployable by itself, and remains compilable, and sometimes, run without a Module1 present at all.


问:
How to implement a software development process in an existing project?
My question involves setting up a Software Development process. If you came in to an existing project that had no formal methodology or process set up, and then were asked to set one up yourself, how would you handle it? I have looked into various methodologies like Agile, or subsets thereof like XP, but these are primarily aimed at how to set up new projects. I am rather unsure how to implement them into an existing project.

Also, many of these are aimed at web or desktop applications. My software project is an embedded system, so while many aspects of them are applicable, it is a bit overwhelming trying to figure out which one to use and how to convert it for use in an embedded system. Unit testing on embedded hardware (especially with a Single Board Computer for which no simulator exists) is incredibly difficult, particularly if the software is very far along, and to add a hardware abstraction layer to aid unit testing would involve tearing up the code dramatically.

What tips would you have for setting up a Software Development Process for an existing project, for a programmer that knows how to program, but is new to software development process management?

答:
as for embedded systems vs TDD:

When I was at university, we were required to write embedded system unit tests by use of a logic analyser. However, the ones we used did cost about 15000 dollars each, and we were told firmly, not to break them. On the other side, it was nice and easy: plug the chip into the board, start app, tadadada, green, bamm.

But I guess you have that.

As for methodologies:

Methodologies are about people. I'm yet to succeed in forcing down a methodology on any company culture, especially in large companies.

When I was in a primary RUP culture, I did XP with my team, in order to be faster than the rest. It did succeed.

When I was in a primary XP (or, fresh Agile, SCRUM wasn't mainstream yet), we did RUP, with modeling and all, in order to have a better understanding on what the f* is happening on the project, and act with much more confidence. It worked.

When I was in a SCRUM environment, I did either RUP (to have the better understanding), or, realizing that scrum backlocks are always broken, that we have no real iterations, etc, (we were the "bugs & small features team") I switched to Lean/Kanban in order to have stability in what we do. It mostly worked, although not as well as previously (and this was an enterprise, while the previous ones had a startup core team)

When I was in the SCRUM environment (you know, the N test), I switched to RUP like it was water in the desert, me being out for weeks there: I was left alone with it, but I had no bugs and was blazingly fast just because I just didn't accept all the excuses SCRUM had.

But all in all: in our new agile world, the programmer is the king. If programmers feel themselves well in chaos, you either switch companies or switch programmers.

I'd suggest instead of speaking about implementation to treat your programmers as your users: you have to solve their problems in order to help them work. I don't always like this approach (or rather, I don't like some programmers' approach and find it hard to support them in what they want) but today's leader is someone who should help the others, not someone who should be obeyed.


问:
Good resources for learning about recursion

Possible Duplicate:

  Resources for improving your comprehension of recursion?

I am a programmer with 2 years experience, and sometimes think I could solve a specific problem with recursion, but in most cases I fail miserably.

I am asking your advice about resources for learning, refreshing and deepening one's knowledge about recursion, preferably:

helping to identify when you could use recursion.

practical examples (applied to contemporary programming languages).

a reference handbook.

source code.

答:
I'm not aware of any recursion-specific books, but it's covered thoroughly in almost any intro to algorithms book.

As far as when you can use recursion, you could use it on practically any algorithm.  In some functional programming languages, you must use recursion for things other languages use loops for.  If you want to practice recursion, learning a functional language is a good step, and you will find tons of recursion examples in their tutorials.

When it's beneficial to use recursion is another question.  Two situations come to mind.  The first is when you find yourself using a stack for a data structure.  In that situation using recursion automatically gives you a stack, so you don't have to worry about those details.  The other situation is when you have a large number of nested loops, or an unknown level of nesting.  Recursion makes nesting loops very easy.

The trick to understanding recursion is to not try to hold the entire stack in your head.  Focus on just one small part at a time.  Think about your current state and trust that the deeper levels are working as advertised.


问:
Recommended methodology for working with shared libraries and Mercurial
I work in a small team of developers who all collaborate on several Zend PHP projects.  We are using Mercurial with a collection of upstream repositories, as well as Jenkins for centralized testing and health reports.  We want to implement a shared library of common classes, but are struggling with finding a workflow that works well with our current environment.

Currently, each project contains a structure like this:

- application        (project specific code)
- build              (temporary files generated by each build)
- library            (code used by multiple projects)
    - OurLibrary     (our company’s shared codebase)
    - Zend           (external libraries)
- tests              (test code specific to this project)
```

The library folder is excluded from testing, and so we have created a project specifically for running unit tests against the shared library.  This decision was made primarily to avoid deploying the test classes by accident, something which can largely be mitigated by a modification to the automated build process, but also because we felt that it was preferable to keep the library lightweight.

We are including the library in each project as a Mercurial sub-repo.  This means that changes pushed into the library from a developer working on ProjectA wil not automatically propagate to ProjectB (good) but will also not propagate to the library testing project (bad), and Jenkins will therefore not automatically warn us of potentially breaking code in the library (very bad).

An ideal situation would be that developers can commit changes to the library from any project, and that our automated tools would then run the latest library tests against the latest library code. Furthermore, this should not result in a version conflict when a developer pulls a new version of the library tests.

Is there an established methodology for this kind of workflow, or should we look into structuring our working practises a little differently before we fully commit ourselves to sub-repos?

答:
The last resort

Consider that sub-repos are considered a feature of last resort.

This essentially means that you shouldn't use sub-repos unless you have a legitimate reason, you have a legitimate reason, so go for it.

When then?

I have a few rules of thumb for subrepos, so then I use them if and only if:

I already have the subrepo as a stand alone repo (i.e. its not a library I may be incubating) AND

(It is code I own OR the code in the sub-repo is being actively developed) AND

Updating the code is not trivial AND

(There is the potential situation where I may want to edit the subrepo code and push it back OR fork the subrepo code with a new project-specific while still being able to pull and integrate latest changes in that repo (keeps things flexible in emergencies and deadlines)).

Last reason...

Configuration management: when I want to track what versions of what coexist with which versions of whatever and —most importantly— I want to have control of these.

For example, say that you want to test your latest development/experimental branch of "OurLibrary" against your production code of your current project. Having subrepos in this situation is very useful.

Keep questioning yourself

You might get comfortable with the idea of using subrepos. Don't. Keep asking yourself "when should I not use subrepos?", if you don't come with a good reason just don't use them and everything will be fine.

Relax

Say that you didn't use subrepos and end up realizing you should've because reason X: you can always fix it later, in any case, you don't need the subrepo history for your current project.

In an extreme case where you wanted to remove the files where the subrepo was supposed to be since day 0, use the ConvertExtension to extract the subrepo with a filemap file.

I wouldn't recommend this for your case (where your main project is the parent of your desired subrepo) but it will be useful for the configuration management use case where you will have a new parent repo to handle versions between components and your main project is one of them (at the same level of the subrepo you want), e.g.:

```<code>project (repo)
|-component1
|-component2
|-component3
</code>```

Turns into

```<code>project (new-repo)
|-component1 (subrepo)
|-component2 (subrepo)
|-component3 (subrepo)
</code>```

Otherwise with:

```<code>project (repo)
|-app
|-lib
|--|-libA
|--|-libB
</code>```

Turning into

```<code>project (repo)
|-app
|-lib
|--|-libA (subrepo)
|--|-libB
</code>```

You will leave a hole in your history where libA doesn't exist up until you create the .hgsub entry.

Body:
The last resort

Consider that sub-repos are considered a feature of last resort.

This essentially means that you shouldn't use sub-repos unless you have a legitimate reason, you have a legitimate reason, so go for it.

When then?

I have a few rules of thumb for subrepos, so then I use them if and only if:

I already have the subrepo as a stand alone repo (i.e. its not a library I may be incubating) AND

(It is code I own OR the code in the sub-repo is being actively developed) AND

Updating the code is not trivial AND

(There is the potential situation where I may want to edit the subrepo code and push it back OR fork the subrepo code with a new project-specific while still being able to pull and integrate latest changes in that repo (keeps things flexible in emergencies and deadlines)).

Last reason...

Configuration management: when I want to track what versions of what coexist with which versions of whatever and —most importantly— I want to have control of these.

For example, say that you want to test your latest development/experimental branch of "OurLibrary" against your production code of your current project. Having subrepos in this situation is very useful.

Keep questioning yourself

You might get comfortable with the idea of using subrepos. Don't. Keep asking yourself "when should I not use subrepos?", if you don't come with a good reason just don't use them and everything will be fine.

Relax

Say that you didn't use subrepos and end up realizing you should've because reason X: you can always fix it later, in any case, you don't need the subrepo history for your current project.

In an extreme case where you wanted to remove the files where the subrepo was supposed to be since day 0, use the ConvertExtension to extract the subrepo with a filemap file.

I wouldn't recommend this for your case (where your main project is the parent of your desired subrepo) but it will be useful for the configuration management use case where you will have a new parent repo to handle versions between components and your main project is one of them (at the same level of the subrepo you want), e.g.:

project (repo)
|-component1
|-component2
|-component3

Turns into

project (new-repo)
|-component1 (subrepo)
|-component2 (subrepo)
|-component3 (subrepo)

Otherwise with:

project (repo)
|-app
|-lib
|--|-libA
|--|-libB

Turning into

project (repo)
|-app
|-lib
|--|-libA (subrepo)
|--|-libB

You will leave a hole in your history where libA doesn't exist up until you create the .hgsub entry.


答:
Spotting when to use recursion is actually quite easy - the key concept is noticing that part of the problem is a smaller version of the whole problem. Examples:

Functions on lists can be written using recursion if you see that you can achieve the result by doing something with the first element of the list and then calling the function recursively on the rest of the list. Here the "smaller version of the whole problem" is the rest of the list excluding the first element.

Functions operating on binary trees can often use recursion by recursively calling the function on the left half of the tree and on the right half of the tree and combining the results in some way. Here the "smaller version of the whole problem" are the left and right sub-trees.

Mathematical functions defined recursively (e.g. a function to generate the fibonacci numbers F(n) = F(n-1) + F(n-2) ) often have a simple recursive implementation that mirrors the mathematical definition. Here the "smaller version of the whole problem" are the two previous numbers in the fibonacci sequence.

If you really want to learn about recursion, then picking up a functional language is a good idea - recursion is a natural programming style in functional languages and you'll be steered away from falling back on "imperative" solutions. I'd suggest a Lisp-1 (e.g. Scheme or Clojure) in particular: some of the recursive functions defined on lists are things of beauty.

Title: Good resources for learning about recursion

Body:
Possible Duplicate:

  Resources for improving your comprehension of recursion?

I am a programmer with 2 years experience, and sometimes think I could solve a specific problem with recursion, but in most cases I fail miserably.

I am asking your advice about resources for learning, refreshing and deepening one's knowledge about recursion, preferably:

helping to identify when you could use recursion.

practical examples (applied to contemporary programming languages).

a reference handbook.

source code.


问:
What imperative programming languages do not support recursion?
To my knowledge, all modern imperative programming languages support recursion in the sense that a procedure can call itself. This was not always the case, but I cannot find any hard facts with a quick Google search. So my question is:

Which languages did not support recursion right from the start and when was that support added?

答: Assembly language doesn't directly support recursion - you have to "do it yourself", typically by pushing parameters onto the machine stack.


问:
Legitimate use for IRC bots
I recently saw a question on SE about how to do such and such when creating an IRC bot. The only use of IRC bots I was familiar with was message flooding and spamming. I did a Google search for the string I used as my title and was led to an article that was an eye opener as to what all an evil IRC bot could do, but I did not see any explanation of a benevolent (or neutral) use of an IRC bot.

Is there any? If so, what are they used for?

答:
Your question is likely off topic for this site.

However, bots are mainly used for gaining access permissions to specific IRC channels and preventing these channels from being taken over by malicious users. I've also seen IRC bots used as file servers where users can request the bot to send them a file after seeing a list of files offered by the bot.

There are many other legitimate uses for IRC bots. For more information, read this article.

Title: Legitimate use for IRC bots


答:
Legitimate IRC bots are used all the time. On some IRC networks Chanserve and Nickserve (for managing channels and handles) are effectively IRC bots, that are just part of the network and have raised privileges. They may not be utilising eggdrop or any of the other more modern bots, but they generally aren't part of the IRC daemon itself.

Other things such as: trivia games (where the bot spits out questions and reads the input for answers and keeps scores), file servers, RSS announcers, etc. are all quite legitimate uses for IRC bots.

Title: Legitimate use for IRC bots

Body:
I recently saw a question on SE about how to do such and such when creating an IRC bot. The only use of IRC bots I was familiar with was message flooding and spamming. I did a Google search for the string I used as my title and was led to an article that was an eye opener as to what all an evil IRC bot could do, but I did not see any explanation of a benevolent (or neutral) use of an IRC bot.

Is there any? If so, what are they used for?


问:
Getting non-programmers to understand the development process
When starting a project for a company that's not primarily a programming company, one of the expectations is that there's a finished product at the end free of all bugs and does everything needed right away. However, that's rarely the case.

What are some ways to manage expectations and explain to non-programmers how software development differs from other types of product development?

答:
Metaphors are leaky abstractions, yet they are little step that take you closer to understanding.

My fave is that building software is often though as a process similar to architecting a house. Yet it's more precise to think of it as creating a system which prints out a custom-architected blueprint based on some parameters and builds a different one for each of its users. In geek talk that be meta-architeting.


答:
There are plenty of valid use cases for IRC bots like:

Reporting commits to your VCS - you can use for example cia.vc

Report build failures from your CI environment

Someone writes a bug number in the channel and the bot automatically posts the headline and link to it

Notification about new bugs

Log meetings - e.g: meetbot

Deploy specific versions to dev/staging/prod

Provide a simple way to refer someone to a documentation

It really depends how your team uses IRC or IM to communicate to determine if it useful to use an IRC-bot.

Title: Legitimate use for IRC bots


问:
How to stop / avoid Over Time on a Scrum Team?
Actually, I'm helping a small software shop on their Scrum Implementation. Recently the Scrum Master reported me that he has a problem because the Team is working Over Time to achieve the Scope (Committed Backlog). So they have an Unreal Velocity.

My formal question(s) is / are:

Apart from speaking about on the Retrospective Meeting; do you think that is a good idea to implement some hard-blocks to avoid Over Time?

If so, what techniques / tools do you suggest?

Revision Control system (SVN, GIT, HG, etc...), blocks by hours (8 to 5)

Work station blocks by hours (8 to 5) or cumulative hours (up to 8 hrs/day)?

Other(s)...

Or, maybe, do not hard-block this kind of things; but implement some "Penalty System" for Unjustified Extra Hours?

First: Tks all for your fast responses.

@Baqueta (and others with similar questions): No they are not been paid for Extra Hours. My first advise to them was to review their estimates because maybe they were underestimating.
This was my favorite advise:

If they have an interest in working overtime, remove it. Development isn't something you can do for 60 hours a week and stay productive, and there are numerous studies out there that prove this. If overtime pay is the issue, get rid of it and improve their base pay so they're getting what they're worth.

Also, I think that the root problem (for this team), is a combination of the following:

The developers are being told what they must achieve in a sprint/aren't being consulted on what's achievable/are being ignored when they say there's too much work.

The developers are consistently underestimating how much time tasks will take/how many units of work are involved in each task.

Summary: I'll talk to the Team to review their estimates, and with the P.O. because I feel that they are not being consulted about the scope, as you mentioned.

答:
First of all, it sounds like they got too much work on a sprint if they have to work overtime to get it done. Are all the hours logged? If so then you could count how much actual work is a story point and use that number to calculate work for next sprint.

It is also important to make sure the team understands they are only harming themselves by taking too much work. Even the agile manifesto talks about sustainable pace:
"Agile processes promote sustainable development. The sponsors, developers, and users should be able to maintain a constant pace indefinitely." Working overtime all the time is not sustainable.

All in all, I'd suggest communication instead of force and penalties. I'd imagine that would only lead to demoralization of the team.


答:
It is more up to the user of the bot to either do "evil" or "good". IRC bots can be useful in chats. E.g. moderating a IRC-channel and providing a chat interface for all kinds of functionality.

One example of a useful chat bot is Hubot (with it's IRC adapter) which is used by developers to start builds and other development related tasks. It can also be used to make searches on google/wolfram alpha whatever. It has a large script repository.

Title: Legitimate use for IRC bots


问:
Biggest obstacles to working on a group project
I'm doing my first group project in a class where most quarters 40% of the students have failed. I believe the reason for this is the poor quality of teaching in the class. For example, the instructor did not know that scriplets in JSP was bad practice. (I learned JSP this week and I know that.) He didn't know that Swing GUIs were supposed to go on the EDT. He didn't know that static imports were bad practice. I could go on.

The project is to design a web application for a quiz website. There is a lot of extra credit available, and it is possible to get 200%. This is my first group project. I am worried about the failure of most of my peers, and I want to avoid it.

What obstacles might I face when working on a project like this and how can I overcome them?

答:
My biggest problem in University was team members who did little or no work. Some through laziness, others through being too busy with other work, others through manipulation and knowing that they could get away with it. Through trial and error, these were the strategies that I found to work in getting them to participate:

Project Manage them. When everyone divvies up the work, give each piece a deadline and agree to have status updates. Be sure to ask if the person needs extra help, early and often. This also includes agreeing to dedicate a certain number of hours to the project, and tracking (hopefully honestly) how much time each member spends.

Give them the "fun bit". If they aren't going to enjoy the work, they won't do it. If it's going to help my grade by writing all of the boilerplate and output formatting and documentation, that's fine. I'll at least be familiar with the code when the slacker ends up partially completing the fun bit and I have to step in to help.

If it comes down to it, threaten (and follow through) on arbitration with the lecturer / tutor. Document your hours, be honest, and have a consistent story with the other (participating) team members. Most of the time when the slacker gets 1-on-1 with the person in charge, they'll admit their laziness and negotiate a lower grade for themselves, leaving you to be judged on the merit of your work.


问:
Allocation problem identification
I have a matrix.  I have a list of people who have to occupy n1,n2,n3 etc cells, different number of cells in different rows.  I have to place the people in the cells.  Occupying the same cell across rows is considered overlap.  Overlap has to be minimized.

I have people referring to this variously as an optimization problem, an allocation problem and even linear programming.

I need to first get a consensus on what is this class of problem called.

Second, I need to know what an efficient solution should look like, in terms of the big-o notation or anything else.

Here is an example:

There is a board of 4 x 4 cells.  There are many pieces each of one color (R, G, B).  Each color peice has to fill a number of columns in each row.  A possible example:

```<code>      Row1   Row2   Row3   Row4
Red      1      2      3      2
Blue     2      2      0      0
Green    1      0      1      2
</code>```

That is the input.  The input arrangement could be different but it occupies the entire board... no cell is left blank.

The count of same color pieces occupying a COLUMN should be minimized.  One possible (bad) arrangement based on the input is this:

```<code>    1    2    3    4
1   r    b    b    g
2   r    r    b    b
3   r    r    r    g
4   r    r    g    g
</code>```

This is bad because it actually maximises the count of colors in the same column.  A better arrangement is like this:

```<code>    1    2    3    4
1   r    b    b    g
2   b    r    r    b
3   g    r    r    r
4   r    g    g    r
</code>```

Overlap is unavoidable, but should be minimized, and provably so.  I dont know if there is only one best solution or if there could be many solutions.  Even if there could be many solutions, we need to come up with just one.

As I think about it more, it looks like a loose version of eight-queens problem.  I am getting worried because I keep seeing recursion and back-tracking.

EDIT 1:

I am thinking a relaxed version of sudoku puzzle generation.

答:
You first need to state the constraints for valid solution. As it stands the question is too vague.

Given what you wrote, it definitely is an "optimization" problem. Any problem where you have a set of acceptable solution and are looking for best or good enough one according to some criterion is an "optimization" problem. That does not mean much, there are several types of optimization problems that need different approach to solve.

It also is an "allocation" problem, but that does not help you all that much. In general such problems may not have polynomial solution (some are NP-complete) and usable heuristics will depend on the exact constraints.

"Linear programming" is a way to formulate a class of optimization problems. It probably can't be used in your case, because linear programming requires real variables that can be varied in some interval, but you can only have someone assigned to cell or not, so only boolean variables. It can probably be formulated as "integer linear programming", but that is significantly more difficult. Integer linear programming is NP-hard, but reasonable approximate methods exist.

It might also be possible to formulate your problem as "scheduling" problem and use some algorithm used for that.

Title: Allocation problem identification


问:
Ruby/RoR development: desktop or server
Our company has started development of own systems "in-house". We already got couple of developers, who will be responsible for writing code in Ruby/RoR.

We are currently discussing infrastructure, and I would like to ask: should we develop everything on local machines, then put it to test server and later to production, or develop everything on a development/test server, then publish it for testing and later to production?

Just an update to the description above: under "local machines" I meant developers' desktops and this test/development server is a machine in our office.

答:
What benefit would you gain on developing on a test server? I can't imagine anythning. It would make it almost impossible for several developers to develop simultaneously. It would also make it impossible to do any testing while developing.

What you want to do is everyone to develop on their own machine. After each commit to version control, you have Continous Integration server that checks out the code, runs tests and deploys it to test server. CI-server and test server could be the same probably. "Ci-Server" could be as simple as some scheduled script that polls version control and runs your rake tasks, but setting up something like Jenkins is so easy I wouldn't bother.

Title: Ruby/RoR development: desktop or server


问:
Is it bad coding practice to create something in a get if it does not exist?
So I have a webservice that has something like a getAccount where it would return an identifier to the account if it got it, else throw an exception. The client will always want to create an account if an exception is thrown with the same info the get is done with.

I am creating a convenience library for clients that will be handling all of the webservice calls inside so they don't need to know how to do the calls themselves.

What I am wondering is in this library if I were to create a getAccount(accountName) that will get the account if it exists, and if it does not then create it and return the info, is that a bad thing to do? Should I leave it to the client to handle the exceptions or simply name it something like getOrCreateAccount? Does it matter?

Is it bad practice to create something in a get operation?

答:
It makes most sense to create 3 methods:

getAccount -> Which just gets the account.

createAccount -> Creates an account.

getAccountAndCreateIfNeeded -> Choose your own naming ;)

Why separation: You have a simple method for getting and creating. That is a clear testable method for both. For getAccount it is not an exception to not find the account. So just return false or something like that, it is expected.

Then you can use that return value in your grouped function: getAccountAndCreateIfNeeded which is now also testable, it should return an account always. Whatever you ask.

All these 3 methods are clear, it is exactly clear what they do and what they return. You may make agreements now with your team but this kind of exceptions are terrible on the long run. Just make them very clear and you will have no issues.


答:
It depends on the circumstances.

For example, you can use it to do lazy loading/instantiation, deferring the loading of data or the creation of an instance until it's actually needed.  This is normally sensible as it saves resources that you might not need (if the class/data is never needed then it's never loaded).

However, in this particular case, I'd say that having a method called getAccount that would create a new account if it didn't exist would not be good practice.  If the user has given some credentials to identify a particular account and that account couldn't be found, does that mean that the user is not yet a customer and should have an account created for them, or does it mean that the credentials were mistyped and the user needs to be asked to verify that they've entered what they meant to enter?

If you have a getAccount method that does create a new account if it couldn't identify one, then you have no choice in the matter.  If you split account creation and account getting out into separate methods, then you have a lot more flexibility in deciding what to do should an attempt to get an account fails.

Title: Is it bad coding practice to create something in a get if it does not exist?

Body:
So I have a webservice that has something like a getAccount where it would return an identifier to the account if it got it, else throw an exception. The client will always want to create an account if an exception is thrown with the same info the get is done with.

I am creating a convenience library for clients that will be handling all of the webservice calls inside so they don't need to know how to do the calls themselves.

What I am wondering is in this library if I were to create a getAccount(accountName) that will get the account if it exists, and if it does not then create it and return the info, is that a bad thing to do? Should I leave it to the client to handle the exceptions or simply name it something like getOrCreateAccount? Does it matter?

Is it bad practice to create something in a get operation?


问:
Template rendering engine legitimate use of a singleton?
I wrote a standalone singleton class (scaffold) tonight that serves as a facade to a few other classes, including a template class and a view class.  Templates and views are both named and instances of each are stored in the scaffold object.   Templates can contain views and views can contain other views.  A template and it's contained views is rendered when:

```<code>scaffold->render('template_name')
</code>```

Making scaffold a Singleton seemed like a good idea because:

I want to control when and how the object is constructed

I only want one instance (the gui will only be rendered once, regardless of the template which is rendered)

All state can easily be released from the scaffold class (if, for testing reasons or whatever, I wanted to)

Does this seem like an acceptable use case?  If not, what specific design considerations am I overlooking?

No religious wars, please.  I didn't include the language because I'm hoping for  a language agnostic consideration, but I will say:

Scripting language

Single threaded

答: There are hardly any circimstances under which a singleton is legitimate (the only one that springs to mind is providing an interface to a hardware device or register which needs to be shared but for which it would be catastrophic if each program that accesses the resource did so at the same time).  Singletons introduce far more difficulties than they do benefits, they are essentially global state and they create hidden dependencies, all of which makes unit testing far more difficult than it would be if you passed the dependencies in as parameters </p>


答:
You need development server, if team has more than 3 members. For 2 developers - local machines is enough. Development process always goes on local machine, and on development server - developers check, if project ready for test.

Test server usually used for review changes by testers/customers/managers.

And after reviewing product on test server - you can push it to production.

In other words, if one developer, developing project for himself - he doesn't need both - development and testing servers. Only local machine and production. If he has client - he needs also test server. And if he has other team players - they need development server.

Title: Ruby/RoR development: desktop or server

Body:
Our company has started development of own systems "in-house". We already got couple of developers, who will be responsible for writing code in Ruby/RoR.

We are currently discussing infrastructure, and I would like to ask: should we develop everything on local machines, then put it to test server and later to production, or develop everything on a development/test server, then publish it for testing and later to production?

Just an update to the description above: under "local machines" I meant developers' desktops and this test/development server is a machine in our office.


答:
It depends...

In my company we have developers, architects, and project managers. For every project we have a Definition of Done which says:

Before commit, developers should test their changes locally to make sure that everything works ok in the latest versions of IE, FF, Chrome, and Opera.

If everything is ok, commit changes to the SVN

CI script will automatically deploy changes to the test server

When User Story is marked as resolved, QA tester (or PM in our case) tests the application on User Story level

If everything is ok, PM marks the User Story as QA verified and notifies the client

Client tests the application, and if everything is ok, he approves changes so we can deploy them when sprint ends

Sometimes the test server is not enough so we have the staging server as well. The reason for this is because we don't want to stop our development while client is testing our application.

Title: Ruby/RoR development: desktop or server


答:
Frankly, those "hard blocks" you mention in #2 are the worst idea I've heard in a long time. What happens if a top-priority bug is found at 4.45pm and the guy who has the ability to override your blocks is off sick? As for #3 - you're suggesting punishing people for doing their jobs.

If the team are consistently working overtime to complete sprints, then either they have an interest in working overtime - e.g. overtime pay or getting overtime back as holidays - or they are committing to doing too much work in the sprints.

If they have an interest in working overtime, remove it. Development isn't something you can do for 60 hours a week and stay productive, and there are numerous studies out there that prove this. If overtime pay is the issue, get rid of it and improve their base pay so they're getting what they're worth.

If there is too much work going into the sprints, this is usually for one of three reasons:

The developers are being told what they must achieve in a sprint/aren't being consulted on what's achievable/are being ignored when they say there's too much work.

The developers are consistently underestimating how much time tasks will take/how many units of work are involved in each task.

The developers keep being pulled onto tasks which aren't part of the scrum.

If it's #1, you're doing it wrong. No two ways about it!

If it's #2, the usual cause is inexperience - either with doing time estimates, or with the system being developed. A good way around this is to stop doing time estimates and start estimating 'units of work'. Use some abstract unit, just make sure it isn't real-time hours (ultimately you're still representing a time interval, but the abstraction is important!). You can then start calculating how many units of work actually get done in a week, then set up sprints using that data.

If it's #3, you need to start factoring in those other tasks somehow. If it's consistent it should be easy to account for (see #2 above). If it's frequent but unpredictable it's much tricker to deal with. You'll want to take a look at why it's happening (e.g. serious bugs in 'live' code => is your testing thorough enough?) but if that can't be fixed then ultimately scrum might not be the right approach for you. My team recently switched over to Kanban for this very reason...

Edit: Clarified my criticism of the ideas presented in the question.

Title: How to stop / avoid Over Time on a Scrum Team?

Body:
Actually, I'm helping a small software shop on their Scrum Implementation. Recently the Scrum Master reported me that he has a problem because the Team is working Over Time to achieve the Scope (Committed Backlog). So they have an Unreal Velocity.

My formal question(s) is / are:

Apart from speaking about on the Retrospective Meeting; do you think that is a good idea to implement some hard-blocks to avoid Over Time?

If so, what techniques / tools do you suggest?

Revision Control system (SVN, GIT, HG, etc...), blocks by hours (8 to 5)

Work station blocks by hours (8 to 5) or cumulative hours (up to 8 hrs/day)?

Other(s)...

Or, maybe, do not hard-block this kind of things; but implement some "Penalty System" for Unjustified Extra Hours?

First: Tks all for your fast responses.

@Baqueta (and others with similar questions): No they are not been paid for Extra Hours. My first advise to them was to review their estimates because maybe they were underestimating.
This was my favorite advise:

If they have an interest in working overtime, remove it. Development isn't something you can do for 60 hours a week and stay productive, and there are numerous studies out there that prove this. If overtime pay is the issue, get rid of it and improve their base pay so they're getting what they're worth.

Also, I think that the root problem (for this team), is a combination of the following:

The developers are being told what they must achieve in a sprint/aren't being consulted on what's achievable/are being ignored when they say there's too much work.

The developers are consistently underestimating how much time tasks will take/how many units of work are involved in each task.

Summary: I'll talk to the Team to review their estimates, and with the P.O. because I feel that they are not being consulted about the scope, as you mentioned.


答:
Some of the things to look for to avoid risk of failure are:

Team should be composed of people who can communicate and accept a leader and ready to work on tasks as assigned by the leader. Team leader to clarify roles and responsibilities. Team members ether to accept or reject and if they accept, they should commit.

Leader must be able to assign tasks and follow through.

Team competency in the technology must be adequate. Otherwise, team leader must factor in training or downsize the scope or expectations.

The requirements must be clear and expectations must be reasonable, e.g. fancy GUI may be great but can you afford it? This is a PM call. Aim for simplicity as much as you can.

The team must have an expert resource to turn to resolve tech. issues that might arise.

Project must be based on a design, even a simple high level one where database is stable and UI style is determined. You want to avoid massive changes because of time limitations.

Team leader must measure progress and document the effort, obstacles, etc. This is part of the deliverable. Have defined milestones and gather the team members and talk face to face about the situation.

Team must be willing to go the extra "10 miles" to achieve success.

Team must be motivated.

Focus on main functionality first, deliver it, then work on nice-to-haves. Prioritize deliverable. Understand how marks are allocated.

Never mind if the instructor is not as competent, as long as you have other sources of knowledge.

Title: Biggest obstacles to working on a group project

Body:
I'm doing my first group project in a class where most quarters 40% of the students have failed. I believe the reason for this is the poor quality of teaching in the class. For example, the instructor did not know that scriplets in JSP was bad practice. (I learned JSP this week and I know that.) He didn't know that Swing GUIs were supposed to go on the EDT. He didn't know that static imports were bad practice. I could go on.

The project is to design a web application for a quiz website. There is a lot of extra credit available, and it is possible to get 200%. This is my first group project. I am worried about the failure of most of my peers, and I want to avoid it.

What obstacles might I face when working on a project like this and how can I overcome them?


问:
Most recent vs Most used
We are building a business application (a laboratory management system to be more precise) mostly for internal company use only. To make it easier for users to find items which they work on we are implementing a list of most used items.

We had a little debate on which method would be better to implement: display the most recent vs display the most used.

My arguments on most-recent

A little bit easier to implement. I think this is worth to mention because we are dealing with business application which will be sold as a single copy, so this may directly effect application price. Also simpler implementation means less code and may effect maintenance code.

Counterargument: difference in implementation difficulty in this case is too small

It is easier for users to guess what will they find in this list so they know if it is worth to look at the list at all.

Items which were relative yesterday and used a lot might not be relevant today and in recent item list they quickly disappear.

My arguments on most-used

Actually it is quite easy to display a mixed version of recently-used and most-used by combining last access date and a number of access something like this (today - lastaccess) * number_of_access

Counterargument: this requires fine-tuning

What arguments would you give for one or another?

答:
This might be down voted for not answering your question directly, but the debate you had with your colleague was a waste of time.

You should have spoken to 3 (mid level, hands on) lab technicians - given them the two options and asked them what they would do.

Title: Most recent vs Most used


答:
Your end users or customer(s) should define expected features and use cases.

However, if there is no such requirement/preference, i would implement most easiest (also fastest) option first and start to collect customer/tester feedback for most wanted features. I would Log them and implement them in defined priorities by customer/planning.

Title: Most recent vs Most used

Body:
We are building a business application (a laboratory management system to be more precise) mostly for internal company use only. To make it easier for users to find items which they work on we are implementing a list of most used items.

We had a little debate on which method would be better to implement: display the most recent vs display the most used.

My arguments on most-recent

A little bit easier to implement. I think this is worth to mention because we are dealing with business application which will be sold as a single copy, so this may directly effect application price. Also simpler implementation means less code and may effect maintenance code.

Counterargument: difference in implementation difficulty in this case is too small

It is easier for users to guess what will they find in this list so they know if it is worth to look at the list at all.

Items which were relative yesterday and used a lot might not be relevant today and in recent item list they quickly disappear.

My arguments on most-used

Actually it is quite easy to display a mixed version of recently-used and most-used by combining last access date and a number of access something like this (today - lastaccess) * number_of_access

Counterargument: this requires fine-tuning

What arguments would you give for one or another?


答: Apart from asking your end users, I'd go with most used in the last x days. But this takes a bit more work as you have to keep a history.</p>

Title: Most recent vs Most used


答:
Look how the answers are ordered here.
You have three options:

 - active _ most recent

 - oldest

 - votes _ most actively "used"

And this is the best decision ever. I'm sure that instead of spending your time on debating (and posting this question and reading the answers) you could have already implemented the easiest way, which is in this case (according to you) most recent items.

I wouldn't say that implementing the easiest way and then letting the users judge is a good idea: many companies have failed with such a strategy. So if you don't have enough resources for both, do as Jonno suggests.

Title: Most recent vs Most used


答:
Do both. Instead of a simple list, have an "Open Recent" command that opens a page or dialog or window or whatever fits in your design. On that page you can then have two sections, one for most recent and another for most used. Or, a radiobutton that toggles between the two. This gives each user the power to choose. </p>

<p>Regardless, instead of asking strangers who have no idea what your actual users are like, ask your actual users. Hallway usability testing goes a long way. </p>

Title: Most recent vs Most used

Body:
Do both. Instead of a simple list, have an "Open Recent" command that opens a page or dialog or window or whatever fits in your design. On that page you can then have two sections, one for most recent and another for most used. Or, a radiobutton that toggles between the two. This gives each user the power to choose.

Regardless, instead of asking strangers who have no idea what your actual users are like, ask your actual users. Hallway usability testing goes a long way.


答:
Simply tell the team not to work overtime. Period.

This may cause them to not be able to finish some work. That's not a problem, that's a data point. They can then use that data point in planning the next sprint. Again, don't let them work overtime. Whether they finish or not, they have another data point. Lather, rinse, repeat.

No amount of tricks or limits are necessary. Just don't work overtime. Learn how much work you can accomplish, and adjust your sprint planning accordingly.


问:
Does Silverlight have a future?
Recently I have read some articles/blogs/comments about the development and history of WPF and Silverlight. In some forums many developers and users criticize the performance of WPF applications (for example Visual Studio 2010). Actually the market share of Silverlight in comparison to Flash is not very high. At PDC 2010 Bob Muglia said something like "our Silverlight strategy and focus going forward has shifted...." and Microsoft wants to push HTML5 in the future.

Additionally, Microsoft has announced HTML5 being a core part of the Windows 8 and Windows Phone 8 ("Mango") platforms.

Recently I have started learning Silverlight and now I must ask myself, if I should continue investing time in learning these (in my opinions) very nice and powerful technologies!? Does they have a future? Does (Windows) desktop (client) applications have a future? Does so called "Rich Internet Applications" have a future? Or will HTML5 become the "absolute truth" in software development?

What is your opinion and what do you think?

答:
This is not very surprising.  With all due apologies to all the devs who picked it, Silverlight has been a real joke from the beginning.  No one's using it on their websites. The target market is saturated by Flash, and three and a half years of Microsoft pushing their alternative hasn't led to widespread adoption, and now that HTML 5 is coming out on all the major browsers, the market really won't bear three competing, mutually incompatible solutions.

Now Microsoft is saying they're going to focus on it as the standard for Windows Phone 7 programming.  This is the final nail in the coffin, since by all signs, WP7 is looking to be a huge flop.

Title: Does Silverlight have a future?


问:
Why was the Java App store discontinued?
A Java App Store sounds like a cool idea right? Well, I turned to Google and found some remnants of an app store that Oracle had been developing. It looks like it has since been discontinued, but I haven't been able to find much commentary on why it was abandoned. So why was it discontinued?

Links to other references, for instance blog posts discussing the difficulties of Oracle's app store, would be much appreciated.

答: I don't have any links but I seem to recall Oracle were alarmed while observing the press regarding the android store and malware and didn't want to invest in apple style scrutiny.</p>


答: It is not obvious how we could associate a given arrangement with a score to know how good/bad it is. Here is one way based on your example to generate a solution, may or may not be optimal.First list colors with max. occurrences at the top. Then, pull items from top-most cell moving downwards and then to the right when a column has ended)

Title: Allocation problem identification

Body:
I have a matrix.  I have a list of people who have to occupy n1,n2,n3 etc cells, different number of cells in different rows.  I have to place the people in the cells.  Occupying the same cell across rows is considered overlap.  Overlap has to be minimized.

I have people referring to this variously as an optimization problem, an allocation problem and even linear programming.

I need to first get a consensus on what is this class of problem called.

Second, I need to know what an efficient solution should look like, in terms of the big-o notation or anything else.

Here is an example:

There is a board of 4 x 4 cells.  There are many pieces each of one color (R, G, B).  Each color peice has to fill a number of columns in each row.  A possible example:

```<code>      Row1   Row2   Row3   Row4
Red      1      2      3      2
Blue     2      2      0      0
Green    1      0      1      2
</code>```

That is the input.  The input arrangement could be different but it occupies the entire board... no cell is left blank.

The count of same color pieces occupying a COLUMN should be minimized.  One possible (bad) arrangement based on the input is this:

```<code>    1    2    3    4
1   r    b    b    g
2   r    r    b    b
3   r    r    r    g
4   r    r    g    g
</code>```

This is bad because it actually maximises the count of colors in the same column.  A better arrangement is like this:

```<code>    1    2    3    4
1   r    b    b    g
2   b    r    r    b
3   g    r    r    r
4   r    g    g    r
</code>```

Overlap is unavoidable, but should be minimized, and provably so.  I dont know if there is only one best solution or if there could be many solutions.  Even if there could be many solutions, we need to come up with just one.

As I think about it more, it looks like a loose version of eight-queens problem.  I am getting worried because I keep seeing recursion and back-tracking.

EDIT 1:

I am thinking a relaxed version of sudoku puzzle generation.


答:
There is no official story from Oracle as to why they closed the store.

From the Distimo Blog article "Java App Store discontinued by Sun/Oracle?":

We have been unable to uncover any official announcement on the matter.

All that is left is speculation (1, 2); perhaps Oracle didn't want to deal with the malware potential and PR nightmare, perhaps internal politics killed it. The Store was originally a Sun idea, and when Oracle purchased Sun many Java ideas died quiet deaths.

We'll never know for sure.

Title: Why was the Java App store discontinued?

Body:
A Java App Store sounds like a cool idea right? Well, I turned to Google and found some remnants of an app store that Oracle had been developing. It looks like it has since been discontinued, but I haven't been able to find much commentary on why it was abandoned. So why was it discontinued?

Links to other references, for instance blog posts discussing the difficulties of Oracle's app store, would be much appreciated.


答:
The unique thing about Singletons is that you enforce that there can only be one instance at any given time. Singletons are somewhat appropriate when you have to enforce this; if being one-of-a-kind is convenient, but not absolutely required, you don't need a Singleton.

There is no reason to hide the constructor: just make it publicly accessible, and provide a static method to get the global 'default' instance. Most of your codebase will use that, it's accessible from anywhere (which isn't necessarily a good thing; you're trading safety for convenience), but if you decide that at some particular point you need a dedicated instance (e.g. for testing, or because the template engine carries some state that you need to mess with without affecting other parts of the codebase), you are free to create one.

Title: Template rendering engine legitimate use of a singleton?

Body:
I wrote a standalone singleton class (scaffold) tonight that serves as a facade to a few other classes, including a template class and a view class.  Templates and views are both named and instances of each are stored in the scaffold object.   Templates can contain views and views can contain other views.  A template and it's contained views is rendered when:

```<code>scaffold->render('template_name')
</code>```

Making scaffold a Singleton seemed like a good idea because:

I want to control when and how the object is constructed

I only want one instance (the gui will only be rendered once, regardless of the template which is rendered)

All state can easily be released from the scaffold class (if, for testing reasons or whatever, I wanted to)

Does this seem like an acceptable use case?  If not, what specific design considerations am I overlooking?

No religious wars, please.  I didn't include the language because I'm hoping for  a language agnostic consideration, but I will say:

Scripting language

Single threaded


问:
Add complex customization to form or create two forms?
I'm working in a WPF application that both imports and exports delimited text files.  At both ends, there is a UserControl which encapsulates some logic about delimiter configuration.  It has some controls for individually selecting delimiters, and a 'Presets' dropdown for quickly selecting certain common combinations such as CSV.

I've been tasked with modifying the export configuration dialog. They want the presets feature modified to also cover some text formatting options that aren't related to delimiters. The changes should only appear in the export configuration dialog, because the settings in question aren't applicable to importing.  They will involve both adding some new controls, which isn't too bad.  But there will also need to be some additional presets which aren't available on the import dialog, and their presence may impact the behavior of the dialog overall.

I'm unsure of the best way to do this.  Three options come to mind, but of course I might be missing one:

Clone the UserControl and make the requisite changes to it.  Each dialog now has a separate control.  However, both controls will have a lot of logic in common, so I'm uncomfortable with this from a DRY perspective.

Keep the single UserControl but throw in a 'mode' property.  Based on its setting, show or hide certain controls, swap out the ItemsSource for the 'Presets' dropdown, etc.  This is attractive since it involves less copy-and-paste, but at the cost of the single control being more complicated overall, and perhaps more difficult to maintain on down the road.

Redo the whole thing's architecture so that the behavior-related aspects are properly managed in a separate ViewModel.  This new ViewModel should be programmatically configurable to represent the different working modes (basically by just swapping out the list of available Presets, each represented as an instance of a Preset class).  Create two different sets of UI to represent the different layouts, with one simply not having the controls for options it doesn't care about.

My gut instinct is that #3 is the best option. I'm concerned that it's an excessive effort, though, and that I'm just being too picky about one of the first two options.  Or that there's some other pitfall with it I haven't thought of.  I have a bit of a history with this UserControl and my personal feeling is that it's kind of a PITA to maintain, so I want to be cautious in case I'm overeager for the rewrite for emotional reasons.

答:
Option 1 is the quick and easy solution, and if the logic being duplicated isn't likely to change, or if any likely change would cause the duplicated logic to diverge, this option makes sense.

In my experience, solutions like option 2 become unwieldy unless you can clearly and simply differentiate the branches for the possible modes. If that's possible in this situation, take this option, because you get the benefit of easier logical changes (through less code duplication) without the complexity of abstraction.

Option 3 seems to be the ideal solution; however assuming that it will take more time to implement than the other two, it's worthwhile to guess at the likelihood that you'll be able to leverage your abstraction for future pages. We obviously can't know this with certainty, but avoiding unnecessary complexity will simplify maintenance.

With the information given, I would choose option 2 for now, and if any future enhancements require additional modes or forms, refactor to option 3 at that time.


问:
How often should we launch SONAR analysis?
I successfully installed Jenkins and then Sonar to go with continuous integration. The firsts reports are not that good in term of rules violations ,comments, code duplication ...

I set Jenkins to get java classes, run tests with cobertura and then launch SONAR once every night during week days.

I then asked the developers to put some time and effort in correcting rules violations, and try to re-factor the code using SONAR data. However it seems they would like to see their corrections in SONAR almost as they commit them.

So I got different choices :

Let the SONAR launch to once a day

Allow developers to launch sonar task themselves

Decrease Jenkins time between builds (like every 1h)

2nd solution : I'm afraid of the number of snapshot that will appear in the SONAR history and the fact that it'll make the "compare since last build" a lot less useful.

3rd solution : A bit of the 2nd solutions problems adding that Jenkins will have a lot of builds, most of them irrelevant.

What are your experiences on these problems?
Thanks

答:
It makes sense that your developers want to see their changes as soon as they make them. Much like you typically build and run unit tests before you check in (or merge upstream), it's a good idea to run static analysis before you check in (or, again, merge upstream). They all serve the same high-level purpose: make sure that you didn't introduce any new problems or reintroduce an old problem.

I don't know how long it takes to build your system, but some organizations have success with running a build and test on every check in. If you have a team that is frequently checking in or merging or if the build/test/analyze cycle takes too long, this might not work for you. In addition, like you mentioned, it reduces the "compare since last build" functionality since I would suspect that many of the check ins and builds would be fairly small changes.

I think the best option would probably be to allow developers to run SONAR locally as part of their pre-commit build/test/merge process. This would be especially helpful if they are targeting a particular SONAR-identified problem. Prior to checking in and merging, a developer can be sure that they have fixed the issue they intended to without introducing new (or higher priority) problems. This would also prevent cluttering your nightly build environment with a large number of builds - each build should be reflective of a day's work for your team.


答: I like @jozzas answer overall, but I believe I can add a little to it.  The wrong people tend to end up doing the work.  The smart people who know what's going on tend to let the others do the work.  The dumb people in the group tend to like to hoard the majority of the project.  They also tend to mangle it badly enough that the average people in the group throw up their hands in frustration and give up.  So, the project ends up being the worst case as far as quality goes.  UNLESS, someone steps up and manages the workload...


答:
Why not simply allow the user to bookmark whatever links they want and to be able to sort/group them.  Unless you are going to some kind of analysis, there is no point in maintaining frequent/recent usage statistics per user.

Any kind of smartness shown by applications usually gets in the way.  Just because it is cool to implement, does not mean it is fun to use.

Deep pocket guys like microsoft and google do real usability studies, and they give you ways to both clear and turn off MRU lists.  So if you implement recent/frequent lists, you should also implement clearing them and disabling them.

Title: Most recent vs Most used


问:
What's the most important, useful or enlightening thing you learnt in the last 12 months?
A lot of people in the coding community talk about continuous improvement, deliberate practice and so-on - but when they talk about their current practices it's almost like they 'sprang fully formed from the loins of Zeus' because you don't hear about how their opinions changed over time or what they learnt recently.

Every now and then though I go to a talk, or read a book, or talk to someone and they open up a bit more and I find that I learn a lot from these insights.

So, if you had to pick one thing from the last 12 months that you learnt what would it be?

答:
The true value of egoless programming.

At some level I always knew that ego and programming don't mix, but never quite reasoned out the consequences. The notion that you have to actively review and find fault in your own practices is something that I've only started realizing last year. I'm also learning to actively seek out criticism of my designs (in both UI and code).

To be honest however, I'm still learning how to drop the ego, and I probably will be learning how to do that for the rest of my programming career.


问:
Are fluent interfaces more flexible than attributes and why?
In a EF 4.1 Code First tutorial the following code is given:

```<code>public class Department
{
    public int DepartmentId { get; set; }
    [Required]
    public string Name { get; set; }
    public virtual ICollection<Collaborator> Collaborators { get; set; }
}
</code>```

Then it is explained that the fluent interface is more flexible:

Data Annotations are definitely easy to use but it  is preferable to
  use a programmatic approach that provides much more flexibility.

The example of using the fluent interface is then given:

```<code>protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Department>().Property(dp => dp.Name).IsRequired();
    modelBuilder.Entity<Manager>().HasKey(ma => ma.ManagerCode);
    modelBuilder.Entity<Manager>().Property(ma => ma.Name)
        .IsConcurrencyToken(true)
        .IsVariableLength()
        .HasMaxLength(20);
}
</code>```

I can't understand why the fluent interface is supposedly better. Is it really? From my perspective it looks like the data annotations are more clear, and have more of a clean semantic feel to it.

My question is why would a fluent interface be a better option than using attributes, especially in this case?

(Note: I'm quite new to the whole concept of fluent interfaces, so please expect no prior knowledge on this.)

Reference: http://codefirst.codeplex.com/

答:
Answer to your question is provided in the link.

Then you define your constraints applicable to your domain within this method programmatically.

Basically, it is more or less preference to use Attributes vs programmatic approach, where programmatic approach has more control over the entity. However, there a custom way of adding Attributes to decorate your model that you may look as well.

When using this approach you may even describe relations between tables and columns.
  Bottom line, if you are willing to have more fine-grain control over your domain you may use this new approach that comes with EF4.1.

However, for common scenarios of validation applying Attributes should work fine because it is robust to cover most cases; and in addition it might save you time.


问:
What is the term for this type of refactoring
I am sure there is a term for the following bit of refactoring, but I can't remember it and my Google-fu is failing me!

The refactor moves if statements to where they are going to have most impact, for example changing this

```<code>$test = someFunctionThatReturnsABool();
for($x = 0; $x < 10000; $x++) {
    if ($test) {
        echo $x;
    }
}
</code>```

To this

```<code>$test = someFunctionThatReturnsABool();
if ($test) {
    for($x = 0; $x < 10000; $x++) {
        echo $x;
    }
}
</code>```

答:
I don't think such a refactoring exists.

So, it would be hard to find it amongst ''lists of refactorings''.

I'd class that example  as an optimisation not a refactoring.

Refactoring, to me, is changing the code to improve its understandability without affecting its behaviour.

Optimisation, to me, is changing the code to improve performance.

Since optimised code tends to be less easy to understand. The two practices tend to work against each other.


问:
What is a good starting point for small scale PHP development and would a framework be overkill?
I'm a web development intern working on a small PHP application (just a few pages with a little database access) which has fast become a couple of very non-DRY, non-OO, individual scripts.

A framework seems like overkill (maybe not?) but I was wondering what some best practices for code / folder structure and general solo, small-scale PHP development. What is your starting point for a small application such as this?

答:
Did you try using thinga like Silex, micro-framework from Sensio Labs?

There are number of other practices on code organization, and framework usage that you may find helpful:

Ten PHP Best Practices Tips that will get you a job

63+ best practice to optimize PHP code performances


答: My thought is that they recommend the fluent API for code first implementations because you explicitly describe how the relationships are created in the database. If you use data annotations the database created by Entity Framework may not be what you expect. Your initial example is very simple so, like you, I would just use the data annotation method.</p>

Title: Are fluent interfaces more flexible than attributes and why?

Body:
In a EF 4.1 Code First tutorial the following code is given:

```<code>public class Department
{
    public int DepartmentId { get; set; }
    [Required]
    public string Name { get; set; }
    public virtual ICollection<Collaborator> Collaborators { get; set; }
}
</code>```

Then it is explained that the fluent interface is more flexible:

Data Annotations are definitely easy to use but it  is preferable to
  use a programmatic approach that provides much more flexibility.

The example of using the fluent interface is then given:

```<code>protected override void OnModelCreating(ModelBuilder modelBuilder)
{
    modelBuilder.Entity<Department>().Property(dp => dp.Name).IsRequired();
    modelBuilder.Entity<Manager>().HasKey(ma => ma.ManagerCode);
    modelBuilder.Entity<Manager>().Property(ma => ma.Name)
        .IsConcurrencyToken(true)
        .IsVariableLength()
        .HasMaxLength(20);
}
</code>```

I can't understand why the fluent interface is supposedly better. Is it really? From my perspective it looks like the data annotations are more clear, and have more of a clean semantic feel to it.

My question is why would a fluent interface be a better option than using attributes, especially in this case?

(Note: I'm quite new to the whole concept of fluent interfaces, so please expect no prior knowledge on this.)

Reference: http://codefirst.codeplex.com/


答:
The devs working overtime are likely responding to some incentive, either actual or perceived.  The is to either remove the incentive if it is actual, or to communicate that a perceived incentive is not operational.

Each suggested hard limit has some workarounds or other problems.  Source control blocks would just lead to developers holding onto their commits until the window opens again.  Workstation blocks would have to go as soon as there was some support issue or one of the devs needed to shift his hours for some reason.  Penalty systems will just lead to hiding or burying overtime hours.

I think the problem is more fundamental -- the team has some incentive (or believes they have an incentive) to work overtime.

This is what needs to be addressed.  Are their performance appraisals tied to their velocity numbers?  Does management work overtime? Are promotions and awards given to those who work long hours?  Are they contractors who are paid for overtime?


答:
Well my advice for you is to use MVC and a PHP framework.

This will let you focus more on developing the application itself rather than the basic setting up of the project structure.

I use Zend framework and it's great. The only drawback is its steep learning curve and awkward documentation. However, it has the biggest library of classes I have ever seen.

If you feel intimidated by the complexity of Zend framework then you can try CodeIgniter which has the best documentation out there in addition to many video tutorials. These tutorials got me to understand MVC in action.

When you get comfortable with it maybe you can move to a more full stack framework such as Symfony or CakePHP.

Note:

Some will argue that frameworks such as Zend, Symfony and CakePHP are overkill for a simple application, but it all depends on goal. If you just wanna build the application fast and dirty make some scripts and it will work fine.

However, if you really want to learn good OO design practices and deep knowledge from some of the top frameworks out there the go for the kill :)

Title: What is a good starting point for small scale PHP development and would a framework be overkill?

Body:
I'm a web development intern working on a small PHP application (just a few pages with a little database access) which has fast become a couple of very non-DRY, non-OO, individual scripts.

A framework seems like overkill (maybe not?) but I was wondering what some best practices for code / folder structure and general solo, small-scale PHP development. What is your starting point for a small application such as this?


答:
Maybe there is an issue of not how "much" they are working but when. This can be a problem when there is a scheduled work day, but much of the normal hours are made up of meetings and other social and personal distractions. Are they working during over-time periods because they just feel more productive.

Cut down on the amount of work in the sprint and start working on flex time. Allow them to come in later. The person in charge needs to just tell people to go home; it's all right. There are some corporate cultures that create an environment where leaving early can bring some frowns.


答:
I advise strongly against "hard blocks". Such controls could be perceived as micro-management and may fail to address the underlying issue.

I suggest that you find out why programmers are working overtime. The answer may surprise you. It sounds like you are an "outsider" (not an employee of the company), and programmers may be willing to be candid with you if you meet with them privately (one-on-one).

Is the reason for working overtime truly the workload, or is the reason more to do with culture or expectations?

Workload reasons could be

The committed backlog is too big

Either programmers or the product
owner is "gold-plating" (making features more complex than needed)

Expectations could be

Some sort of financial or recognition reward for working overtime

Fear of failure. The programmers are afraid that they will look bad or be punished if they do not meet the deadline

The programmers are underestimating the harmful long-term effects of working overtime.


问:
Advice for solo programmer whose team will expand in the near future
For 4 years now, I've been the solo developer for a small company. We have a handful of well establish products in a niche industry. We will be hiring 1-2 developers soon, and that will likely change the way things operate around here.

While I won't have a "real" title, I will be "in charge" of this team. What I want to do is establish a very organized and productive programming department for my company. I got this solo job right out of college, so while I've become proficient as a programmer in this industry, I lack a lot of team programming experience. I feel that starting out on the right foot will be key.

Right now it's just me, a few computers, and an SVN server. I'm looking for any general guidance on building a team from the ground up.

答:
Get your house in order and ensure that things are setup for a collaborative effort.

Version Control - You mentioned that you already have an SVN server, which is great. Make sure that you have established the repo and organized the projects in a standardized way.

Automated Builds

Issue/Bug tracking software

Unit/Integration tests

Continuous Integration server

Having the following items setup and integrated into your development process makes it much easier to bring people on board, track what is being done, and keep things from getting "messy".


问:
How have languages influenced CPU design?
We are often told that the hardware doesn't care what language a program is written in as it only sees the compiled binary code, however this is not the whole truth. For example, consider the humble Z80; its extensions to the 8080 instruction set include instructions like CPIR which is useful for scanning C-style (NULL-terminated) strings, e.g. to perform strlen(). The designers must have identified that running C programs (as opposed to Pascal, where the length of a string is in the header) was something that their design was likely to be used for. Another classic example is the Lisp Machine.

What other examples are there? E.g. instructions, number and type of registers, addressing modes, that make a particular processor favour the conventions of a particular language? I am particularly interested in revisions of the same family.

答:
Early Intel CPUs had the following features, many of them now obsoleted in 64-bit mode:

ENTER, LEAVE and RET nn instructions [early manuals told explicitly those were introduced for block structured languages, e.g., Pascal, which supports nested procedures]

instructions for speeding up BCD arithmetic (AAA, AAM, etc.); also BCD support in x87

JCXZ and LOOP instructions for implementing counted loops

INTO, for generating a trap on arithmetic overflow (e.g., in Ada)

XLAT for table lookups

BOUND for checking array bounds

Sign flag, found in the status register of many CPUs, exists to easily perform signed AND unsigned arithmetic.

SSE 4.1 instruction set introduces instructions for string processing, both counted and zero-terminated (PCMPESTR, etc.)

Also, I could imagine that a number of system-level features were designed to support
safety of compiled code (segment limit checking, call gates with parameter copying, etc.)


问:
Can CC0 code use a GPL library?
Suppose my code uses (simply links to) a library licensed under the GPL. Can I release my code under CC0 (public domain dedication)? Is my code affected by the copyleft nature of the GPL?

答:
If your code uses someone else's GPL (ie not LGPL) code then you have (probably) created a derived work. The only license you have to distribute the other person's GPLed work is GPL.

You cannot take their work and give it away as CC - it's not yours!

edit: If you merely wish to release you own code on it's own (eg as source) then even if that requires your users to get the GPL lib to use it, that is fine. You can do whatever you want with your code.

What you can't do is take the combination of GPL+yours and give away the result,  eg a compiled program, as CC.

Title: Can CC0 code use a GPL library?


答:
The thing about "small" projects is they rarely stay small.  If they're successful they grow.  Otherwise they die.  What happens is you add "just one more little thing" until eventually you have implemented a framework anyway, and it's usually poorly designed because it was never intended to grow.

Even if you are convinced this time is different and your application won't grow, there are so many things you get for free with a framework that I have a hard time seeing why anyone would forgo it.  You get themes, user authentication and roles, administration pages, tested modules, security fixes, and more, all of better quality than an individual developer starting from scratch could produce.

Yes, there's a learning curve associated with any framework, which is why people think they're saving time by starting from scratch.  That notion is very short-sighted.  It's ridiculous to assume that learning a heavily used and tested software application is harder than implementing one of your own from scratch.  They have already encountered and solved hundreds of problems that you aren't even yet aware exist.


答:
If the library is under the regular GPL, then your CC0 code cannot use it (at least according to the GPL FAQ). The main intention of the GPL is to prevent proprietary software makers from profiting from free software without giving back anything. If it were possible to put a program that uses GPL code under a license that does not require making the entire program open source, then the GPL could be trivially circumvented by writing wrapper for the GPL code that has a very permissive license.

There is a separate license, the LGPL that puts a library's code under the GPL while allowing non-GPL code to use that library.

Title: Can CC0 code use a GPL library?

Body: Suppose my code uses (simply links to) a library licensed under the GPL. Can I release my code under CC0 (public domain dedication)? Is my code affected by the copyleft nature of the GPL?


答:
For small scale PHP development you can use MVC framework. It will allow you to have your codes and folders organized. One of which is CodeIgniter. They have good manual which is also included when you download their framework and they have a much bigger community.

But if you want to make your own framework you can try this folder structure.

```<code>lib/ == contains your classes
app/
app/view == contains the templates
app/model == contains the business logics
app/controler/ == contains the implementations of the business logics
config/ == site configurations
index.php
.htaccess
</code>```

Body:
For small scale PHP development you can use MVC framework. It will allow you to have your codes and folders organized. One of which is CodeIgniter. They have good manual which is also included when you download their framework and they have a much bigger community.

But if you want to make your own framework you can try this folder structure.

lib/ == contains your classes
app/
app/view == contains the templates
app/model == contains the business logics
app/controler/ == contains the implementations of the business logics
config/ == site configurations
index.php
.htaccess


答:
Data annotations are static, for instance this method declaration cannot change at runtime:

[MinLength(5)]
[MaxLength(20,ErrorMessage="Le nom ne peut pas avoir plus de 20 caractères")]
public new string Name { get; set; }
```
<p>The fluent interface can be dynamic:</p>
<pre class="lang-cs prettyprint-override"><code>if (longNamesEnabled)
{
    modelBuilder.Entity<Manager>().Property(ma => ma.Name)
    .HasMaxLength(100);
}
else
{
    modelBuilder.Entity<Manager>().Property(ma => ma.Name)
    .HasMaxLength(20);
}
</code>```

not to mention the code can be reused between properties.

Body:
Data annotations are static, for instance this method declaration cannot change at runtime:

[MinLength(5)]
[MaxLength(20,ErrorMessage="Le nom ne peut pas avoir plus de 20 caractères")]
public new string Name { get; set; }

The fluent interface can be dynamic:

if (longNamesEnabled)
{
    modelBuilder.Entity<Manager>().Property(ma => ma.Name)
    .HasMaxLength(100);
}
else
{
    modelBuilder.Entity<Manager>().Property(ma => ma.Name)
    .HasMaxLength(20);
}

not to mention the code can be reused between properties.

ContentLicense: CC BY-SA 4.0


问:
shortening url to cms
Hi
We have a CMS application that lets people create websites under our domain.
The system was built a few years ago and it used a method that transfers parameters such as website id, folder code and more using the url. this method created a giant url for every item in the website

For example:
My domain is www.domain.com

A users website on my domain is www.domain.com/user

and every time that a user enters his website he gets a link like this
www.domain.com/page.aspx?code=blablasdsdsdsdsds&folder=blablablablablabla and more.

We are trying to reduce the string size in the url.
What are our options? can we show the user one url like a virtual one and still work the same with the old url?
We are trying to locate a solution that wont make us rewrite our entire application.

the application is built in c# and the web server is iis 6.
Thanks

答:
You might want to consider URL Rewrite (or friendly URL) techniques. IIS6 could be a little tricky though.

You can find lots of resource just by google-ing.

http://www.google.com/search?q=url+rewrite+asp.net

An example can be found in this SO post:

https://stackoverflow.com/questions/2262/asp-net-url-rewriting

Title: shortening url to cms


问:
How to stop / avoid Over Time on a Scrum Team?
Actually, I'm helping a small software shop on their Scrum Implementation. Recently the Scrum Master reported me that he has a problem because the Team is working Over Time to achieve the Scope (Committed Backlog). So they have an Unreal Velocity.

My formal question(s) is / are:

Apart from speaking about on the Retrospective Meeting; do you think that is a good idea to implement some hard-blocks to avoid Over Time?

If so, what techniques / tools do you suggest?

Revision Control system (SVN, GIT, HG, etc...), blocks by hours (8 to 5)

Work station blocks by hours (8 to 5) or cumulative hours (up to 8 hrs/day)?

Other(s)...

Or, maybe, do not hard-block this kind of things; but implement some "Penalty System" for Unjustified Extra Hours?

First: Tks all for your fast responses.

@Baqueta (and others with similar questions): No they are not been paid for Extra Hours. My first advise to them was to review their estimates because maybe they were underestimating.
This was my favorite advise:

If they have an interest in working overtime, remove it. Development isn't something you can do for 60 hours a week and stay productive, and there are numerous studies out there that prove this. If overtime pay is the issue, get rid of it and improve their base pay so they're getting what they're worth.

Also, I think that the root problem (for this team), is a combination of the following:

The developers are being told what they must achieve in a sprint/aren't being consulted on what's achievable/are being ignored when they say there's too much work.

The developers are consistently underestimating how much time tasks will take/how many units of work are involved in each task.

Summary: I'll talk to the Team to review their estimates, and with the P.O. because I feel that they are not being consulted about the scope, as you mentioned.

答:
I struggled with this when I first switched to scrum.  It's natural to want to put in extra effort near a deadline, but scrum has deadlines every two weeks so it's an adjustment.  In addition to the suggestion others have made to cut back on the committed story points every iteration, I would also suggest ensuring the stories are broken down enough, so each developer can finish at least two or three in an iteration.

That not only ensures each developer feels like they have accomplished something each iteration, it also gives you some slack in your scope.  When your burndown shows you won't be able to finish a story, you can pull it out and reallocate people to the stories that can be finished.  When people see that scope can be adjusted, they will be less likely to stress out about unrealistic deadlines.  If you start an iteration with every story in progress, you have no room for adjustment.

An ideal cumulative flow chart should look something like this if everyone is finishing two stories per iteration:

It never looks like that because in reality it's very difficult to time all the stories to end on the last day while keeping everyone busy, but it's a good rule of thumb.  If you are overcommitted, the red area will be larger and you can remove stories.  If you are undercommitted, the blue area will be larger and you can add stories.  If your stories are too big, the green area will be larger and you should split stories.


问:
Storing plaintext passwords for detecting fraud
I am well aware of best practices for storing user passwords:

Never store passwords in plaintext

Never store encrypted passwords; always store password hashes

Always salt your password hash to deter brute force attacks

Always use unique salts to deter attacks using rainbow tables.

However, I have recently came upon on a potentially legitimate use case for keeping plaintext (or plaintext-accessible encrypted) user passwords: fraud detection. For example, if we have a system that needs to restrict purchases to 1 (or a small number) per person, we have observed that fraudsters often use the same password over and over, so if we have detected fraudulent purchases on one account, we can use the fact that password matches as a useful signal in a fraud detection system.

But implementing such a system requires breaking all the best practices for password storage.

Question: If it is determined that the fraud-detection ability of being to retrieve passwords is necessary, what are the best practices for storing passwords securely but in a way that is plaintext-accessible?

答:
It's probably not a good idea to store plaintext passwords, but if you wanted to use "same password" as an indicator of fraud, here's how I'd do it:

When a user signs up, generate a hash using a different salt to the one you otherwise use.

Truncate to the first n bits.

So for each user you'd have two distinct hashes -- one with, say, 64 bytes. The other with 2 bytes, say. Theoretically, this will make your hashing 65,536 times weaker (not entirely confident with this; maybe somebody could support/refute).

You'd then be able to use this value as a weak indicator of fraud.