问:
How to prioritize tasks when you have multiple programming projects running in parallel?
Say you have 5 customers, you develop 2 or 3 different projects for each. Each project has Xi tasks.

Each project takes from 2 to 10 man weeks.

Given that there are few resources, it is desired to minimize the management overhead.

Two questions in this scenario:

What tools would you use to prioritize the tasks and track their completion, while tending to minimize the overhead?

What criteria would you take into consideration to determine which task to assign to the next available resource given that the primary objective is to increase throughput (more projects finished per time unit, this objective conflicts with starting one project and finishing it and then moving on to the next)?

Ideas, management techniques, algorithms are welcome

答:
Kanban allows you to track tasks in workflows. They show areas in the workflow that are experiencing backlogs so you can dedicate more effort to clearing them, as well as begin to isolate what's causing them.

There are several nice references on the techniques.

Read them all. Yes. Read them again until nothing seems to contradict your "learned" experience. Then take out some post-its and try to teach someone else what kanban is. Then read them again so you see what you didn't understand as well as you thought.


问:
How should standards and process improvements be introduced to an organization without them?
I've been tasked with improving the software development process through the implementation of process improvements, of which we will most likely be using CMMI for Development, Version 1.3 as a guideline and adopting the best practices in whole or in part. What is the best way to introduce standards and process improvements so that the degree of push back and resistance from developers is minimized?</p>

答:
Start software process improvement (SPI) project. Define its scope and goals. It will definitely help if standardization has its own goals and measure applicable to your organization.

Assign person responsible for adopting standards. It also might be several people or even department in the case of large organization. Important thing is that all those responsible for the standardization would be:

professional enough to see the whole picture

influential enough in order to deal with teams and help them to adopt/negotiate changes

Develop trainings covering both standard you want to adopt and its specifics applied to your organization. And its really important as long as all people who were not trained are potentially resistant to changes. For example, when I worked in a large company, I instructed all newcomer employees about QA processes, CMMI, ISO and Quality Management System. Such training was obligatory. It helped to improve knowledge about the quality management processes and raise employees awareness regarding the important issue of software quality.

Negotiate changes and tailor generally accepted practices for your specific needs. It will help to avoid bureaucracy and implementation of heavy-weight processes nobody really need.

Establish monitoring of how implemented process improvements are being supported and whether they are effective enough in your organization.

It will also help if you will find all the people within your organization who are truly concerned about the quality. Most probably, those would be the most important resource helping you to promote changes and establish mature practices.

ContentLicense: CC BY-SA 3.0


问:
Sending a collection of data to an API. Multiple small calls vs one big call
I am currently creating an API and implemented a few basic REST actions such as get, update, search etc. Another program that collects data needs to synchronize these to this API. My current thought is: What would be good practice to synchronize this data?

A few informations:
The amount of data that needs to be synchronized is different between applications. Some may transfer 100 records a minute, others 10k records a minute. There will be a transfer limit per hour to keep the server load balanced. Additionally, requests are signed with a token to check authenticity.

Here's a little pro/con list I've made just now. I'm neither sure if these are real pros/cons there nor am I sure if I should weight some of them.

Option One

Loop through this data and create an API call for every record.

Pros:

integrates better with the current REST API

failed synchronisation entries can be queued for a resend

Cons:

a bigger overhead because of multiple calls

Option Two

Build a package of all those data and send over that package in one call.

Pros:

less overhead

just one query

Cons:

transfer error may drop all data

separate implementation to allow

答:
Generally, the overhead of initiating and ending the remote request is high enough that you are going to want to batch the calls. Exactly where this line is really depends on how much data is involved here to say where your batching lines should be. It really should not be that much overhead to make the receiving system handle batches -- computers are real good at "run this function again with new parameters" last time I checked.

From a logical perspective, would a batch be considered a transaction in the typical database sense? If so, it also makes loads of sense to let it travel and succeed (or fail) together rather than trying to work out how to spread a single logical transaction over separate physical transactions.

What would push me towards doing single calls is if each request had a lot of data involved -- hundreds of KB at least -- or if things needed to be a bit more real time and you couldn't wait to build batches.


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

For example:

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

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

So in the HTML I would put:

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

and in the CSS:

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

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

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

答: No, this is not a good practice. You should use already semantic, meaningful tags -- perhaps  in this case -- and apply CSS styles to achieve your design requirements.

Body: No, this is not a good practice. You should use already semantic, meaningful tags -- perhaps <em> in this case -- and apply CSS styles to achieve your design requirements.


答:
No you can't create your own HTML tags, because you would then have to get all major browsers to implement them, currently when browsers find an unrecognized tag they ignore everything in it, so unless you want to make your own browser creating a new tag is pointless, and even then they would only work in your browser.

You could try submitting a use-case for them to the w3c, but I doubt it would get anywhere.

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

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

For example:

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

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

So in the HTML I would put:

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

and in the CSS:

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

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

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


答: No, although it is allowed to add new tags from another namespace in XHTML, the processing of HTML tags which are not specified is strongly discouraged.</p>


问:
What types of positions might involve improving processes using CMMI and Scrum?
I'm an IT student and have been working on team based projects for several years. I've read some papers about CMMI and Scrum; this is really interesting to me and I would like to know what kind of jobs involve improving processes inside an organization.

What kind of studies can lead someone towards these jobs? Management? I doubt it's only that, as CMMI/Scrum affect management as well, I think it's something above it all, that will hold together the organization.

答:
QA Engineer

And I do not mean testing. Testing is Quality Control, while Quality Assurance  (QC vs QA) is more broad area which includes everything you mentioned (establishing best practices such as CMMI, ISO, COBIT, etc) and is focused on software processes improvement (SPI) - not only testing, but also project management, release management, reporting, etc (full list of QA responsibilities is the list of CMMI process areas). And the most important thing comparatively to other positions (that might involve software process/quality improvements), QA Engineer has software processes and quality as its primary responsibility.

OwnerDisplayName: Aki


答:
I would like to know what kind of jobs involve improving processes
  inside an organization.

In some organizations, especially those in industries that rely heavily on process and quality certifications, there will be process engineers and engineering process groups. From my own experiences in the defense industry, nearly every defense contractor has people who specialize in engineering process, as well as engineers from various disciplines that support ongoing process improvement.

What kind of studies can lead someone towards these jobs? Management?
  what's the idea? Management as a topic to be studied? And what other
  topics could be studied to lead to a job using such methodologies /
  frameworks?

I studied software engineering, emphasizing the engineering process and quality courses. I also minored in business management. Within the first 6 months of my first post-college job, I was already working on the engineering process group within my organization.

Some kind of business or engineering management background is probably useful, since many process improvement opportunities are a balance between maintaining or achieving a certification and the needs of the business. However, engineering process groups might not be just process specialists, but also contain those knowledgable in the business and engineering disciplines of the company, who serve to ensure that the processes in place work within the context of ongoing projects.

This is a cross-posting of my answer to the same question on the Project Management Stack Exchange

Title: What types of positions might involve improving processes using CMMI and Scrum?

Body:
I'm an IT student and have been working on team based projects for several years. I've read some papers about CMMI and Scrum; this is really interesting to me and I would like to know what kind of jobs involve improving processes inside an organization.

What kind of studies can lead someone towards these jobs? Management? I doubt it's only that, as CMMI/Scrum affect management as well, I think it's something above it all, that will hold together the organization.


问:
How to talk a client out of a Flash website?
I have recently been doing a bunch of web side projects through word of mouth recommendations only.  Although I am much more a of a programmer than a designer by any means, my design skills are not terrible, and do not hate dealing with UI like many programmers.  As a result, I find myself lured into a bunch of side projects where aside from a minimal back end for content administration, most of the programming is on front end interfaces (read javascript/css).

By far the biggest frustration I have had is convincing clients that they do not want Flash.  Aside the fact that I really do not enjoy Flash "development", there are many practical reasons why Flash is not desirable (lack of compatibility across devices, decreased client accessibility, plug-in requirements, increased development time, etc.).  Instead of just flat out telling the clients "I will not build you a flash website", I would much rather use tactics to convince/explain to them that this is not what they actually want, ie: meet their requirements any better than standard html/css/js and distract users from their content.

What kind of first hand experience do others have with this?  How do you explain to someone that javascript/css/AJAX is usually a better option for most websites?  Why do people want to use Flash so bad to begin with?

This question pertains to clients who do not have any technical reasons for wanting flash, but just want it because they think it makes pretty websites.

答:
TL;DR

This more so goes inline with what a lot of contributors have already pointed out, but you really need to stick to the FACT that Flash is not fully supported. Adobe has pulled the plug on Flash Mobile support. This move made by Adobe means that other Mobile devices will soon be affected, leaving mobile devices without Flash viewing capability altogether. We have seen this happen before. Take ColdFusion for example. There are quite a few programmers and clients who were affected by the Adobe-caused death of ColdFusion.

In conclusion, a web-based platform (and any platform for that matter) is only as good as its supporters, contributors, and creators. Building a whole entire website on a wobbly platform WILL, without a doubt, cause the client to spend outside of their budget when it comes time to rebuild their website.

ContentLicense: CC BY-SA 2.5


答:
Why don't you "wow" them with non-flash examples of your work? They can see the potential along with your expertise. Let them know there is nothing that can be done in Flash that you can't do your way (I hope this is true.). If they argue, then just use Flash, there have been several more technical reasons to avoid it. You need to make sure in their mind, they won't be limited by making this choice.

They may be under the impression a novice is more likely to learn how to tweak something in Flash in an emergency and not worry about being locked into a particular developer.

There's always the old "Nobody got fired for buying IBM." mentality. Flash is in the news and your clients don't distinguish good from bad publicity.

Title: How to talk a client out of a Flash website?

Body:
I have recently been doing a bunch of web side projects through word of mouth recommendations only.  Although I am much more a of a programmer than a designer by any means, my design skills are not terrible, and do not hate dealing with UI like many programmers.  As a result, I find myself lured into a bunch of side projects where aside from a minimal back end for content administration, most of the programming is on front end interfaces (read javascript/css).

By far the biggest frustration I have had is convincing clients that they do not want Flash.  Aside the fact that I really do not enjoy Flash "development", there are many practical reasons why Flash is not desirable (lack of compatibility across devices, decreased client accessibility, plug-in requirements, increased development time, etc.).  Instead of just flat out telling the clients "I will not build you a flash website", I would much rather use tactics to convince/explain to them that this is not what they actually want, ie: meet their requirements any better than standard html/css/js and distract users from their content.

What kind of first hand experience do others have with this?  How do you explain to someone that javascript/css/AJAX is usually a better option for most websites?  Why do people want to use Flash so bad to begin with?

This question pertains to clients who do not have any technical reasons for wanting flash, but just want it because they think it makes pretty websites.


答:
A couple thoughts from the school of hard knocks:

1) Most process improvement initiatives spend 80% of their time on process design and 20% on education and socialization.  Flip these percentages.  A mediocre standard that's followed beats a perfect one that isn't.

2) Identify clear reasons why you're asking people to change how they work.  What's the business case?  Ideally it benefits every team individually.  Sometimes it's just systemic improvement.  Either way, make the case visible.

3) Simplify, then standardize, not the other way around.

4) You can't fully delegate this to a PMO.  Direct managers need to be bought in, and the head of the business unit will need to break ties when complaints come in.

5) Find friendly early adopters.  People will complain about how much time it all takes.  You need someone you can point to and say, "it only took them 15 minutes"

6) For metrics, push hard for quantitative over qualitative.  Otherwise you have projects that are Green until a day before Go Live, when everything slips by a month.

7) Emphasize techniques over tools.  Good planning is more important than MS Project.

8) Put in a level of process relative to the needs.  Every restaurant needs process, but Nobu and the French Laundry need a different kind than McDonalds.  Same with software firms.

Good luck!

Title: How should standards and process improvements be introduced to an organization without them?

Body: I've been tasked with improving the software development process through the implementation of process improvements, of which we will most likely be using CMMI for Development, Version 1.3 as a guideline and adopting the best practices in whole or in part. What is the best way to introduce standards and process improvements so that the degree of push back and resistance from developers is minimized?</p>


问:
Linux distro for software development support?
I've spent too much time on setup & maintain a development server, which contains following tools:

Common services like SSH, BIND, rsync, etc.

Subversion, Git.

Apache server, which runs CGit, Trac, Webmin, phpmyadmin, phppgadmin, etc.

Jetty, which runs Archiva and Hudson.

Bugzilla.

PostgresSQL server, MySQL server.

I've created a lot of Debian packages, like my-trac-utils, my-bugzilla-utils, my-bind9-utils, my-mysql-utils, etc. to make my life more convenient. However, I still feel I need a lot more utils. And I've spent a lot of time to maintain these packages, too.

I think there maybe many developers doing the same things. As tools like subversion, git, trac are so common today. It's not to hard to install and configure each of them, but it took a long time to install them all. And it's time consuming to maintain them. Like backup the data, plot the usage graph and generate web reports. (gitstat for example)

So, I'd like to hear if there exist any pre-configured distro for Development Server purpose, i.e., something like BackTrack for hackers?

答:
My recommended distributions are Ubuntu, CentOS and OpenSUSE.

But to solve the problem in your questions, I think you can utilize the Virtual machine tools (VMWare Server, VirtualBox, etc), especially the features like snapshot or clone.

And you can wrap the installation steps/scripts by using some cross-platform tools for automated setup, such as Puppet or Chef .

It's not to hard to install and configure each of them, but it took a
  long time to install them all. And it's time consuming to maintain
  them.

The remaining part, reporting and charts, is probably not much a question after you solve the installation and configuration IMHO.


答:
I think that you should also consider a configuration management tool such as:

Puppet

Chef

Juju (from canonical)

Blueprint (ubuntu/redhat oriented)

After you write down scripts for configuration once, you will never have to do them again...
Additionally you can use other peoples scripts to save time from writing everything (Puppet modules)

I did once something similar by writing a long bash script with lines like:

```<code>apt-get install packageXYZ
</code>```

Title: Linux distro for software development support?

Body:
I've spent too much time on setup & maintain a development server, which contains following tools:

Common services like SSH, BIND, rsync, etc.

Subversion, Git.

Apache server, which runs CGit, Trac, Webmin, phpmyadmin, phppgadmin, etc.

Jetty, which runs Archiva and Hudson.

Bugzilla.

PostgresSQL server, MySQL server.

I've created a lot of Debian packages, like my-trac-utils, my-bugzilla-utils, my-bind9-utils, my-mysql-utils, etc. to make my life more convenient. However, I still feel I need a lot more utils. And I've spent a lot of time to maintain these packages, too.

I think there maybe many developers doing the same things. As tools like subversion, git, trac are so common today. It's not to hard to install and configure each of them, but it took a long time to install them all. And it's time consuming to maintain them. Like backup the data, plot the usage graph and generate web reports. (gitstat for example)

So, I'd like to hear if there exist any pre-configured distro for Development Server purpose, i.e., something like BackTrack for hackers?

Body:
I think that you should also consider a configuration management tool such as:

Puppet

Chef

Juju (from canonical)

Blueprint (ubuntu/redhat oriented)

After you write down scripts for configuration once, you will never have to do them again...
Additionally you can use other peoples scripts to save time from writing everything (Puppet modules)

I did once something similar by writing a long bash script with lines like:

apt-get install packageXYZ


问:
Is validating HTML a thing of the past?
With us moving continually closer to HTML5 in terms of adoption, is writing HTML for validity something the web is rejecting, allowing us to straddle standards as the web continues to be in a perpetual state of transition to the "next" thing?

Is validation important?

If so, what is the net gain?

If not, why not?

答:
Validation will always be important, but during times of transition from one standard to another it's very difficult to pull off. It's especially hard when the standard isn't even finalized and agreed upon yet. So while validation is important, business is more important and simply won't wait for validation. So there will inevitably be some indefinite transitional period where validation will be summarily discarded in many cases until a more stable standard is reached and implemented that can provide a reliable basis for validation.

Html5 is "out", but it isn't set to be finalized until 2014 sometime.

Title: Is validating HTML a thing of the past?


答:
If you need to keep the semantics of <important/> for specific reasons, you can use XSL to transform your custom tags into valid HTML. You can read more on this topic here:

https://www.w3.org/Style/XSL/WhatIsXSL.html

https://web.archive.org/web/20210301191904/https://www.4guysfromrolla.com/webtech/081300-2.shtml

https://developer.ibm.com/technologies/web-development/

https://web.archive.org/web/20130521021917/http://www.siteexperts.com/tips/xml/ts01/page5.asp

https://www.htmlgoodies.com/xml/converting-xml-to-html-using-xsl/

You still can't have <important/> in the final HTML output, but you can have it automatically transformed to something like <span class="important"....

ContentLicense: CC BY-SA 4.0


问:
Why should identifiers not begin with a number?
Most programming languages appear to be designed to not allow one to declare an identifier that starts with a number. I was just curious to know the reason. I have already searched the web, but couldn't find a satisfactory explanation.</p>

答: The answer to this question lies in automata or more precisely finite automata that defines the regular expression. The rule is...compilers need exact algorithms or rules to decide at every character that they parse. If identifiers were allowee  to start with a number then the compiler will be in a fix..about the nature of the token coming...will it be a number or an identifier...and as compilers cant backtrack to earlier positions...so..to make it clear to the compiler that the coming token is precisely an identifier or a number...this restriction is there...coz of this...compiler knows just by scanning the first character that the coming token is an identifier or a number. </p>


答:
You could use  and  with custom CSS to alter how it's displayed.

Strong, refers to stronger importance.

Emphasis, refers to increased emphasis.

Body:
You could use <em /> and <strong /> with custom CSS to alter how it's displayed.

Strong, refers to stronger importance.

Emphasis, refers to increased emphasis.


问:
Do GUI programmers have an undue advantage over others?
It is easy for managers and customers to appreciate what they can see.

I have seen many GUI developers who are average programmers with minimal knowledge of design principles or other programming idioms. However, these shortcomings often go unnoticed, specially by management and customers, if the programmer can create an impressive looking user interface. So much so that many GUI developers I know spend hours beautifying the GUI at the expense of writing bad, unmaintainable code.

On the other hand, middle tier programmers who develop APIs or business functionality or database code (SQLs etc.) are at a disadvantage as there is nothing tangible to showcase. Perhaps a code reviewer or an architect may appreciate the elegance, good design, scalability etc. of code but it means nothing to the outside world. Your code may run for years without breaking, may be very easy to maintain and have good performance, yet it never elicits the 'wow' that a slick looking GUI does.

In my opinion, a corollary to this is (and I am going to get heavily downvoted for this, I know) that there is less motivation for a GUI programmer to write good clean code.

EDIT: I must explain here that by GUI programmer, I don't mean a full-fledged web/GUI designer but a front-end programmer e.g., a java-swing programmer.

Does the rest of the community agree ?

答:
I hate GUI development for two reasons,

I am more logical than graphically artistic and my UI always suffers as a result.

As UI isn't based on logic, unit tests are nigh on impossible to write with any meaning

At the end of the day, however, I think that my code will be better appreciated by the end user (as opposed, perhaps to a project sponsor), than that of a mediocre developer who is a whiz at UI, as it generally works.


答:
On the practical side, it is unnecessary to use new tags for highlighting. You can use em or i tags if you prefer italics as default (non-CSS) rendering and strong or b if you prefer bolding as default. If, for some reason, you prefer default rendering as normal text, i.e. no highlighting, use span. In each case, you can use a class attribute to distinguish this usage from other usage you might have for the markup.

HTML specicifications and (HTML5) drafts are obscure as regards to the semantics of these elements, but this need not cause any major headache.


答:
HTML 4.01 Strict Validation is one of my automated tests in my ATDD test suite.

For us validation is important because of consistency of browser behavior.  So if you don't need consistency of behavior across different browsers (and browser versions), then it's probably more of a nice-to-have.

Driving consistency of behavior for all your pages makes the following cheaper:

more uniform behavior

more uniform placement

page "tweaking"

easier ADA compliance (remember Target, Walmart, and other have been sued over this)

Title: Is validating HTML a thing of the past?

Body:
With us moving continually closer to HTML5 in terms of adoption, is writing HTML for validity something the web is rejecting, allowing us to straddle standards as the web continues to be in a perpetual state of transition to the "next" thing?

Is validation important?

If so, what is the net gain?

If not, why not?


答:
For each change:

Call out the 1 change and how it will improve development.

Implement the change.

Demonstrate improvement

Remove changes that did not demonstrate improvement

Obviously the analysis needs to happen over time, but no change should be accepted until it's demonstrated to be effective.  That's also why I would implement no more than 2-3 changes per cycle otherwise you often can't measure if there has been improvement or not.

Nothing irritates me more than blindly following best practices without doing the analysis to show that is actually is a best practice for your environment.  A best practice that doesn't demonstrate improvement is at best wasteful and at worst damaging.

All steps in your process and all practices in methodology should analyzed and proved to be of benefit.  If it isn't it should be removed.  This analysis should be done on an on-going basis regardless of adding or removing steps or practices.


问:
What is the difference between a software process model and software engineering methods (methodology)?
I'm an academic guy, who is now venturing into the software engineering world, puzzled by the fact that many terms seem to overlap each other. I'm reading some books and cannot quite distinguish/correlate a software process model from software engineering methods.

For instance, in Software Engineering Ian Sommerville defines a software process model as:

A simplified representation of a software process, presented from a
  specific perspective.

And software methodology (software engineering methods) as:

Structured approaches to software development which include system models, notations, rules, design advice and process guidance.

However, Wikipedia defines software development methodology like this:

A software development methodology or system development methodology in software engineering is a framework that is used to structure, plan, and control the process of developing an information system.

In my opinion, Sommerville's definition of a software process model can enter on the scope of the Wikipedia definition. Can anyone enlighten me on this issue? An example would rock, e.g, A is a software process model and B is a software engineering methods (methodology).

答: Software model describes a hypothetical or existing instance of software. Software methodology are the steps to create an instance of software regardless of its model. </p>


答:
HTML validation isn't a huge deal deal for a few reasons, that don't really have anything to do with HTML 5.

It doesn't really mean anything other than some group says this is right, if you did everything else right a validator can't check.

HTML isn't source code for a vast majority of projects, other things are generating HTML and you have limited power over influencing how that is done.

The only thing that has ever really mattered is it works in popular browsers and validation has traditionally been a mediocre guarantee of that.

Title: Is validating HTML a thing of the past?


问:
What are the practical uses of Windows Services?
I am new to working with Windows Services. Although I have learnt to create  Windows Services in VS2010  I would like to know some practical ways in which windows services could be used?

I tried Googling with the current context in mind only to find more tutorials on how to create Windows Services.

EDIT on Bounty Offer:

All the answers are great but I was looking for more practical examples on windows services and their implications? This will help developers know when it is appropriate to use them with the case study.

答:
Since you added the note about practical examples to your question, I will give you some examples of services I have written for enterprise applications (you don't say if you are an enterprise applications programmer but my guess is that most C# VS2010 programmers are).  I think you are looking for an idea of what developers that don't work for Microsoft might write.

A heartbeat monitor service that checked if other programs were still running (this might have worked as a scheduled task as well, but was implemented as a service).

A report writing service that worked through queues of report requests, ran the reports, and sent them to different printers depending on what printer was busy.  This helped offload a fair amount of work from a legacy application and allowed the report running to be shared by multiple cheap boxes running the service.

It was implemented as a service so that it would run continuously, start automatically on a reboot, and be able to use the standard windows services interface to start, stop, pause, etc.  Also, if it was a scheduled task it would need to initiate getting data from other programs or a persistent source (a queue, a file, a database) rather than being available for other program's to call (socket, pipe).

The server portion of a that client/server application was also implemented as a service so that it would restart on a reboot, etc.  There was another project with an .exe that ran the same program not as a service, to make it easier to debug on development machines.

I hope that helps.  The other answers are better general answers though, especially the idea that scheduled tasks are probably easier to write and administer for most purposes now.


问:
How can a child state machine relinquish control back to the parent state machine?
My top level state machine has some states and edges. I will call this the parent state machine.

```<code>A ----> B ----> C
</code>```

Any state within the parent state machine can be a state machine too. I will call these children state machines.

```<code>           ___________
         /            \
A ----> |  B0->B1->B2  | ----> C
         \____________/
</code>```

If the parent state machine transitions from A to B, B's state machine takes over. Once B is done running, how should it relinquish control to the parent state machine and transition to state C? Which design pattern do you use?

If you're wondering, I have children state machines within parent state machines because my exact project is quite complex and it is natural to encapsulate the internal workings of a child state.

答:
Have you read this section of Taoup? There are several different ways to accomplis this but many of them depend on how you have split your state machines. Are they separate processes? Threads? Objects?

Figure out how you have them built, and look to see if there is a canonical way for them to communicate. If one does not exist, you may be designing your system wrong.

For me, I'd look at separate processes, hooking stdin and stdout together. The child state machine then becomes standalone, acting on stdin and outputing on stdout. It becomes the parent state machine's job to start the child process, hook up the pipes, and then dump in data and wait for results. All of those things have already been done in all modern languages, so it should be easy to do.


答:
Every state machine has some sort of event handler and a means to trigger those events.  That handler takes as input the existing state and type of event, chooses the new state, and optionally runs some side effect code.

Essentially, while in state B, your main event handler forwards any events it doesn't recognize to B's event handler and remains in state B.  When B wants to transition to C, it posts the appropriate event to the main event handler.

Title: How can a child state machine relinquish control back to the parent state machine?

Body:
My top level state machine has some states and edges. I will call this the parent state machine.

```<code>A ----> B ----> C
</code>```

Any state within the parent state machine can be a state machine too. I will call these children state machines.

```<code>           ___________
         /            \
A ----> |  B0->B1->B2  | ----> C
         \____________/
</code>```

If the parent state machine transitions from A to B, B's state machine takes over. Once B is done running, how should it relinquish control to the parent state machine and transition to state C? Which design pattern do you use?

If you're wondering, I have children state machines within parent state machines because my exact project is quite complex and it is natural to encapsulate the internal workings of a child state.


答:
My favorite examples of using services:

Servers - programs that serve requests from remote clients. They will usually run as services to make sure that they are available no matter if any user is logged in to the server or not. Running as a service also means that the server starts processing requests as soon as the machine is started, no one has to log in to the machine to start the program after the machine is restarted for any reason. A database server is a great example.

Background processing - programs that are responsible for processing data from a data source and storing results into a data target. The data target is often a source for another process, and so on. Running as services allows those programs to just sit there and wait for the data to arrive. It also lets developers improve the robustness of the processing by splitting the process into multiple semi-independent steps.

Title: What are the practical uses of Windows Services?

Body:
I am new to working with Windows Services. Although I have learnt to create  Windows Services in VS2010  I would like to know some practical ways in which windows services could be used?

I tried Googling with the current context in mind only to find more tutorials on how to create Windows Services.

EDIT on Bounty Offer:

All the answers are great but I was looking for more practical examples on windows services and their implications? This will help developers know when it is appropriate to use them with the case study.


答:
Separate the two state machines and use message passing between them. Thus, state machine 1 would proceed from A B C, where at state B it checks for the current results from state machine 2. If the output has changed, then state machine 1 can account for it and state machine 2 does not need to have any awareness of how state machine 1 actually works. Something like:

typedef struct StateMachine {
  void(*Update)(); // function to update the state machine
  int Data;        // generic temp holder to survive state contexts
  int State;       // current state of our state machine
  int *Message;    // pointer to a shared integer for message passing
};

int main(void) {
  int Message = 0;
  /* NewStateMachine would malloc the struct, pass in the int reference
   * and function pointer as well as add it to a circularly linked list */
  NewStateMachine(&Message, MainLoop);
  NewStateMachine(&Message, MinorLoop);
  StateMachine *Current = StateMachine_CLL.First;

  for(;;) {
    Current->Update(Current); /* Update the current state machine */
    Current = Current->Next;  /* And the advance to the next one */
  }
}

void MainLoop(StateMachine *this) {
  switch(this.State) {
  case 0:
    CloseCoolantTank(1); /* safe to call if valve already closed */
    CloseCoolantTank(2); /* safe to call if valve already closed */
    this.State = 1;
    break;
  case 1:
    /* we have a message, do something */
    if(*this.Message) this.State = 2;
    /* otherwise stall at this state until we get a message */
    else this.State = 1;
    break;
  case 2:
    if(*this.Message == 1) this.State = 3;      /* warm */
    else if(*this.Message == 2) this.State = 4; /* hot! */
    else this.State = 0;                        /* cooled down, shut off valves */
    this.Message = 0;                           /* clear the message */
    break;
  case 3:
    OpenCoolantTank(1); /* opens the valve, safe to call if already open */
    this.State = 2;     /* recheck for new message */
    break;
  case 4:
    OpenCoolantTank(2); /* opens the valve, safe to call if already open */
    this.State = 3;     /* also open coolant tank 1 for extra cooling */
    break;
  }
}

/* Monitor temperature and send messages on overheat */
void MinorLoop(StateMachine *this) {
  switch(this.State) {
  case 0:
    this.Data = ReadADCValue();
    this.State = 1;
    break;
  case 1:
    if(this.Data > 150) *this.Message = 2;
    else if(this.Data > 100) *this.Message = 1;
    this.State = 0;
    break;
  }
}
```


答:
I think there is a general presumption out there that the UI developers are the "junior" developers. I can only think of one case I ran into where a UI guy was considered senior.

That said, I think UI is a lot harder than any other part of our apps. And I'm not talking about the UX design, I'm talking about the coding. How many other areas do we code in where we have to account for dozens, if not hundreds, or possible scenarios? Just resizing a screen can sometimes become a royal pain when you need to figure out what needs to happen with a couple of dozen elements. This primarily comes up when you have guidelines that say "we need to support 800x600" and then UX designers that never use anything other than HD resolutions.

So, if they get more goodness because of more exposure, they probably deserve it. Usually, they are on the wrong receiving end more often than the good receiving end.

Title: Do GUI programmers have an undue advantage over others?

Body:
It is easy for managers and customers to appreciate what they can see.

I have seen many GUI developers who are average programmers with minimal knowledge of design principles or other programming idioms. However, these shortcomings often go unnoticed, specially by management and customers, if the programmer can create an impressive looking user interface. So much so that many GUI developers I know spend hours beautifying the GUI at the expense of writing bad, unmaintainable code.

On the other hand, middle tier programmers who develop APIs or business functionality or database code (SQLs etc.) are at a disadvantage as there is nothing tangible to showcase. Perhaps a code reviewer or an architect may appreciate the elegance, good design, scalability etc. of code but it means nothing to the outside world. Your code may run for years without breaking, may be very easy to maintain and have good performance, yet it never elicits the 'wow' that a slick looking GUI does.

In my opinion, a corollary to this is (and I am going to get heavily downvoted for this, I know) that there is less motivation for a GUI programmer to write good clean code.

EDIT: I must explain here that by GUI programmer, I don't mean a full-fledged web/GUI designer but a front-end programmer e.g., a java-swing programmer.

Does the rest of the community agree ?


答:
The way that I was taught, there is a clear difference between the two.

A software process model is an abstract representation of a process methodology. Waterfall1 is a process model. Iterative methodologies are process models. They don't specify how to do things, but outline the types of things that are done and sequencing for things. For example, Waterfall identifies the phases that a project goes through - requirements, design, implementation/unit testing, integration testing, system testing, deployment - without saying what artifacts to produce or what tools to use (although the output of code is implied). Agile defines core values in the form of the Manifesto for Agile Software Development, time-boxed iterations, and continuous response to change, but it doesn't say how long your iterations should be or how you go about responding to change. The Spiral model is a third software process model.

A software process methodology is a specific way of conducting a software project. These are things like the Rational Unified Process and Scrum. They define exactly what, when, and/or how various artifacts are produced. They might not be entirely explicit with all regards - for example, Scrum doesn't identify what documents to produce or not to produce, since it's focus is on delivering value to the customer - but they define, in some way, the actions that members of the project team must deliver.

However, in actuality, the point is often moot. Many times, process methodologies are presented as frameworks in which you tailor to the needs of your customer and development team, based on requirements and resources. On top of this, organizations might deal with regulatory or legal guidelines that dictate certain aspects of what must be produced or how to go about performing certain tasks (especially related to verification and validation activities).

It frequently becomes more important to discuss each team or organization's process in terms of plan-driven versus agile or amount of formality and ceremony. Discussing the terminology difference between a "process model" and a "process methodology" is mostly useful during academic discussions of process models.

1 I'm referring to the traditionally taught Waterfall, not the more explicitly defined Waterfall in Winston Royce's paper.

Title: What is the difference between a software process model and software engineering methods (methodology)?

Body:
I'm an academic guy, who is now venturing into the software engineering world, puzzled by the fact that many terms seem to overlap each other. I'm reading some books and cannot quite distinguish/correlate a software process model from software engineering methods.

For instance, in Software Engineering Ian Sommerville defines a software process model as:

A simplified representation of a software process, presented from a
  specific perspective.

And software methodology (software engineering methods) as:

Structured approaches to software development which include system models, notations, rules, design advice and process guidance.

However, Wikipedia defines software development methodology like this:

A software development methodology or system development methodology in software engineering is a framework that is used to structure, plan, and control the process of developing an information system.

In my opinion, Sommerville's definition of a software process model can enter on the scope of the Wikipedia definition. Can anyone enlighten me on this issue? An example would rock, e.g, A is a software process model and B is a software engineering methods (methodology).


问:
What is a good strategy for testing UserControls?
A UserControl cannot be dragged-dropped onto a winform.  Instead, I must compile the assembly add it to my toolbox, then I can drag it onto a Form.

Doing this toolbox approach just to test out a control and then "tweak" it repeatedly is quite cumbersome.

Right now, I plan to simply have this toolbox item pointing to a bin/debug assembly which will be repeatedly re-built.  I imagine this will come with it's own set of problems.

So what is a good strategy for testing UserControls?

答:
In your comments, you state that you unit test your Windows forms by programmatically instantiating them and performing a visual inspection.  I don't normally associate such testing with "unit testing," as unit testing is normally accomplished without any kind of user confirmation of the results; i.e. it is completely automated.

Regardless, if you simply want to instantiate a User Control programmatically, just add the User Control to a Windows form using code, and then show that form in the usual manner.

The necessary code for adding your User Control to the form will be automatically code-generated by Visual Studio if you drag the User Control onto the new form (the new code will be in the #region marked "Windows Forms Designer generated code" of the designer file).  You can then copy-paste that code to an appropriate place, and execute it as part of your test.


答:
For every task it is possible to create a model, complex enough to describe that task. But always out there exists another task, that couldn't be covered by that very model. But - that is the first important point - for any real task such model would be useless.

Models are made to look at the task or solution process from some one side, to provide easy understanding for some features of the subject. Of course, model consist of views, that is correct, but it is the view itself, too. Methodology is the organization of the process (as opposed to the final product and the starting task). It could demand many models for the task/product/process or their parts/stages.

Of course, it could contain some model(s) that look(s) at the process as a whole. But that bird view is not the methodology, too. It is not even "the root" of the methodology. The attempt to push all methodology into one model simply causes the unwholeness of the methodology. Because - that is the second important point - methodology is much more alive and changing thing than model. At least, it should be.


问:
How do people doing TDD handle loss of work when doing major refactoring
For a while I have been trying to learn to write unit tests for my code.

Initially I started out doing true TDD, where I wouldn't write any code until I'd written a failing test first.

However, I recently had a thorny problem to solve which involved a lot of code. After spending a good couple of weeks writing tests and then code, I came to the unfortunate conclusion that my entire approach was not going to work, and I would have to throw out two weeks work and start again.

This is a bad enough decision to come to when you've just written the code, but when you've also written several hundred unit tests it becomes even more emotionally difficult to just throw it all away.

I can't help thinking that I've wasted 3 or 4 days of effort writing those tests when I could have just put the code together for proof of concept and then written the tests afterwards once I was happy with my approach.

How do people who practice TDD properly handle such situations? Is there a case for bending the rules in some cases or do you always slavishly write the tests first, even when that code may turn out to be useless?

答:
The problem with doing a major refactoring is that you can and will sometimes follow a path that leads you to realize that you've bitten off more than you can chew. Giant refactorings are a mistake. If the system design is flawed in the first place, then refactoring may only take you so far before you need to make a hard decision.  Either leave the system as it is and work around it, or plan to redesign and make some major changes.

There is however another way.  The real benefit of refactoring code is to make things simpler, easier to read, and even easier to maintain.  Where you approach a problem that you have uncertainty about, you spike a change, go so far to see where it might lead in order to learn more about the problem, then throw away the spike, and apply a new refactoring based on what the spike taught you. The thing is, you can really only improve your code with certainty if the steps are small and your refactoring efforts don't overrun your ability to write your tests first. The temptation is to write a test, then code, then code some more because a solution may seem obvious, but soon you realise that your change will change many more tests, so you need to be careful to only change one thing at a time.

The answer therefore is to never make your refactoring a major one. Baby steps.  Start by extracting methods, then look to removing duplication. Then move to extracting classes. Each in tiny steps one minor change at a time.  IF you're extracting code, write a test first. If you are removing code, then remove it and run your tests, and decide if any of the broken tests will be needed any more.  One tiny baby step at a time.  It seems like it will take longer, but will actually shorten your refactoring time considerably.

The reality is however, that every spike is seemingly a potential waste of effort.  Code changes sometimes go nowhere, and you find yourself restoring your code from your vcs.  This is just a reality of what we do from day to day.  Every spike that fails is not wasted however, if it teaches you something.  Every refactoring effort that fails will teach you that you are either trying to do too much too quickly, or that your approach may be wrong. That too is not a waste of time if you learn something from it.  The more you do this stuff, the more you learn and the more efficient you will become at it.  My advice is to just wear it for now, learn to do more by doing less, and accept that this is just the way things probably need to be until you get better at identifying how far to take a spike before it leads you nowhere.


问:
How effective are programming challenges in the recruiting process?
I think our company can create challenges designed to find software engineer candidates who are:

Good at solving problems, not at wowing recruiters.

More likely to be afraid to come up to us at a career fair.

More likely to be underutilized in their current programming job but are too introverted to do anything about it.

For an example see this article that discusses Facebook hiding an email address in an image using Piet.

I just can't find any studies or hard data on whether this actually works or not.

答:
I am assuming you want someone to work as part of a team - as such the better programmer is the person who works better with the existing team members. You want to get a group of people together that can effectively communicate to each other, who actually get along well with each other (they don't have to be friends, but they need good rapport and respect), who are willing to agree and use a common development standards (code and process), who are willing to help their colleges when they deal with a new issue or have a mental block ( four eye theory ). You also need to find a mix of personality types, so if you have a team of introverts that rarely talk, then bringing in a more talkative team member may well improve team dynamics which will make the team more productive. On the other hand, you want to avoid a person with a overly strong personality because they will dominate the team and that will reduce quality and productivity - particularly with introverts in the team.

After you get a person to fit into that mix, then consider technical skill/ability. These too need to complement. Every one has different areas that they are strong at, others they are OK at and some they have no clue. So you need to get a mix of strengths together relevant to the project at hand. Remember that an intermediate coder who works well with a good coder will have the level of their work raised by the stronger person. The weak link in the chain is relationships, not skills (provided the skill is in the team)

Good luck in putting that together.


问:
What is wrong with Java's generics?
I have seen several times on this site posts that decry Java's implementation of generics. Now, I can honestly say that I have not had any issues with using them. However, I have not attempted to make a generic class myself. So, what are your issues with Java's generic support?</p>

答:
I could say a few good things about generics, but that wasn't the question.  I could complain that they're not available at run time and don't work with arrays, but that's been mentioned.

A big psychological annoyance:  I occasionally get into situations where generics cannot be made to work.  (Arrays being the simplest example.)  And I cannot figure out whether generics can't do the job or whether I'm just stupid.  I hate that.  Something like generics ought to work always.  Every other time I can't do what I want using Java-the-language, I know the problem is me, and I know if I just keep pushing, I'll get there eventually.  With generics, if I become too persistent, I can waste a lot of time.

But the real problem is that generics add too much complexity for too little gain.  In the simplest cases it can stop me from adding an apple to a list containing cars.  Fine.  But without generics this error would throw a ClassCastException really quick at run time with little time wasted.  If I add a car with a child seat with a child in it, do I need a compile-time warning that the list is only for cars with child seats that contain baby chimpanzees?  A list of plain Object instances starts to look like a good idea.

Generic'ed code can have a lot of words and characters and take up a lot of extra space and take a lot longer to read.  I can spend a lot of time getting all that extra code to work right.  When it does, I feel insanely clever.  I've also wasted several hours or more of my own time and I have to wonder if anyone else is ever going to be able to figure out the code.  I'd like to be able to hand it off for maintenance to people who are either less smart than myself or who have less time to waste.

On the other hand (I got a bit wound up there and feel a need to provide some balance), it is nice when using simple collections and maps to have adds, puts, and gets checked when written, and it usually does not add much complexity to the code (if someone else writes the collection or map).  And Java is better at this than C#.  It seems none of the C# collections I want to use ever handle generics.  (I admit I have strange tastes in collections.)

Title: What is wrong with Java's generics?


答:
Very effective.

... as long as your recruitment process doesn't just contain programming challenges. While I fret and hate doing the technical assessment of any interview, it does act as a simple gauge to filter out idiots. And filtering out idiots is the crux of the recruitment process, so you can spend more of your time on those who are fit for the role.

When interviewing, I deem it very important to see what people say under pressure. If they're incline to spit out a bunch of blatant crap, it's easily identifiable and I'll know this person isn't worth my time.

More likely to be afraid to come up to us at a career fair.

This isn't a bad thing. If your potential candidate isn't willing to bet that he's worth being employed there, do you really want to recruit him anyway?

Title: How effective are programming challenges in the recruiting process?

Body:
I think our company can create challenges designed to find software engineer candidates who are:

Good at solving problems, not at wowing recruiters.

More likely to be afraid to come up to us at a career fair.

More likely to be underutilized in their current programming job but are too introverted to do anything about it.

For an example see this article that discusses Facebook hiding an email address in an image using Piet.

I just can't find any studies or hard data on whether this actually works or not.


问:
How should I plan and start a project?
Every time I start a project, I decide at crucial moments to completely change the core classes and get caught up in obscure errors. I try planning in advanced and usually start off on a good foot but then I go to it another day and decide I would like to do it 'another way'.

Is there a standard, of sorts, when starting a project such as mapping out classes and starting with unit tests? What is a good convention when planning and starting a medium project.

The last project and started was a projectile motion simulator - I know, predictable.

答:
The reason you are finding this so difficult is that you have an idea, but you don't really have a complete idea what you want it to do.  If you are doing your own project and you don't have a customer to tell you what they want, then it is up to you to be your own customer.  Put yourself into the customer's shoes and start building an impossible wish list.

In other words, when you start Don't design ANYTHING!!!.

Once you have a big list of things you want the system to do, prioritize everything and decide what the minimum functionality will be to have a basic system running.  This could be a single basic function, or an entire screen, but it needs to be something you feel - as the customer -will be useful enough to test.

So, Wish list of features + basic priorities = Requirements.

Once you have all of that, do a very high level design.  Just sit and think about what your system will need to get the first few priorities up and running.  Change you mind if you wish, but here is where you may wish to spike some code or a system configuration to learn more about what is possible.  Go only far enough to validate your basic idea of a design.

I.e.: NOW you get to indulge your designers urges.

Once done, you start implementing your features.  Create for each feature a basic functional spec.  This could be as simple as a collection of feature statements. Story cards if you like. This allows you to develop your idea in your mind a little, and to create a set of statements that will become the specification that you will be testing and building your implementation against.

Cry Havoc, let slip the dogs of... Code!!

From there, implement your tests to match your specifications, then for each test, write your code. Build, "release", then repeat with the next feature until you decide the project is complete enough.

It really comes down to experienced, but this approach I've found is a simple formula to help you focus your mind on what needs to be done, rather than getting locked into an endless cycle of procrastination due to trying to do too much all at once.

Title: How should I plan and start a project?


问:
Who does test-driven development?
I've been working in the enterprise space for the past 4½ years and have noticed that generally speaking, enterprises are not conducive environments for the test-first style of development. Projects are usually fixed-cost, fixed-timeline and waterfall style. Any unit testing, if done at all, usually comes after development in the QA phase and done by another team.

Prior to working for an enterprise, I consulted for many small to medium sized companies, and none of them were willing to pay for a test-first style of development project. They usually wanted development started immediately, or after a short design stint: i.e., something more akin to Agile, though some clients wanted everything mapped out similar to waterfall.

With what types of shops, companies, and clients does test-driven development work
best? What types of projects tend to be conducive to TDD?

答:
Your situation won't change quickly, and the key to getting it through is to make it part of your personal discipline, and to be good at it, before trying to push it on others.  If you can be the example of it working then your managers should see objective benefits.

You can also make good business cases:

TDD can be simply summarized as "spec which the system can automatically verify itself against".  It's not programming differently, it's not building a different product.

Unit testing is really just a form of automated-testing; which is just letting the computer do for itself what the company is likely paying meat-space engineers to do manually.  Automated tests run faster, more consistently, and--when well written--provide fast, concise and accurate feedback and descriptions and direction for the issue

TDD, when being done by someone who knows what they're doing, produces results just as fast as code-first.  There will be a learning/training curve (and, if your engineers are from the short-end of the talent pool then this may entirely kill your chances of pushing TDD--in this case the best you can do is to continue to champion it and make management question them rather than TDD)

TDD is very much about thinking through the task at hand before starting it.  It's along the lines of "measure twice, cut once"--the extra measurment adds a marginal amount of time to the task, but avoids throwing away your most precious resource--dev hours).

...and just remember; the most important thing you can do is to lead by example.  If you're rough in TDD, invest some extra hours in becomming better.  Once you're proficient, just start doing it at work (would your managers really complain that you write tests?).  Fight one battle at a time and make steps towards it--going for the whole shebang likely will result in failure and the blame will fall on you if you pushed hard for it.

Title: Who does test-driven development?


问:
Programming judge with versus system
I'm looking for a programming judge system which supports putting contestants programs against each other in "matches". The format could be either for example a tournament style or chess ranking, but this isn't that important. A good example would be Google's AI challenge (http://aichallenge.org/)

The only systems I've found so far are "regular" programming judges, i.e. those who can check if a program passes or fails a given problem, like DOMJudge.

Do you know of any systems like this?

答:
Back when I was heavily into linux I remember a battlebot program or something like that where you built a program that would enter the arena with another users program...the victory was determined by wiping out the other program. I can't remember the name of it, but there are systems like that.

Edit
I found a resource that collects similar games and applications that do just this

Title: Programming judge with versus system


答:
Like any tool, they can be extremely helpful, or extremely dangerous. A power drill will make your life so much easier - until you drill through the top of your hand and land yourself in the ER. The same is true with programming challenges in recruiting.

The Good: This may be an effective way to detect someone who, on paper, might not be all that compelling as a programmer. The one with a degree in something that has very little to do with what people normally consider "programming" related fields - Biology, Political Science, Art History...

If they blow through your challenges, then great. They learned programming, somehow, and it's apparently stuck. If they get bogged down, their application may really just be something that slipped through HR.

The Bad: A poorly written programming challenge doesn't actually assess programming skill. It tests puzzle solving via programming skill. The problem is the later is a two variable question - are you good at puzzle solving, and can you do said puzzle solving via code. It's possible to have a perfectly talented programmer who utterly fails at the puzzle solving part.

Most programming challenges I've seen also fail at detecting people who are close to what you want, depending on how it's written.

There's ways to mitigate both of those. For the latter, I'd consider accepting "partial credit" in the form of solutions that don't seem to quite be getting there, "Here's how I would solve this..." etc. if you're genuinely looking for problem solvers. After all, very few people code all alone, and if their answer would have been right if they could ask a senior colleague "Hey Jim, do you know a good way to implement X?", that may very well be someone you want on your team.

The former is somewhat harder, because the burden for that is on you. Pick puzzles/problems/challenges that matter. If no one in your group has ever come up against anything even remotely resembling the Traveling Salesman problem in their work, don't make some clever spin on Traveling Salesman the challenge you come up with. That way, if they're failing at the problem solving aspect of "solve the problem and code it", they're at least failing at something that will actually come up, rather than some arbitrary bit of cleverness your team spitballed over lunch.


问:
Product classifying algorithm - text classification - C# - algorithm suggestions
Alright people. Finally with the help of stackoverflow community i have gathered 20 commercial product selling websites product pages with the following features

```<code>Product URL
Product Price
Product Name
Product Category
Product Page Title
Product Page Description
Product Page Keywords
</code>```

Now with using these features of the products i have to classify them. What does classification means ? Let me explain it.

Now as you can imagine every website lists the products in their own ways. There is not format. So lets say iphone 4 is being sold at 20 different websites with 20 different way. So what i need to achieve is grouping the these 20 iphone page at 20 different websites.
So when person query my website with iphone 4 word i will show that 20 results. Basically out of over 500.000 product urls i need to group every product. So lets say there are 15 gefore gtx 570 card out of these 500k urls so i need to group them as same product. You can imagine it as google products. But i am doing it at my own country which is Turkey and google does not have product search for Turkey.

In short with using the features above what algorithm would you suggest. I don't want to use any training techniques if possible. Everything automated.

I am using C# 4.0 WPF and data is stored at the MSSQL 2008 R2 database

答:
Wouldn't you just need to reverse index the words in the various fields back to the page? As a simplistic example, break down each Product Name (say, by spaces) and normalize each keyword (say, lowercase, throw out punctuation), and then map it to the product's URL or record. Searching for "iphone" would then give you close to the right results. You even have a Product Page Keywords field.

Product grouping would then just be a search on a combination of keywords, like "iphone case".

Getting such a system perfect, of course, can be immensely complex, but the basic logic seems like it would apply here. For example, your tokenization of Turkish terms may require special treatment.


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

For example:

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

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

So in the HTML I would put:

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

and in the CSS:

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

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

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

答:
Your question asked if it's "good practice or legal".

Firstly: it's sort-of legal - at least, it's tolerated. Browsers have always been programmed to cope with tags they don't understand, even if that means they just ignore them. This HTML code:

```<code>Some <b>bold</b> and some <slanted>italic</slanted>.
</code>```

Will appear like this is every single browser:

Some bold and some italic.

Furthermore, most browsers will allow you to style that element in CSS. So if you add the following CSS definition:

```<code>slanted { font-style: italic; }
</code>```

most browsers will now render as follows:

Some bold and some italic.

Really: try it for yourself. Incidentally, this is a trick web developers use to try and ensure that new HTML5 tags display correctly in older browsers.

However, that's not quite the complete picture. The full answer is no, it is not good practice. You may have noticed my use of the phrase "most browsers". Unfortunately, all versions of Internet Explorer prior to IE9 fail to implement this behaviour. In IE8 and earlier, the code above will still look like this:

Some bold and some italic.

There's an excellently detailed description of the problem over at Dive Into HTML5, where you'll also find details of a workaround. However, the workaround requires JavaScript so it's not a pure HTML solution and won't work in all scenarios.

So, short answer: stick to standard HTML elements only and style them however you like in your CSS.

Body:
Your question asked if it's "good practice or legal".

Firstly: it's sort-of legal - at least, it's tolerated. Browsers have always been programmed to cope with tags they don't understand, even if that means they just ignore them. This HTML code:

Some <b>bold</b> and some <slanted>italic</slanted>.

Will appear like this is every single browser:

Some bold and some italic.

Furthermore, most browsers will allow you to style that element in CSS. So if you add the following CSS definition:

slanted { font-style: italic; }

most browsers will now render as follows:

Some bold and some italic.

Really: try it for yourself. Incidentally, this is a trick web developers use to try and ensure that new HTML5 tags display correctly in older browsers.

However, that's not quite the complete picture. The full answer is no, it is not good practice. You may have noticed my use of the phrase "most browsers". Unfortunately, all versions of Internet Explorer prior to IE9 fail to implement this behaviour. In IE8 and earlier, the code above will still look like this:

Some bold and some italic.

There's an excellently detailed description of the problem over at Dive Into HTML5, where you'll also find details of a workaround. However, the workaround requires JavaScript so it's not a pure HTML solution and won't work in all scenarios.

So, short answer: stick to standard HTML elements only and style them however you like in your CSS.


问:
How often do you use Formal UML?
I used ad-hoc MUML (made-up modeling language) to design and explain system fairly frequently.  It looks similar to UML and tends to be pretty well understood.

However, I've had a professor or two that harped on the use of strict, formal UML, as close to the spec as possible.  I always suspected that strict UML wasn't really as common as they claimed.  So, how 'bout it- how often do you actually draw out complete diagrams that use all the proper line endings, multiplicity, member type symbols, etc?

答:
I used UML very regularly for about four years for a product that generated all (most) of its code skeletons from Rational Rose.

The last five years there have been more of "boxes and arrows" mostly invented on the spot and usually enough to get the general idea across. Formally correct UML only a few times during this time.

Title: How often do you use Formal UML?


问:
Maintainability of Boolean logic - Is nesting if statements needed?
Which of these is better for maintainability?

```<code>if (byteArrayVariable != null)
    if (byteArrayVariable .Length != 0)
         //Do something with byteArrayVariable
</code>```

OR

```<code>if ((byteArrayVariable != null) && (byteArrayVariable.Length != 0))
  //Do something with byteArrayVariable
</code>```

I prefer reading and writing the second, but I recall reading in code complete that doing things like that is bad for maintainability.

This is because you are relying on the language to not evaluate the second part of the if if the first part is false and not all languages do that.  (The second part will throw an exception if evaluated with a null byteArrayVariable.)

I don't know if that is really something to worry about or not, and I would like general feedback on the question.

Thanks.

答:
I'm surprised nobody has mentioned it (so hopefully I'm not misreading the question)--but both kind of suck!

The better alternative would be to use early-exits (placing a return statement early in the code if no other code should execute).  This makes the assumption that your code is relatively well refactored, and that each method has a concise purpose.

At that point you would do something like:

```<code>if ((byteArrayVariable == null) || (byteArrayVariable.Length != 0)) {
  return; // nothing to be done, leaving
}

// Conditions met, do something
</code>```

It might look a lot like validation--and that's precisely what it is.  It validates that conditions have been satisfied for the method to do it's thing--both options you offered hid the actual logic within the pre-condition checks.

If your code is a lot of spaghetti (loooong methods, lots of nested ifs with logic scattered between them, etc) then you should focus on the bigger problem of getting your code into shape before the smaller stylistic issues.  Depending on your environment, and the severity of the mess, there are some great tools to help (e.g. Visual Studio has an "Extract Method" refactoring function).

As Jim mentions, there's still room for debate about how to structure the early-exit.  The alternative to what is above would be:

```<code>if (byteArrayVariable == null)
  return; // nothing to be done, leaving

if (byteArrayVariable.Length != 0)
  return;

// Conditions met, do something
</code>```

Body:
I'm surprised nobody has mentioned it (so hopefully I'm not misreading the question)--but both kind of suck!

The better alternative would be to use early-exits (placing a return statement early in the code if no other code should execute).  This makes the assumption that your code is relatively well refactored, and that each method has a concise purpose.

At that point you would do something like:

if ((byteArrayVariable == null) || (byteArrayVariable.Length != 0)) {
  return; // nothing to be done, leaving
}

// Conditions met, do something

It might look a lot like validation--and that's precisely what it is.  It validates that conditions have been satisfied for the method to do it's thing--both options you offered hid the actual logic within the pre-condition checks.

If your code is a lot of spaghetti (loooong methods, lots of nested ifs with logic scattered between them, etc) then you should focus on the bigger problem of getting your code into shape before the smaller stylistic issues.  Depending on your environment, and the severity of the mess, there are some great tools to help (e.g. Visual Studio has an "Extract Method" refactoring function).

As Jim mentions, there's still room for debate about how to structure the early-exit.  The alternative to what is above would be:

if (byteArrayVariable == null)
  return; // nothing to be done, leaving

if (byteArrayVariable.Length != 0)
  return;

// Conditions met, do something


问:
What types of positions might involve improving processes using CMMI and Scrum?
I'm an IT student and have been working on team based projects for several years. I've read some papers about CMMI and Scrum; this is really interesting to me and I would like to know what kind of jobs involve improving processes inside an organization.

What kind of studies can lead someone towards these jobs? Management? I doubt it's only that, as CMMI/Scrum affect management as well, I think it's something above it all, that will hold together the organization.

答:
Consulting and PMO jobs are the easiest way before getting into management.  Be careful though.  It is hard to tell someone how to change their job without knowing how to do it yourself.

Want to consult on CMM?  Join a firm that is level 5 and learn.

Want to consult on 6 sigma?  Join GE.

Want to consult in scrum?  Find the best mentor you can and offer to work for free.

Do this and you will have ten times the confidence and credibility when you consult.   Your clients will appreciate your academic credentials more if you have also walked the walk.


答:
Ignoring everyone elses opinion here.

It's not good practice for two very important reasons:

First, it is entirely possible that at some point the standards committee decides to include a tag named <important> that ends up wacking your use for it.  Sure, it might take a while.. But its possible you are going to waste time ripping it out afterwards.

Second, (this is the real reason) the programmer that inherits your code is either going to constantly say "wtf" at your non-standard approach while yanking all of that out, or, equally possible, be utterly confused by what it is you've done and simply quit in frustration.

So, be nice.  You never know, you might end up asking one of them for a job some day.


答:
After you have done the basics such as establish the projects goals, got your list of requirements, and locked down any interfaces to external systems.

Then you need to do a use case or "story" for every user interaction. Volumes have been written on what makes a "good" use case or story and there are many variations. Use cases are the single most effective design tool I have come across. They help pick up missing functionality at the same time as eliminating unnecessary requirements and strip your design down to its essentials. As I said methodologies vary but most practioners agree on:-

concise plain English text.

"Goal Driven" works best i.e. "Monkey gets a grape" is better than "Monkey Pushes red button".

ban technical terminology. No "pulldowns", "text boxes". A good use case should be independent of any interface technology. You should be able to take a use case for a HTML based system and use it for a voice activated system without any changes to the use case itself. (this is very hard to do but worth it!).

Aim to reduce the word count of your first draft by 50%, get rid of any unnecessary steps and verbiage.

Than you are ready to specify your major classes:

UML- Universal Modeling Language. Is the standard tool for designing classes.
You specify the public members and methods of each class and link them together in a clear an concise graphical model.

In conjunction with sequence diagrams, data models, you can verify and improve your design before any coding takes place.

Title: How should I plan and start a project?

Body:
Every time I start a project, I decide at crucial moments to completely change the core classes and get caught up in obscure errors. I try planning in advanced and usually start off on a good foot but then I go to it another day and decide I would like to do it 'another way'.

Is there a standard, of sorts, when starting a project such as mapping out classes and starting with unit tests? What is a good convention when planning and starting a medium project.

The last project and started was a projectile motion simulator - I know, predictable.


答:
Shift your focus on the result you want to obtain and weigh the potential gains of learning/trying new implementations with the risk of going down a road that winds you up back at square one.

In the case that you do end up back at square one, all is not lost because you gained experience.

If you have a deadline (it sounded like maybe you are programming for fun) then this is really tricky.  If you continually go one way, you risk using outdated methods as time goes on.  If you continually go the other way, you risk the consequences of producing output at a slower rate (a variably slower rate depending on the outcomes of your learning adventures).

I used to blaze through work, getting things done fast year after year, and then one day I realized I was becoming non-current in my skillset.

Title: How should I plan and start a project?


问:
To use, or not to use, commons-io in a Java applet
I am building a Java applet for a client. Yes, we have gone over all the options, and for the client's requirements and environment, this is the Right Choice.

I am a big believer in using Apache Commons whenever possible to simplify my code and avoid reinventing the wheel. One part of the functionality I need for this applet is implemented in the Commons IO library, which is 160kb in size.

Or I could create a custom build of Commons IO with just the classes I want. Less easily maintained, but minimizes the overhead of the applet.

I could also write the needed functions; they would be far smaller than 160kb.

I've probably spent more time pondering the Right Thing To Do than it would take me to write the code by hand.

As an additional consideration, I will be doing a code review with the client, and would like to take any opportunities I have to teach them best practices like using Apache Commons.

Any strong opinions, and justifications, for which option I should choose?

答:
What's the performance requirements of your application?  Is the footprint/impact of this library a bottleneck that stops you from reaching that performance goal?

If the impact is too great, then use a subset, else I'd use the official library to avoid re-inventing the wheel.


答:
Well, it's legal in that you aren't going to get arrested for doing it. But if assassins from the W3C show up at your door, don't be surprised.

First off, other devs aren't going to know what they mean. In the case of <important> and <highlight> they are, but if you use something like, say, <set>, you might know you're referring to a mathematical set, but someone else reading your code might mistake it for something else. Without the spec there to give an answer, there could be a great deal of confusion.

Second, what if the W3C decides that an <important> element is a good idea, but thinks it should mean an urgent notice, like

```<code><important>This site is going to be down for maintenance 2/29/2012.</important>
</code>```

Then you're screwed. Browsers and your fellow developers will be rather confused. They'll probably force you to parse your code with regexes until you go insane. And we all know how that turns out.

Third, IE < 9 doesn't let you style unknown elements without a little hack. Not a big thing, but annoying.

Lastly, in this case, <important> and <highlight> already exist!  and  are what you're looking for. According to the HTML5 spec

The strong element represents strong importance for its contents.

and

The mark element represents a run of text in one document marked or highlighted for reference purposes ...

If you aren't using it for "reference purposes", a  with a class would be fine.

Body:
Well, it's legal in that you aren't going to get arrested for doing it. But if assassins from the W3C show up at your door, don't be surprised.

First off, other devs aren't going to know what they mean. In the case of <important> and <highlight> they are, but if you use something like, say, <set>, you might know you're referring to a mathematical set, but someone else reading your code might mistake it for something else. Without the spec there to give an answer, there could be a great deal of confusion.

Second, what if the W3C decides that an <important> element is a good idea, but thinks it should mean an urgent notice, like

<important>This site is going to be down for maintenance 2/29/2012.</important>

Then you're screwed. Browsers and your fellow developers will be rather confused. They'll probably force you to parse your code with regexes until you go insane. And we all know how that turns out.

Third, IE < 9 doesn't let you style unknown elements without a little hack. Not a big thing, but annoying.

Lastly, in this case, <important> and <highlight> already exist! <strong> and <mark> are what you're looking for. According to the HTML5 spec

The strong element represents strong importance for its contents.

and

The mark element represents a run of text in one document marked or highlighted for reference purposes ...

If you aren't using it for "reference purposes", a <span> with a class would be fine.


问:
What data structure could I use for modeling a network of nodes and edges?
My application needs to model of and perform operations on a network with 40 - 50 nodes and typically less than 6 edges per node. Both nodes and edges are objects with around 1K data each. During execution the mapping of the network is frequently changed - nodes added and deleted, edges added and deleted, in addition to the properties of individual nodes and edges being adjusted. The node objects and edge objects are allocated using 'new' with the resulting pointers stored in a std::list for each object type.

I have experimented with two different approaches for mapping:

Put a container in each node to hold IDs of edges, and 2 variables in each edge to store the IDs of the end nodes.

Add a new top-level container, separate from the container of edges and container of nodes, to store the mapping information.

Functions in the node and member classes will be easier to implement, if the mapping information is stored in those classes. Making changes to the network mapping would be much easier, if all the mapping data was stored separately. But if the mapping is not stored in the nodes and edges, then member functions in the nodes and edges need a way to get mapping information from the parent object.

Is there a data structure or a conceptual technique that gives the best of both approaches, without duplicating data or breaking encapsulation? Performance is not major concern, since there are not any extremely expensive calculations involved. The more important concern is for safe, understandable, maintainable code.

答:
Graphs can be implemented in many ways, and the one you've outlined is certainly not wrong.

For C++ I think you should take a gander into the Boost C++ libraries (BGL) that also has a library specifically for implementing graphs. If you use that then you can also use algorithms implemented in BGL (searches and traversals) or even use the _edge and _vertex visitors directly.


答:
I've implemented network operations in Python. Here is my solution.

a class Node which owns a list of Ports

each Port object has attributes destination, proper_direction and back_port

Node provides linking functions and ensures that for each Port object in its list has another back-port Port object is created at the destination node with the negative proper_direction and also this back-port is referenced by back_port

This way Nodes are linked by a pair of Ports in both directions with reverse proper_directions. Make C-pointers as appropriate - in Python we don't care about pointers ;-)

To store data in each Node I derive a subclass which adds a mapping. If I also want to store data in each Link, then I emulate Links by Node objects, and basically link Objects and Links (both Node) by Ports.

This data structure turned out to be really convenient for network search and operations.

Title: What data structure could I use for modeling a network of nodes and edges?

Body:
My application needs to model of and perform operations on a network with 40 - 50 nodes and typically less than 6 edges per node. Both nodes and edges are objects with around 1K data each. During execution the mapping of the network is frequently changed - nodes added and deleted, edges added and deleted, in addition to the properties of individual nodes and edges being adjusted. The node objects and edge objects are allocated using 'new' with the resulting pointers stored in a std::list for each object type.

I have experimented with two different approaches for mapping:

Put a container in each node to hold IDs of edges, and 2 variables in each edge to store the IDs of the end nodes.

Add a new top-level container, separate from the container of edges and container of nodes, to store the mapping information.

Functions in the node and member classes will be easier to implement, if the mapping information is stored in those classes. Making changes to the network mapping would be much easier, if all the mapping data was stored separately. But if the mapping is not stored in the nodes and edges, then member functions in the nodes and edges need a way to get mapping information from the parent object.

Is there a data structure or a conceptual technique that gives the best of both approaches, without duplicating data or breaking encapsulation? Performance is not major concern, since there are not any extremely expensive calculations involved. The more important concern is for safe, understandable, maintainable code.


答:
Your example is the perfect example of why the nested ifs are a bad approach for most languages that properly support boolean comparison. Nesting the ifs creates a situation where your intention is not at all clear. Is it required that the second if immediately follows the first one? Or is it just because you haven't put another operation in there yet?

```<code>if ((byteArrayVariable != null) && (byteArrayVariable.Length != 0))
  //Do something with byteArrayVariable
</code>```

In this case, these pretty much must be together. They are acting as a guard to ensure you don't perform an operation that would result in an exception. Using nested ifs, you leave it up to interpretation of the person following you as to whether the two represent a two-part guard or some other branching logic. By combining them into a single if I am stating that. It's a lot harder to sneak an operation inside of there where it shouldn't be.

I will always favor clear communication of my intention over someone's stupid assertion that it "doesn't work in all languages". Guess what... throw doesn't work in all languages either, does that mean I shouldn't use it when coding in C# or Java and should instead rely on return values to signal when there was a problem?

All that said, it's a lot more readable to invert it and just return out of the method if either is not satisfied as STW says in their answer.

Title: Maintainability of Boolean logic - Is nesting if statements needed?

Body:
Which of these is better for maintainability?

```<code>if (byteArrayVariable != null)
    if (byteArrayVariable .Length != 0)
         //Do something with byteArrayVariable
</code>```

OR

```<code>if ((byteArrayVariable != null) && (byteArrayVariable.Length != 0))
  //Do something with byteArrayVariable
</code>```

I prefer reading and writing the second, but I recall reading in code complete that doing things like that is bad for maintainability.

This is because you are relying on the language to not evaluate the second part of the if if the first part is false and not all languages do that.  (The second part will throw an exception if evaluated with a null byteArrayVariable.)

I don't know if that is really something to worry about or not, and I would like general feedback on the question.

Thanks.

Body:
Your example is the perfect example of why the nested ifs are a bad approach for most languages that properly support boolean comparison. Nesting the ifs creates a situation where your intention is not at all clear. Is it required that the second if immediately follows the first one? Or is it just because you haven't put another operation in there yet?

if ((byteArrayVariable != null) && (byteArrayVariable.Length != 0))
  //Do something with byteArrayVariable

In this case, these pretty much must be together. They are acting as a guard to ensure you don't perform an operation that would result in an exception. Using nested ifs, you leave it up to interpretation of the person following you as to whether the two represent a two-part guard or some other branching logic. By combining them into a single if I am stating that. It's a lot harder to sneak an operation inside of there where it shouldn't be.

I will always favor clear communication of my intention over someone's stupid assertion that it "doesn't work in all languages". Guess what... throw doesn't work in all languages either, does that mean I shouldn't use it when coding in C# or Java and should instead rely on return values to signal when there was a problem?

All that said, it's a lot more readable to invert it and just return out of the method if either is not satisfied as STW says in their answer.


问:
Is it possible to release Code using the MS Solver Foundation under GPLv3?
I have written a piece of software using the Microsoft Solver Foundation.
Now the work is done I want to release the code under the Terms of the GPLv3, if that is possible.

The problem is, the GPLv3 states in section 1:

The "System Libraries" of an executable work include anything, other
  than the work as a whole, that (a) is included in the normal form of
  packaging a Major Component, but which is not part of that Major
  Component, and (b) serves only to enable use of the work with that
  Major Component, or to implement a Standard Interface for which an
  implementation is available to the public in source code form.  A
  "Major Component", in this context, means a major essential component
  (kernel, window system, and so on) of the specific operating system
  (if any) on which the executable work runs, or a compiler used to
  produce the work, or an object code interpreter used to run it.

The way I see it, the Solver Foundation does not fall into this definition, making it incompatible with the GPL (which is not a surprise by itself).

Now, I do not want to distribute any form of the MSF (or the included Gurobi license for that part) and I will not provide any binaries for the software, so I am unsure whether thew MSF not being a system library does affect my licensing options at all (first time I have to choose a license myself for anything).

The rest of the libraries I used use Apache2 and (L)GPLv3 licenses plus the zlib license for NUnit (which allows everything for binary distribution), so those should not be a problem (please correct me if I'm wrong).

But the MSF and Gurobi part bothers me a bit.
What I had in mind was to provide the Visual Studio solution (which lists the MSF as a dependency) and instead of including the gurobi plugin dlls, there would be a readme on how to include them after acquiring the gurobi solver along with the MSF.

So, is this possible?
If it isn't, maybe a different FOSS license could be found?

答:
The usual IANAL applies, if you want legal advice, get a lawyer, yadda yadda. That said:

As long as you only distribute your own code, and no libraries, you can pick any license you want; it's probably wise to pick a GPL-compatible one, in case others want to use your code in GPL projects. You are not bound to licenses of software you don't include in your distribution: it's up to the user to install the libraries and comply with their respective licenses.

If, however, your project contains code from MSF (e.g., the output of any code generators), then the MSF license may put extra restrictions on your code, and may make it incompatible with GPL and similar licenses.


问:
Is it a good practice to name the returned variable "result"?
Is it a good practice to call the variable a method returns with a variable name result?

For instance:

```<code>public Zorglub calculate() {
    Zorglub result = [...]
    [...]
    return result;
}
</code>```

Or should I name it by its type?

```<code>public Zorglub calculate() {
    Zorglub zorglub = [...]
    [...]
    return zorglub;
}
</code>```

I have seen both in the wild, if I need to choose one what reasons could make me prefer the former or latter (or any better name)?

I am mainly thinking about Java.

答:
If this is a method variable, it really depends on readability.

Seeing as you already have the type name in both the variable declaration and the method return type, you might as well use result - it is descriptive of the role of the variable.